changeset 2907:d7eca687b7d2

Add 2013/06/18 security patches. 2013-06-22 Andrew John Hughes <gnu.andrew@member.fsf.org> * patches/idresolver_fix.patch: Removed. Part of 6469266. * Makefile.am: (SECURITY_PATCHES): Add new ones. (SPECIAL_SECURITY_PATCH_1): Renamed from SPECIAL_SECURITY_PATCH. (SPECIAL_SECURITY_PATCH_2): Add 8009071, which needs to be applied after some AWT backports. (ICEDTEA_PATCHES): Use SPECIAL_SECURITY_PATCH_{1,2}. Move 8005615, 8007393 & 8007611 to SECURITY_PATCHES as must be applied before 8004584. Add 7171223 to end. * patches/openjdk/6307603-xrender-01.patch, * patches/openjdk/6469266-xmlsec_1.4.2.patch, * patches/openjdk/6656651-windows_lcd_glyphs.patch, * patches/openjdk/6786028-wcag_bold_tags.patch, * patches/openjdk/6786682-wcag_lang.patch, * patches/openjdk/6786688-wcag_table.patch, * patches/openjdk/6786690-wcag_dl.patch, * patches/openjdk/6802694-no_deprecated.patch, * patches/openjdk/6851834-restructure.patch, * patches/openjdk/6888167-medialib_memory_leaks.patch, * patches/openjdk/6961178-doclet_xml.patch, * patches/openjdk/6990754-use_native_memory_for_symboltable.patch, * patches/openjdk/7006270-regressions.patch, * patches/openjdk/7008809-report_class_in_arraystoreexception.patch, * patches/openjdk/7014851-unused_parallel_compaction_code.patch, * patches/openjdk/7017732-move_static_fields_to_class.patch, * patches/openjdk/7036747-elfstringtable.patch, * patches/openjdk/7086585-flexible_field_injection.patch, * patches/openjdk/7171223-strict_aliasing.patch, * patches/openjdk/7195301-no_instanceof_node.patch, * patches/security/20130618/6741606-apache_santuario.patch, * patches/security/20130618/7158805-nested_subroutine_rewriting.patch, * patches/security/20130618/7170730-windows_network_stack.patch, * patches/security/20130618/8000638-improve_deserialization.patch, * patches/security/20130618/8000642-better_transportation_handling.patch, * patches/security/20130618/8001032-restrict_object_access-corba.patch, * patches/security/20130618/8001032-restrict_object_access-jdk.patch, * patches/security/20130618/8001033-refactor_address_handling.patch, * patches/security/20130618/8001034-memory_management.patch, * patches/security/20130618/8001038-resourcefully_handle_resources.patch, * patches/security/20130618/8001043-clarify_definition_restrictions.patch, * patches/security/20130618/8001309-better_handling_of_annotation_interfaces.patch, * patches/security/20130618/8001318-6_fixup.patch, * patches/security/20130618/8001318-socket_getlocaladdress_consistency.patch, * patches/security/20130618/8001330-checking_order_improvement.patch, * patches/security/20130618/8001330-improve_checking_order.patch, * patches/security/20130618/8003703-update_rmi_connection_dialog.patch, * patches/security/20130618/8004584-augment_applet_contextualization.patch, * patches/security/20130618/8005007-better_glyph_processing.patch, * patches/security/20130618/8006328-6_fixup.patch, * patches/security/20130618/8006328-sound_class_robustness.patch, * patches/security/20130618/8006611-improve_scripting.patch, * patches/security/20130618/8007467-improve_jmx_internal_api_robustness.patch, * patches/security/20130618/8007471-6_fixup.patch, * patches/security/20130618/8007471-improve_mbean_notifications.patch, * patches/security/20130618/8007812-getenclosingmethod.patch, * patches/security/20130618/8008120-improve_jmx_class_checking.patch, * patches/security/20130618/8008124-better_compliance_testing.patch, * patches/security/20130618/8008128-better_jmx_api_coherence.patch, * patches/security/20130618/8008132-better_serialization.patch, * patches/security/20130618/8008585-jmx_data_handling.patch, * patches/security/20130618/8008593-better_urlclassloader.patch, * patches/security/20130618/8008603-jmx_provider_provision.patch, * patches/security/20130618/8008611-6_fixup.patch, * patches/security/20130618/8008611-jmx_annotations.patch, * patches/security/20130618/8008615-jmx_internal_api_robustness.patch, * patches/security/20130618/8008623-mbeanserver_handling.patch, * patches/security/20130618/8008744-6741606_rework.patch, * patches/security/20130618/8008982-jmx_interface_changes.patch, * patches/security/20130618/8009004-rmi_connection_improvement.patch, * patches/security/20130618/8009013-t2k_glyphs.patch, * patches/security/20130618/8009034-jmx_notification_improvement.patch, * patches/security/20130618/8009038-jmx_notification_support_improvement.patch, * patches/security/20130618/8009067-improve_key_storing.patch, * patches/security/20130618/8009071-improve_shape_handling.patch, * patches/security/20130618/8009235-improve_tsa_data_handling.patch, * patches/security/20130618/8009554-serialjavaobject.patch, * patches/security/20130618/8011243-improve_imaginglib.patch, * patches/security/20130618/8011248-better_component_rasters.patch, * patches/security/20130618/8011253-better_short_component_rasters.patch, * patches/security/20130618/8011257-better_byte_component_rasters.patch, * patches/security/20130618/8011557-improve_reflection.patch, * patches/security/20130618/8012375-javadoc_framing.patch, * patches/security/20130618/8012421-better_positioning.patch, * patches/security/20130618/8012438-better_image_validation.patch, * patches/security/20130618/8012597-better_image_channel_validation.patch, * patches/security/20130618/8012601-better_layout_validation.patch, * patches/security/20130618/8014281-better_xml_signature_checking.patch, * patches/security/20130618/8015997-more_javadoc_framing.patch, * patches/security/20130618/diamond_fix.patch, * patches/security/20130618/handle_npe.patch, * patches/security/20130618/hs_merge-01.patch, * patches/security/20130618/hs_merge-02.patch, * patches/security/20130618/hs_merge-03.patch, * patches/security/20130618/hs_merge-04.patch, * patches/security/20130618/javac_issue.patch, * patches/security/20130618/langtools_generics.patch, * patches/security/20130618/langtools_merge-01.patch, * patches/security/20130618/langtools_merge-02.patch, * patches/security/20130618/langtools_merge-03.patch: 2013/06/18 security patches.
author Andrew John Hughes <gnu.andrew@redhat.com>
date Sat, 22 Jun 2013 16:38:24 -0500
parents 272824be5054
children f352f5c79104
files ChangeLog Makefile.am patches/idresolver_fix.patch patches/openjdk/6307603-xrender-01.patch patches/openjdk/6469266-xmlsec_1.4.2.patch patches/openjdk/6656651-windows_lcd_glyphs.patch patches/openjdk/6786028-wcag_bold_tags.patch patches/openjdk/6786682-wcag_lang.patch patches/openjdk/6786688-wcag_table.patch patches/openjdk/6786690-wcag_dl.patch patches/openjdk/6802694-no_deprecated.patch patches/openjdk/6851834-restructure.patch patches/openjdk/6888167-medialib_memory_leaks.patch patches/openjdk/6961178-doclet_xml.patch patches/openjdk/6990754-use_native_memory_for_symboltable.patch patches/openjdk/7006270-regressions.patch patches/openjdk/7008809-report_class_in_arraystoreexception.patch patches/openjdk/7014851-unused_parallel_compaction_code.patch patches/openjdk/7017732-move_static_fields_to_class.patch patches/openjdk/7036747-elfstringtable.patch patches/openjdk/7086585-flexible_field_injection.patch patches/openjdk/7171223-strict_aliasing.patch patches/openjdk/7195301-no_instanceof_node.patch patches/security/20130618/6741606-apache_santuario.patch patches/security/20130618/7158805-nested_subroutine_rewriting.patch patches/security/20130618/7170730-windows_network_stack.patch patches/security/20130618/8000638-improve_deserialization.patch patches/security/20130618/8000642-better_transportation_handling.patch patches/security/20130618/8001032-restrict_object_access-corba.patch patches/security/20130618/8001032-restrict_object_access-jdk.patch patches/security/20130618/8001033-refactor_address_handling.patch patches/security/20130618/8001034-memory_management.patch patches/security/20130618/8001038-resourcefully_handle_resources.patch patches/security/20130618/8001043-clarify_definition_restrictions.patch patches/security/20130618/8001309-better_handling_of_annotation_interfaces.patch patches/security/20130618/8001318-6_fixup.patch patches/security/20130618/8001318-socket_getlocaladdress_consistency.patch patches/security/20130618/8001330-checking_order_improvement.patch patches/security/20130618/8001330-improve_checking_order.patch patches/security/20130618/8003703-update_rmi_connection_dialog.patch patches/security/20130618/8004584-augment_applet_contextualization.patch patches/security/20130618/8005007-better_glyph_processing.patch patches/security/20130618/8006328-6_fixup.patch patches/security/20130618/8006328-sound_class_robustness.patch patches/security/20130618/8006611-improve_scripting.patch patches/security/20130618/8007467-improve_jmx_internal_api_robustness.patch patches/security/20130618/8007471-6_fixup.patch patches/security/20130618/8007471-improve_mbean_notifications.patch patches/security/20130618/8007812-getenclosingmethod.patch patches/security/20130618/8008120-improve_jmx_class_checking.patch patches/security/20130618/8008124-better_compliance_testing.patch patches/security/20130618/8008128-better_jmx_api_coherence.patch patches/security/20130618/8008132-better_serialization.patch patches/security/20130618/8008585-jmx_data_handling.patch patches/security/20130618/8008593-better_urlclassloader.patch patches/security/20130618/8008603-jmx_provider_provision.patch patches/security/20130618/8008611-6_fixup.patch patches/security/20130618/8008611-jmx_annotations.patch patches/security/20130618/8008615-jmx_internal_api_robustness.patch patches/security/20130618/8008623-mbeanserver_handling.patch patches/security/20130618/8008744-6741606_rework.patch patches/security/20130618/8008982-jmx_interface_changes.patch patches/security/20130618/8009004-rmi_connection_improvement.patch patches/security/20130618/8009013-t2k_glyphs.patch patches/security/20130618/8009034-jmx_notification_improvement.patch patches/security/20130618/8009038-jmx_notification_support_improvement.patch patches/security/20130618/8009067-improve_key_storing.patch patches/security/20130618/8009071-improve_shape_handling.patch patches/security/20130618/8009235-improve_tsa_data_handling.patch patches/security/20130618/8009554-serialjavaobject.patch patches/security/20130618/8011243-improve_imaginglib.patch patches/security/20130618/8011248-better_component_rasters.patch patches/security/20130618/8011253-better_short_component_rasters.patch patches/security/20130618/8011257-better_byte_component_rasters.patch patches/security/20130618/8011557-improve_reflection.patch patches/security/20130618/8012375-javadoc_framing.patch patches/security/20130618/8012421-better_positioning.patch patches/security/20130618/8012438-better_image_validation.patch patches/security/20130618/8012597-better_image_channel_validation.patch patches/security/20130618/8012601-better_layout_validation.patch patches/security/20130618/8014281-better_xml_signature_checking.patch patches/security/20130618/8015997-more_javadoc_framing.patch patches/security/20130618/diamond_fix.patch patches/security/20130618/handle_npe.patch patches/security/20130618/hs_merge-01.patch patches/security/20130618/hs_merge-02.patch patches/security/20130618/hs_merge-03.patch patches/security/20130618/hs_merge-04.patch patches/security/20130618/javac_issue.patch patches/security/20130618/langtools_generics.patch patches/security/20130618/langtools_merge-01.patch patches/security/20130618/langtools_merge-02.patch patches/security/20130618/langtools_merge-03.patch
diffstat 93 files changed, 118852 insertions(+), 410 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Apr 25 14:16:00 2013 +0100
+++ b/ChangeLog	Sat Jun 22 16:38:24 2013 -0500
@@ -1,3 +1,109 @@
+2013-06-22  Andrew John Hughes  <gnu.andrew@member.fsf.org>
+
+	* patches/idresolver_fix.patch:
+	Removed.  Part of 6469266.
+	* Makefile.am:
+	(SECURITY_PATCHES): Add new ones.
+	(SPECIAL_SECURITY_PATCH_1): Renamed from
+	SPECIAL_SECURITY_PATCH.
+	(SPECIAL_SECURITY_PATCH_2): Add 8009071, which
+	needs to be applied after some AWT backports.
+	(ICEDTEA_PATCHES): Use SPECIAL_SECURITY_PATCH_{1,2}.
+	Move 8005615, 8007393 & 8007611 to SECURITY_PATCHES
+	as must be applied before 8004584.  Add 7171223 to
+	end.
+	* patches/openjdk/6307603-xrender-01.patch,
+	* patches/openjdk/6469266-xmlsec_1.4.2.patch,
+	* patches/openjdk/6656651-windows_lcd_glyphs.patch,
+	* patches/openjdk/6786028-wcag_bold_tags.patch,
+	* patches/openjdk/6786682-wcag_lang.patch,
+	* patches/openjdk/6786688-wcag_table.patch,
+	* patches/openjdk/6786690-wcag_dl.patch,
+	* patches/openjdk/6802694-no_deprecated.patch,
+	* patches/openjdk/6851834-restructure.patch,
+	* patches/openjdk/6888167-medialib_memory_leaks.patch,
+	* patches/openjdk/6961178-doclet_xml.patch,
+	* patches/openjdk/6990754-use_native_memory_for_symboltable.patch,
+	* patches/openjdk/7006270-regressions.patch,
+	* patches/openjdk/7008809-report_class_in_arraystoreexception.patch,
+	* patches/openjdk/7014851-unused_parallel_compaction_code.patch,
+	* patches/openjdk/7017732-move_static_fields_to_class.patch,
+	* patches/openjdk/7036747-elfstringtable.patch,
+	* patches/openjdk/7086585-flexible_field_injection.patch,
+	* patches/openjdk/7171223-strict_aliasing.patch,
+	* patches/openjdk/7195301-no_instanceof_node.patch,
+	* patches/security/20130618/6741606-apache_santuario.patch,
+	* patches/security/20130618/7158805-nested_subroutine_rewriting.patch,
+	* patches/security/20130618/7170730-windows_network_stack.patch,
+	* patches/security/20130618/8000638-improve_deserialization.patch,
+	* patches/security/20130618/8000642-better_transportation_handling.patch,
+	* patches/security/20130618/8001032-restrict_object_access-corba.patch,
+	* patches/security/20130618/8001032-restrict_object_access-jdk.patch,
+	* patches/security/20130618/8001033-refactor_address_handling.patch,
+	* patches/security/20130618/8001034-memory_management.patch,
+	* patches/security/20130618/8001038-resourcefully_handle_resources.patch,
+	* patches/security/20130618/8001043-clarify_definition_restrictions.patch,
+	* patches/security/20130618/8001309-better_handling_of_annotation_interfaces.patch,
+	* patches/security/20130618/8001318-6_fixup.patch,
+	* patches/security/20130618/8001318-socket_getlocaladdress_consistency.patch,
+	* patches/security/20130618/8001330-checking_order_improvement.patch,
+	* patches/security/20130618/8001330-improve_checking_order.patch,
+	* patches/security/20130618/8003703-update_rmi_connection_dialog.patch,
+	* patches/security/20130618/8004584-augment_applet_contextualization.patch,
+	* patches/security/20130618/8005007-better_glyph_processing.patch,
+	* patches/security/20130618/8006328-6_fixup.patch,
+	* patches/security/20130618/8006328-sound_class_robustness.patch,
+	* patches/security/20130618/8006611-improve_scripting.patch,
+	* patches/security/20130618/8007467-improve_jmx_internal_api_robustness.patch,
+	* patches/security/20130618/8007471-6_fixup.patch,
+	* patches/security/20130618/8007471-improve_mbean_notifications.patch,
+	* patches/security/20130618/8007812-getenclosingmethod.patch,
+	* patches/security/20130618/8008120-improve_jmx_class_checking.patch,
+	* patches/security/20130618/8008124-better_compliance_testing.patch,
+	* patches/security/20130618/8008128-better_jmx_api_coherence.patch,
+	* patches/security/20130618/8008132-better_serialization.patch,
+	* patches/security/20130618/8008585-jmx_data_handling.patch,
+	* patches/security/20130618/8008593-better_urlclassloader.patch,
+	* patches/security/20130618/8008603-jmx_provider_provision.patch,
+	* patches/security/20130618/8008611-6_fixup.patch,
+	* patches/security/20130618/8008611-jmx_annotations.patch,
+	* patches/security/20130618/8008615-jmx_internal_api_robustness.patch,
+	* patches/security/20130618/8008623-mbeanserver_handling.patch,
+	* patches/security/20130618/8008744-6741606_rework.patch,
+	* patches/security/20130618/8008982-jmx_interface_changes.patch,
+	* patches/security/20130618/8009004-rmi_connection_improvement.patch,
+	* patches/security/20130618/8009013-t2k_glyphs.patch,
+	* patches/security/20130618/8009034-jmx_notification_improvement.patch,
+	* patches/security/20130618/8009038-jmx_notification_support_improvement.patch,
+	* patches/security/20130618/8009067-improve_key_storing.patch,
+	* patches/security/20130618/8009071-improve_shape_handling.patch,
+	* patches/security/20130618/8009235-improve_tsa_data_handling.patch,
+	* patches/security/20130618/8009554-serialjavaobject.patch,
+	* patches/security/20130618/8011243-improve_imaginglib.patch,
+	* patches/security/20130618/8011248-better_component_rasters.patch,
+	* patches/security/20130618/8011253-better_short_component_rasters.patch,
+	* patches/security/20130618/8011257-better_byte_component_rasters.patch,
+	* patches/security/20130618/8011557-improve_reflection.patch,
+	* patches/security/20130618/8012375-javadoc_framing.patch,
+	* patches/security/20130618/8012421-better_positioning.patch,
+	* patches/security/20130618/8012438-better_image_validation.patch,
+	* patches/security/20130618/8012597-better_image_channel_validation.patch,
+	* patches/security/20130618/8012601-better_layout_validation.patch,
+	* patches/security/20130618/8014281-better_xml_signature_checking.patch,
+	* patches/security/20130618/8015997-more_javadoc_framing.patch,
+	* patches/security/20130618/diamond_fix.patch,
+	* patches/security/20130618/handle_npe.patch,
+	* patches/security/20130618/hs_merge-01.patch,
+	* patches/security/20130618/hs_merge-02.patch,
+	* patches/security/20130618/hs_merge-03.patch,
+	* patches/security/20130618/hs_merge-04.patch,
+	* patches/security/20130618/javac_issue.patch,
+	* patches/security/20130618/langtools_generics.patch,
+	* patches/security/20130618/langtools_merge-01.patch,
+	* patches/security/20130618/langtools_merge-02.patch,
+	* patches/security/20130618/langtools_merge-03.patch:
+	2013/06/18 security patches.
+
 2013-04-25  Andrew John Hughes  <gnu.andrew@member.fsf.org>
 
 	* configure.ac: Bump to 1.11.12pre.
--- a/Makefile.am	Thu Apr 25 14:16:00 2013 +0100
+++ b/Makefile.am	Sat Jun 22 16:38:24 2013 -0500
@@ -315,9 +315,99 @@
 	patches/security/20130416/8009305.patch \
 	patches/security/20130416/8009699.patch \
 	patches/security/20130416/8009814.patch \
-	patches/security/20130416/8009857.patch
+	patches/security/20130416/8009857.patch \
+	patches/openjdk/7195301-no_instanceof_node.patch \
+	patches/openjdk/6469266-xmlsec_1.4.2.patch \
+	patches/security/20130618/6741606-apache_santuario.patch \
+	patches/security/20130618/7170730-windows_network_stack.patch \
+	patches/security/20130618/8000638-improve_deserialization.patch \
+	patches/security/20130618/8001032-restrict_object_access-corba.patch \
+	patches/security/20130618/8001032-restrict_object_access-jdk.patch \
+	patches/security/20130618/8001033-refactor_address_handling.patch \
+	patches/security/20130618/8001034-memory_management.patch \
+	patches/security/20130618/8001038-resourcefully_handle_resources.patch \
+	patches/security/20130618/8001043-clarify_definition_restrictions.patch \
+	patches/security/20130618/8001309-better_handling_of_annotation_interfaces.patch \
+	patches/security/20130618/8001318-socket_getlocaladdress_consistency.patch \
+	patches/security/20130618/8001318-6_fixup.patch \
+	patches/security/20130618/8001330-improve_checking_order.patch \
+	patches/security/20130618/8003703-update_rmi_connection_dialog.patch \
+	patches/openjdk/8005615-failure_to_load_logger_implementation.patch \
+	patches/openjdk/8007393.patch \
+	patches/openjdk/8007611.patch \
+	patches/security/20130618/8004584-augment_applet_contextualization.patch \
+	patches/security/20130618/8005007-better_glyph_processing.patch \
+	patches/security/20130618/8006328-sound_class_robustness.patch \
+	patches/security/20130618/8006328-6_fixup.patch \
+	patches/security/20130618/8006611-improve_scripting.patch \
+	patches/security/20130618/8007467-improve_jmx_internal_api_robustness.patch \
+	patches/security/20130618/8007471-improve_mbean_notifications.patch \
+	patches/security/20130618/8007471-6_fixup.patch \
+	patches/security/20130618/8007812-getenclosingmethod.patch \
+	patches/security/20130618/8008120-improve_jmx_class_checking.patch \
+	patches/security/20130618/8008124-better_compliance_testing.patch \
+	patches/security/20130618/8008128-better_jmx_api_coherence.patch \
+	patches/security/20130618/8008132-better_serialization.patch \
+	patches/security/20130618/8008585-jmx_data_handling.patch \
+	patches/security/20130618/8008593-better_urlclassloader.patch \
+	patches/security/20130618/8008603-jmx_provider_provision.patch \
+	patches/security/20130618/8008611-jmx_annotations.patch \
+	patches/security/20130618/8008611-6_fixup.patch \
+	patches/security/20130618/8008615-jmx_internal_api_robustness.patch \
+	patches/security/20130618/8008623-mbeanserver_handling.patch \
+	patches/security/20130618/8008744-6741606_rework.patch \
+	patches/security/20130618/8008982-jmx_interface_changes.patch \
+	patches/security/20130618/8009004-rmi_connection_improvement.patch \
+	patches/security/20130618/8009013-t2k_glyphs.patch \
+	patches/security/20130618/8009034-jmx_notification_improvement.patch \
+	patches/security/20130618/8009038-jmx_notification_support_improvement.patch \
+	patches/security/20130618/8009067-improve_key_storing.patch \
+	patches/security/20130618/8009235-improve_tsa_data_handling.patch \
+	patches/security/20130618/8009554-serialjavaobject.patch \
+	patches/openjdk/6888167-medialib_memory_leaks.patch \
+	patches/security/20130618/8011243-improve_imaginglib.patch \
+	patches/security/20130618/8011248-better_component_rasters.patch \
+	patches/security/20130618/8011253-better_short_component_rasters.patch \
+	patches/security/20130618/8011257-better_byte_component_rasters.patch \
+	patches/security/20130618/8011557-improve_reflection.patch \
+	patches/security/20130618/8012421-better_positioning.patch \
+	patches/security/20130618/8012438-better_image_validation.patch \
+	patches/security/20130618/8012597-better_image_channel_validation.patch \
+	patches/security/20130618/8012601-better_layout_validation.patch \
+	patches/security/20130618/8014281-better_xml_signature_checking.patch \
+	patches/security/20130618/diamond_fix.patch \
+	patches/security/20130618/handle_npe.patch \
+	patches/security/20130618/javac_issue.patch \
+	patches/security/20130618/7158805-nested_subroutine_rewriting.patch \
+	patches/security/20130618/8001330-checking_order_improvement.patch \
+	patches/openjdk/7036747-elfstringtable.patch \
+	patches/openjdk/7017732-move_static_fields_to_class.patch \
+	patches/openjdk/6990754-use_native_memory_for_symboltable.patch \
+	patches/openjdk/7008809-report_class_in_arraystoreexception.patch \
+	patches/openjdk/7086585-flexible_field_injection.patch \
+	patches/security/20130618/hs_merge-01.patch \
+	patches/security/20130618/hs_merge-02.patch \
+	patches/security/20130618/hs_merge-03.patch \
+	patches/openjdk/7014851-unused_parallel_compaction_code.patch \
+	patches/security/20130618/hs_merge-04.patch \
+	patches/security/20130618/8000642-better_transportation_handling.patch \
+	patches/openjdk/6786028-wcag_bold_tags.patch \
+	patches/openjdk/6786682-wcag_lang.patch \
+	patches/openjdk/6802694-no_deprecated.patch \
+	patches/openjdk/6786690-wcag_dl.patch \
+	patches/openjdk/6786688-wcag_table.patch \
+	patches/openjdk/6961178-doclet_xml.patch \
+	patches/openjdk/6851834-restructure.patch \
+	patches/openjdk/7006270-regressions.patch \
+	patches/security/20130618/8012375-javadoc_framing.patch \
+	patches/security/20130618/8015997-more_javadoc_framing.patch \
+	patches/security/20130618/langtools_merge-01.patch \
+	patches/security/20130618/langtools_merge-02.patch \
+	patches/security/20130618/langtools_generics.patch \
+	patches/security/20130618/langtools_merge-03.patch
 
-SPECIAL_SECURITY_PATCH = patches/security/20120214/7112642.patch
+SPECIAL_SECURITY_PATCH_1 = patches/security/20120214/7112642.patch
+SPECIAL_SECURITY_PATCH_2 = patches/security/20130618/8009071-improve_shape_handling.patch
 
 ICEDTEA_PATCHES = \
 	$(DROP_PATCHES) \
@@ -335,13 +425,15 @@
 	patches/openjdk/6725214-direct3d-01.patch \
 	patches/openjdk/6748082-isDisplayLocal.patch \
 	patches/openjdk/6633275-shaped_translucent_windows.patch \
-	$(SPECIAL_SECURITY_PATCH) \
+	$(SPECIAL_SECURITY_PATCH_1) \
 	patches/openjdk/6769607-modal-hangs.patch \
 	patches/openjdk/6791612-opengl-jni-fix.patch \
 	patches/openjdk/6755274-glgetstring-crash.patch \
 	patches/openjdk/6984543-onscreen_rendering_resize_test.patch \
 	patches/openjdk/6693253-security_warning.patch \
 	patches/openjdk/6444769-windowwithwarningtest.patch \
+	patches/openjdk/6656651-windows_lcd_glyphs.patch \
+	$(SPECIAL_SECURITY_PATCH_2) \
 	patches/notice-safepoints.patch \
 	patches/parisc-opt.patch \
 	patches/lucene-crash.patch \
@@ -521,7 +613,6 @@
 	patches/openjdk/7103725-ssl_beast_regression.patch \
 	patches/openjdk/7140882-dont-return-booleans-from-methods-returning-pointers.patch \
 	patches/openjdk/remove-mimpure-option-to-gcc.patch \
-	patches/idresolver_fix.patch \
 	patches/openjdk/6792400-Avoid_loading_Normalizer_resources.patch \
 	patches/openjdk/7185678-xmenuitem_peer_npe.patch \
 	patches/merge_fix.patch \
@@ -529,18 +620,16 @@
 	patches/openjdk/7177216-native2ascii_changes_file_permissions.patch \
 	patches/openjdk/7199153-try_with_resources_pushed_to_6.patch \
 	patches/openjdk/7010849-modernise_sa.patch \
-	patches/openjdk/8005615-failure_to_load_logger_implementation.patch \
 	patches/openjdk/8004341-jck_dialog_failure.patch \
 	patches/openjdk/8004341-jck_dialog_failure-02.patch \
 	patches/pr1319-support_giflib_5.patch \
-	patches/openjdk/8007393.patch \
-	patches/openjdk/8007611.patch \
 	patches/fix_get_stack_bounds_leak.patch \
 	patches/openjdk/7197906-handle_32_bit_shifts.patch \
 	patches/aarch64.patch \
 	patches/jaxws-tempfiles-ioutils-6.patch \
 	patches/object-factory-cl-internal.patch \
-	patches/openjdk/8009530-icu_kern_table_support_broken.patch
+	patches/openjdk/8009530-icu_kern_table_support_broken.patch \
+	patches/openjdk/7171223-strict_aliasing.patch
 
 if WITH_RHINO
 ICEDTEA_PATCHES += \
--- a/patches/idresolver_fix.patch	Thu Apr 25 14:16:00 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,194 +0,0 @@
---- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java	2012-03-20 20:29:30.000000000 +0100
-+++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java	2012-03-20 22:18:41.094309861 +0100
-@@ -26,6 +26,7 @@
- import org.w3c.dom.Attr;
- import org.w3c.dom.Document;
- import org.w3c.dom.Element;
-+import org.w3c.dom.NamedNodeMap;
- import org.w3c.dom.Node;
- 
- import java.util.Arrays;
-@@ -175,69 +176,124 @@
-        return null;
-    }
- 
-+    private static java.util.List names;
-+    private static int namesLength;
-+    static {
-+        String namespaces[]={
-+            Constants.SignatureSpecNS,
-+            EncryptionConstants.EncryptionSpecNS,
-+            "http://schemas.xmlsoap.org/soap/security/2000-12",
-+            "http://www.w3.org/2002/03/xkms#",
-+            "urn:oasis:names:tc:SAML:1.0:assertion",
-+            "urn:oasis:names:tc:SAML:1.0:protocol"
-+        };
-+        names = Arrays.asList(namespaces);
-+        namesLength = names.size();
-+    }
- 
--   static java.util.List names;
--   static {
--           String namespaces[]={ Constants.SignatureSpecNS,
--                           EncryptionConstants.EncryptionSpecNS,
--                           "http://schemas.xmlsoap.org/soap/security/2000-12",
--                           "http://www.w3.org/2002/03/xkms#"
--                   };
--           names=Arrays.asList(namespaces);
--   }
- 
-+    private static Element getElementBySearching(Node root,String id) {
-+            Element []els=new Element[namesLength + 1];
-+            getEl(root,id,els);
-+            for (int i=0;i<els.length;i++) {
-+                    if (els[i]!=null) {
-+                            return els[i];
-+                    }
-+            }
-+            return null;
-+    }
- 
--   private static Element getElementBySearching(Node root,String id) {
--           Element []els=new Element[5];
--           getElementBySearching(root,id,els);
--           for (int i=0;i<els.length;i++) {
--                   if (els[i]!=null) {
--                           return els[i];
--                   }
--           }
--           return null;
-+    private static int getEl(Node currentNode,String id,Element []els) {
-+        Node sibling=null;
-+        Node parentNode=null;
-+        do {
-+                switch (currentNode.getNodeType()) {
-+                case Node.DOCUMENT_FRAGMENT_NODE :
-+                case Node.DOCUMENT_NODE :
-+                        sibling= currentNode.getFirstChild();
-+                        break;
-+
-+
-+                case Node.ELEMENT_NODE :
-+                        Element currentElement = (Element) currentNode;
-+                        if (isElement(currentElement, id, els)==1)
-+                                return 1;
-+                        sibling= currentNode.getFirstChild();
-+                        if (sibling==null) {
-+                            if (parentNode != null) {
-+                                        sibling= currentNode.getNextSibling();
-+                                    }
-+                        } else {
-+                                parentNode=currentElement;
-+                        }
-+                        break;
-+        } while (sibling==null  && parentNode!=null) {
-+                        sibling=parentNode.getNextSibling();
-+                        parentNode=parentNode.getParentNode();
-+                        if (!(parentNode instanceof Element)) {
-+                                parentNode=null;
-+                        }
-+                }
-+                if (sibling==null)
-+                        return 1;
-+                currentNode=sibling;
-+                sibling=currentNode.getNextSibling();
-+        } while(true);
- 
--   }
--   private static int getElementBySearching(Node root,String id,Element []els) {
--           switch (root.getNodeType()) {
--           case Node.ELEMENT_NODE:
--                   Element el=(Element)root;
--                   if (el.hasAttributes()) {
--                           int index=names.indexOf(el.getNamespaceURI());
--                           if (index<0) {
--                                   index=4;
--                           }
--                           if (el.getAttribute("Id").equals(id)) {
--                                   els[index]=el;
--                                   if (index==0) {
--                                           return 1;
--                                   }
--                           } else if ( el.getAttribute("id").equals(id) ) {
--                                   if (index!=2) {
--                                           index=4;
--                                   }
--                                   els[index]=el;
--                           } else if ( el.getAttribute("ID").equals(id) ) {
--                                   if (index!=3) {
--                                           index=4;
--                                   }
--                                   els[index]=el;
--                           } else if ((index==3)&&(
--                                   el.getAttribute("OriginalRequestID").equals(id) ||
--                                   el.getAttribute("RequestID").equals(id) ||
--                                   el.getAttribute("ResponseID" ).equals(id))) {
--                                   els[3]=el;
--                           }
--                   }
--                case Node.DOCUMENT_NODE:
--                        Node sibling=root.getFirstChild();
--                        while (sibling!=null) {
--                                if (getElementBySearching(sibling,id,els)==1)
-+    }
-+    private static int isElement(Element el, String id,Element[] els) {
-+        if (!el.hasAttributes()) {
-+                return 0;
-+        }
-+        NamedNodeMap ns=el.getAttributes();
-+        int elementIndex=names.indexOf(el.getNamespaceURI());
-+            elementIndex=(elementIndex<0) ? namesLength : elementIndex;
-+        for (int length=ns.getLength(), i=0; i<length; i++) {
-+                Attr n=(Attr)ns.item(i);
-+                String s=n.getNamespaceURI();
-+
-+                    int index=s==null ? elementIndex : names.indexOf(n.getNamespaceURI());
-+                    index=(index<0) ? namesLength : index;
-+                    String name=n.getLocalName();
-+                    if (name == null)
-+                        name = n.getName();
-+                    if (name.length()>2)
-+                        continue;
-+                    String value=n.getNodeValue();
-+                    if (name.charAt(0)=='I') {
-+                        char ch=name.charAt(1);
-+                        if (ch=='d' && value.equals(id)) {
-+                                els[index]=el;
-+                                if (index==0) {
-                                         return 1;
--                                sibling=sibling.getNextSibling();
-+                                }
-+                        } else if (ch=='D' &&value.endsWith(id)) {
-+                                if (index!=3) {
-+                                    index=namesLength;
-+                                }
-+                                els[index]=el;
-                         }
--           }
--           return 0;
--   }
--
-+                    } else if ( "id".equals(name) && value.equals(id) ) {
-+                        if (index!=2) {
-+                                index=namesLength;
-+                        }
-+                        els[index]=el;
-+                    }
-+        }
-+        //For an element namespace search for importants
-+        if ((elementIndex==3)&&(
-+                    el.getAttribute("OriginalRequestID").equals(id) ||
-+                    el.getAttribute("RequestID").equals(id) ||
-+                    el.getAttribute("ResponseID").equals(id))) {
-+                    els[3]=el;
-+        } else if ((elementIndex==4)&&(
-+                    el.getAttribute("AssertionID").equals(id))) {
-+                    els[4]=el;
-+        } else if ((elementIndex==5)&&(
-+                    el.getAttribute("RequestID").equals(id) ||
-+                    el.getAttribute("ResponseID").equals(id))) {
-+                    els[5]=el;
-+                 }
-+        return 0;
-+    }
- }
--- a/patches/openjdk/6307603-xrender-01.patch	Thu Apr 25 14:16:00 2013 +0100
+++ b/patches/openjdk/6307603-xrender-01.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -1,6 +1,6 @@
 diff -Nru openjdk.orig/jdk/make/sun/awt/mapfile-mawt-vers openjdk/jdk/make/sun/awt/mapfile-mawt-vers
---- openjdk.orig/jdk/make/sun/awt/mapfile-mawt-vers	2011-02-17 16:00:41.000000000 +0000
-+++ openjdk/jdk/make/sun/awt/mapfile-mawt-vers	2011-02-17 16:52:48.186147394 +0000
+--- openjdk.orig/jdk/make/sun/awt/mapfile-mawt-vers	2013-06-22 16:01:50.561607738 -0500
++++ openjdk/jdk/make/sun/awt/mapfile-mawt-vers	2013-06-22 16:16:23.516699861 -0500
 @@ -312,6 +312,7 @@
                  Java_sun_awt_X11GraphicsEnvironment_initGLX;
  		Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama;
@@ -71,9 +71,9 @@
                  Java_sun_java2d_opengl_OGLContext_getOGLIdString;
                  Java_sun_java2d_opengl_OGLMaskFill_maskFill;
 diff -Nru openjdk.orig/jdk/make/sun/awt/mapfile-vers-linux openjdk/jdk/make/sun/awt/mapfile-vers-linux
---- openjdk.orig/jdk/make/sun/awt/mapfile-vers-linux	2011-02-17 16:00:41.000000000 +0000
-+++ openjdk/jdk/make/sun/awt/mapfile-vers-linux	2011-02-17 16:52:48.186147394 +0000
-@@ -426,6 +426,7 @@
+--- openjdk.orig/jdk/make/sun/awt/mapfile-vers-linux	2013-06-22 16:01:50.740608553 -0500
++++ openjdk/jdk/make/sun/awt/mapfile-vers-linux	2013-06-22 16:16:23.517699859 -0500
+@@ -428,6 +428,7 @@
  		Java_sun_awt_X11GraphicsEnvironment_initDisplay;
  		Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama;
  		Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint;
@@ -82,8 +82,8 @@
          
  
 diff -Nru openjdk.orig/jdk/make/sun/headless/mapfile-vers openjdk/jdk/make/sun/headless/mapfile-vers
---- openjdk.orig/jdk/make/sun/headless/mapfile-vers	2011-02-17 16:00:33.000000000 +0000
-+++ openjdk/jdk/make/sun/headless/mapfile-vers	2011-02-17 16:52:48.186147394 +0000
+--- openjdk.orig/jdk/make/sun/headless/mapfile-vers	2013-06-22 16:01:48.352591297 -0500
++++ openjdk/jdk/make/sun/headless/mapfile-vers	2013-06-22 16:16:23.518699857 -0500
 @@ -46,17 +46,20 @@
  		Java_sun_java2d_x11_X11Renderer_XFillRoundRect;
  		Java_sun_java2d_x11_X11Renderer_devCopyArea;
@@ -112,8 +112,8 @@
  		Java_java_awt_Font_initIDs;
                  Java_sun_font_FontManager_getFontConfig;
 diff -Nru openjdk.orig/jdk/make/sun/jawt/Makefile openjdk/jdk/make/sun/jawt/Makefile
---- openjdk.orig/jdk/make/sun/jawt/Makefile	2011-02-17 16:00:41.000000000 +0000
-+++ openjdk/jdk/make/sun/jawt/Makefile	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/make/sun/jawt/Makefile	2013-06-22 16:01:49.796603467 -0500
++++ openjdk/jdk/make/sun/jawt/Makefile	2013-06-22 16:16:23.518699857 -0500
 @@ -118,7 +118,7 @@
  # Libraries to link in.
  #
@@ -124,8 +124,8 @@
  
  ifeq ($(PLATFORM), linux)
 diff -Nru openjdk.orig/jdk/make/sun/xawt/FILES_c_unix.gmk openjdk/jdk/make/sun/xawt/FILES_c_unix.gmk
---- openjdk.orig/jdk/make/sun/xawt/FILES_c_unix.gmk	2011-02-17 16:00:41.000000000 +0000
-+++ openjdk/jdk/make/sun/xawt/FILES_c_unix.gmk	2011-02-17 16:53:14.908062495 +0000
+--- openjdk.orig/jdk/make/sun/xawt/FILES_c_unix.gmk	2013-06-22 16:01:49.406600186 -0500
++++ openjdk/jdk/make/sun/xawt/FILES_c_unix.gmk	2013-06-22 16:16:23.518699857 -0500
 @@ -79,4 +79,7 @@
  	gtk2_interface.c \
          swing_GTKEngine.c \
@@ -136,8 +136,8 @@
 +	XRBackendNative.c
 +
 diff -Nru openjdk.orig/jdk/make/sun/xawt/Makefile openjdk/jdk/make/sun/xawt/Makefile
---- openjdk.orig/jdk/make/sun/xawt/Makefile	2011-02-17 16:00:41.000000000 +0000
-+++ openjdk/jdk/make/sun/xawt/Makefile	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/make/sun/xawt/Makefile	2013-06-22 16:01:49.406600186 -0500
++++ openjdk/jdk/make/sun/xawt/Makefile	2013-06-22 16:16:23.518699857 -0500
 @@ -48,6 +48,11 @@
  
  LDFLAGS += -L$(OPENWIN_LIB)
@@ -169,8 +169,8 @@
  ifeq ($(PLATFORM), linux)
  # Allows for builds on Debian GNU Linux, X11 is in a different place 
 diff -Nru openjdk.orig/jdk/make/sun/xawt/mapfile-vers openjdk/jdk/make/sun/xawt/mapfile-vers
---- openjdk.orig/jdk/make/sun/xawt/mapfile-vers	2011-02-17 16:00:41.000000000 +0000
-+++ openjdk/jdk/make/sun/xawt/mapfile-vers	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/make/sun/xawt/mapfile-vers	2013-06-22 16:01:51.483611926 -0500
++++ openjdk/jdk/make/sun/xawt/mapfile-vers	2013-06-22 16:16:23.518699857 -0500
 @@ -186,6 +186,7 @@
  	Java_sun_font_FontManager_populateFontFileNameMap;
          Java_sun_awt_X11GraphicsEnvironment_initDisplay;
@@ -179,7 +179,7 @@
          Java_sun_awt_X11GraphicsEnvironment_checkShmExt;
          Java_sun_awt_X11GraphicsEnvironment_getNumScreens;
          Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum;
-@@ -337,21 +338,52 @@
+@@ -339,21 +340,52 @@
  	Java_sun_java2d_x11_X11Renderer_XFillRect;
  	Java_sun_java2d_x11_X11Renderer_XFillRoundRect;
          Java_sun_java2d_x11_X11Renderer_devCopyArea;
@@ -241,8 +241,8 @@
          Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow;
          Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box;
 diff -Nru openjdk.orig/jdk/src/share/classes/sun/font/GlyphDisposedListener.java openjdk/jdk/src/share/classes/sun/font/GlyphDisposedListener.java
---- openjdk.orig/jdk/src/share/classes/sun/font/GlyphDisposedListener.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/share/classes/sun/font/GlyphDisposedListener.java	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/share/classes/sun/font/GlyphDisposedListener.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/share/classes/sun/font/GlyphDisposedListener.java	2013-06-22 16:16:23.519699855 -0500
 @@ -0,0 +1,32 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -277,8 +277,8 @@
 +    public void glyphDisposed(ArrayList<Long> glyphs);
 +}
 diff -Nru openjdk.orig/jdk/src/share/classes/sun/font/StrikeCache.java openjdk/jdk/src/share/classes/sun/font/StrikeCache.java
---- openjdk.orig/jdk/src/share/classes/sun/font/StrikeCache.java	2011-02-17 16:00:33.000000000 +0000
-+++ openjdk/jdk/src/share/classes/sun/font/StrikeCache.java	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/share/classes/sun/font/StrikeCache.java	2013-06-22 16:01:48.356591329 -0500
++++ openjdk/jdk/src/share/classes/sun/font/StrikeCache.java	2013-06-22 16:16:23.519699855 -0500
 @@ -31,6 +31,7 @@
  import java.lang.ref.ReferenceQueue;
  import java.lang.ref.SoftReference;
@@ -440,8 +440,8 @@
      public static Reference getStrikeRef(FontStrike strike) {
          return getStrikeRef(strike, cacheRefTypeWeak);
 diff -Nru openjdk.orig/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java openjdk/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java
---- openjdk.orig/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java	2011-01-20 23:54:26.000000000 +0000
-+++ openjdk/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java	2011-11-14 16:12:00.000000000 -0600
++++ openjdk/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java	2013-06-22 16:16:23.519699855 -0500
 @@ -307,7 +307,7 @@
       * linear RGB space.  Copied directly from the
       * MultipleGradientPaintContext class.
@@ -452,8 +452,8 @@
  
          input = color / 255.0f;
 diff -Nru openjdk.orig/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java openjdk/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java
---- openjdk.orig/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java	2011-01-20 23:54:26.000000000 +0000
-+++ openjdk/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java	2011-11-14 16:12:00.000000000 -0600
++++ openjdk/jdk/src/share/classes/sun/java2d/pipe/RenderBuffer.java	2013-06-22 16:16:23.519699855 -0500
 @@ -131,6 +131,11 @@
          curAddress = baseAddress;
      }
@@ -467,8 +467,8 @@
       * putByte() methods...
       */
 diff -Nru openjdk.orig/jdk/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine openjdk/jdk/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine
---- openjdk.orig/jdk/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine	2011-01-20 23:54:26.000000000 +0000
-+++ openjdk/jdk/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine	2011-11-14 16:12:00.000000000 -0600
++++ openjdk/jdk/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine	2013-06-22 16:16:23.519699855 -0500
 @@ -1,2 +1,5 @@
 +# Jules Rendering Engine module
 +sun.java2d.jules.JulesRenderingEngine
@@ -478,8 +478,8 @@
 +sun.java2d.pisces.PiscesRenderingEngine
 \ No newline at end of file
 diff -Nru openjdk.orig/jdk/src/share/native/sun/font/AccelGlyphCache.c openjdk/jdk/src/share/native/sun/font/AccelGlyphCache.c
---- openjdk.orig/jdk/src/share/native/sun/font/AccelGlyphCache.c	2011-02-17 16:00:33.000000000 +0000
-+++ openjdk/jdk/src/share/native/sun/font/AccelGlyphCache.c	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/share/native/sun/font/AccelGlyphCache.c	2013-06-22 16:01:48.363591389 -0500
++++ openjdk/jdk/src/share/native/sun/font/AccelGlyphCache.c	2013-06-22 16:16:23.519699855 -0500
 @@ -325,6 +325,7 @@
      cellInfo->glyphInfo = glyph;
      cellInfo->nextGCI = glyph->cellInfo;
@@ -489,8 +489,8 @@
  
  /**
 diff -Nru openjdk.orig/jdk/src/share/native/sun/font/fontscalerdefs.h openjdk/jdk/src/share/native/sun/font/fontscalerdefs.h
---- openjdk.orig/jdk/src/share/native/sun/font/fontscalerdefs.h	2011-01-20 23:54:38.000000000 +0000
-+++ openjdk/jdk/src/share/native/sun/font/fontscalerdefs.h	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/share/native/sun/font/fontscalerdefs.h	2013-06-22 16:01:44.530580871 -0500
++++ openjdk/jdk/src/share/native/sun/font/fontscalerdefs.h	2013-06-22 16:16:23.520699854 -0500
 @@ -84,15 +84,26 @@
  
  #define t2kScalarAverage(a, b) (((a) + (b)) / (t2kScalar)(2))
@@ -520,8 +520,8 @@
  } GlyphInfo;
  
 diff -Nru openjdk.orig/jdk/src/share/native/sun/font/freetypeScaler.c openjdk/jdk/src/share/native/sun/font/freetypeScaler.c
---- openjdk.orig/jdk/src/share/native/sun/font/freetypeScaler.c	2011-02-17 16:00:43.000000000 +0000
-+++ openjdk/jdk/src/share/native/sun/font/freetypeScaler.c	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/share/native/sun/font/freetypeScaler.c	2013-06-22 16:01:50.403607017 -0500
++++ openjdk/jdk/src/share/native/sun/font/freetypeScaler.c	2013-06-22 16:16:23.520699854 -0500
 @@ -783,6 +783,7 @@
          return ptr_to_jlong(glyphInfo);
      }
@@ -540,8 +540,8 @@
                     point; and a second-order control point if unset.  */
                  current_type = SEG_CUBICTO;
 diff -Nru openjdk.orig/jdk/src/share/native/sun/font/sunFont.c openjdk/jdk/src/share/native/sun/font/sunFont.c
---- openjdk.orig/jdk/src/share/native/sun/font/sunFont.c	2011-02-17 16:00:33.000000000 +0000
-+++ openjdk/jdk/src/share/native/sun/font/sunFont.c	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/share/native/sun/font/sunFont.c	2013-06-22 16:01:48.363591389 -0500
++++ openjdk/jdk/src/share/native/sun/font/sunFont.c	2013-06-22 16:16:23.520699854 -0500
 @@ -294,7 +294,8 @@
          for (i=0; i< len; i++) {
              if (ptrs[i] != 0) {
@@ -572,8 +572,8 @@
  }
  
 diff -Nru openjdk.orig/jdk/src/share/native/sun/java2d/opengl/OGLTextRenderer.c openjdk/jdk/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
---- openjdk.orig/jdk/src/share/native/sun/java2d/opengl/OGLTextRenderer.c	2011-01-20 23:54:39.000000000 +0000
-+++ openjdk/jdk/src/share/native/sun/java2d/opengl/OGLTextRenderer.c	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/share/native/sun/java2d/opengl/OGLTextRenderer.c	2011-11-14 16:12:13.000000000 -0600
++++ openjdk/jdk/src/share/native/sun/java2d/opengl/OGLTextRenderer.c	2013-06-22 16:16:23.521699853 -0500
 @@ -244,6 +244,7 @@
  OGLTR_AddToGlyphCache(GlyphInfo *glyph, jboolean rgbOrder)
  {
@@ -616,8 +616,8 @@
  
      // location of the glyph in the destination's coordinate space
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java openjdk/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java
---- openjdk.orig/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java	2011-02-17 16:00:33.000000000 +0000
-+++ openjdk/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java	2013-06-22 16:01:48.369591440 -0500
++++ openjdk/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java	2013-06-22 16:16:23.521699853 -0500
 @@ -37,6 +37,7 @@
  import java.util.HashMap;
  
@@ -679,8 +679,8 @@
          }
      }
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java openjdk/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java
---- openjdk.orig/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java	2011-01-20 23:54:40.000000000 +0000
-+++ openjdk/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java	2013-06-22 16:01:48.462592225 -0500
++++ openjdk/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java	2013-06-22 16:16:23.522699852 -0500
 @@ -26,6 +26,7 @@
  package sun.awt;
  
@@ -764,8 +764,8 @@
       * Checks if Shared Memory extension can be used.
       * Returns:
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java openjdk/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java
---- openjdk.orig/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java	2011-02-17 16:52:48.198146458 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/font/XRGlyphCacheEntry.java	2013-06-22 16:16:23.522699852 -0500
 @@ -0,0 +1,206 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -974,8 +974,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/font/XRGlyphCache.java openjdk/jdk/src/solaris/classes/sun/font/XRGlyphCache.java
---- openjdk.orig/jdk/src/solaris/classes/sun/font/XRGlyphCache.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/font/XRGlyphCache.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/font/XRGlyphCache.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/font/XRGlyphCache.java	2013-06-22 16:16:23.522699852 -0500
 @@ -0,0 +1,301 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -1279,8 +1279,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/font/XRTextRenderer.java openjdk/jdk/src/solaris/classes/sun/font/XRTextRenderer.java
---- openjdk.orig/jdk/src/solaris/classes/sun/font/XRTextRenderer.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/font/XRTextRenderer.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/font/XRTextRenderer.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/font/XRTextRenderer.java	2013-06-22 16:16:23.523699851 -0500
 @@ -0,0 +1,152 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -1435,8 +1435,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/IdleTileCache.java openjdk/jdk/src/solaris/classes/sun/java2d/jules/IdleTileCache.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/IdleTileCache.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/IdleTileCache.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/IdleTileCache.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/IdleTileCache.java	2013-06-22 16:16:23.523699851 -0500
 @@ -0,0 +1,109 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -1548,8 +1548,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesAATileGenerator.java openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesAATileGenerator.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesAATileGenerator.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesAATileGenerator.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesAATileGenerator.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesAATileGenerator.java	2013-06-22 16:16:23.523699851 -0500
 @@ -0,0 +1,349 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -1901,8 +1901,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesPathBuf.java openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesPathBuf.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesPathBuf.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesPathBuf.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesPathBuf.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesPathBuf.java	2013-06-22 16:16:23.524699850 -0500
 @@ -0,0 +1,271 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -2176,8 +2176,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesRenderingEngine.java openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesRenderingEngine.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesRenderingEngine.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesRenderingEngine.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesRenderingEngine.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesRenderingEngine.java	2013-06-22 16:16:23.524699850 -0500
 @@ -0,0 +1,54 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -2234,8 +2234,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesShapePipe.java	2013-06-22 16:16:23.524699850 -0500
 @@ -0,0 +1,102 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -2340,8 +2340,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesTile.java openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesTile.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesTile.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesTile.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/JulesTile.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/JulesTile.java	2013-06-22 16:16:23.524699850 -0500
 @@ -0,0 +1,67 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -2411,8 +2411,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/TileWorker.java openjdk/jdk/src/solaris/classes/sun/java2d/jules/TileWorker.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/TileWorker.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/TileWorker.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/TileWorker.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/TileWorker.java	2013-06-22 16:16:23.524699850 -0500
 @@ -0,0 +1,146 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -2561,8 +2561,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/TrapezoidList.java openjdk/jdk/src/solaris/classes/sun/java2d/jules/TrapezoidList.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/TrapezoidList.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/TrapezoidList.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/jules/TrapezoidList.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/jules/TrapezoidList.java	2013-06-22 16:16:23.524699850 -0500
 @@ -0,0 +1,110 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -2675,8 +2675,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/SurfaceManagerFactory.java openjdk/jdk/src/solaris/classes/sun/java2d/SurfaceManagerFactory.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/SurfaceManagerFactory.java	2011-01-20 23:54:41.000000000 +0000
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/SurfaceManagerFactory.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/SurfaceManagerFactory.java	2011-11-14 16:12:15.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/SurfaceManagerFactory.java	2013-06-22 16:16:23.524699850 -0500
 @@ -34,6 +34,8 @@
  import sun.java2d.opengl.GLXGraphicsConfig;
  import sun.java2d.opengl.GLXVolatileSurfaceManager;
@@ -2705,8 +2705,8 @@
              return new X11VolatileSurfaceManager(vImg, context);
          }
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java openjdk/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	2011-02-17 16:00:43.000000000 +0000
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	2013-06-22 16:01:50.582607833 -0500
++++ openjdk/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	2013-06-22 16:16:23.525699849 -0500
 @@ -46,6 +46,7 @@
  import sun.awt.SunToolkit;
  import sun.awt.X11ComponentPeer;
@@ -2715,7 +2715,7 @@
  import sun.awt.image.PixelConverter;
  import sun.font.X11TextRenderer;
  import sun.java2d.InvalidPipeException;
-@@ -63,7 +64,7 @@
+@@ -64,7 +65,7 @@
  import sun.java2d.pipe.TextPipe;
  import sun.java2d.pipe.Region;
  
@@ -2724,7 +2724,7 @@
      X11ComponentPeer peer;
      X11GraphicsConfig graphicsConfig;
      private RenderLoops solidloops;
-@@ -73,8 +74,6 @@
+@@ -74,8 +75,6 @@
      private static native void initIDs(Class xorComp, boolean tryDGA);
      protected native void initSurface(int depth, int width, int height,
                                        long drawable);
@@ -2733,7 +2733,7 @@
  
      public static final String
          DESC_INT_BGR_X11        = "Integer BGR Pixmap";
-@@ -199,7 +198,8 @@
+@@ -200,7 +199,8 @@
      protected static boolean dgaAvailable;
  
      static {
@@ -2743,7 +2743,7 @@
              // If a screen magnifier is present, don't attempt to use DGA
              String magPresent = (String) java.security.AccessController.doPrivileged
                  (new sun.security.action.GetPropertyAction("javax.accessibility.screen_magnifier_present"));
-@@ -232,7 +232,7 @@
+@@ -233,7 +233,7 @@
                  X11PMBlitLoops.register();
                  X11PMBlitBgLoops.register();
              }
@@ -2752,7 +2752,7 @@
      }
  
      /**
-@@ -405,11 +405,11 @@
+@@ -420,11 +420,11 @@
                                          cm, drawable, transparency);
      }
  
@@ -2769,7 +2769,7 @@
  
      protected X11SurfaceData(X11ComponentPeer peer,
                               X11GraphicsConfig gc,
-@@ -568,8 +568,6 @@
+@@ -583,8 +583,6 @@
          return sType;
      }
  
@@ -2778,7 +2778,7 @@
      public void invalidate() {
          if (isValid()) {
              setInvalid();
-@@ -583,16 +581,9 @@
+@@ -598,16 +596,9 @@
       * X11SurfaceData object.
       */
  
@@ -2796,8 +2796,8 @@
      private long xgc;
      private Region validatedClip;
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/x11/XSurfaceData.java openjdk/jdk/src/solaris/classes/sun/java2d/x11/XSurfaceData.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/x11/XSurfaceData.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/x11/XSurfaceData.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/x11/XSurfaceData.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/x11/XSurfaceData.java	2013-06-22 16:16:23.525699849 -0500
 @@ -0,0 +1,40 @@
 +package sun.java2d.x11;
 +
@@ -2840,8 +2840,8 @@
 +    protected static native void XSetGraphicsExposures(long xgc, boolean needExposures);
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/DirtyRegion.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/DirtyRegion.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/DirtyRegion.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/DirtyRegion.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/DirtyRegion.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/DirtyRegion.java	2013-06-22 16:16:23.525699849 -0500
 @@ -0,0 +1,133 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -2977,8 +2977,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableByteArray.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableByteArray.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableByteArray.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableByteArray.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableByteArray.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableByteArray.java	2013-06-22 16:16:23.525699849 -0500
 @@ -0,0 +1,127 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -3108,8 +3108,8 @@
 +
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableEltArray.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableEltArray.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableEltArray.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableEltArray.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableEltArray.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableEltArray.java	2013-06-22 16:16:23.525699849 -0500
 @@ -0,0 +1,84 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -3196,8 +3196,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableIntArray.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableIntArray.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableIntArray.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableIntArray.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableIntArray.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableIntArray.java	2013-06-22 16:16:23.526699847 -0500
 @@ -0,0 +1,114 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -3314,8 +3314,8 @@
 +
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowablePointArray.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowablePointArray.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowablePointArray.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowablePointArray.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowablePointArray.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowablePointArray.java	2013-06-22 16:16:23.526699847 -0500
 @@ -0,0 +1,62 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -3380,8 +3380,8 @@
 +        }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableRectArray.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableRectArray.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableRectArray.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableRectArray.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/GrowableRectArray.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/GrowableRectArray.java	2013-06-22 16:16:23.526699847 -0500
 @@ -0,0 +1,79 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -3463,8 +3463,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/MaskTile.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/MaskTile.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/MaskTile.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/MaskTile.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/MaskTile.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/MaskTile.java	2013-06-22 16:16:23.526699847 -0500
 @@ -0,0 +1,166 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -3633,8 +3633,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/MaskTileManager.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/MaskTileManager.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/MaskTileManager.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/MaskTileManager.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/MaskTileManager.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/MaskTileManager.java	2013-06-22 16:16:23.526699847 -0500
 @@ -0,0 +1,327 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -3964,8 +3964,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/MutableInteger.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/MutableInteger.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/MutableInteger.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/MutableInteger.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/MutableInteger.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/MutableInteger.java	2013-06-22 16:16:23.527699845 -0500
 @@ -0,0 +1,57 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -4025,8 +4025,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XcbRequestCounter.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XcbRequestCounter.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XcbRequestCounter.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XcbRequestCounter.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XcbRequestCounter.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XcbRequestCounter.java	2013-06-22 16:16:23.527699845 -0500
 @@ -0,0 +1,59 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -4088,8 +4088,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XIDGenerator.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XIDGenerator.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XIDGenerator.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XIDGenerator.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XIDGenerator.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XIDGenerator.java	2013-06-22 16:16:23.527699845 -0500
 @@ -0,0 +1,53 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -4145,8 +4145,8 @@
 +    private static native void bufferXIDs(int[] buffer, int arraySize);
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRBackend.java	2013-06-22 16:16:23.527699845 -0500
 @@ -0,0 +1,117 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -4266,8 +4266,8 @@
 +                                          TrapezoidList trapList);
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRBackendNative.java	2013-06-22 16:16:23.527699845 -0500
 @@ -0,0 +1,343 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -4613,8 +4613,8 @@
 +                                        int[] trapezoids);
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRColor.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRColor.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRColor.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRColor.java	2011-02-17 16:52:48.202146146 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRColor.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRColor.java	2013-06-22 16:16:23.528699843 -0500
 @@ -0,0 +1,141 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -4758,8 +4758,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRCompositeManager.java	2013-06-22 16:16:23.528699843 -0500
 @@ -0,0 +1,334 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -5096,8 +5096,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRDrawImage.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRDrawImage.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRDrawImage.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRDrawImage.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRDrawImage.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRDrawImage.java	2013-06-22 16:16:23.528699843 -0500
 @@ -0,0 +1,67 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -5167,8 +5167,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRGraphicsConfig.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRGraphicsConfig.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRGraphicsConfig.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRGraphicsConfig.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRGraphicsConfig.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRGraphicsConfig.java	2013-06-22 16:16:23.528699843 -0500
 @@ -0,0 +1,61 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -5232,8 +5232,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRMaskBlit.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRMaskBlit.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRMaskBlit.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRMaskBlit.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRMaskBlit.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRMaskBlit.java	2013-06-22 16:16:23.528699843 -0500
 @@ -0,0 +1,94 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -5330,8 +5330,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRMaskFill.java	2013-06-22 16:16:23.528699843 -0500
 @@ -0,0 +1,115 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -5449,8 +5449,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRMaskImage.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRMaskImage.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRMaskImage.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRMaskImage.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRMaskImage.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRMaskImage.java	2013-06-22 16:16:23.528699843 -0500
 @@ -0,0 +1,129 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -5582,8 +5582,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRPaints.java	2013-06-22 16:16:23.529699842 -0500
 @@ -0,0 +1,314 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -5900,8 +5900,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRPMBlitLoops.java	2013-06-22 16:16:23.529699842 -0500
 @@ -0,0 +1,400 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -6304,8 +6304,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRRenderer.java	2013-06-22 16:16:23.530699841 -0500
 @@ -0,0 +1,331 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -6639,8 +6639,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java	2013-06-22 16:16:23.530699841 -0500
 @@ -0,0 +1,668 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -7311,8 +7311,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceDataProxy.java	2013-06-22 16:16:23.530699841 -0500
 @@ -0,0 +1,83 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -7398,8 +7398,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRUtils.java	2013-06-22 16:16:23.530699841 -0500
 @@ -0,0 +1,261 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -7663,8 +7663,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRVolatileSurfaceManager.java openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRVolatileSurfaceManager.java
---- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRVolatileSurfaceManager.java	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRVolatileSurfaceManager.java	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/classes/sun/java2d/xr/XRVolatileSurfaceManager.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/classes/sun/java2d/xr/XRVolatileSurfaceManager.java	2013-06-22 16:16:23.530699841 -0500
 @@ -0,0 +1,94 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -7761,8 +7761,8 @@
 +    }
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c openjdk/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
---- openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	2011-01-20 23:54:42.000000000 +0000
-+++ openjdk/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	2013-06-22 16:01:50.563607746 -0500
++++ openjdk/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	2013-06-22 16:19:02.233536415 -0500
 @@ -71,7 +71,7 @@
  extern AwtGraphicsConfigDataPtr
      getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
@@ -7772,7 +7772,7 @@
  static int X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
                            X11SDOps *xsdo);
  static int X11SD_ClipToRoot(SurfaceDataBounds *b, SurfaceDataBounds *bounds,
-@@ -97,19 +97,10 @@
+@@ -98,19 +98,10 @@
  
  #endif /* !HEADLESS */
  
@@ -7794,7 +7794,7 @@
          char c[4];
          int i;
      } endian;
-@@ -117,20 +108,64 @@
+@@ -118,12 +109,32 @@
      endian.i = 0xff000000;
      nativeByteOrder = (endian.c[0]) ? MSBFirst : LSBFirst;
  
@@ -7806,32 +7806,8 @@
          JNU_ThrowInternalError(env, "Private RasInfo structure too large!");
 -        return;
 +        return JNI_FALSE;
-+    }
-+
-+#ifdef MITSHM
-+    if (getenv("NO_AWT_MITSHM") == NULL &&
-+        getenv("NO_J2D_MITSHM") == NULL) {
-+        char * force;
-+        TryInitMITShm(env, &useMitShmExt, &useMitShmPixmaps);
-+
-+        if(allowShmPixmaps) {
-+          useMitShmPixmaps = (useMitShmPixmaps == CAN_USE_MITSHM);
-+          force = getenv("J2D_PIXMAPS");
-+          if (force != NULL) {
-+              if (useMitShmPixmaps && (strcmp(force, "shared") == 0)) {
-+                  forceSharedPixmaps = JNI_TRUE;
-+              } else if (strcmp(force, "server") == 0) {
-+                  useMitShmPixmaps = JNI_FALSE;
-+              }
-+          }
-+        }else {
-+          useMitShmPixmaps = JNI_FALSE;
-+        }
      }
- 
-+    return JNI_TRUE;
-+#endif /* MITSHM */
-+
++}
 +#endif /* !HEADLESS */
 +}
 +
@@ -7849,10 +7825,10 @@
 +  if(XShared_initIDs(env, JNI_TRUE))
 +  {
 +    void *lib = 0;
-+
+ 
      xorCompClass = (*env)->NewGlobalRef(env, XORComp);
  
-     if (tryDGA && (getenv("NO_J2D_DGA") == NULL)) {
+@@ -131,7 +142,7 @@
      /* we use RTLD_NOW because of bug 4032715 */
          lib = dlopen("libsunwjdga.so", RTLD_NOW);
      }
@@ -7861,33 +7837,7 @@
      if (lib != NULL) {
          JDgaStatus ret = JDGA_FAILED;
          void *sym = dlsym(lib, "JDgaLibInit");
-@@ -149,24 +184,7 @@
-             lib = NULL;
-         }
-     }
--
--#ifdef MITSHM
--    if (getenv("NO_AWT_MITSHM") == NULL &&
--        getenv("NO_J2D_MITSHM") == NULL) {
--        char * force;
--        TryInitMITShm(env, &useMitShmExt, &useMitShmPixmaps);
--        useMitShmPixmaps = (useMitShmPixmaps == CAN_USE_MITSHM);
--        force = getenv("J2D_PIXMAPS");
--        if (force != NULL) {
--            if (useMitShmPixmaps && (strcmp(force, "shared") == 0)) {
--                forceSharedPixmaps = JNI_TRUE;
--            } else if (strcmp(force, "server") == 0) {
--                useMitShmPixmaps = JNI_FALSE;
--            }
--        }
--    }
--#endif /* MITSHM */
--
-+  }
- #endif /* !HEADLESS */
- }
- 
-@@ -176,7 +194,7 @@
+@@ -184,7 +195,7 @@
   * Signature: ()Z
   */
  JNIEXPORT jboolean JNICALL
@@ -7896,7 +7846,7 @@
  {
      jboolean ret = JNI_FALSE;
  
-@@ -214,9 +232,9 @@
+@@ -239,9 +250,9 @@
   * Signature: (Ljava/lang/Object;I)V
   */
  JNIEXPORT void JNICALL
@@ -7909,7 +7859,7 @@
  {
  #ifndef HEADLESS
      X11SDOps *xsdo = (X11SDOps*)SurfaceData_InitOps(env, xsd, sizeof(X11SDOps));
-@@ -286,6 +304,8 @@
+@@ -311,6 +322,8 @@
      } else {
          xsdo->pixelmask = 0xff;
      }
@@ -7918,7 +7868,7 @@
  #endif /* !HEADLESS */
  }
  
-@@ -295,7 +315,7 @@
+@@ -320,7 +333,7 @@
   * Signature: ()V
   */
  JNIEXPORT void JNICALL
@@ -7927,7 +7877,7 @@
  {
  #ifndef HEADLESS
      SurfaceDataOps *ops = SurfaceData_GetOps(env, xsd);
-@@ -366,6 +386,11 @@
+@@ -391,6 +404,11 @@
          XFreeGC(awt_display, xsdo->cachedGC);
          xsdo->cachedGC = NULL;
      }
@@ -7939,7 +7889,7 @@
      AWT_UNLOCK();
  #endif /* !HEADLESS */
  }
-@@ -375,7 +400,7 @@
+@@ -400,7 +418,7 @@
   * Signature: ()V
   */
  JNIEXPORT void JNICALL
@@ -7948,7 +7898,7 @@
  {
  #ifndef HEADLESS
      X11SDOps *xsdo = (X11SDOps *) SurfaceData_GetOps(env, xsd);
-@@ -386,29 +411,10 @@
+@@ -411,29 +429,10 @@
  #endif /* !HEADLESS */
  }
  
@@ -7980,7 +7930,7 @@
  
      if (drawable != (jlong)0) {
          /* Double-buffering */
-@@ -434,7 +440,7 @@
+@@ -459,7 +458,7 @@
              if (xsdo->drawable) {
                  xsdo->shmPMData.usingShmPixmap = JNI_TRUE;
                  xsdo->shmPMData.shmPixmap = xsdo->drawable;
@@ -7989,12 +7939,12 @@
              }
          }
  #endif /* MITSHM */
-@@ -454,7 +460,40 @@
+@@ -479,7 +478,40 @@
      if (xsdo->drawable == 0) {
          JNU_ThrowOutOfMemoryError(env,
                                    "Can't create offscreen surface");
 +        return JNI_FALSE;
-     }
++    }
 +
 +    return JNI_TRUE;
 +#endif /* !HEADLESS */
@@ -8016,7 +7966,7 @@
 +    X11SDOps *xsdo = X11SurfaceData_GetOps(env, xsd);
 +    if (xsdo == NULL) {
 +        return;
-+    }
+     }
 +
 +    if (xsdo->configData->awt_cmap == (Colormap)NULL) {
 +        awtJNI_CreateColorData(env, xsdo->configData, 1);
@@ -8030,7 +7980,7 @@
  #endif /* !HEADLESS */
  }
  
-@@ -700,7 +739,7 @@
+@@ -726,7 +758,7 @@
  }
  #endif /* MITSHM */
  
@@ -8039,7 +7989,7 @@
  {
      if (xsdo->isPixmap == JNI_TRUE) {
          return SD_FAILURE;
-@@ -1549,7 +1588,7 @@
+@@ -1575,7 +1607,7 @@
   * Signature: (I)J
   */
  JNIEXPORT jlong JNICALL
@@ -8048,7 +7998,7 @@
      (JNIEnv *env, jclass xsd, jlong pXSData)
  {
      jlong ret;
-@@ -1579,7 +1618,7 @@
+@@ -1605,7 +1637,7 @@
   * Signature: (JIIIILsun/java2d/pipe/Region;)V
   */
  JNIEXPORT void JNICALL
@@ -8057,7 +8007,7 @@
      (JNIEnv *env, jclass xsd, jlong xgc)
  {
  #ifndef HEADLESS
-@@ -1594,7 +1633,7 @@
+@@ -1620,7 +1652,7 @@
   * Signature: (JIIIILsun/java2d/pipe/Region;)V
   */
  JNIEXPORT void JNICALL
@@ -8066,7 +8016,7 @@
      (JNIEnv *env, jclass xsd, jlong xgc,
       jint x1, jint y1, jint x2, jint y2,
       jobject complexclip)
-@@ -1669,7 +1708,7 @@
+@@ -1695,7 +1727,7 @@
   * Signature: (JZ)V
   */
  JNIEXPORT void JNICALL
@@ -8076,8 +8026,8 @@
  {
  #ifndef HEADLESS
 diff -Nru openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h openjdk/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h
---- openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h	2011-01-20 23:54:42.000000000 +0000
-+++ openjdk/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h	2011-11-14 16:12:16.000000000 -0600
++++ openjdk/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h	2013-06-22 16:16:23.531699840 -0500
 @@ -30,6 +30,8 @@
  
  #include <jdga.h>
@@ -8106,8 +8056,8 @@
   * This function returns a pointer to a native X11SDOps structure
   * for accessing the indicated X11 SurfaceData Java object.  It
 diff -Nru openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c openjdk/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c
---- openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c	2013-06-22 16:16:23.532699839 -0500
 @@ -0,0 +1,784 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
@@ -8894,8 +8844,8 @@
 +    (*env)->ReleasePrimitiveArrayCritical(env, trapArray, traps, JNI_ABORT);
 +}
 diff -Nru openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c openjdk/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c
---- openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c	1970-01-01 01:00:00.000000000 +0100
-+++ openjdk/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c	2011-02-17 16:52:48.206145834 +0000
+--- openjdk.orig/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c	2013-06-22 16:16:23.532699839 -0500
 @@ -0,0 +1,116 @@
 +/*
 + * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6469266-xmlsec_1.4.2.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,23876 @@
+# HG changeset patch
+# User andrew
+# Date 1371136223 -3600
+# Node ID a955a845f0d1b8e21e0780986d971b3712db26c7
+# Parent  2ae6d8da293f30c94c9478a6634c7a480328c5c5
+6469266: Integrate Apache XMLSec 1.4.2 into JDK 7
+Reviewed-by: valeriep
+
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java b/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
+@@ -20,12 +20,9 @@
+  */
+ package com.sun.org.apache.xml.internal.security;
+ 
+-
+-
+ import java.io.InputStream;
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
+-
+ import javax.xml.parsers.DocumentBuilder;
+ import javax.xml.parsers.DocumentBuilderFactory;
+ 
+@@ -51,7 +48,7 @@
+  * done by calling {@link Init#init} which should be done in any static block
+  * of the files of this library. We ensure that this call is only executed once.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public final class Init {
+ 
+@@ -113,20 +110,19 @@
+             dbf.setValidating(false);
+ 
+             DocumentBuilder db = dbf.newDocumentBuilder();
+-
+             // We don't allow users to override the Apache XML Security
+             // configuration in the JRE. Users should use the standard security
+             // provider mechanism instead if implementing their own
+             // transform or canonicalization algorithms.
+-            // String cfile = System.getProperty("com.sun.org.apache.xml.internal.security.resource.config");
+-            // InputStream is =
+-            //     Class.forName("com.sun.org.apache.xml.internal.security.Init")
+-            //     .getResourceAsStream(cfile != null ? cfile : "resource/config.xml");
++            // InputStream is = Class.forName("com.sun.org.apache.xml.internal.security.Init").getResourceAsStream("resource/config.xml");
+             InputStream is = (InputStream) AccessController.doPrivileged(
+                 new PrivilegedAction() {
+                     public Object run() {
++//                        String cfile = System.getProperty
++//                            ("com.sun.org.apache.xml.internal.security.resource.config");
+                         return getClass().getResourceAsStream
+-                                ("resource/config.xml");
++//                            (cfile != null ? cfile : "resource/config.xml");
++                            ("resource/config.xml");
+                     }
+                 });
+ 
+@@ -167,7 +163,7 @@
+ //
+ //            if (tag.equals("ResourceBundles")){
+ //                XX_configure_i18n_start = System.currentTimeMillis();
+-//              Element resource=(Element)el;
++//                Element resource=(Element)el;
+ //               /* configure internationalization */
+ //               Attr langAttr = resource.getAttributeNode("defaultLanguageCode");
+ //               Attr countryAttr = resource.getAttributeNode("defaultCountryCode");
+@@ -202,11 +198,11 @@
+ 
+                         if (currMeth.getDeclaringClass().getName()
+                                 .equals(JAVACLASS)) {
+-                           log.log(java.util.logging.Level.FINE, currMeth.getDeclaringClass().toString());
++                           log.log(java.util.logging.Level.FINE, currMeth.getDe claringClass().toString());
+                         }
+                      }*/
+-                      if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Canonicalizer.register(" + URI + ", "
++                      if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "Canonicalizer.register(" + URI + ", "
+                             + JAVACLASS + ")");
+                      Canonicalizer.register(URI, JAVACLASS);
+                   } catch (ClassNotFoundException e) {
+@@ -233,9 +229,8 @@
+                         "JAVACLASS");
+                   try {
+                      Class.forName(JAVACLASS);
+-                     if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Transform.register(" + URI + ", " + JAVACLASS
+-                            + ")");
++                     if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "Transform.register(" + URI + ", " + JAVACLASS + ")");
+                      Transform.register(URI, JAVACLASS);
+                   } catch (ClassNotFoundException e) {
+                      Object exArgs[] = { URI, JAVACLASS };
+@@ -284,12 +279,11 @@
+ //
+ //                        if (currMeth.getDeclaringClass().getName()
+ //                                .equals(JAVACLASS)) {
+-//                           log.log(java.util.logging.Level.FINE, currMeth.getDeclaringClass().toString());
++//                           log.log(java.util.logging.Level.FINE, currMeth.getDe claringClass().toString());
+ //                        }
+ //                     }
+-                      if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "SignatureAlgorithm.register(" + URI + ", "
+-                            + JAVACLASS + ")");
++                      if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "SignatureAlgorithm.register(" + URI + ", " + JAVACLASS + ")");
+                      SignatureAlgorithm.register(URI, JAVACLASS);
+                   } catch (ClassNotFoundException e) {
+                      Object exArgs[] = { URI, JAVACLASS };
+@@ -320,13 +314,11 @@
+                         "DESCRIPTION");
+ 
+                   if ((Description != null) && (Description.length() > 0)) {
+-                    if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": "
+-                               + Description);
++                    if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": " + Description);
+                   } else {
+-                    if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS
+-                               + ": For unknown purposes");
++                    if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": For unknown purposes");
+                   }
+                                   try {
+                                           ResourceResolver.register(JAVACLASS);
+@@ -359,13 +351,11 @@
+                         "DESCRIPTION");
+ 
+                   if ((Description != null) && (Description.length() > 0)) {
+-                    if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": "
+-                               + Description);
++                    if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": " + Description);
+                   } else {
+-                    if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS
+-                               + ": For unknown purposes");
++                    if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": For unknown purposes");
+                   }
+ 
+                   KeyResolver.register(JAVACLASS);
+@@ -376,8 +366,8 @@
+ 
+             if (tag.equals("PrefixMappings")){
+                 XX_configure_reg_prefixes_start = System.currentTimeMillis();
+-                if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Now I try to bind prefixes:");
++                if (log.isLoggable(java.util.logging.Level.FINE))
++                    log.log(java.util.logging.Level.FINE, "Now I try to bind prefixes:");
+ 
+                Element[] nl = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,"PrefixMapping");
+ 
+@@ -386,8 +376,8 @@
+                                         "namespace");
+                   String prefix = nl[i].getAttributeNS(null,
+                                      "prefix");
+-                  if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Now I try to bind " + prefix + " to " + namespace);
++                  if (log.isLoggable(java.util.logging.Level.FINE))
++                      log.log(java.util.logging.Level.FINE, "Now I try to bind " + prefix + " to " + namespace);
+                   com.sun.org.apache.xml.internal.security.utils.ElementProxy
+                      .setDefaultPrefix(namespace, prefix);
+                }
+@@ -398,19 +388,19 @@
+             long XX_init_end = System.currentTimeMillis();
+ 
+             //J-
+-            if (true) {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "XX_init                             " + ((int)(XX_init_end - XX_init_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_prng                           " + ((int)(XX_prng_end - XX_prng_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_parsing                        " + ((int)(XX_parsing_end - XX_parsing_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_configure_i18n                 " + ((int)(XX_configure_i18n_end- XX_configure_i18n_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_configure_reg_c14n             " + ((int)(XX_configure_reg_c14n_end- XX_configure_reg_c14n_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_configure_reg_jcemapper        " + ((int)(XX_configure_reg_jcemapper_end- XX_configure_reg_jcemapper_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_configure_reg_keyInfo          " + ((int)(XX_configure_reg_keyInfo_end- XX_configure_reg_keyInfo_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_configure_reg_keyResolver      " + ((int)(XX_configure_reg_keyResolver_end- XX_configure_reg_keyResolver_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_configure_reg_prefixes         " + ((int)(XX_configure_reg_prefixes_end- XX_configure_reg_prefixes_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_configure_reg_resourceresolver " + ((int)(XX_configure_reg_resourceresolver_end- XX_configure_reg_resourceresolver_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_configure_reg_sigalgos         " + ((int)(XX_configure_reg_sigalgos_end- XX_configure_reg_sigalgos_start)) + " ms");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "  XX_configure_reg_transforms       " + ((int)(XX_configure_reg_transforms_end- XX_configure_reg_transforms_start)) + " ms");
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, "XX_init                             " + ((int)(XX_init_end - XX_init_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_prng                           " + ((int)(XX_prng_end - XX_prng_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_parsing                        " + ((int)(XX_parsing_end - XX_parsing_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_configure_i18n                 " + ((int)(XX_configure_i18n_end- XX_configure_i18n_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_c14n             " + ((int)(XX_configure_reg_c14n_end- XX_configure_reg_c14n_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_jcemapper        " + ((int)(XX_configure_reg_jcemapper_end- XX_configure_reg_jcemapper_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_keyInfo          " + ((int)(XX_configure_reg_keyInfo_end- XX_configure_reg_keyInfo_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_keyResolver      " + ((int)(XX_configure_reg_keyResolver_end- XX_configure_reg_keyResolver_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_prefixes         " + ((int)(XX_configure_reg_prefixes_end- XX_configure_reg_prefixes_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_resourceresolver " + ((int)(XX_configure_reg_resourceresolver_end- XX_configure_reg_resourceresolver_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_sigalgos         " + ((int)(XX_configure_reg_sigalgos_end- XX_configure_reg_sigalgos_start)) + " ms");
++                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_transforms       " + ((int)(XX_configure_reg_transforms_end- XX_configure_reg_transforms_start)) + " ms");
+             }
+          } catch (Exception e) {
+             log.log(java.util.logging.Level.SEVERE, "Bad: ", e);
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/Algorithm.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/Algorithm.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/Algorithm.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/Algorithm.java
+@@ -24,7 +24,7 @@
+ 
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+-import com.sun.org.apache.xml.internal.security.utils.ElementProxy;
++import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+@@ -33,11 +33,7 @@
+  * The Algorithm class which stores the Algorithm URI as a string.
+  *
+  */
+-public abstract class Algorithm extends ElementProxy {
+-
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(Algorithm.class.getName());
++public abstract class Algorithm extends SignatureElementProxy {
+ 
+    /**
+     *
+@@ -79,7 +75,7 @@
+     */
+    protected void setAlgorithmURI(String algorithmURI) {
+ 
+-      if ((this._state == MODE_CREATE) && (algorithmURI != null)) {
++      if ( (algorithmURI != null)) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_ALGORITHM,
+                                                 algorithmURI);
+       }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
+@@ -35,7 +35,7 @@
+ /**
+  * This class maps algorithm identifier URIs to JAVA JCE class names.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class JCEMapper {
+ 
+@@ -45,9 +45,9 @@
+ 
+ 
+ 
+-   private static Map uriToJCEName = new HashMap();
++   private static Map uriToJCEName;
+ 
+-   private static Map algorithmsMap = new HashMap();
++   private static Map algorithmsMap;
+ 
+    private static String providerName = null;
+    /**
+@@ -63,6 +63,8 @@
+ 
+    static void loadAlgorithms( Element algorithmsEl) {
+        Element[] algorithms = XMLUtils.selectNodes(algorithmsEl.getFirstChild(),Init.CONF_NS,"Algorithm");
++       uriToJCEName = new HashMap( algorithms.length * 2);
++       algorithmsMap = new HashMap( algorithms.length * 2);
+        for (int i = 0 ;i < algorithms.length ;i ++) {
+            Element el = algorithms[i];
+            String id = el.getAttribute("URI");
+@@ -70,6 +72,7 @@
+            uriToJCEName.put(id, jceName);
+            algorithmsMap.put(id, new Algorithm(el));
+        }
++
+    }
+ 
+    static Algorithm getAlgorithmMapping(String algoURI) {
+@@ -84,8 +87,8 @@
+     *
+     */
+    public static String translateURItoJCEID(String AlgorithmURI) {
+-      if (true)
+-          if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
++      if (log.isLoggable(java.util.logging.Level.FINE))
++          log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
+ 
+       String jceName = (String) uriToJCEName.get(AlgorithmURI);
+       return jceName;
+@@ -100,8 +103,8 @@
+     *
+     */
+    public static String getAlgorithmClassFromURI(String AlgorithmURI) {
+-       if (true)
+-           if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
++       if (log.isLoggable(java.util.logging.Level.FINE))
++           log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
+ 
+        return ((Algorithm) algorithmsMap.get(AlgorithmURI)).algorithmClass;
+    }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/MessageDigestAlgorithm.java
+@@ -20,10 +20,10 @@
+  */
+ package com.sun.org.apache.xml.internal.security.algorithms;
+ 
+-
+-
+ import java.security.MessageDigest;
+ import java.security.NoSuchProviderException;
++import java.util.HashMap;
++import java.util.Map;
+ 
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+@@ -41,11 +41,6 @@
+  */
+ public class MessageDigestAlgorithm extends Algorithm {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(
+-                    MessageDigestAlgorithm.class.getName());
+-
+     /** Message Digest - NOT RECOMMENDED MD5*/
+    public static final String ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5 = Constants.MoreAlgorithmsSpecNS + "md5";
+    /** Digest - Required SHA1*/
+@@ -76,6 +71,12 @@
+       this.algorithm = messageDigest;
+    }
+ 
++   static ThreadLocal instances=new ThreadLocal() {
++           protected Object initialValue() {
++                   return new HashMap();
++           };
++   };
++
+    /**
+     * Factory method for constructing a message digest algorithm by name.
+     *
+@@ -86,8 +87,15 @@
+     */
+    public static MessageDigestAlgorithm getInstance(
+            Document doc, String algorithmURI) throws XMLSignatureException {
++          MessageDigest md = getDigestInstance(algorithmURI);
++      return new MessageDigestAlgorithm(doc, md, algorithmURI);
++   }
+ 
+-      String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
++private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException {
++        MessageDigest result=(MessageDigest) ((Map)instances.get()).get(algorithmURI);
++        if (result!=null)
++                return result;
++    String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
+ 
+           if (algorithmID == null) {
+                   Object[] exArgs = { algorithmURI };
+@@ -113,8 +121,9 @@
+ 
+         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
+         }
+-      return new MessageDigestAlgorithm(doc, md, algorithmURI);
+-   }
++      ((Map)instances.get()).put(algorithmURI, md);
++        return md;
++}
+ 
+    /**
+     * Returns the actual {@link java.security.MessageDigest} algorithm object
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
+@@ -25,6 +25,7 @@
+ import java.security.SecureRandom;
+ import java.security.spec.AlgorithmParameterSpec;
+ import java.util.HashMap;
++import java.util.Map;
+ 
+ import com.sun.org.apache.xml.internal.security.algorithms.implementations.IntegrityHmac;
+ import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
+@@ -52,9 +53,35 @@
+    /** All available algorithm classes are registered here */
+    static HashMap _algorithmHash = null;
+ 
++   static ThreadLocal instancesSigning=new ThreadLocal() {
++           protected Object initialValue() {
++                   return new HashMap();
++           };
++   };
++
++   static ThreadLocal instancesVerify=new ThreadLocal() {
++           protected Object initialValue() {
++                   return new HashMap();
++           };
++   };
++
++   static ThreadLocal keysSigning=new ThreadLocal() {
++           protected Object initialValue() {
++                   return new HashMap();
++           };
++   };
++   static ThreadLocal keysVerify=new ThreadLocal() {
++           protected Object initialValue() {
++                   return new HashMap();
++           };
++   };
++//   boolean isForSigning=false;
++
+    /** Field _signatureAlgorithm */
+    protected SignatureAlgorithmSpi _signatureAlgorithm = null;
+ 
++   private String algorithmURI;
++
+    /**
+     * Constructor SignatureAlgorithm
+     *
+@@ -64,18 +91,49 @@
+     */
+    public SignatureAlgorithm(Document doc, String algorithmURI)
+            throws XMLSecurityException {
++      super(doc, algorithmURI);
++      this.algorithmURI = algorithmURI;
++   }
+ 
+-      super(doc, algorithmURI);
+ 
+-      try {
++   private void initializeAlgorithm(boolean isForSigning) throws XMLSignatureException {
++           if (_signatureAlgorithm!=null) {
++                   return;
++           }
++           _signatureAlgorithm=isForSigning ? getInstanceForSigning(algorithmURI) : getInstanceForVerify(algorithmURI);
++                this._signatureAlgorithm
++                      .engineGetContextFromElement(this._constructionElement);
++   }
++   private static SignatureAlgorithmSpi getInstanceForSigning(String algorithmURI) throws XMLSignatureException {
++           SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesSigning.get()).get(algorithmURI);
++           if (result!=null) {
++                   result.reset();
++                   return result;
++           }
++           result=buildSigner(algorithmURI, result);
++           ((Map)instancesSigning.get()).put(algorithmURI,result);
++           return result;
++   }
++   private static SignatureAlgorithmSpi getInstanceForVerify(String algorithmURI) throws XMLSignatureException {
++           SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesVerify.get()).get(algorithmURI);
++           if (result!=null) {
++                   result.reset();
++                   return result;
++           }
++           result=buildSigner(algorithmURI, result);
++           ((Map)instancesVerify.get()).put(algorithmURI,result);
++           return result;
++   }
++
++   private static SignatureAlgorithmSpi buildSigner(String algorithmURI, SignatureAlgorithmSpi result) throws XMLSignatureException {
++        try {
+          Class implementingClass =
+             SignatureAlgorithm.getImplementingClass(algorithmURI);
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
+                    + implementingClass + "\"");
+-
+-         this._signatureAlgorithm =
+-            (SignatureAlgorithmSpi) implementingClass.newInstance();
++         result=(SignatureAlgorithmSpi) implementingClass.newInstance();
++         return   result;
+       }  catch (IllegalAccessException ex) {
+          Object exArgs[] = { algorithmURI, ex.getMessage() };
+ 
+@@ -92,7 +150,7 @@
+          throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
+                                          ex);
+       }
+-   }
++}
+ 
+    /**
+     * Constructor SignatureAlgorithm
+@@ -107,7 +165,8 @@
+               throws XMLSecurityException {
+ 
+       this(doc, algorithmURI);
+-
++      this.algorithmURI=algorithmURI;
++      initializeAlgorithm(true);
+       this._signatureAlgorithm.engineSetHMACOutputLength(HMACOutputLength);
+       ((IntegrityHmac)this._signatureAlgorithm)
+          .engineAddContextToElement(this._constructionElement);
+@@ -124,37 +183,7 @@
+            throws XMLSecurityException {
+ 
+       super(element, BaseURI);
+-
+-      String algorithmURI = this.getURI();
+-
+-      try {
+-         Class implementingClass =
+-            SignatureAlgorithm.getImplementingClass(algorithmURI);
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
+-                   + implementingClass + "\"");
+-
+-         this._signatureAlgorithm =
+-            (SignatureAlgorithmSpi) implementingClass.newInstance();
+-
+-         this._signatureAlgorithm
+-            .engineGetContextFromElement(this._constructionElement);
+-      }  catch (IllegalAccessException ex) {
+-         Object exArgs[] = { algorithmURI, ex.getMessage() };
+-
+-         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
+-                                         ex);
+-      } catch (InstantiationException ex) {
+-         Object exArgs[] = { algorithmURI, ex.getMessage() };
+-
+-         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
+-                                         ex);
+-      } catch (NullPointerException ex) {
+-         Object exArgs[] = { algorithmURI, ex.getMessage() };
+-
+-         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
+-                                         ex);
+-      }
++      algorithmURI = this.getURI();
+    }
+ 
+    /**
+@@ -175,7 +204,12 @@
+     * @return the result of the {@link java.security.Signature#getAlgorithm} method
+     */
+    public String getJCEAlgorithmString() {
+-      return this._signatureAlgorithm.engineGetJCEAlgorithmString();
++      try {
++                return getInstanceForVerify(algorithmURI).engineGetJCEAlgorithmString();
++        } catch (XMLSignatureException e) {
++                //Ignore.
++                return null;
++        }
+    }
+ 
+    /**
+@@ -184,7 +218,11 @@
+     * @return The Provider of this Signature Alogrithm
+     */
+    public String getJCEProviderName() {
+-      return this._signatureAlgorithm.engineGetJCEProviderName();
++      try {
++                return getInstanceForVerify(algorithmURI).engineGetJCEProviderName();
++        } catch (XMLSignatureException e) {
++                return null;
++        }
+    }
+ 
+    /**
+@@ -231,7 +269,13 @@
+     * @throws XMLSignatureException
+     */
+    public void initSign(Key signingKey) throws XMLSignatureException {
+-      this._signatureAlgorithm.engineInitSign(signingKey);
++           initializeAlgorithm(true);
++           Map map=(Map)keysSigning.get();
++       if (map.get(this.algorithmURI)==signingKey) {
++           return;
++       }
++       map.put(this.algorithmURI,signingKey);
++           this._signatureAlgorithm.engineInitSign(signingKey);
+    }
+ 
+    /**
+@@ -244,6 +288,7 @@
+     */
+    public void initSign(Key signingKey, SecureRandom secureRandom)
+            throws XMLSignatureException {
++           initializeAlgorithm(true);
+       this._signatureAlgorithm.engineInitSign(signingKey, secureRandom);
+    }
+ 
+@@ -258,6 +303,7 @@
+    public void initSign(
+            Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
+               throws XMLSignatureException {
++           initializeAlgorithm(true);
+       this._signatureAlgorithm.engineInitSign(signingKey,
+                                               algorithmParameterSpec);
+    }
+@@ -282,7 +328,13 @@
+     * @throws XMLSignatureException
+     */
+    public void initVerify(Key verificationKey) throws XMLSignatureException {
+-      this._signatureAlgorithm.engineInitVerify(verificationKey);
++           initializeAlgorithm(false);
++           Map map=(Map)keysVerify.get();
++           if (map.get(this.algorithmURI)==verificationKey) {
++           return;
++       }
++           map.put(this.algorithmURI,verificationKey);
++           this._signatureAlgorithm.engineInitVerify(verificationKey);
+    }
+ 
+    /**
+@@ -320,7 +372,7 @@
+                .getLogger(SignatureAlgorithm.class.getName());
+       }
+ 
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Init() called");
++      log.log(java.util.logging.Level.FINE, "Init() called");
+ 
+       if (!SignatureAlgorithm._alreadyInitialized) {
+          SignatureAlgorithm._algorithmHash = new HashMap(10);
+@@ -340,8 +392,8 @@
+            throws AlgorithmAlreadyRegisteredException,XMLSignatureException {
+ 
+       {
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
+ 
+          // are we already registered?
+          Class registeredClassClass =
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithmSpi.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithmSpi.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithmSpi.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithmSpi.java
+@@ -20,27 +20,20 @@
+  */
+ package com.sun.org.apache.xml.internal.security.algorithms;
+ 
+-
+-
+ import java.security.Key;
+ import java.security.SecureRandom;
+ import java.security.spec.AlgorithmParameterSpec;
+ 
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
+-import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public abstract class SignatureAlgorithmSpi {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(SignatureAlgorithmSpi.class.getName());
+-
+    /**
+     * Returns the URI representation of <code>Transformation algorithm</code>
+     *
+@@ -167,20 +160,6 @@
+    protected abstract void engineSetParameter(AlgorithmParameterSpec params)
+       throws XMLSignatureException;
+ 
+-   /** Field _doc */
+-   Document _doc = null;
+-
+-   /**
+-    * Method engineSetDocument
+-    *
+-    * @param doc
+-    */
+-   protected void engineSetDocument(Document doc) {
+-      this._doc = doc;
+-   }
+-
+-   /** Field _constructionElement */
+-   Element _constructionElement = null;
+ 
+    /**
+     * Method engineGetContextFromElement
+@@ -188,7 +167,6 @@
+     * @param element
+     */
+    protected void engineGetContextFromElement(Element element) {
+-      this._constructionElement = element;
+    }
+ 
+    /**
+@@ -199,4 +177,7 @@
+     */
+    protected abstract void engineSetHMACOutputLength(int HMACOutputLength)
+       throws XMLSignatureException;
++
++    public void reset() {
++        }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/IntegrityHmac.java
+@@ -45,7 +45,7 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
+ 
+@@ -80,8 +80,8 @@
+    public IntegrityHmac() throws XMLSignatureException {
+ 
+       String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
+-      if (true)
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Created IntegrityHmacSHA1 using " + algorithmID);
++      if (log.isLoggable(java.util.logging.Level.FINE))
++        log.log(java.util.logging.Level.FINE, "Created IntegrityHmacSHA1 using " + algorithmID);
+ 
+       try {
+          this._macAlgorithm = Mac.getInstance(algorithmID);
+@@ -105,6 +105,10 @@
+       throw new XMLSignatureException("empty");
+    }
+ 
++   public void reset() {
++           _HMACOutputLength=0;
++   }
++
+    /**
+     * Proxy method for {@link java.security.Signature#verify(byte[])}
+     * which is executed on the internal {@link java.security.Signature} object.
+@@ -153,7 +157,20 @@
+       try {
+          this._macAlgorithm.init(secretKey);
+       } catch (InvalidKeyException ex) {
+-         throw new XMLSignatureException("empty", ex);
++            // reinstantiate Mac object to work around bug in JDK
++            // see: http://bugs.sun.com/view_bug.do?bug_id=4953555
++            Mac mac = this._macAlgorithm;
++            try {
++                this._macAlgorithm = Mac.getInstance
++                    (_macAlgorithm.getAlgorithm());
++            } catch (Exception e) {
++                // this shouldn't occur, but if it does, restore previous Mac
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Mac:" + e);
++                }
++                this._macAlgorithm = mac;
++            }
++            throw new XMLSignatureException("empty", ex);
+       }
+    }
+ 
+@@ -333,7 +350,7 @@
+     */
+    protected String engineGetJCEAlgorithmString() {
+ 
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "engineGetJCEAlgorithmString()");
++      log.log(java.util.logging.Level.FINE, "engineGetJCEAlgorithmString()");
+ 
+       return this._macAlgorithm.getAlgorithm();
+    }
+@@ -407,7 +424,8 @@
+    /**
+     * Class IntegrityHmacSHA1
+     *
+-    * @author $Author: raul $
++    * @author $Author: mullan $
++    * @version $Revision: 1.5 $
+     */
+    public static class IntegrityHmacSHA1 extends IntegrityHmac {
+ 
+@@ -437,7 +455,8 @@
+    /**
+     * Class IntegrityHmacSHA256
+     *
+-    * @author $Author: raul $
++    * @author $Author: mullan $
++    * @version $Revision: 1.5 $
+     */
+    public static class IntegrityHmacSHA256 extends IntegrityHmac {
+ 
+@@ -467,7 +486,8 @@
+    /**
+     * Class IntegrityHmacSHA384
+     *
+-    * @author $Author: raul $
++    * @author $Author: mullan $
++    * @version $Revision: 1.5 $
+     */
+    public static class IntegrityHmacSHA384 extends IntegrityHmac {
+ 
+@@ -497,7 +517,8 @@
+    /**
+     * Class IntegrityHmacSHA512
+     *
+-    * @author $Author: raul $
++    * @author $Author: mullan $
++    * @version $Revision: 1.5 $
+     */
+    public static class IntegrityHmacSHA512 extends IntegrityHmac {
+ 
+@@ -527,7 +548,8 @@
+    /**
+     * Class IntegrityHmacRIPEMD160
+     *
+-    * @author $Author: raul $
++    * @author $Author: mullan $
++    * @version $Revision: 1.5 $
+     */
+    public static class IntegrityHmacRIPEMD160 extends IntegrityHmac {
+ 
+@@ -557,7 +579,8 @@
+    /**
+     * Class IntegrityHmacMD5
+     *
+-    * @author $Author: raul $
++    * @author $Author: mullan $
++    * @version $Revision: 1.5 $
+     */
+    public static class IntegrityHmacMD5 extends IntegrityHmac {
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureBaseRSA.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureBaseRSA.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureBaseRSA.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureBaseRSA.java
+@@ -3,7 +3,7 @@
+  * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * Copyright  1999-2004 The Apache Software Foundation.
++ * Copyright  1999-2007 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.
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.algorithms.implementations;
+ 
+-
+-
+ import java.security.InvalidAlgorithmParameterException;
+ import java.security.InvalidKeyException;
+ import java.security.Key;
+@@ -38,329 +36,344 @@
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
+ 
+-
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
+ 
+-   /** {@link java.util.logging} logging facility */
++    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(SignatureBaseRSA.class.getName());
++        java.util.logging.Logger.getLogger
++        (SignatureBaseRSA.class.getName());
+ 
+     /** @inheritDoc */
+-   public abstract String engineGetURI();
++    public abstract String engineGetURI();
+ 
+-   /** Field algorithm */
+-   private java.security.Signature _signatureAlgorithm = null;
++    /** Field algorithm */
++    private java.security.Signature _signatureAlgorithm = null;
+ 
+-   /**
+-    * Constructor SignatureRSA
+-    *
+-    * @throws XMLSignatureException
+-    */
+-   public SignatureBaseRSA() throws XMLSignatureException {
++    /**
++     * Constructor SignatureRSA
++     *
++     * @throws XMLSignatureException
++     */
++    public SignatureBaseRSA() throws XMLSignatureException {
+ 
+-      String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
++        String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
+ 
+-      if (true)
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Created SignatureDSA using " + algorithmID);
+-      String provider=JCEMapper.getProviderId();
+-      try {
+-         if (provider==null) {
++        if (log.isLoggable(java.util.logging.Level.FINE))
++            log.log(java.util.logging.Level.FINE, "Created SignatureRSA using " + algorithmID);
++        String provider=JCEMapper.getProviderId();
++        try {
++            if (provider==null) {
+                 this._signatureAlgorithm = Signature.getInstance(algorithmID);
+-         } else {
++            } else {
+                 this._signatureAlgorithm = Signature.getInstance(algorithmID,provider);
+-         }
+-      } catch (java.security.NoSuchAlgorithmException ex) {
+-         Object[] exArgs = { algorithmID,
+-                             ex.getLocalizedMessage() };
++            }
++        } catch (java.security.NoSuchAlgorithmException ex) {
++            Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
+ 
+-         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
+-      } catch (NoSuchProviderException ex) {
+-         Object[] exArgs = { algorithmID,
+-                                                 ex.getLocalizedMessage() };
++            throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
++        } catch (NoSuchProviderException ex) {
++            Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
+ 
+-         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
++            throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
+         }
+-   }
++    }
+ 
+-   /** @inheritDoc */
+-   protected void engineSetParameter(AlgorithmParameterSpec params)
+-           throws XMLSignatureException {
++    /** @inheritDoc */
++    protected void engineSetParameter(AlgorithmParameterSpec params)
++        throws XMLSignatureException {
+ 
+-      try {
+-         this._signatureAlgorithm.setParameter(params);
+-      } catch (InvalidAlgorithmParameterException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++        try {
++            this._signatureAlgorithm.setParameter(params);
++        } catch (InvalidAlgorithmParameterException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-   /** @inheritDoc */
+-   protected boolean engineVerify(byte[] signature)
+-           throws XMLSignatureException {
++    /** @inheritDoc */
++    protected boolean engineVerify(byte[] signature)
++        throws XMLSignatureException {
+ 
+-      try {
+-         return this._signatureAlgorithm.verify(signature);
+-      } catch (SignatureException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++        try {
++            return this._signatureAlgorithm.verify(signature);
++        } catch (SignatureException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-   /** @inheritDoc */
+-   protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
++    /** @inheritDoc */
++    protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
+ 
+-      if (!(publicKey instanceof PublicKey)) {
+-         String supplied = publicKey.getClass().getName();
+-         String needed = PublicKey.class.getName();
+-         Object exArgs[] = { supplied, needed };
++        if (!(publicKey instanceof PublicKey)) {
++            String supplied = publicKey.getClass().getName();
++            String needed = PublicKey.class.getName();
++            Object exArgs[] = { supplied, needed };
+ 
+-         throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
+-                                         exArgs);
+-      }
++            throw new XMLSignatureException
++                ("algorithms.WrongKeyForThisOperation", exArgs);
++        }
+ 
+-      try {
+-         this._signatureAlgorithm.initVerify((PublicKey) publicKey);
+-      } catch (InvalidKeyException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++        try {
++            this._signatureAlgorithm.initVerify((PublicKey) publicKey);
++        } catch (InvalidKeyException ex) {
++            // reinstantiate Signature object to work around bug in JDK
++            // see: http://bugs.sun.com/view_bug.do?bug_id=4953555
++            Signature sig = this._signatureAlgorithm;
++            try {
++                this._signatureAlgorithm = Signature.getInstance
++                    (_signatureAlgorithm.getAlgorithm());
++            } catch (Exception e) {
++                // this shouldn't occur, but if it does, restore previous
++                // Signature
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e);
++                }
++                this._signatureAlgorithm = sig;
++            }
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-   /** @inheritDoc */
+-   protected byte[] engineSign() throws XMLSignatureException {
++    /** @inheritDoc */
++    protected byte[] engineSign() throws XMLSignatureException {
++        try {
++            return this._signatureAlgorithm.sign();
++        } catch (SignatureException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-      try {
+-         return this._signatureAlgorithm.sign();
+-      } catch (SignatureException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++    /** @inheritDoc */
++    protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
++        throws XMLSignatureException {
+ 
+-   /** @inheritDoc */
+-   protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
+-           throws XMLSignatureException {
++        if (!(privateKey instanceof PrivateKey)) {
++            String supplied = privateKey.getClass().getName();
++            String needed = PrivateKey.class.getName();
++            Object exArgs[] = { supplied, needed };
+ 
+-      if (!(privateKey instanceof PrivateKey)) {
+-         String supplied = privateKey.getClass().getName();
+-         String needed = PrivateKey.class.getName();
+-         Object exArgs[] = { supplied, needed };
++            throw new XMLSignatureException
++                ("algorithms.WrongKeyForThisOperation", exArgs);
++        }
+ 
+-         throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
+-                                         exArgs);
+-      }
++        try {
++            this._signatureAlgorithm.initSign
++                ((PrivateKey) privateKey, secureRandom);
++        } catch (InvalidKeyException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-      try {
+-         this._signatureAlgorithm.initSign((PrivateKey) privateKey,
+-                                           secureRandom);
+-      } catch (InvalidKeyException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++    /** @inheritDoc */
++    protected void engineInitSign(Key privateKey) throws XMLSignatureException {
+ 
+-   /** @inheritDoc */
+-   protected void engineInitSign(Key privateKey) throws XMLSignatureException {
++        if (!(privateKey instanceof PrivateKey)) {
++            String supplied = privateKey.getClass().getName();
++            String needed = PrivateKey.class.getName();
++            Object exArgs[] = { supplied, needed };
+ 
+-      if (!(privateKey instanceof PrivateKey)) {
+-         String supplied = privateKey.getClass().getName();
+-         String needed = PrivateKey.class.getName();
+-         Object exArgs[] = { supplied, needed };
++            throw new XMLSignatureException
++                ("algorithms.WrongKeyForThisOperation", exArgs);
++        }
+ 
+-         throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
+-                                         exArgs);
+-      }
++        try {
++            this._signatureAlgorithm.initSign((PrivateKey) privateKey);
++        } catch (InvalidKeyException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-      try {
+-         this._signatureAlgorithm.initSign((PrivateKey) privateKey);
+-      } catch (InvalidKeyException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++    /** @inheritDoc */
++    protected void engineUpdate(byte[] input) throws XMLSignatureException {
++        try {
++            this._signatureAlgorithm.update(input);
++        } catch (SignatureException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-   /** @inheritDoc */
+-   protected void engineUpdate(byte[] input) throws XMLSignatureException {
++    /** @inheritDoc */
++    protected void engineUpdate(byte input) throws XMLSignatureException {
++        try {
++            this._signatureAlgorithm.update(input);
++        } catch (SignatureException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-      try {
+-         this._signatureAlgorithm.update(input);
+-      } catch (SignatureException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++    /** @inheritDoc */
++    protected void engineUpdate(byte buf[], int offset, int len)
++        throws XMLSignatureException {
++        try {
++            this._signatureAlgorithm.update(buf, offset, len);
++        } catch (SignatureException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-   /** @inheritDoc */
+-   protected void engineUpdate(byte input) throws XMLSignatureException {
++    /** @inheritDoc */
++    protected String engineGetJCEAlgorithmString() {
++        return this._signatureAlgorithm.getAlgorithm();
++    }
+ 
+-      try {
+-         this._signatureAlgorithm.update(input);
+-      } catch (SignatureException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++    /** @inheritDoc */
++    protected String engineGetJCEProviderName() {
++        return this._signatureAlgorithm.getProvider().getName();
++    }
+ 
+-   /** @inheritDoc */
+-   protected void engineUpdate(byte buf[], int offset, int len)
+-           throws XMLSignatureException {
++    /** @inheritDoc */
++    protected void engineSetHMACOutputLength(int HMACOutputLength)
++        throws XMLSignatureException {
++        throw new XMLSignatureException
++            ("algorithms.HMACOutputLengthOnlyForHMAC");
++    }
+ 
+-      try {
+-         this._signatureAlgorithm.update(buf, offset, len);
+-      } catch (SignatureException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++    /** @inheritDoc */
++    protected void engineInitSign(
++        Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
++        throws XMLSignatureException {
++        throw new XMLSignatureException(
++            "algorithms.CannotUseAlgorithmParameterSpecOnRSA");
++    }
+ 
+-   /** @inheritDoc */
+-   protected String engineGetJCEAlgorithmString() {
+-      return this._signatureAlgorithm.getAlgorithm();
+-   }
++    /**
++     * Class SignatureRSASHA1
++     *
++     * @author $Author: mullan $
++     * @version $Revision: 1.5 $
++     */
++    public static class SignatureRSASHA1 extends SignatureBaseRSA {
+ 
+-   /** @inheritDoc */
+-   protected String engineGetJCEProviderName() {
+-      return this._signatureAlgorithm.getProvider().getName();
+-   }
++        /**
++         * Constructor SignatureRSASHA1
++         *
++         * @throws XMLSignatureException
++         */
++        public SignatureRSASHA1() throws XMLSignatureException {
++            super();
++        }
+ 
+-   /** @inheritDoc */
+-   protected void engineSetHMACOutputLength(int HMACOutputLength)
+-           throws XMLSignatureException {
+-      throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
+-   }
++        /** @inheritDoc */
++        public String engineGetURI() {
++            return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1;
++        }
++    }
+ 
+-   /** @inheritDoc */
+-   protected void engineInitSign(
+-           Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
+-              throws XMLSignatureException {
+-      throw new XMLSignatureException(
+-         "algorithms.CannotUseAlgorithmParameterSpecOnRSA");
+-   }
++    /**
++     * Class SignatureRSASHA256
++     *
++     * @author $Author: mullan $
++     * @version $Revision: 1.5 $
++     */
++    public static class SignatureRSASHA256 extends SignatureBaseRSA {
+ 
+-   /**
+-    * Class SignatureRSASHA1
+-    *
+-    * @author $Author: raul $
+-    */
+-   public static class SignatureRSASHA1 extends SignatureBaseRSA {
++        /**
++         * Constructor SignatureRSASHA256
++         *
++         * @throws XMLSignatureException
++         */
++        public SignatureRSASHA256() throws XMLSignatureException {
++            super();
++        }
+ 
+-      /**
+-       * Constructor SignatureRSASHA1
+-       *
+-       * @throws XMLSignatureException
+-       */
+-      public SignatureRSASHA1() throws XMLSignatureException {
+-         super();
+-      }
++        /** @inheritDoc */
++        public String engineGetURI() {
++            return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256;
++        }
++    }
+ 
+-      /** @inheritDoc */
+-      public String engineGetURI() {
+-         return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1;
+-      }
+-   }
++    /**
++     * Class SignatureRSASHA384
++     *
++     * @author $Author: mullan $
++     * @version $Revision: 1.5 $
++     */
++    public static class SignatureRSASHA384 extends SignatureBaseRSA {
+ 
+-   /**
+-    * Class SignatureRSASHA256
+-    *
+-    * @author $Author: raul $
+-    */
+-   public static class SignatureRSASHA256 extends SignatureBaseRSA {
++        /**
++         * Constructor SignatureRSASHA384
++         *
++         * @throws XMLSignatureException
++         */
++        public SignatureRSASHA384() throws XMLSignatureException {
++            super();
++        }
+ 
+-      /**
+-       * Constructor SignatureRSASHA256
+-       *
+-       * @throws XMLSignatureException
+-       */
+-      public SignatureRSASHA256() throws XMLSignatureException {
+-         super();
+-      }
++        /** @inheritDoc */
++        public String engineGetURI() {
++            return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384;
++        }
++    }
+ 
+-      /** @inheritDoc */
+-      public String engineGetURI() {
+-         return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256;
+-      }
+-   }
++    /**
++     * Class SignatureRSASHA512
++     *
++     * @author $Author: mullan $
++     * @version $Revision: 1.5 $
++     */
++    public static class SignatureRSASHA512 extends SignatureBaseRSA {
+ 
+-   /**
+-    * Class SignatureRSASHA384
+-    *
+-    * @author $Author: raul $
+-    */
+-   public static class SignatureRSASHA384 extends SignatureBaseRSA {
++        /**
++         * Constructor SignatureRSASHA512
++         *
++         * @throws XMLSignatureException
++         */
++        public SignatureRSASHA512() throws XMLSignatureException {
++            super();
++        }
+ 
+-      /**
+-       * Constructor SignatureRSASHA384
+-       *
+-       * @throws XMLSignatureException
+-       */
+-      public SignatureRSASHA384() throws XMLSignatureException {
+-         super();
+-      }
++        /** @inheritDoc */
++        public String engineGetURI() {
++            return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512;
++        }
++    }
+ 
+-      /** @inheritDoc */
+-      public String engineGetURI() {
+-         return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384;
+-      }
+-   }
++    /**
++     * Class SignatureRSARIPEMD160
++     *
++     * @author $Author: mullan $
++     * @version $Revision: 1.5 $
++     */
++    public static class SignatureRSARIPEMD160 extends SignatureBaseRSA {
+ 
+-   /**
+-    * Class SignatureRSASHA512
+-    *
+-    * @author $Author: raul $
+-    */
+-   public static class SignatureRSASHA512 extends SignatureBaseRSA {
++        /**
++         * Constructor SignatureRSARIPEMD160
++         *
++         * @throws XMLSignatureException
++         */
++        public SignatureRSARIPEMD160() throws XMLSignatureException {
++            super();
++        }
+ 
+-      /**
+-       * Constructor SignatureRSASHA512
+-       *
+-       * @throws XMLSignatureException
+-       */
+-      public SignatureRSASHA512() throws XMLSignatureException {
+-         super();
+-      }
++        /** @inheritDoc */
++        public String engineGetURI() {
++            return XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160;
++        }
++    }
+ 
+-      /** @inheritDoc */
+-      public String engineGetURI() {
+-         return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512;
+-      }
+-   }
++    /**
++     * Class SignatureRSAMD5
++     *
++     * @author $Author: mullan $
++     * @version $Revision: 1.5 $
++     */
++    public static class SignatureRSAMD5 extends SignatureBaseRSA {
+ 
+-   /**
+-    * Class SignatureRSARIPEMD160
+-    *
+-    * @author $Author: raul $
+-    */
+-   public static class SignatureRSARIPEMD160 extends SignatureBaseRSA {
++        /**
++         * Constructor SignatureRSAMD5
++         *
++         * @throws XMLSignatureException
++         */
++        public SignatureRSAMD5() throws XMLSignatureException {
++            super();
++        }
+ 
+-      /**
+-       * Constructor SignatureRSARIPEMD160
+-       *
+-       * @throws XMLSignatureException
+-       */
+-      public SignatureRSARIPEMD160() throws XMLSignatureException {
+-         super();
+-      }
+-
+-      /** @inheritDoc */
+-      public String engineGetURI() {
+-         return XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160;
+-      }
+-   }
+-
+-   /**
+-    * Class SignatureRSAMD5
+-    *
+-    * @author $Author: raul $
+-    */
+-   public static class SignatureRSAMD5 extends SignatureBaseRSA {
+-
+-      /**
+-       * Constructor SignatureRSAMD5
+-       *
+-       * @throws XMLSignatureException
+-       */
+-      public SignatureRSAMD5() throws XMLSignatureException {
+-         super();
+-      }
+-
+-      /** @inheritDoc */
+-      public String engineGetURI() {
+-         return XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5;
+-      }
+-   }
++        /** @inheritDoc */
++        public String engineGetURI() {
++            return XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5;
++        }
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureDSA.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.algorithms.implementations;
+ 
+-
+-
+ import java.io.IOException;
+ import java.security.InvalidAlgorithmParameterException;
+ import java.security.InvalidKeyException;
+@@ -39,342 +37,359 @@
+ import com.sun.org.apache.xml.internal.security.utils.Base64;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ 
+-
+ /**
+  *
+- * @author $Author: vishal $
++ * @author $Author: mullan $
+  */
+ public class SignatureDSA extends SignatureAlgorithmSpi {
+ 
+-   /** {@link java.util.logging} logging facility */
++    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(SignatureDSA.class.getName());
+ 
+-   /** Field _URI */
+-   public static final String _URI = Constants.SignatureSpecNS + "dsa-sha1";
++    /** Field _URI */
++    public static final String _URI = Constants.SignatureSpecNS + "dsa-sha1";
+ 
+-   /** Field algorithm */
+-   private java.security.Signature _signatureAlgorithm = null;
++    /** Field algorithm */
++    private java.security.Signature _signatureAlgorithm = null;
+ 
+-   /**
+-    * Method engineGetURI
+-    *
+-    * @inheritDoc
+-    */
+-   protected String engineGetURI() {
+-      return SignatureDSA._URI;
+-   }
++    /**
++     * Method engineGetURI
++     *
++     * @inheritDoc
++     */
++    protected String engineGetURI() {
++        return SignatureDSA._URI;
++    }
+ 
+-   /**
+-    * Constructor SignatureDSA
+-    *
+-    * @throws XMLSignatureException
+-    */
+-   public SignatureDSA() throws XMLSignatureException {
++    /**
++     * Constructor SignatureDSA
++     *
++     * @throws XMLSignatureException
++     */
++    public SignatureDSA() throws XMLSignatureException {
+ 
+-      String algorithmID = JCEMapper.translateURItoJCEID(SignatureDSA._URI);
+-      if (true)
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Created SignatureDSA using " + algorithmID);
++        String algorithmID = JCEMapper.translateURItoJCEID(SignatureDSA._URI);
++        if (log.isLoggable(java.util.logging.Level.FINE))
++            log.log(java.util.logging.Level.FINE, "Created SignatureDSA using " + algorithmID);
+ 
+-      try {
+-         this._signatureAlgorithm = Signature.getInstance(algorithmID);
+-      } catch (java.security.NoSuchAlgorithmException ex) {
+-         Object[] exArgs = { algorithmID,
+-                             ex.getLocalizedMessage() };
++        String provider = JCEMapper.getProviderId();
++        try {
++            if (provider == null) {
++                this._signatureAlgorithm = Signature.getInstance(algorithmID);
++            } else {
++                this._signatureAlgorithm =
++                    Signature.getInstance(algorithmID, provider);
++            }
++        } catch (java.security.NoSuchAlgorithmException ex) {
++            Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
++            throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
++        } catch (java.security.NoSuchProviderException ex) {
++            Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
++            throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
++        }
++    }
+ 
+-         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
+-      }
+-   }
++    /**
++     * @inheritDoc
++     */
++    protected void engineSetParameter(AlgorithmParameterSpec params)
++        throws XMLSignatureException {
+ 
+-   /**
+-    * @inheritDoc
+-    */
+-   protected void engineSetParameter(AlgorithmParameterSpec params)
++        try {
++            this._signatureAlgorithm.setParameter(params);
++        } catch (InvalidAlgorithmParameterException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
++
++    /**
++     * @inheritDoc
++     */
++    protected boolean engineVerify(byte[] signature)
+            throws XMLSignatureException {
+ 
+-      try {
+-         this._signatureAlgorithm.setParameter(params);
+-      } catch (InvalidAlgorithmParameterException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++        try {
++            if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Called DSA.verify() on " + Base64.encode(signature));
+ 
+-   /**
+-    * @inheritDoc
+-    */
+-   protected boolean engineVerify(byte[] signature)
++            byte[] jcebytes = SignatureDSA.convertXMLDSIGtoASN1(signature);
++
++            return this._signatureAlgorithm.verify(jcebytes);
++        } catch (SignatureException ex) {
++            throw new XMLSignatureException("empty", ex);
++        } catch (IOException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
++
++    /**
++     * @inheritDoc
++     */
++    protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
++
++        if (!(publicKey instanceof PublicKey)) {
++            String supplied = publicKey.getClass().getName();
++            String needed = PublicKey.class.getName();
++            Object exArgs[] = { supplied, needed };
++
++            throw new XMLSignatureException
++                ("algorithms.WrongKeyForThisOperation", exArgs);
++        }
++
++        try {
++            this._signatureAlgorithm.initVerify((PublicKey) publicKey);
++        } catch (InvalidKeyException ex) {
++            // reinstantiate Signature object to work around bug in JDK
++            // see: http://bugs.sun.com/view_bug.do?bug_id=4953555
++            Signature sig = this._signatureAlgorithm;
++            try {
++                this._signatureAlgorithm = Signature.getInstance
++                    (_signatureAlgorithm.getAlgorithm());
++            } catch (Exception e) {
++                // this shouldn't occur, but if it does, restore previous
++                // Signature
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e);
++                }
++                this._signatureAlgorithm = sig;
++            }
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
++
++    /**
++     * @inheritDoc
++     */
++    protected byte[] engineSign() throws XMLSignatureException {
++
++        try {
++            byte jcebytes[] = this._signatureAlgorithm.sign();
++
++            return SignatureDSA.convertASN1toXMLDSIG(jcebytes);
++        } catch (IOException ex) {
++            throw new XMLSignatureException("empty", ex);
++        } catch (SignatureException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
++
++    /**
++     * @inheritDoc
++     */
++    protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
+            throws XMLSignatureException {
+ 
+-      try {
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Called DSA.verify() on " + Base64.encode(signature));
++        if (!(privateKey instanceof PrivateKey)) {
++            String supplied = privateKey.getClass().getName();
++            String needed = PrivateKey.class.getName();
++            Object exArgs[] = { supplied, needed };
+ 
+-         byte[] jcebytes = SignatureDSA.convertXMLDSIGtoASN1(signature);
++            throw new XMLSignatureException
++                ("algorithms.WrongKeyForThisOperation", exArgs);
++        }
+ 
+-         return this._signatureAlgorithm.verify(jcebytes);
+-      } catch (SignatureException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      } catch (IOException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++        try {
++            this._signatureAlgorithm.initSign((PrivateKey) privateKey,
++                                           secureRandom);
++        } catch (InvalidKeyException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-   /**
+-    * @inheritDoc
+-    */
+-   protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
++    /**
++     * @inheritDoc
++     */
++    protected void engineInitSign(Key privateKey) throws XMLSignatureException {
+ 
+-      if (!(publicKey instanceof PublicKey)) {
+-         String supplied = publicKey.getClass().getName();
+-         String needed = PublicKey.class.getName();
+-         Object exArgs[] = { supplied, needed };
++        if (!(privateKey instanceof PrivateKey)) {
++            String supplied = privateKey.getClass().getName();
++            String needed = PrivateKey.class.getName();
++            Object exArgs[] = { supplied, needed };
+ 
+-         throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
+-                                         exArgs);
+-      }
++            throw new XMLSignatureException
++                ("algorithms.WrongKeyForThisOperation", exArgs);
++        }
+ 
+-      try {
+-         this._signatureAlgorithm.initVerify((PublicKey) publicKey);
+-      } catch (InvalidKeyException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++        try {
++            this._signatureAlgorithm.initSign((PrivateKey) privateKey);
++        } catch (InvalidKeyException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-   /**
+-    * @inheritDoc
+-    */
+-   protected byte[] engineSign() throws XMLSignatureException {
++    /**
++     * @inheritDoc
++     */
++    protected void engineUpdate(byte[] input) throws XMLSignatureException {
++        try {
++            this._signatureAlgorithm.update(input);
++        } catch (SignatureException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-      try {
+-         byte jcebytes[] = this._signatureAlgorithm.sign();
++    /**
++     * @inheritDoc
++     */
++    protected void engineUpdate(byte input) throws XMLSignatureException {
++        try {
++            this._signatureAlgorithm.update(input);
++        } catch (SignatureException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-         return SignatureDSA.convertASN1toXMLDSIG(jcebytes);
+-      } catch (IOException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      } catch (SignatureException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
++    /**
++     * @inheritDoc
++     */
++    protected void engineUpdate(byte buf[], int offset, int len)
++        throws XMLSignatureException {
++        try {
++            this._signatureAlgorithm.update(buf, offset, len);
++        } catch (SignatureException ex) {
++            throw new XMLSignatureException("empty", ex);
++        }
++    }
+ 
+-   /**
+-    * @inheritDoc
+-    */
+-   protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
+-           throws XMLSignatureException {
++    /**
++     * Method engineGetJCEAlgorithmString
++     *
++     * @inheritDoc
++     */
++    protected String engineGetJCEAlgorithmString() {
++        return this._signatureAlgorithm.getAlgorithm();
++    }
+ 
+-      if (!(privateKey instanceof PrivateKey)) {
+-         String supplied = privateKey.getClass().getName();
+-         String needed = PrivateKey.class.getName();
+-         Object exArgs[] = { supplied, needed };
++    /**
++     * Method engineGetJCEProviderName
++     *
++     * @inheritDoc
++     */
++    protected String engineGetJCEProviderName() {
++        return this._signatureAlgorithm.getProvider().getName();
++    }
+ 
+-         throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
+-                                         exArgs);
+-      }
+-
+-      try {
+-         this._signatureAlgorithm.initSign((PrivateKey) privateKey,
+-                                           secureRandom);
+-      } catch (InvalidKeyException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
+-
+-   /**
+-    * @inheritDoc
+-    */
+-   protected void engineInitSign(Key privateKey) throws XMLSignatureException {
+-
+-      if (!(privateKey instanceof PrivateKey)) {
+-         String supplied = privateKey.getClass().getName();
+-         String needed = PrivateKey.class.getName();
+-         Object exArgs[] = { supplied, needed };
+-
+-         throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
+-                                         exArgs);
+-      }
+-
+-      try {
+-         this._signatureAlgorithm.initSign((PrivateKey) privateKey);
+-      } catch (InvalidKeyException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
+-
+-   /**
+-    * @inheritDoc
+-    */
+-   protected void engineUpdate(byte[] input) throws XMLSignatureException {
+-
+-      try {
+-         this._signatureAlgorithm.update(input);
+-      } catch (SignatureException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
+-
+-   /**
+-    * @inheritDoc
+-    */
+-   protected void engineUpdate(byte input) throws XMLSignatureException {
+-
+-      try {
+-         this._signatureAlgorithm.update(input);
+-      } catch (SignatureException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
+-
+-   /**
+-    * @inheritDoc
+-    */
+-   protected void engineUpdate(byte buf[], int offset, int len)
+-           throws XMLSignatureException {
+-
+-      try {
+-         this._signatureAlgorithm.update(buf, offset, len);
+-      } catch (SignatureException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
+-   }
+-
+-   /**
+-    * Method engineGetJCEAlgorithmString
+-    *
+-    * @inheritDoc
+-    */
+-   protected String engineGetJCEAlgorithmString() {
+-      return this._signatureAlgorithm.getAlgorithm();
+-   }
+-
+-   /**
+-    * Method engineGetJCEProviderName
+-    *
+-    * @inheritDoc
+-    */
+-   protected String engineGetJCEProviderName() {
+-      return this._signatureAlgorithm.getProvider().getName();
+-   }
+-
+-
+-   /**
+-    * Converts an ASN.1 DSA value to a XML Signature DSA Value.
+-    *
+-    * The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
+-    * pairs; the XML Signature requires the core BigInteger values.
+-    *
+-    * @param asn1Bytes
+-    * @return the decode bytes
+-    *
+-    * @throws IOException
+-    * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
+-    */
+-   private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[])
++    /**
++     * Converts an ASN.1 DSA value to a XML Signature DSA Value.
++     *
++     * The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
++     * pairs; the XML Signature requires the core BigInteger values.
++     *
++     * @param asn1Bytes
++     * @return the decode bytes
++     *
++     * @throws IOException
++     * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
++     */
++    private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[])
+            throws IOException {
+ 
+-      byte rLength = asn1Bytes[3];
+-      int i;
++        byte rLength = asn1Bytes[3];
++        int i;
+ 
+-      for (i = rLength; (i > 0) && (asn1Bytes[(4 + rLength) - i] == 0); i--);
++        for (i = rLength; (i > 0) && (asn1Bytes[(4 + rLength) - i] == 0); i--);
+ 
+-      byte sLength = asn1Bytes[5 + rLength];
+-      int j;
++        byte sLength = asn1Bytes[5 + rLength];
++        int j;
+ 
+-      for (j = sLength;
++        for (j = sLength;
+               (j > 0) && (asn1Bytes[(6 + rLength + sLength) - j] == 0); j--);
+ 
+-      if ((asn1Bytes[0] != 48) || (asn1Bytes[1] != asn1Bytes.length - 2)
++        if ((asn1Bytes[0] != 48) || (asn1Bytes[1] != asn1Bytes.length - 2)
+               || (asn1Bytes[2] != 2) || (i > 20)
+               || (asn1Bytes[4 + rLength] != 2) || (j > 20)) {
+-         throw new IOException("Invalid ASN.1 format of DSA signature");
+-      }
+-      byte xmldsigBytes[] = new byte[40];
++            throw new IOException("Invalid ASN.1 format of DSA signature");
++        }
++        byte xmldsigBytes[] = new byte[40];
+ 
+-      System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 20 - i,
++        System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 20 - i,
+                           i);
+-      System.arraycopy(asn1Bytes, (6 + rLength + sLength) - j, xmldsigBytes,
++        System.arraycopy(asn1Bytes, (6 + rLength + sLength) - j, xmldsigBytes,
+                           40 - j, j);
+ 
+-       return xmldsigBytes;
+-   }
++        return xmldsigBytes;
++    }
+ 
+-   /**
+-    * Converts a XML Signature DSA Value to an ASN.1 DSA value.
+-    *
+-    * The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
+-    * pairs; the XML Signature requires the core BigInteger values.
+-    *
+-    * @param xmldsigBytes
+-    * @return the encoded ASN.1 bytes
+-    *
+-    * @throws IOException
+-    * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
+-    */
+-   private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[])
++    /**
++     * Converts a XML Signature DSA Value to an ASN.1 DSA value.
++     *
++     * The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
++     * pairs; the XML Signature requires the core BigInteger values.
++     *
++     * @param xmldsigBytes
++     * @return the encoded ASN.1 bytes
++     *
++     * @throws IOException
++     * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
++     */
++    private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[])
+            throws IOException {
+ 
+-      if (xmldsigBytes.length != 40) {
+-         throw new IOException("Invalid XMLDSIG format of DSA signature");
+-      }
++        if (xmldsigBytes.length != 40) {
++            throw new IOException("Invalid XMLDSIG format of DSA signature");
++        }
+ 
+-      int i;
++        int i;
+ 
+-      for (i = 20; (i > 0) && (xmldsigBytes[20 - i] == 0); i--);
++        for (i = 20; (i > 0) && (xmldsigBytes[20 - i] == 0); i--);
+ 
+-      int j = i;
++        int j = i;
+ 
+-      if (xmldsigBytes[20 - i] < 0) {
++        if (xmldsigBytes[20 - i] < 0) {
+          j += 1;
+-      }
++        }
+ 
+-      int k;
++        int k;
+ 
+-      for (k = 20; (k > 0) && (xmldsigBytes[40 - k] == 0); k--);
++        for (k = 20; (k > 0) && (xmldsigBytes[40 - k] == 0); k--);
+ 
+-      int l = k;
++        int l = k;
+ 
+-      if (xmldsigBytes[40 - k] < 0) {
+-         l += 1;
+-      }
++        if (xmldsigBytes[40 - k] < 0) {
++            l += 1;
++        }
+ 
+-      byte asn1Bytes[] = new byte[6 + j + l];
++        byte asn1Bytes[] = new byte[6 + j + l];
+ 
+-      asn1Bytes[0] = 48;
+-      asn1Bytes[1] = (byte) (4 + j + l);
+-      asn1Bytes[2] = 2;
+-      asn1Bytes[3] = (byte) j;
++        asn1Bytes[0] = 48;
++        asn1Bytes[1] = (byte) (4 + j + l);
++        asn1Bytes[2] = 2;
++        asn1Bytes[3] = (byte) j;
+ 
+-      System.arraycopy(xmldsigBytes, 20 - i, asn1Bytes, (4 + j) - i, i);
++        System.arraycopy(xmldsigBytes, 20 - i, asn1Bytes, (4 + j) - i, i);
+ 
+-      asn1Bytes[4 + j] = 2;
+-      asn1Bytes[5 + j] = (byte) l;
++        asn1Bytes[4 + j] = 2;
++        asn1Bytes[5 + j] = (byte) l;
+ 
+-      System.arraycopy(xmldsigBytes, 40 - k, asn1Bytes, (6 + j + l) - k, k);
++        System.arraycopy(xmldsigBytes, 40 - k, asn1Bytes, (6 + j + l) - k, k);
+ 
+-      return asn1Bytes;
+-   }
++        return asn1Bytes;
++    }
+ 
+-   /**
+-    * Method engineSetHMACOutputLength
+-    *
+-    * @param HMACOutputLength
+-    * @throws XMLSignatureException
+-    */
+-   protected void engineSetHMACOutputLength(int HMACOutputLength)
+-           throws XMLSignatureException {
+-      throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
+-   }
++    /**
++     * Method engineSetHMACOutputLength
++     *
++     * @param HMACOutputLength
++     * @throws XMLSignatureException
++     */
++    protected void engineSetHMACOutputLength(int HMACOutputLength)
++            throws XMLSignatureException {
++        throw new XMLSignatureException(
++            "algorithms.HMACOutputLengthOnlyForHMAC");
++    }
+ 
+-   /**
+-    * Method engineInitSign
+-    *
+-    * @param signingKey
+-    * @param algorithmParameterSpec
+-    * @throws XMLSignatureException
+-    */
+-   protected void engineInitSign(
+-           Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
+-              throws XMLSignatureException {
+-      throw new XMLSignatureException(
+-         "algorithms.CannotUseAlgorithmParameterSpecOnDSA");
+-   }
++    /**
++     * Method engineInitSign
++     *
++     * @param signingKey
++     * @param algorithmParameterSpec
++     * @throws XMLSignatureException
++     */
++    protected void engineInitSign(
++        Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
++            throws XMLSignatureException {
++        throw new XMLSignatureException(
++            "algorithms.CannotUseAlgorithmParameterSpecOnDSA");
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/implementations/SignatureECDSA.java
+@@ -0,0 +1,384 @@
++/*
++ * 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.
++ *
++ */
++package com.sun.org.apache.xml.internal.security.algorithms.implementations;
++
++
++
++import java.io.IOException;
++import java.security.InvalidAlgorithmParameterException;
++import java.security.InvalidKeyException;
++import java.security.Key;
++import java.security.NoSuchProviderException;
++import java.security.PrivateKey;
++import java.security.PublicKey;
++import java.security.SecureRandom;
++import java.security.Signature;
++import java.security.SignatureException;
++import java.security.spec.AlgorithmParameterSpec;
++
++import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
++import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi;
++import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
++import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
++import com.sun.org.apache.xml.internal.security.utils.Base64;
++
++
++/**
++ *
++ * @author $Author: mullan $
++ */
++public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
++
++   /** {@link java.util.logging} logging facility */
++    static java.util.logging.Logger log =
++        java.util.logging.Logger.getLogger(SignatureECDSA.class.getName());
++
++    /** @inheritDoc */
++   public abstract String engineGetURI();
++
++   /** Field algorithm */
++   private java.security.Signature _signatureAlgorithm = null;
++
++   /**
++    * Converts an ASN.1 ECDSA value to a XML Signature ECDSA Value.
++    *
++    * The JAVA JCE ECDSA Signature algorithm creates ASN.1 encoded (r,s) value
++    * pairs; the XML Signature requires the core BigInteger values.
++    *
++    * @param asn1Bytes
++    * @return the decode bytes
++    *
++    * @throws IOException
++    * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
++    * @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
++    */
++   private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[])
++           throws IOException {
++
++      byte rLength = asn1Bytes[3];
++      int i;
++
++      for (i = rLength; (i > 0) && (asn1Bytes[(4 + rLength) - i] == 0); i--);
++
++      byte sLength = asn1Bytes[5 + rLength];
++      int j;
++
++      for (j = sLength;
++              (j > 0) && (asn1Bytes[(6 + rLength + sLength) - j] == 0); j--);
++
++      if ((asn1Bytes[0] != 48) || (asn1Bytes[1] != asn1Bytes.length - 2)
++              || (asn1Bytes[2] != 2) || (i > 24)
++              || (asn1Bytes[4 + rLength] != 2) || (j > 24)) {
++         throw new IOException("Invalid ASN.1 format of ECDSA signature");
++      }
++      byte xmldsigBytes[] = new byte[48];
++
++      System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 24 - i,
++                          i);
++      System.arraycopy(asn1Bytes, (6 + rLength + sLength) - j, xmldsigBytes,
++                          48 - j, j);
++
++       return xmldsigBytes;
++   }
++
++   /**
++    * Converts a XML Signature ECDSA Value to an ASN.1 DSA value.
++    *
++    * The JAVA JCE ECDSA Signature algorithm creates ASN.1 encoded (r,s) value
++    * pairs; the XML Signature requires the core BigInteger values.
++    *
++    * @param xmldsigBytes
++    * @return the encoded ASN.1 bytes
++    *
++    * @throws IOException
++    * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
++    * @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
++    */
++   private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[])
++           throws IOException {
++
++      if (xmldsigBytes.length != 48) {
++         throw new IOException("Invalid XMLDSIG format of ECDSA signature");
++      }
++
++      int i;
++
++      for (i = 24; (i > 0) && (xmldsigBytes[24 - i] == 0); i--);
++
++      int j = i;
++
++      if (xmldsigBytes[24 - i] < 0) {
++         j += 1;
++      }
++
++      int k;
++
++      for (k = 24; (k > 0) && (xmldsigBytes[48 - k] == 0); k--);
++
++      int l = k;
++
++      if (xmldsigBytes[48 - k] < 0) {
++         l += 1;
++      }
++
++      byte asn1Bytes[] = new byte[6 + j + l];
++
++      asn1Bytes[0] = 48;
++      asn1Bytes[1] = (byte) (4 + j + l);
++      asn1Bytes[2] = 2;
++      asn1Bytes[3] = (byte) j;
++
++      System.arraycopy(xmldsigBytes, 24 - i, asn1Bytes, (4 + j) - i, i);
++
++      asn1Bytes[4 + j] = 2;
++      asn1Bytes[5 + j] = (byte) l;
++
++      System.arraycopy(xmldsigBytes, 48 - k, asn1Bytes, (6 + j + l) - k, k);
++
++      return asn1Bytes;
++   }
++
++   /**
++    * Constructor SignatureRSA
++    *
++    * @throws XMLSignatureException
++    */
++   public SignatureECDSA() throws XMLSignatureException {
++
++      String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
++
++      if (log.isLoggable(java.util.logging.Level.FINE))
++        log.log(java.util.logging.Level.FINE, "Created SignatureECDSA using " + algorithmID);
++      String provider=JCEMapper.getProviderId();
++      try {
++         if (provider==null) {
++                this._signatureAlgorithm = Signature.getInstance(algorithmID);
++         } else {
++                this._signatureAlgorithm = Signature.getInstance(algorithmID,provider);
++         }
++      } catch (java.security.NoSuchAlgorithmException ex) {
++         Object[] exArgs = { algorithmID,
++                             ex.getLocalizedMessage() };
++
++         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
++      } catch (NoSuchProviderException ex) {
++         Object[] exArgs = { algorithmID,
++                                                 ex.getLocalizedMessage() };
++
++         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
++        }
++   }
++
++   /** @inheritDoc */
++   protected void engineSetParameter(AlgorithmParameterSpec params)
++           throws XMLSignatureException {
++
++      try {
++         this._signatureAlgorithm.setParameter(params);
++      } catch (InvalidAlgorithmParameterException ex) {
++         throw new XMLSignatureException("empty", ex);
++      }
++   }
++
++   /** @inheritDoc */
++   protected boolean engineVerify(byte[] signature)
++           throws XMLSignatureException {
++
++      try {
++         byte[] jcebytes = SignatureECDSA.convertXMLDSIGtoASN1(signature);
++
++         if (log.isLoggable(java.util.logging.Level.FINE))
++            log.log(java.util.logging.Level.FINE, "Called ECDSA.verify() on " + Base64.encode(signature));
++
++         return this._signatureAlgorithm.verify(jcebytes);
++      } catch (SignatureException ex) {
++         throw new XMLSignatureException("empty", ex);
++      } catch (IOException ex) {
++         throw new XMLSignatureException("empty", ex);
++      }
++   }
++
++   /** @inheritDoc */
++   protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
++
++      if (!(publicKey instanceof PublicKey)) {
++         String supplied = publicKey.getClass().getName();
++         String needed = PublicKey.class.getName();
++         Object exArgs[] = { supplied, needed };
++
++         throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
++                                         exArgs);
++      }
++
++      try {
++         this._signatureAlgorithm.initVerify((PublicKey) publicKey);
++      } catch (InvalidKeyException ex) {
++            // reinstantiate Signature object to work around bug in JDK
++            // see: http://bugs.sun.com/view_bug.do?bug_id=4953555
++            Signature sig = this._signatureAlgorithm;
++            try {
++                this._signatureAlgorithm = Signature.getInstance
++                    (_signatureAlgorithm.getAlgorithm());
++            } catch (Exception e) {
++                // this shouldn't occur, but if it does, restore previous
++                // Signature
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e);
++                }
++                this._signatureAlgorithm = sig;
++            }
++            throw new XMLSignatureException("empty", ex);
++      }
++   }
++
++   /** @inheritDoc */
++   protected byte[] engineSign() throws XMLSignatureException {
++
++      try {
++         byte jcebytes[] = this._signatureAlgorithm.sign();
++
++         return SignatureECDSA.convertASN1toXMLDSIG(jcebytes);
++      } catch (SignatureException ex) {
++         throw new XMLSignatureException("empty", ex);
++      } catch (IOException ex) {
++          throw new XMLSignatureException("empty", ex);
++      }
++   }
++
++   /** @inheritDoc */
++   protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
++           throws XMLSignatureException {
++
++      if (!(privateKey instanceof PrivateKey)) {
++         String supplied = privateKey.getClass().getName();
++         String needed = PrivateKey.class.getName();
++         Object exArgs[] = { supplied, needed };
++
++         throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
++                                         exArgs);
++      }
++
++      try {
++         this._signatureAlgorithm.initSign((PrivateKey) privateKey,
++                                           secureRandom);
++      } catch (InvalidKeyException ex) {
++         throw new XMLSignatureException("empty", ex);
++      }
++   }
++
++   /** @inheritDoc */
++   protected void engineInitSign(Key privateKey) throws XMLSignatureException {
++
++      if (!(privateKey instanceof PrivateKey)) {
++         String supplied = privateKey.getClass().getName();
++         String needed = PrivateKey.class.getName();
++         Object exArgs[] = { supplied, needed };
++
++         throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
++                                         exArgs);
++      }
++
++      try {
++         this._signatureAlgorithm.initSign((PrivateKey) privateKey);
++      } catch (InvalidKeyException ex) {
++         throw new XMLSignatureException("empty", ex);
++      }
++   }
++
++   /** @inheritDoc */
++   protected void engineUpdate(byte[] input) throws XMLSignatureException {
++
++      try {
++         this._signatureAlgorithm.update(input);
++      } catch (SignatureException ex) {
++         throw new XMLSignatureException("empty", ex);
++      }
++   }
++
++   /** @inheritDoc */
++   protected void engineUpdate(byte input) throws XMLSignatureException {
++
++      try {
++         this._signatureAlgorithm.update(input);
++      } catch (SignatureException ex) {
++         throw new XMLSignatureException("empty", ex);
++      }
++   }
++
++   /** @inheritDoc */
++   protected void engineUpdate(byte buf[], int offset, int len)
++           throws XMLSignatureException {
++
++      try {
++         this._signatureAlgorithm.update(buf, offset, len);
++      } catch (SignatureException ex) {
++         throw new XMLSignatureException("empty", ex);
++      }
++   }
++
++   /** @inheritDoc */
++   protected String engineGetJCEAlgorithmString() {
++      return this._signatureAlgorithm.getAlgorithm();
++   }
++
++   /** @inheritDoc */
++   protected String engineGetJCEProviderName() {
++      return this._signatureAlgorithm.getProvider().getName();
++   }
++
++   /** @inheritDoc */
++   protected void engineSetHMACOutputLength(int HMACOutputLength)
++           throws XMLSignatureException {
++      throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
++   }
++
++   /** @inheritDoc */
++   protected void engineInitSign(
++           Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
++              throws XMLSignatureException {
++      throw new XMLSignatureException(
++         "algorithms.CannotUseAlgorithmParameterSpecOnRSA");
++   }
++
++   /**
++    * Class SignatureRSASHA1
++    *
++    * @author $Author: mullan $
++    * @version $Revision: 1.2 $
++    */
++   public static class SignatureECDSASHA1 extends SignatureECDSA {
++
++      /**
++       * Constructor SignatureRSASHA1
++       *
++       * @throws XMLSignatureException
++       */
++      public SignatureECDSASHA1() throws XMLSignatureException {
++         super();
++      }
++
++      /** @inheritDoc */
++      public String engineGetURI() {
++         return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1;
++      }
++   }
++
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizationException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizationException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizationException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizationException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java
+@@ -3,7 +3,7 @@
+  * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * Copyright  1999-2004 The Apache Software Foundation.
++ * Copyright  1999-2008 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.
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.c14n;
+ 
+-
+-
+ import java.io.ByteArrayInputStream;
+ import java.io.OutputStream;
+ import java.util.HashMap;
+@@ -37,318 +35,326 @@
+ import org.w3c.dom.NodeList;
+ import org.xml.sax.InputSource;
+ 
+-
+ /**
+  *
+- *
+  * @author Christian Geuer-Pollmann
+  */
+ public class Canonicalizer {
+ 
+-   //J-
+-   /** The output encoding of canonicalized data */
+-   public static final String ENCODING = "UTF8";
++    /** The output encoding of canonicalized data */
++    public static final String ENCODING = "UTF8";
+ 
++    /**
++     * XPath Expresion for selecting every node and continuous comments joined
++     * in only one node
++     */
++    public static final String XPATH_C14N_WITH_COMMENTS_SINGLE_NODE =
++        "(.//. | .//@* | .//namespace::*)";
+ 
+-   /**
+-     * XPath Expresion for selecting every node and continuos comments joined in only one node
+-     */
+-    public static final String XPATH_C14N_WITH_COMMENTS_SINGLE_NODE = "(.//. | .//@* | .//namespace::*)";
+-
+-
+-   /**
++    /**
+      * The URL defined in XML-SEC Rec for inclusive c14n <b>without</b> comments.
+      */
+-   public static final String ALGO_ID_C14N_OMIT_COMMENTS = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
+-   /**
+-    * The URL defined in XML-SEC Rec for inclusive c14n <b>with</b> comments.
+-    */
+-   public static final String ALGO_ID_C14N_WITH_COMMENTS = ALGO_ID_C14N_OMIT_COMMENTS + "#WithComments";
+-   /**
+-    * The URL defined in XML-SEC Rec for exclusive c14n <b>without</b> comments.
+-    */
+-   public static final String ALGO_ID_C14N_EXCL_OMIT_COMMENTS = "http://www.w3.org/2001/10/xml-exc-c14n#";
+-   /**
+-    * The URL defined in XML-SEC Rec for exclusive c14n <b>with</b> comments.
+-    */
+-   public static final String ALGO_ID_C14N_EXCL_WITH_COMMENTS = ALGO_ID_C14N_EXCL_OMIT_COMMENTS + "WithComments";
++    public static final String ALGO_ID_C14N_OMIT_COMMENTS =
++        "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
++    /**
++     * The URL defined in XML-SEC Rec for inclusive c14n <b>with</b> comments.
++     */
++    public static final String ALGO_ID_C14N_WITH_COMMENTS =
++        ALGO_ID_C14N_OMIT_COMMENTS + "#WithComments";
++    /**
++     * The URL defined in XML-SEC Rec for exclusive c14n <b>without</b> comments.
++     */
++    public static final String ALGO_ID_C14N_EXCL_OMIT_COMMENTS =
++        "http://www.w3.org/2001/10/xml-exc-c14n#";
++    /**
++     * The URL defined in XML-SEC Rec for exclusive c14n <b>with</b> comments.
++     */
++    public static final String ALGO_ID_C14N_EXCL_WITH_COMMENTS =
++        ALGO_ID_C14N_EXCL_OMIT_COMMENTS + "WithComments";
++    /**
++     * The URI for inclusive c14n 1.1 <b>without</b> comments.
++     */
++    public static final String ALGO_ID_C14N11_OMIT_COMMENTS =
++        "http://www.w3.org/2006/12/xml-c14n11";
++    /**
++     * The URI for inclusive c14n 1.1 <b>with</b> comments.
++     */
++    public static final String ALGO_ID_C14N11_WITH_COMMENTS =
++        ALGO_ID_C14N11_OMIT_COMMENTS + "#WithComments";
+ 
+-   static boolean _alreadyInitialized = false;
+-   static Map _canonicalizerHash = null;
++    static boolean _alreadyInitialized = false;
++    static Map _canonicalizerHash = null;
+ 
+-   protected CanonicalizerSpi canonicalizerSpi = null;
+-   //J+
++    protected CanonicalizerSpi canonicalizerSpi = null;
+ 
+-   /**
+-    * Method init
+-    *
+-    */
+-   public static void init() {
++    /**
++     * Method init
++     *
++     */
++    public static void init() {
+ 
+-      if (!Canonicalizer._alreadyInitialized) {
+-         Canonicalizer._canonicalizerHash = new HashMap(10);
+-         Canonicalizer._alreadyInitialized = true;
+-      }
+-   }
++        if (!Canonicalizer._alreadyInitialized) {
++            Canonicalizer._canonicalizerHash = new HashMap(10);
++            Canonicalizer._alreadyInitialized = true;
++        }
++    }
+ 
+-   /**
+-    * Constructor Canonicalizer
+-    *
+-    * @param algorithmURI
+-    * @throws InvalidCanonicalizerException
+-    */
+-   private Canonicalizer(String algorithmURI)
++    /**
++     * Constructor Canonicalizer
++     *
++     * @param algorithmURI
++     * @throws InvalidCanonicalizerException
++     */
++    private Canonicalizer(String algorithmURI)
+            throws InvalidCanonicalizerException {
+ 
+-      try {
+-         Class implementingClass = getImplementingClass(algorithmURI);
++        try {
++            Class implementingClass = getImplementingClass(algorithmURI);
+ 
+-         this.canonicalizerSpi =
+-            (CanonicalizerSpi) implementingClass.newInstance();
+-         this.canonicalizerSpi.reset=true;
+-      } catch (Exception e) {
+-         Object exArgs[] = { algorithmURI };
++            this.canonicalizerSpi =
++                (CanonicalizerSpi) implementingClass.newInstance();
++            this.canonicalizerSpi.reset=true;
++        } catch (Exception e) {
++            Object exArgs[] = { algorithmURI };
+ 
+-         throw new InvalidCanonicalizerException(
+-            "signature.Canonicalizer.UnknownCanonicalizer", exArgs);
+-      }
+-   }
++            throw new InvalidCanonicalizerException(
++               "signature.Canonicalizer.UnknownCanonicalizer", exArgs);
++        }
++    }
+ 
+-   /**
+-    * Method getInstance
+-    *
+-    * @param algorithmURI
+-    * @return a Conicicalizer instance ready for the job
+-    * @throws InvalidCanonicalizerException
+-    */
+-   public static final Canonicalizer getInstance(String algorithmURI)
++    /**
++     * Method getInstance
++     *
++     * @param algorithmURI
++     * @return a Conicicalizer instance ready for the job
++     * @throws InvalidCanonicalizerException
++     */
++    public static final Canonicalizer getInstance(String algorithmURI)
+            throws InvalidCanonicalizerException {
+ 
+-      Canonicalizer c14nizer = new Canonicalizer(algorithmURI);
++        Canonicalizer c14nizer = new Canonicalizer(algorithmURI);
+ 
+-      return c14nizer;
+-   }
++        return c14nizer;
++    }
+ 
+-   /**
+-    * Method register
+-    *
+-    * @param algorithmURI
+-    * @param implementingClass
+-    * @throws AlgorithmAlreadyRegisteredException
+-    */
+-   public static void register(String algorithmURI, String implementingClass)
++    /**
++     * Method register
++     *
++     * @param algorithmURI
++     * @param implementingClass
++     * @throws AlgorithmAlreadyRegisteredException
++     */
++    public static void register(String algorithmURI, String implementingClass)
+            throws AlgorithmAlreadyRegisteredException {
+ 
+-      // check whether URI is already registered
+-      Class registeredClass = getImplementingClass(algorithmURI);
++        // check whether URI is already registered
++        Class registeredClass = getImplementingClass(algorithmURI);
+ 
+-      if (registeredClass != null)  {
+-         Object exArgs[] = { algorithmURI, registeredClass };
++        if (registeredClass != null)  {
++            Object exArgs[] = { algorithmURI, registeredClass };
+ 
+-         throw new AlgorithmAlreadyRegisteredException(
+-            "algorithm.alreadyRegistered", exArgs);
+-      }
++            throw new AlgorithmAlreadyRegisteredException(
++                "algorithm.alreadyRegistered", exArgs);
++        }
+ 
+-      try {
+-                _canonicalizerHash.put(algorithmURI, Class.forName(implementingClass));
++        try {
++            _canonicalizerHash.put(algorithmURI, Class.forName(implementingClass));
+         } catch (ClassNotFoundException e) {
+-                throw new RuntimeException("c14n class not found");
++            throw new RuntimeException("c14n class not found");
+         }
+-   }
++    }
+ 
+-   /**
+-    * Method getURI
+-    *
+-    * @return the URI defined for this c14n instance.
+-    */
+-   public final String getURI() {
+-      return this.canonicalizerSpi.engineGetURI();
+-   }
++    /**
++     * Method getURI
++     *
++     * @return the URI defined for this c14n instance.
++     */
++    public final String getURI() {
++        return this.canonicalizerSpi.engineGetURI();
++    }
+ 
+-   /**
+-    * Method getIncludeComments
+-    *
+-    * @return true if the c14n respect the comments.
+-    */
+-   public boolean getIncludeComments() {
+-      return this.canonicalizerSpi.engineGetIncludeComments();
+-   }
++    /**
++     * Method getIncludeComments
++     *
++     * @return true if the c14n respect the comments.
++     */
++    public boolean getIncludeComments() {
++        return this.canonicalizerSpi.engineGetIncludeComments();
++    }
+ 
+-   /**
+-    * This method tries to canonicalize the given bytes. It's possible to even
+-    * canonicalize non-wellformed sequences if they are well-formed after being
+-    * wrapped with a <CODE>&gt;a&lt;...&gt;/a&lt;</CODE>.
+-    *
+-    * @param inputBytes
+-    * @return the result of the conicalization.
+-    * @throws CanonicalizationException
+-    * @throws java.io.IOException
+-    * @throws javax.xml.parsers.ParserConfigurationException
+-    * @throws org.xml.sax.SAXException
+-    */
+-   public byte[] canonicalize(byte[] inputBytes)
++    /**
++     * This method tries to canonicalize the given bytes. It's possible to even
++     * canonicalize non-wellformed sequences if they are well-formed after being
++     * wrapped with a <CODE>&gt;a&lt;...&gt;/a&lt;</CODE>.
++     *
++     * @param inputBytes
++     * @return the result of the conicalization.
++     * @throws CanonicalizationException
++     * @throws java.io.IOException
++     * @throws javax.xml.parsers.ParserConfigurationException
++     * @throws org.xml.sax.SAXException
++     */
++    public byte[] canonicalize(byte[] inputBytes)
+            throws javax.xml.parsers.ParserConfigurationException,
+                   java.io.IOException, org.xml.sax.SAXException,
+                   CanonicalizationException {
+ 
+-      ByteArrayInputStream bais = new ByteArrayInputStream(inputBytes);
+-      InputSource in = new InputSource(bais);
+-      DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
++        ByteArrayInputStream bais = new ByteArrayInputStream(inputBytes);
++        InputSource in = new InputSource(bais);
++        DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+ 
+-      dfactory.setNamespaceAware(true);
++        dfactory.setNamespaceAware(true);
+ 
+-      // needs to validate for ID attribute nomalization
+-      dfactory.setValidating(true);
++        // needs to validate for ID attribute nomalization
++        dfactory.setValidating(true);
+ 
+-      DocumentBuilder db = dfactory.newDocumentBuilder();
++        DocumentBuilder db = dfactory.newDocumentBuilder();
+ 
+-      /*
+-       * for some of the test vectors from the specification,
+-       * there has to be a validatin parser for ID attributes, default
+-       * attribute values, NMTOKENS, etc.
+-       * Unfortunaltely, the test vectors do use different DTDs or
+-       * even no DTD. So Xerces 1.3.1 fires many warnings about using
+-       * ErrorHandlers.
+-       *
+-       * Text from the spec:
+-       *
+-       * The input octet stream MUST contain a well-formed XML document,
+-       * but the input need not be validated. However, the attribute
+-       * value normalization and entity reference resolution MUST be
+-       * performed in accordance with the behaviors of a validating
+-       * XML processor. As well, nodes for default attributes (declared
+-       * in the ATTLIST with an AttValue but not specified) are created
+-       * in each element. Thus, the declarations in the document type
+-       * declaration are used to help create the canonical form, even
+-       * though the document type declaration is not retained in the
+-       * canonical form.
+-       *
+-       */
+-      db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils
+-         .IgnoreAllErrorHandler());
++        /*
++         * for some of the test vectors from the specification,
++         * there has to be a validatin parser for ID attributes, default
++         * attribute values, NMTOKENS, etc.
++         * Unfortunaltely, the test vectors do use different DTDs or
++         * even no DTD. So Xerces 1.3.1 fires many warnings about using
++         * ErrorHandlers.
++         *
++         * Text from the spec:
++         *
++         * The input octet stream MUST contain a well-formed XML document,
++         * but the input need not be validated. However, the attribute
++         * value normalization and entity reference resolution MUST be
++         * performed in accordance with the behaviors of a validating
++         * XML processor. As well, nodes for default attributes (declared
++         * in the ATTLIST with an AttValue but not specified) are created
++         * in each element. Thus, the declarations in the document type
++         * declaration are used to help create the canonical form, even
++         * though the document type declaration is not retained in the
++         * canonical form.
++         *
++         */
++        db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils
++            .IgnoreAllErrorHandler());
+ 
+-      Document document = db.parse(in);
+-      byte result[] = this.canonicalizeSubtree(document);
++        Document document = db.parse(in);
++        byte result[] = this.canonicalizeSubtree(document);
+ 
+-      return result;
+-   }
++        return result;
++    }
+ 
+-   /**
+-    * Canonicalizes the subtree rooted by <CODE>node</CODE>.
+-    *
+-    * @param node The node to canicalize
+-    * @return the result of the c14n.
+-    *
+-    * @throws CanonicalizationException
+-    */
+-   public byte[] canonicalizeSubtree(Node node)
++    /**
++     * Canonicalizes the subtree rooted by <CODE>node</CODE>.
++     *
++     * @param node The node to canicalize
++     * @return the result of the c14n.
++     *
++     * @throws CanonicalizationException
++     */
++    public byte[] canonicalizeSubtree(Node node)
+            throws CanonicalizationException {
+-      return this.canonicalizerSpi.engineCanonicalizeSubTree(node);
+-   }
++        return this.canonicalizerSpi.engineCanonicalizeSubTree(node);
++    }
+ 
+-   /**
+-    * Canonicalizes the subtree rooted by <CODE>node</CODE>.
+-    *
+-    * @param node
+-    * @param inclusiveNamespaces
+-    * @return the result of the c14n.
+-    * @throws CanonicalizationException
+-    */
+-   public byte[] canonicalizeSubtree(Node node, String inclusiveNamespaces)
++    /**
++     * Canonicalizes the subtree rooted by <CODE>node</CODE>.
++     *
++     * @param node
++     * @param inclusiveNamespaces
++     * @return the result of the c14n.
++     * @throws CanonicalizationException
++     */
++    public byte[] canonicalizeSubtree(Node node, String inclusiveNamespaces)
+            throws CanonicalizationException {
+-      return this.canonicalizerSpi.engineCanonicalizeSubTree(node,
++        return this.canonicalizerSpi.engineCanonicalizeSubTree(node,
+               inclusiveNamespaces);
+-   }
++    }
+ 
+-   /**
+-    * Canonicalizes an XPath node set. The <CODE>xpathNodeSet</CODE> is treated
+-    * as a list of XPath nodes, not as a list of subtrees.
+-    *
+-    * @param xpathNodeSet
+-    * @return the result of the c14n.
+-    * @throws CanonicalizationException
+-    */
+-   public byte[] canonicalizeXPathNodeSet(NodeList xpathNodeSet)
++    /**
++     * Canonicalizes an XPath node set. The <CODE>xpathNodeSet</CODE> is treated
++     * as a list of XPath nodes, not as a list of subtrees.
++     *
++     * @param xpathNodeSet
++     * @return the result of the c14n.
++     * @throws CanonicalizationException
++     */
++    public byte[] canonicalizeXPathNodeSet(NodeList xpathNodeSet)
+            throws CanonicalizationException {
+-      return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
+-   }
++        return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
++    }
+ 
+-   /**
+-    * Canonicalizes an XPath node set. The <CODE>xpathNodeSet</CODE> is treated
+-    * as a list of XPath nodes, not as a list of subtrees.
+-    *
+-    * @param xpathNodeSet
+-    * @param inclusiveNamespaces
+-    * @return the result of the c14n.
+-    * @throws CanonicalizationException
+-    */
+-   public byte[] canonicalizeXPathNodeSet(
++    /**
++     * Canonicalizes an XPath node set. The <CODE>xpathNodeSet</CODE> is treated
++     * as a list of XPath nodes, not as a list of subtrees.
++     *
++     * @param xpathNodeSet
++     * @param inclusiveNamespaces
++     * @return the result of the c14n.
++     * @throws CanonicalizationException
++     */
++    public byte[] canonicalizeXPathNodeSet(
+            NodeList xpathNodeSet, String inclusiveNamespaces)
+               throws CanonicalizationException {
+-      return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
++        return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
+               inclusiveNamespaces);
+-   }
++    }
+ 
+-   /**
+-    * Canonicalizes an XPath node set.
+-    *
+-    * @param xpathNodeSet
+-    * @return the result of the c14n.
+-    * @throws CanonicalizationException
+-    */
+-   public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet)
++    /**
++     * Canonicalizes an XPath node set.
++     *
++     * @param xpathNodeSet
++     * @return the result of the c14n.
++     * @throws CanonicalizationException
++     */
++    public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet)
+            throws CanonicalizationException {
+-       return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
+-   }
++        return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
++    }
+ 
+-   /**
+-    * Canonicalizes an XPath node set.
+-    *
+-    * @param xpathNodeSet
+-    * @param inclusiveNamespaces
+-    * @return the result of the c14n.
+-    * @throws CanonicalizationException
+-    */
+-   public byte[] canonicalizeXPathNodeSet(
+-           Set xpathNodeSet, String inclusiveNamespaces)
+-              throws CanonicalizationException {
+-       return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
+-              inclusiveNamespaces);
+-   }
++    /**
++     * Canonicalizes an XPath node set.
++     *
++     * @param xpathNodeSet
++     * @param inclusiveNamespaces
++     * @return the result of the c14n.
++     * @throws CanonicalizationException
++     */
++    public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet,
++        String inclusiveNamespaces) throws CanonicalizationException {
++        return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
++            inclusiveNamespaces);
++    }
+ 
+-   /**
+-    * Sets the writter where the cannocalization ends. ByteArrayOutputStream if
+-    * none is setted.
+-    * @param os
+-    */
+-   public void setWriter(OutputStream os) {
+-            this.canonicalizerSpi.setWriter(os);
+-   }
++    /**
++     * Sets the writer where the canonicalization ends.  ByteArrayOutputStream
++     * if none is set.
++     * @param os
++     */
++    public void setWriter(OutputStream os) {
++        this.canonicalizerSpi.setWriter(os);
++    }
+ 
+-   /**
+-    * Returns the name of the implementing {@link CanonicalizerSpi} class
+-    *
+-    * @return the name of the implementing {@link CanonicalizerSpi} class
+-    */
+-   public String getImplementingCanonicalizerClass() {
+-      return this.canonicalizerSpi.getClass().getName();
+-   }
++    /**
++     * Returns the name of the implementing {@link CanonicalizerSpi} class
++     *
++     * @return the name of the implementing {@link CanonicalizerSpi} class
++     */
++    public String getImplementingCanonicalizerClass() {
++        return this.canonicalizerSpi.getClass().getName();
++    }
+ 
+-   /**
+-    * Method getImplementingClass
+-    *
+-    * @param URI
+-    * @return the name of the class that implements the give URI
+-    */
+-   private static Class getImplementingClass(String URI) {
+-      return (Class) _canonicalizerHash.get(URI);
+-   }
++    /**
++     * Method getImplementingClass
++     *
++     * @param URI
++     * @return the name of the class that implements the given URI
++     */
++    private static Class getImplementingClass(String URI) {
++        return (Class) _canonicalizerHash.get(URI);
++    }
+ 
+-   /**
+-    * Set the canonicalizator behaviour to not reset.
+-    *
+-    */
+-   public void notReset() {
+-            this.canonicalizerSpi.reset=false;
+-   }
++    /**
++     * Set the canonicalizer behaviour to not reset.
++     */
++    public void notReset() {
++        this.canonicalizerSpi.reset = false;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/InvalidCanonicalizerException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/InvalidCanonicalizerException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/InvalidCanonicalizerException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/InvalidCanonicalizerException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/helper/AttrCompare.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -21,17 +20,17 @@
+  */
+ package com.sun.org.apache.xml.internal.security.c14n.helper;
+ 
+-
+-
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import org.w3c.dom.Attr;
+-
++import java.io.Serializable;
++import java.util.Comparator;
+ 
+ /**
+  * Compares two attributes based on the C14n specification.
+  *
+  * <UL>
+- * <LI>Namespace nodes have a lesser document order position than attribute nodes.
++ * <LI>Namespace nodes have a lesser document order position than attribute
++ *   nodes.
+  * <LI> An element's namespace nodes are sorted lexicographically by
+  *   local name (the default namespace node, if one exists, has no
+  *   local name and is therefore lexicographically least).
+@@ -40,104 +39,89 @@
+  *   key (an empty namespace URI is lexicographically least).
+  * </UL>
+  *
+- * $todo$ Should we implement java.util.Comparator and import java.util.Arrays to use Arrays.sort(intarray);
+  * @author Christian Geuer-Pollmann
+  */
+-public class AttrCompare implements java.util.Comparator {
++public class AttrCompare implements Comparator, Serializable {
+ 
+-   private final int ATTR0_BEFORE_ATTR1 = -1;
+-   private final int ATTR1_BEFORE_ATTR0 = 1;
++    private final static long serialVersionUID = -7113259629930576230L;
++    private final static int ATTR0_BEFORE_ATTR1 = -1;
++    private final static int ATTR1_BEFORE_ATTR0 = 1;
++    private final static String XMLNS=Constants.NamespaceSpecNS;
+ 
+-   private final static String XMLNS=Constants.NamespaceSpecNS;
+-   /**
+-    * Compares two attributes based on the C14n specification.
+-    *
+-    * <UL>
+-    * <LI>Namespace nodes have a lesser document order position than attribute nodes.
+-    * <LI> An element's namespace nodes are sorted lexicographically by
+-    *   local name (the default namespace node, if one exists, has no
+-    *   local name and is therefore lexicographically least).
+-    * <LI> An element's attribute nodes are sorted lexicographically with
+-    *   namespace URI as the primary key and local name as the secondary
+-    *   key (an empty namespace URI is lexicographically least).
+-    * </UL>
+-    *
+-    * @param obj0 casted Attr
+-    * @param obj1 casted Attr
+-    * @return returns a negative integer, zero, or a positive integer as obj0 is less than, equal to, or greater than obj1
+-    *
+-    */
+-   public int compare(Object obj0, Object obj1) {
++    /**
++     * Compares two attributes based on the C14n specification.
++     *
++     * <UL>
++     * <LI>Namespace nodes have a lesser document order position than
++     *   attribute nodes.
++     * <LI> An element's namespace nodes are sorted lexicographically by
++     *   local name (the default namespace node, if one exists, has no
++     *   local name and is therefore lexicographically least).
++     * <LI> An element's attribute nodes are sorted lexicographically with
++     *   namespace URI as the primary key and local name as the secondary
++     *   key (an empty namespace URI is lexicographically least).
++     * </UL>
++     *
++     * @param obj0 casted Attr
++     * @param obj1 casted Attr
++     * @return returns a negative integer, zero, or a positive integer as
++     *   obj0 is less than, equal to, or greater than obj1
++     *
++     */
++    public int compare(Object obj0, Object obj1) {
+ 
+-      Attr attr0 = (Attr) obj0;
+-      Attr attr1 = (Attr) obj1;
+-      String namespaceURI0 = attr0.getNamespaceURI();
+-      String namespaceURI1 = attr1.getNamespaceURI();
++        Attr attr0 = (Attr) obj0;
++        Attr attr1 = (Attr) obj1;
++        String namespaceURI0 = attr0.getNamespaceURI();
++        String namespaceURI1 = attr1.getNamespaceURI();
+ 
+-      boolean isNamespaceAttr0 =
+-        XMLNS.equals(namespaceURI0);
+-      boolean isNamespaceAttr1 =
+-        XMLNS.equals(namespaceURI1);
++        boolean isNamespaceAttr0 = XMLNS==namespaceURI0;
++        boolean isNamespaceAttr1 = XMLNS==namespaceURI1;
+ 
+-      if (isNamespaceAttr0) {
+-         if (isNamespaceAttr1) {
++        if (isNamespaceAttr0) {
++            if (isNamespaceAttr1) {
++                // both are namespaces
++                String localname0 = attr0.getLocalName();
++                String localname1 = attr1.getLocalName();
+ 
+-            // both are namespaces
+-            String localname0 = attr0.getLocalName();
+-            String localname1 = attr1.getLocalName();
++                if (localname0.equals("xmlns")) {
++                    localname0 = "";
++                }
+ 
+-            if (localname0.equals("xmlns")) {
+-               localname0 = "";
++                if (localname1.equals("xmlns")) {
++                    localname1 = "";
++                }
++
++                return localname0.compareTo(localname1);
+             }
++            // attr0 is a namespace, attr1 is not
++            return ATTR0_BEFORE_ATTR1;
++        }
+ 
+-            if (localname1.equals("xmlns")) {
+-               localname1 = "";
+-            }
+-
+-            return localname0.compareTo(localname1);
+-         }
+-         // attr0 is a namespace, attr1 is not
+-         return ATTR0_BEFORE_ATTR1;
+-
+-      }
+-      if (isNamespaceAttr1) {
+-
++        if (isNamespaceAttr1) {
+             // attr1 is a namespace, attr0 is not
+             return ATTR1_BEFORE_ATTR0;
+-      }
++        }
+ 
+-      // none is a namespae
+-
+-      if (namespaceURI0 == null) {
+-        if (namespaceURI1 == null) {
+-                /*
+-                 String localName0 = attr0.getLocalName();
+-                 String localName1 = attr1.getLocalName();
+-                 return localName0.compareTo(localName1);
+-                 */
+-
++        // none is a namespace
++        if (namespaceURI0 == null) {
++            if (namespaceURI1 == null) {
+                 String name0 = attr0.getName();
+                 String name1 = attr1.getName();
+                 return name0.compareTo(name1);
++            }
++            return ATTR0_BEFORE_ATTR1;
+         }
+-        return ATTR0_BEFORE_ATTR1;
+ 
+-      }
+-      if (namespaceURI1 == null) {
+-                return ATTR1_BEFORE_ATTR0;
+-      }
+-      int a = namespaceURI0.compareTo(namespaceURI1);
++        if (namespaceURI1 == null) {
++            return ATTR1_BEFORE_ATTR0;
++        }
+ 
+-      if (a != 0) {
+-        return a;
+-      }
+-      /*
+-      String localName0 = ;
+-      String localName1 =;*/
++        int a = namespaceURI0.compareTo(namespaceURI1);
++        if (a != 0) {
++            return a;
++        }
+ 
+-      return (attr0.getLocalName())
+-                                .compareTo( attr1.getLocalName());
+-
+-   }
+-
++        return (attr0.getLocalName()).compareTo(attr1.getLocalName());
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11.java
+@@ -0,0 +1,684 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2008 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.
++ *
++ */
++package com.sun.org.apache.xml.internal.security.c14n.implementations;
++
++import java.io.IOException;
++import java.net.URI;
++import java.net.URISyntaxException;
++import java.util.ArrayList;
++import java.util.Collection;
++import java.util.HashMap;
++import java.util.Iterator;
++import java.util.List;
++import java.util.Map;
++import java.util.Set;
++import java.util.SortedSet;
++import java.util.TreeSet;
++import javax.xml.parsers.ParserConfigurationException;
++import org.w3c.dom.Attr;
++import org.w3c.dom.Document;
++import org.w3c.dom.Element;
++import org.w3c.dom.NamedNodeMap;
++import org.w3c.dom.Node;
++import org.xml.sax.SAXException;
++
++import java.util.logging.Logger;
++import java.util.logging.Logger;
++import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
++import com.sun.org.apache.xml.internal.security.c14n.helper.C14nHelper;
++import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.utils.Constants;
++import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
++
++/**
++ * Implements <A HREF="http://www.w3.org/TR/2008/PR-xml-c14n11-20080129/">
++ * Canonical XML Version 1.1</A>, a W3C Proposed Recommendation from 29
++ * January 2008.
++ *
++ * @author Sean Mullan
++ * @author Raul Benito
++ * @version $Revision: 1.2 $
++ */
++public abstract class Canonicalizer11 extends CanonicalizerBase {
++    boolean firstCall = true;
++    final SortedSet result = new TreeSet(COMPARE);
++    static final String XMLNS_URI = Constants.NamespaceSpecNS;
++    static final String XML_LANG_URI = Constants.XML_LANG_SPACE_SpecNS;
++
++    static Logger log = Logger.getLogger(Canonicalizer11.class.getName());
++
++    static class XmlAttrStack {
++        int currentLevel = 0;
++        int lastlevel = 0;
++        XmlsStackElement cur;
++        static class XmlsStackElement {
++            int level;
++            boolean rendered = false;
++            List nodes = new ArrayList();
++        };
++        List levels = new ArrayList();
++        void push(int level) {
++            currentLevel = level;
++            if (currentLevel == -1)
++                return;
++            cur = null;
++            while (lastlevel >= currentLevel) {
++                levels.remove(levels.size() - 1);
++                if (levels.size() == 0) {
++                    lastlevel = 0;
++                    return;
++                }
++                lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level;
++            }
++        }
++        void addXmlnsAttr(Attr n) {
++            if (cur == null) {
++                cur = new XmlsStackElement();
++                cur.level = currentLevel;
++                levels.add(cur);
++                lastlevel = currentLevel;
++            }
++            cur.nodes.add(n);
++        }
++        void getXmlnsAttr(Collection col) {
++            if (cur == null) {
++                cur = new XmlsStackElement();
++                cur.level = currentLevel;
++                lastlevel = currentLevel;
++                levels.add(cur);
++            }
++            int size = levels.size() - 2;
++            boolean parentRendered = false;
++            XmlsStackElement e = null;
++            if (size == -1) {
++                parentRendered = true;
++            } else {
++                e = (XmlsStackElement) levels.get(size);
++                if (e.rendered && e.level+1 == currentLevel)
++                    parentRendered = true;
++            }
++            if (parentRendered) {
++                col.addAll(cur.nodes);
++                cur.rendered = true;
++                return;
++            }
++
++            Map loa = new HashMap();
++            List baseAttrs = new ArrayList();
++            boolean successiveOmitted = true;
++            for (;size>=0;size--) {
++                e = (XmlsStackElement) levels.get(size);
++                if (e.rendered) {
++                    successiveOmitted = false;
++                }
++                Iterator it = e.nodes.iterator();
++                while (it.hasNext() && successiveOmitted) {
++                    Attr n = (Attr) it.next();
++                    if (n.getLocalName().equals("base")) {
++                        if (!e.rendered) {
++                            baseAttrs.add(n);
++                        }
++                    } else if (!loa.containsKey(n.getName()))
++                        loa.put(n.getName(), n);
++                }
++            }
++            if (!baseAttrs.isEmpty()) {
++                Iterator it = cur.nodes.iterator();
++                String base = null;
++                Attr baseAttr = null;
++                while (it.hasNext()) {
++                    Attr n = (Attr) it.next();
++                    if (n.getLocalName().equals("base")) {
++                        base = n.getValue();
++                        baseAttr = n;
++                        break;
++                    }
++                }
++                it = baseAttrs.iterator();
++                while (it.hasNext()) {
++                    Attr n = (Attr) it.next();
++                    if (base == null) {
++                        base = n.getValue();
++                        baseAttr = n;
++                    } else {
++                        try {
++                            base = joinURI(n.getValue(), base);
++                        } catch (URISyntaxException ue) {
++                            ue.printStackTrace();
++                        }
++                    }
++                }
++                if (base != null && base.length() != 0) {
++                    baseAttr.setValue(base);
++                    col.add(baseAttr);
++                }
++            }
++
++            cur.rendered = true;
++            col.addAll(loa.values());
++        }
++    };
++    XmlAttrStack xmlattrStack = new XmlAttrStack();
++
++    /**
++     * Constructor Canonicalizer11
++     *
++     * @param includeComments
++     */
++    public Canonicalizer11(boolean includeComments) {
++        super(includeComments);
++    }
++
++    /**
++     * Returns the Attr[]s to be outputted for the given element.
++     * <br>
++     * The code of this method is a copy of {@link #handleAttributes(Element,
++     * NameSpaceSymbTable)},
++     * whereas it takes into account that subtree-c14n is -- well --
++     * subtree-based.
++     * So if the element in question isRoot of c14n, it's parent is not in the
++     * node set, as well as all other ancestors.
++     *
++     * @param E
++     * @param ns
++     * @return the Attr[]s to be outputted
++     * @throws CanonicalizationException
++     */
++    Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
++        throws CanonicalizationException {
++        if (!E.hasAttributes() && !firstCall) {
++            return null;
++        }
++        // result will contain the attrs which have to be outputted
++        final SortedSet result = this.result;
++        result.clear();
++        NamedNodeMap attrs = E.getAttributes();
++        int attrsLength = attrs.getLength();
++
++        for (int i = 0; i < attrsLength; i++) {
++            Attr N = (Attr) attrs.item(i);
++            String NUri = N.getNamespaceURI();
++
++            if (XMLNS_URI != NUri) {
++                // It's not a namespace attr node. Add to the result and
++                // continue.
++                result.add(N);
++                continue;
++            }
++
++            String NName = N.getLocalName();
++            String NValue = N.getValue();
++            if (XML.equals(NName)
++                && XML_LANG_URI.equals(NValue)) {
++                // The default mapping for xml must not be output.
++                continue;
++            }
++
++            Node n = ns.addMappingAndRender(NName, NValue, N);
++
++            if (n != null) {
++                // Render the ns definition
++                result.add(n);
++                if (C14nHelper.namespaceIsRelative(N)) {
++                    Object exArgs[] = {E.getTagName(), NName, N.getNodeValue()};
++                    throw new CanonicalizationException(
++                        "c14n.Canonicalizer.RelativeNamespace", exArgs);
++                }
++            }
++        }
++
++        if (firstCall) {
++            // It is the first node of the subtree
++            // Obtain all the namespaces defined in the parents, and added
++            // to the output.
++            ns.getUnrenderedNodes(result);
++            // output the attributes in the xml namespace.
++            xmlattrStack.getXmlnsAttr(result);
++            firstCall = false;
++        }
++
++        return result.iterator();
++    }
++
++    /**
++     * Returns the Attr[]s to be outputted for the given element.
++     * <br>
++     * IMPORTANT: This method expects to work on a modified DOM tree, i.e. a
++     * DOM which has been prepared using
++     * {@link com.sun.org.apache.xml.internal.security.utils.XMLUtils#circumventBug2650(
++     * org.w3c.dom.Document)}.
++     *
++     * @param E
++     * @param ns
++     * @return the Attr[]s to be outputted
++     * @throws CanonicalizationException
++     */
++    Iterator handleAttributes(Element E, NameSpaceSymbTable ns)
++        throws CanonicalizationException {
++        // result will contain the attrs which have to be output
++        xmlattrStack.push(ns.getLevel());
++        boolean isRealVisible = isVisibleDO(E, ns.getLevel()) == 1;
++        NamedNodeMap attrs = null;
++        int attrsLength = 0;
++        if (E.hasAttributes()) {
++            attrs = E.getAttributes();
++            attrsLength = attrs.getLength();
++        }
++
++        SortedSet result = this.result;
++        result.clear();
++
++        for (int i = 0; i < attrsLength; i++) {
++            Attr N = (Attr) attrs.item(i);
++            String NUri = N.getNamespaceURI();
++
++            if (XMLNS_URI != NUri) {
++                // A non namespace definition node.
++                if (XML_LANG_URI == NUri) {
++                    if (N.getLocalName().equals("id")) {
++                        if (isRealVisible) {
++                            // treat xml:id like any other attribute
++                            // (emit it, but don't inherit it)
++                            result.add(N);
++                        }
++                    } else {
++                        xmlattrStack.addXmlnsAttr(N);
++                    }
++                } else if (isRealVisible) {
++                    // The node is visible add the attribute to the list of
++                    // output attributes.
++                    result.add(N);
++                }
++                // keep working
++                continue;
++            }
++
++            String NName = N.getLocalName();
++            String NValue = N.getValue();
++            if ("xml".equals(NName)
++                && XML_LANG_URI.equals(NValue)) {
++                /* except omit namespace node with local name xml, which defines
++                 * the xml prefix, if its string value is
++                 * http://www.w3.org/XML/1998/namespace.
++                 */
++                continue;
++            }
++            // add the prefix binding to the ns symb table.
++            // ns.addInclusiveMapping(NName,NValue,N,isRealVisible);
++            if (isVisible(N))  {
++                if (!isRealVisible && ns.removeMappingIfRender(NName)) {
++                    continue;
++                }
++                // The xpath select this node output it if needed.
++                // Node n = ns.addMappingAndRenderXNodeSet
++                //      (NName, NValue, N, isRealVisible);
++                Node n = ns.addMappingAndRender(NName, NValue, N);
++                if (n != null) {
++                    result.add(n);
++                    if (C14nHelper.namespaceIsRelative(N)) {
++                        Object exArgs[] =
++                            { E.getTagName(), NName, N.getNodeValue() };
++                        throw new CanonicalizationException(
++                            "c14n.Canonicalizer.RelativeNamespace", exArgs);
++                    }
++                }
++            } else {
++                if (isRealVisible && NName != XMLNS) {
++                    ns.removeMapping(NName);
++                } else {
++                    ns.addMapping(NName, NValue, N);
++                }
++            }
++        }
++        if (isRealVisible) {
++            // The element is visible, handle the xmlns definition
++            Attr xmlns = E.getAttributeNodeNS(XMLNS_URI, XMLNS);
++            Node n = null;
++            if (xmlns == null) {
++                // No xmlns def just get the already defined.
++                n = ns.getMapping(XMLNS);
++            } else if (!isVisible(xmlns)) {
++                // There is a defn but the xmlns is not selected by the xpath.
++                // then xmlns=""
++                n = ns.addMappingAndRender(XMLNS, "", nullNode);
++            }
++            // output the xmlns def if needed.
++            if (n != null) {
++                result.add(n);
++            }
++            // Float all xml:* attributes of the unselected parent elements to
++            // this one. addXmlAttributes(E,result);
++            xmlattrStack.getXmlnsAttr(result);
++            ns.getUnrenderedNodes(result);
++        }
++
++        return result.iterator();
++    }
++
++    /**
++     * Always throws a CanonicalizationException because this is inclusive c14n.
++     *
++     * @param xpathNodeSet
++     * @param inclusiveNamespaces
++     * @return none it always fails
++     * @throws CanonicalizationException always
++     */
++    public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet,
++        String inclusiveNamespaces) throws CanonicalizationException {
++        throw new CanonicalizationException(
++         "c14n.Canonicalizer.UnsupportedOperation");
++    }
++
++    /**
++     * Always throws a CanonicalizationException because this is inclusive c14n.
++     *
++     * @param rootNode
++     * @param inclusiveNamespaces
++     * @return none it always fails
++     * @throws CanonicalizationException
++     */
++    public byte[] engineCanonicalizeSubTree(Node rootNode,
++        String inclusiveNamespaces) throws CanonicalizationException {
++        throw new CanonicalizationException(
++            "c14n.Canonicalizer.UnsupportedOperation");
++    }
++
++    void circumventBugIfNeeded(XMLSignatureInput input)
++        throws CanonicalizationException, ParserConfigurationException,
++        IOException, SAXException {
++        if (!input.isNeedsToBeExpanded())
++            return;
++        Document doc = null;
++        if (input.getSubNode() != null) {
++            doc = XMLUtils.getOwnerDocument(input.getSubNode());
++        } else {
++            doc = XMLUtils.getOwnerDocument(input.getNodeSet());
++        }
++        XMLUtils.circumventBug2650(doc);
++    }
++
++    void handleParent(Element e, NameSpaceSymbTable ns) {
++        if (!e.hasAttributes()) {
++            return;
++        }
++        xmlattrStack.push(-1);
++        NamedNodeMap attrs = e.getAttributes();
++        int attrsLength = attrs.getLength();
++        for (int i = 0; i < attrsLength; i++) {
++            Attr N = (Attr) attrs.item(i);
++            if (Constants.NamespaceSpecNS != N.getNamespaceURI()) {
++                // Not a namespace definition, ignore.
++                if (XML_LANG_URI == N.getNamespaceURI()) {
++                    xmlattrStack.addXmlnsAttr(N);
++                }
++                continue;
++            }
++
++            String NName = N.getLocalName();
++            String NValue = N.getNodeValue();
++            if (XML.equals(NName)
++                && Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
++                continue;
++            }
++            ns.addMapping(NName,NValue,N);
++        }
++    }
++
++    private static String joinURI(String baseURI, String relativeURI)
++        throws URISyntaxException {
++        String bscheme = null;
++        String bauthority = null;
++        String bpath = "";
++        String bquery = null;
++        String bfragment = null; // Is this correct?
++
++        // pre-parse the baseURI
++        if (baseURI != null) {
++            if (baseURI.endsWith("..")) {
++                baseURI = baseURI + "/";
++            }
++            URI base = new URI(baseURI);
++            bscheme = base.getScheme();
++            bauthority = base.getAuthority();
++            bpath = base.getPath();
++            bquery = base.getQuery();
++            bfragment = base.getFragment();
++        }
++
++        URI r = new URI(relativeURI);
++        String rscheme = r.getScheme();
++        String rauthority = r.getAuthority();
++        String rpath = r.getPath();
++        String rquery = r.getQuery();
++        String rfragment = null;
++
++        String tscheme, tauthority, tpath, tquery, tfragment;
++        if (rscheme != null && rscheme.equals(bscheme)) {
++            rscheme = null;
++        }
++        if (rscheme != null) {
++            tscheme = rscheme;
++            tauthority = rauthority;
++            tpath = removeDotSegments(rpath);
++            tquery = rquery;
++        } else {
++            if (rauthority != null) {
++                tauthority = rauthority;
++                tpath = removeDotSegments(rpath);
++                tquery = rquery;
++            } else {
++                if (rpath.length() == 0) {
++                    tpath = bpath;
++                    if (rquery != null) {
++                        tquery = rquery;
++                    } else {
++                        tquery = bquery;
++                    }
++                } else {
++                    if (rpath.startsWith("/")) {
++                        tpath = removeDotSegments(rpath);
++                    } else {
++                        if (bauthority != null && bpath.length() == 0) {
++                            tpath = "/" + rpath;
++                        } else {
++                            int last = bpath.lastIndexOf('/');
++                            if (last == -1) {
++                                tpath = rpath;
++                            } else {
++                                tpath = bpath.substring(0, last+1) + rpath;
++                            }
++                        }
++                        tpath = removeDotSegments(tpath);
++                    }
++                    tquery = rquery;
++                }
++                tauthority = bauthority;
++            }
++            tscheme = bscheme;
++        }
++        tfragment = rfragment;
++        return new URI(tscheme, tauthority, tpath, tquery, tfragment).toString();
++    }
++
++    private static String removeDotSegments(String path) {
++
++        log.log(java.util.logging.Level.FINE, "STEP   OUTPUT BUFFER\t\tINPUT BUFFER");
++
++        // 1. The input buffer is initialized with the now-appended path
++        // components then replace occurrences of "//" in the input buffer
++        // with "/" until no more occurrences of "//" are in the input buffer.
++        String input = path;
++        while (input.indexOf("//") > -1) {
++            input = input.replaceAll("//", "/");
++        }
++
++        // Initialize the output buffer with the empty string.
++        StringBuffer output = new StringBuffer();
++
++        // If the input buffer starts with a root slash "/" then move this
++        // character to the output buffer.
++        if (input.charAt(0) == '/') {
++            output.append("/");
++            input = input.substring(1);
++        }
++
++        printStep("1 ", output.toString(), input);
++
++        // While the input buffer is not empty, loop as follows
++        while (input.length() != 0) {
++            // 2A. If the input buffer begins with a prefix of "./",
++            // then remove that prefix from the input buffer
++            // else if the input buffer begins with a prefix of "../", then
++            // if also the output does not contain the root slash "/" only,
++            // then move this prefix to the end of the output buffer else
++            // remove that prefix
++            if (input.startsWith("./")) {
++                input = input.substring(2);
++                printStep("2A", output.toString(), input);
++            } else if (input.startsWith("../")) {
++                input = input.substring(3);
++                if (!output.toString().equals("/")) {
++                    output.append("../");
++                }
++                printStep("2A", output.toString(), input);
++            // 2B. if the input buffer begins with a prefix of "/./" or "/.",
++            // where "." is a complete path segment, then replace that prefix
++            // with "/" in the input buffer; otherwise,
++            } else if (input.startsWith("/./")) {
++                input = input.substring(2);
++                printStep("2B", output.toString(), input);
++            } else if (input.equals("/.")) {
++                // FIXME: what is complete path segment?
++                input = input.replaceFirst("/.", "/");
++                printStep("2B", output.toString(), input);
++            // 2C. if the input buffer begins with a prefix of "/../" or "/..",
++            // where ".." is a complete path segment, then replace that prefix
++            // with "/" in the input buffer and if also the output buffer is
++            // empty, last segment in the output buffer equals "../" or "..",
++            // where ".." is a complete path segment, then append ".." or "/.."
++            // for the latter case respectively to the output buffer else
++            // remove the last segment and its preceding "/" (if any) from the
++            // output buffer and if hereby the first character in the output
++            // buffer was removed and it was not the root slash then delete a
++            // leading slash from the input buffer; otherwise,
++            } else if (input.startsWith("/../")) {
++                input = input.substring(3);
++                if (output.length() == 0) {
++                    output.append("/");
++                } else if (output.toString().endsWith("../")) {
++                    output.append("..");
++                } else if (output.toString().endsWith("..")) {
++                    output.append("/..");
++                } else {
++                    int index = output.lastIndexOf("/");
++                    if (index == -1) {
++                        output = new StringBuffer();
++                        if (input.charAt(0) == '/') {
++                            input = input.substring(1);
++                        }
++                    } else {
++                        output = output.delete(index, output.length());
++                    }
++                }
++                printStep("2C", output.toString(), input);
++            } else if (input.equals("/..")) {
++                // FIXME: what is complete path segment?
++                input = input.replaceFirst("/..", "/");
++                if (output.length() == 0) {
++                    output.append("/");
++                } else if (output.toString().endsWith("../")) {
++                    output.append("..");
++                } else if (output.toString().endsWith("..")) {
++                    output.append("/..");
++                } else {
++                    int index = output.lastIndexOf("/");
++                    if (index == -1) {
++                        output = new StringBuffer();
++                        if (input.charAt(0) == '/') {
++                            input = input.substring(1);
++                        }
++                    } else {
++                        output = output.delete(index, output.length());
++                    }
++                }
++                printStep("2C", output.toString(), input);
++            // 2D. if the input buffer consists only of ".", then remove
++            // that from the input buffer else if the input buffer consists
++            // only of ".." and if the output buffer does not contain only
++            // the root slash "/", then move the ".." to the output buffer
++            // else delte it.; otherwise,
++            } else if (input.equals(".")) {
++                input = "";
++                printStep("2D", output.toString(), input);
++            } else if (input.equals("..")) {
++                if (!output.toString().equals("/"))
++                    output.append("..");
++                input = "";
++                printStep("2D", output.toString(), input);
++            // 2E. move the first path segment (if any) in the input buffer
++            // to the end of the output buffer, including the initial "/"
++            // character (if any) and any subsequent characters up to, but not
++            // including, the next "/" character or the end of the input buffer.
++            } else {
++                int end = -1;
++                int begin = input.indexOf('/');
++                if (begin == 0) {
++                    end = input.indexOf('/', 1);
++                } else {
++                    end = begin;
++                    begin = 0;
++                }
++                String segment;
++                if (end == -1) {
++                    segment = input.substring(begin);
++                    input = "";
++                } else {
++                    segment = input.substring(begin, end);
++                    input = input.substring(end);
++                }
++                output.append(segment);
++                printStep("2E", output.toString(), input);
++            }
++        }
++
++        // 3. Finally, if the only or last segment of the output buffer is
++        // "..", where ".." is a complete path segment not followed by a slash
++        // then append a slash "/". The output buffer is returned as the result
++        // of remove_dot_segments
++        if (output.toString().endsWith("..")) {
++            output.append("/");
++            printStep("3 ", output.toString(), input);
++        }
++
++        return output.toString();
++    }
++
++    private static void printStep(String step, String output, String input) {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, " " + step + ":   " + output);
++            if (output.length() == 0) {
++                log.log(java.util.logging.Level.FINE, "\t\t\t\t" + input);
++            } else {
++                log.log(java.util.logging.Level.FINE, "\t\t\t" + input);
++            }
++        }
++    }
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_OmitComments.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_OmitComments.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_OmitComments.java
+@@ -0,0 +1,41 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2008 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.
++ *
++ */
++package com.sun.org.apache.xml.internal.security.c14n.implementations;
++
++import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
++
++/**
++ * @author Sean Mullan
++ */
++public class Canonicalizer11_OmitComments extends Canonicalizer11 {
++
++    public Canonicalizer11_OmitComments() {
++        super(false);
++    }
++
++    public final String engineGetURI() {
++        return Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
++    }
++
++    public final boolean engineGetIncludeComments() {
++        return false;
++    }
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_WithComments.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_WithComments.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer11_WithComments.java
+@@ -0,0 +1,41 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2008 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.
++ *
++ */
++package com.sun.org.apache.xml.internal.security.c14n.implementations;
++
++import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
++
++/**
++ * @author Sean Mullan
++ */
++public class Canonicalizer11_WithComments extends Canonicalizer11 {
++
++    public Canonicalizer11_WithComments() {
++        super(true);
++    }
++
++    public final String engineGetURI() {
++        return Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS;
++    }
++
++    public final boolean engineGetIncludeComments() {
++        return true;
++    }
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -23,20 +22,30 @@
+ 
+ 
+ 
++import java.io.IOException;
++import java.util.ArrayList;
++import java.util.Collection;
+ import java.util.HashMap;
+ import java.util.Iterator;
++import java.util.List;
+ import java.util.Map;
+ import java.util.Set;
+ import java.util.SortedSet;
+ import java.util.TreeSet;
+ 
++import javax.xml.parsers.ParserConfigurationException;
++
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+ import com.sun.org.apache.xml.internal.security.c14n.helper.C14nHelper;
++import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
++import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import org.w3c.dom.Attr;
++import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.NamedNodeMap;
+ import org.w3c.dom.Node;
++import org.xml.sax.SAXException;
+ 
+ 
+ /**
+@@ -44,13 +53,92 @@
+  * XML Version 1.0</A>, a W3C Recommendation from 15 March 2001.
+  *
+  * @author Christian Geuer-Pollmann <geuerp@apache.org>
++ * @version $Revision: 1.5 $
+  */
+ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
+         boolean firstCall=true;
+         final SortedSet result= new TreeSet(COMPARE);
+     static final String XMLNS_URI=Constants.NamespaceSpecNS;
+     static final String XML_LANG_URI=Constants.XML_LANG_SPACE_SpecNS;
+-   /**
++    static class XmlAttrStack {
++        int currentLevel=0;
++        int lastlevel=0;
++        XmlsStackElement cur;
++        static class XmlsStackElement {
++                int level;
++                boolean rendered=false;
++                List nodes=new ArrayList();
++        };
++        List levels=new ArrayList();
++        void push(int level) {
++                currentLevel=level;
++                if (currentLevel==-1)
++                        return;
++                cur=null;
++                while (lastlevel>=currentLevel) {
++                        levels.remove(levels.size()-1);
++                        if (levels.size()==0) {
++                                lastlevel=0;
++                                return;
++                        }
++                        lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level;
++                }
++        }
++        void addXmlnsAttr(Attr n) {
++                if (cur==null) {
++                        cur=new XmlsStackElement();
++                        cur.level=currentLevel;
++                        levels.add(cur);
++                        lastlevel=currentLevel;
++                }
++                cur.nodes.add(n);
++        }
++        void getXmlnsAttr(Collection col) {
++                int size=levels.size()-1;
++                if (cur==null) {
++                        cur=new XmlsStackElement();
++                        cur.level=currentLevel;
++                        lastlevel=currentLevel;
++                        levels.add(cur);
++                }
++                boolean parentRendered=false;
++                XmlsStackElement e=null;
++                if (size==-1) {
++                        parentRendered=true;
++                } else {
++                        e=(XmlsStackElement)levels.get(size);
++                        if (e.rendered && e.level+1==currentLevel)
++                                parentRendered=true;
++
++                }
++                if (parentRendered) {
++                                col.addAll(cur.nodes);
++                                cur.rendered=true;
++                                return;
++                        }
++
++                        Map loa = new HashMap();
++                for (;size>=0;size--) {
++                        e=(XmlsStackElement)levels.get(size);
++                        Iterator it=e.nodes.iterator();
++                        while (it.hasNext()) {
++                                Attr n=(Attr)it.next();
++                                if (!loa.containsKey(n.getName()))
++                                        loa.put(n.getName(),n);
++                        }
++                        //if (e.rendered)
++                                //break;
++
++                };
++                //cur.nodes.clear();
++                //cur.nodes.addAll(loa.values());
++                        cur.rendered=true;
++                col.addAll(loa.values());
++        }
++
++    }
++    XmlAttrStack xmlattrStack=new XmlAttrStack();
++    /**
+     * Constructor Canonicalizer20010315
+     *
+     * @param includeComments
+@@ -86,16 +174,16 @@
+ 
+       for (int i = 0; i < attrsLength; i++) {
+          Attr N = (Attr) attrs.item(i);
+-         String NName=N.getLocalName();
+-         String NValue=N.getValue();
+          String NUri =N.getNamespaceURI();
+ 
+-         if (!XMLNS_URI.equals(NUri)) {
++         if (XMLNS_URI!=NUri) {
+                 //It's not a namespace attr node. Add to the result and continue.
+             result.add(N);
+             continue;
+          }
+ 
++         String NName=N.getLocalName();
++         String NValue=N.getValue();
+          if (XML.equals(NName)
+                  && XML_LANG_URI.equals(NValue)) {
+                 //The default mapping for xml must not be output.
+@@ -120,65 +208,14 @@
+         //Obtain all the namespaces defined in the parents, and added to the output.
+         ns.getUnrenderedNodes(result);
+         //output the attributes in the xml namespace.
+-                addXmlAttributesSubtree(E, result);
+-        firstCall=false;
++        xmlattrStack.getXmlnsAttr(result);
++                firstCall=false;
+       }
+ 
+       return result.iterator();
+    }
+ 
+    /**
+-    * Float the xml:* attributes of the parent nodes to the root node of c14n
+-    * @param E the root node.
+-    * @param result the xml:* attributes  to output.
+-    */
+-   private void addXmlAttributesSubtree(Element E, SortedSet result) {
+-         // E is in the node-set
+-         Node parent = E.getParentNode();
+-         Map loa = new HashMap();
+-
+-         if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE)) {
+-
+-            // parent element is not in node set
+-            for (Node ancestor = parent;
+-                    (ancestor != null)
+-                    && (ancestor.getNodeType() == Node.ELEMENT_NODE);
+-                    ancestor = ancestor.getParentNode()) {
+-               Element el=((Element) ancestor);
+-               if (!el.hasAttributes()) {
+-                    continue;
+-               }
+-               // for all ancestor elements
+-               NamedNodeMap ancestorAttrs = el.getAttributes();
+-
+-               for (int i = 0; i < ancestorAttrs.getLength(); i++) {
+-                  // for all attributes in the ancestor element
+-                  Attr currentAncestorAttr = (Attr) ancestorAttrs.item(i);
+-
+-                  if (XML_LANG_URI.equals(
+-                          currentAncestorAttr.getNamespaceURI())) {
+-
+-                     // do we have an xml:* ?
+-                     if (!E.hasAttributeNS(
+-                             XML_LANG_URI,
+-                             currentAncestorAttr.getLocalName())) {
+-
+-                        // the xml:* attr is not in E
+-                        if (!loa.containsKey(currentAncestorAttr.getName())) {
+-                           loa.put(currentAncestorAttr.getName(),
+-                                   currentAncestorAttr);
+-                        }
+-                     }
+-                  }
+-               }
+-            }
+-         }
+-
+-         result.addAll( loa.values());
+-
+-      }
+-
+-   /**
+     * Returns the Attr[]s to be outputted for the given element.
+     * <br>
+     * IMPORTANT: This method expects to work on a modified DOM tree, i.e. a DOM which has
+@@ -192,7 +229,8 @@
+     */
+    Iterator handleAttributes(Element E,  NameSpaceSymbTable ns ) throws CanonicalizationException {
+     // result will contain the attrs which have to be outputted
+-    boolean isRealVisible=isVisible(E);
++        xmlattrStack.push(ns.getLevel());
++    boolean isRealVisible=isVisibleDO(E,ns.getLevel())==1;
+     NamedNodeMap attrs = null;
+     int attrsLength = 0;
+     if (E.hasAttributes()) {
+@@ -204,16 +242,15 @@
+     SortedSet result = this.result;
+     result.clear();
+ 
+-
+     for (int i = 0; i < attrsLength; i++) {
+        Attr N = (Attr) attrs.item(i);
+-       String NName=N.getLocalName();
+-       String NValue=N.getValue();
+        String NUri =N.getNamespaceURI();
+ 
+-       if (!XMLNS_URI.equals(NUri)) {
++       if (XMLNS_URI!=NUri) {
+           //A non namespace definition node.
+-          if (isRealVisible){
++           if (XML_LANG_URI==NUri) {
++                          xmlattrStack.addXmlnsAttr(N);
++           } else if (isRealVisible){
+                 //The node is visible add the attribute to the list of output attributes.
+                 result.add(N);
+           }
+@@ -221,7 +258,8 @@
+           continue;
+        }
+ 
+-
++       String NName=N.getLocalName();
++       String NValue=N.getValue();
+        if ("xml".equals(NName)
+                && XML_LANG_URI.equals(NValue)) {
+           /* except omit namespace node with local name xml, which defines
+@@ -232,16 +270,26 @@
+        //add the prefix binding to the ns symb table.
+        //ns.addInclusiveMapping(NName,NValue,N,isRealVisible);
+             if  (isVisible(N))  {
+-                            //The xpath select this node output it if needed.
+-                        Node n=ns.addMappingAndRenderXNodeSet(NName,NValue,N,isRealVisible);
+-                                if (n!=null) {
++                if (!isRealVisible && ns.removeMappingIfRender(NName)) {
++                        continue;
++                }
++                        //The xpath select this node output it if needed.
++                //Node n=ns.addMappingAndRenderXNodeSet(NName,NValue,N,isRealVisible);
++                Node n=ns.addMappingAndRender(NName,NValue,N);
++                        if (n!=null) {
+                                         result.add(n);
+                     if (C14nHelper.namespaceIsRelative(N)) {
+                        Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
+                        throw new CanonicalizationException(
+                           "c14n.Canonicalizer.RelativeNamespace", exArgs);
+-                    }
+-                                }
++                   }
++                         }
++        } else {
++                if (isRealVisible && NName!=XMLNS) {
++                        ns.removeMapping(NName);
++                } else {
++                        ns.addMapping(NName,NValue,N);
++                }
+         }
+     }
+     if (isRealVisible) {
+@@ -254,85 +302,22 @@
+         } else if ( !isVisible(xmlns)) {
+                 //There is a definition but the xmlns is not selected by the xpath.
+                 //then xmlns=""
+-                n=ns.addMappingAndRenderXNodeSet(XMLNS,"",nullNode,true);
++                n=ns.addMappingAndRender(XMLNS,"",nullNode);
+         }
+         //output the xmlns def if needed.
+         if (n!=null) {
+                         result.add(n);
+         }
+         //Float all xml:* attributes of the unselected parent elements to this one.
+-        addXmlAttributes(E,result);
++        //addXmlAttributes(E,result);
++        xmlattrStack.getXmlnsAttr(result);
++        ns.getUnrenderedNodes(result);
++
+     }
+ 
+     return result.iterator();
+    }
+    /**
+-    *  Float the xml:* attributes of the unselected parent nodes to the ciurrent node.
+-    * @param E
+-    * @param result
+-    */
+-   private void addXmlAttributes(Element E, SortedSet result) {
+-        /* The processing of an element node E MUST be modified slightly when an
+-       * XPath node-set is given as input and the element's parent is omitted
+-       * from the node-set. The method for processing the attribute axis of an
+-       * element E in the node-set is enhanced. All element nodes along E's
+-       * ancestor axis are examined for nearest occurrences of attributes in
+-       * the xml namespace, such as xml:lang and xml:space (whether or not they
+-       * are in the node-set). From this list of attributes, remove any that are
+-       * in E's attribute axis (whether or not they are in the node-set). Then,
+-       * lexicographically merge this attribute list with the nodes of E's
+-       * attribute axis that are in the node-set. The result of visiting the
+-       * attribute axis is computed by processing the attribute nodes in this
+-       * merged attribute list.
+-       */
+-
+-         // E is in the node-set
+-         Node parent = E.getParentNode();
+-         Map loa = new HashMap();
+-
+-         if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE)
+-                 &&!isVisible(parent)) {
+-
+-            // parent element is not in node set
+-            for (Node ancestor = parent;
+-                    (ancestor != null)
+-                    && (ancestor.getNodeType() == Node.ELEMENT_NODE);
+-                    ancestor = ancestor.getParentNode()) {
+-                Element el=((Element) ancestor);
+-                if (!el.hasAttributes()) {
+-                        continue;
+-                }
+-               // for all ancestor elements
+-               NamedNodeMap ancestorAttrs =el.getAttributes();
+-
+-               for (int i = 0; i < ancestorAttrs.getLength(); i++) {
+-
+-                  // for all attributes in the ancestor element
+-                  Attr currentAncestorAttr = (Attr) ancestorAttrs.item(i);
+-
+-                  if (XML_LANG_URI.equals(
+-                          currentAncestorAttr.getNamespaceURI())) {
+-
+-                     // do we have an xml:* ?
+-                     if (!E.hasAttributeNS(
+-                             XML_LANG_URI,
+-                             currentAncestorAttr.getLocalName())) {
+-
+-                        // the xml:* attr is not in E
+-                        if (!loa.containsKey(currentAncestorAttr.getName())) {
+-                           loa.put(currentAncestorAttr.getName(),
+-                                   currentAncestorAttr);
+-                        }
+-                     }
+-                  }
+-               }
+-            }
+-         }
+-         result.addAll(loa.values());
+-
+-}
+-
+-   /**
+     * Always throws a CanonicalizationException because this is inclusive c14n.
+     *
+     * @param xpathNodeSet
+@@ -363,4 +348,43 @@
+       throw new CanonicalizationException(
+          "c14n.Canonicalizer.UnsupportedOperation");
+    }
++   void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException {
++           if (!input.isNeedsToBeExpanded())
++                   return;
++           Document doc = null;
++       if (input.getSubNode() != null) {
++           doc=XMLUtils.getOwnerDocument(input.getSubNode());
++       } else {
++           doc=XMLUtils.getOwnerDocument(input.getNodeSet());
++       }
++           XMLUtils.circumventBug2650(doc);
++
++   }
++
++   void handleParent(Element e, NameSpaceSymbTable ns) {
++           if (!e.hasAttributes()) {
++                        return;
++           }
++           xmlattrStack.push(-1);
++           NamedNodeMap attrs = e.getAttributes();
++           int attrsLength = attrs.getLength();
++           for (int i = 0; i < attrsLength; i++) {
++                   Attr N = (Attr) attrs.item(i);
++                   if (Constants.NamespaceSpecNS!=N.getNamespaceURI()) {
++                           //Not a namespace definition, ignore.
++                           if (XML_LANG_URI==N.getNamespaceURI()) {
++                                   xmlattrStack.addXmlnsAttr(N);
++                           }
++                           continue;
++                   }
++
++                   String NName=N.getLocalName();
++                   String NValue=N.getNodeValue();
++                   if (XML.equals(NName)
++                                   && Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
++                                continue;
++                   }
++                   ns.addMapping(NName,NValue,N);
++           }
++   }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright 1999-2004 The Apache Software Foundation.
+  *
+@@ -21,20 +20,26 @@
+  */
+ package com.sun.org.apache.xml.internal.security.c14n.implementations;
+ 
++import java.io.IOException;
+ import java.util.Iterator;
+ import java.util.Set;
+ import java.util.SortedSet;
+ import java.util.TreeSet;
+ 
++import javax.xml.parsers.ParserConfigurationException;
++
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+ import com.sun.org.apache.xml.internal.security.c14n.helper.C14nHelper;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+ import com.sun.org.apache.xml.internal.security.transforms.params.InclusiveNamespaces;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
++import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import org.w3c.dom.Attr;
++import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.NamedNodeMap;
+ import org.w3c.dom.Node;
++import org.xml.sax.SAXException;
+ /**
+  * Implements &quot; <A
+  * HREF="http://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/">Exclusive XML
+@@ -47,6 +52,7 @@
+  * <i>THIS </i> implementation is a complete rewrite of the algorithm.
+  *
+  * @author Christian Geuer-Pollmann <geuerp@apache.org>
++ * @version $Revision: 1.5 $
+  * @see <a href="http://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/ Exclusive#">
+  *          XML Canonicalization, Version 1.0</a>
+  */
+@@ -55,7 +61,7 @@
+       * This Set contains the names (Strings like "xmlns" or "xmlns:foo") of
+       * the inclusive namespaces.
+       */
+-    TreeSet _inclusiveNSSet = null;
++    TreeSet _inclusiveNSSet = new TreeSet();
+     static final String XMLNS_URI=Constants.NamespaceSpecNS;
+     final SortedSet result = new TreeSet(COMPARE);
+         /**
+@@ -143,10 +149,8 @@
+ 
+                 for (int i = 0; i < attrsLength; i++) {
+                         Attr N = (Attr) attrs.item(i);
+-                        String NName=N.getLocalName();
+-                        String NNodeValue=N.getNodeValue();
+ 
+-                        if (!XMLNS_URI.equals(N.getNamespaceURI())) {
++                        if (XMLNS_URI!=N.getNamespaceURI()) {
+                                 //Not a namespace definition.
+                                 //The Element is output element, add his prefix(if used) to visibyUtilized
+                                 String prefix = N.getPrefix();
+@@ -157,6 +161,8 @@
+                                  result.add(N);
+                                 continue;
+                         }
++                        String NName=N.getLocalName();
++                        String NNodeValue=N.getNodeValue();
+ 
+                         if (ns.addMapping(NName, NNodeValue,N)) {
+                                 //New definition check if it is relative.
+@@ -168,17 +174,17 @@
+                 }
+             }
+                 }
++                String prefix;
++                if (E.getNamespaceURI() != null) {
++                        prefix = E.getPrefix();
++                        if ((prefix == null) || (prefix.length() == 0)) {
++                                prefix=XMLNS;
++                        }
+ 
+-                if (E.getNamespaceURI() != null) {
+-                        String prefix = E.getPrefix();
+-                        if ((prefix == null) || (prefix.length() == 0)) {
+-                                visiblyUtilized.add(XMLNS);
+-                        } else {
+-                                visiblyUtilized.add(prefix);
+-                        }
+                 } else {
+-                        visiblyUtilized.add(XMLNS);
++                        prefix=XMLNS;
+                 }
++                visiblyUtilized.add(prefix);
+ 
+                 //This can be optimezed by I don't have time
+                 Iterator it=visiblyUtilized.iterator();
+@@ -211,12 +217,6 @@
+ 
+         }
+ 
+-    /** @inheritDoc */
+-    public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet
+-            ) throws CanonicalizationException {
+-        return engineCanonicalizeXPathNodeSet(xpathNodeSet,"");
+-    }
+-
+         /**
+      * @inheritDoc
+          * @param E
+@@ -236,21 +236,20 @@
+                 //The prefix visibly utilized(in the attribute or in the name) in the element
+                 Set visiblyUtilized =null;
+                 //It's the output selected.
+-                boolean isOutputElement = isVisible(E);
++                boolean isOutputElement=isVisibleDO(E,ns.getLevel())==1;
+                 if (isOutputElement) {
+                         visiblyUtilized =  (Set) this._inclusiveNSSet.clone();
+                 }
+ 
+                 for (int i = 0; i < attrsLength; i++) {
+                         Attr N = (Attr) attrs.item(i);
+-                        String NName=N.getLocalName();
+-                        String NNodeValue=N.getNodeValue();
+-                        if ( !isVisible(N) )  {
+-                                //The node is not in the nodeset(if there is a nodeset)
+-                                continue;
+-                        }
+ 
+-                        if (!XMLNS_URI.equals(N.getNamespaceURI())) {
++
++                        if (XMLNS_URI!=N.getNamespaceURI()) {
++                                if ( !isVisible(N) )  {
++                                        //The node is not in the nodeset(if there is a nodeset)
++                                        continue;
++                                }
+                                 //Not a namespace definition.
+                                 if (isOutputElement) {
+                                         //The Element is output element, add his prefix(if used) to visibyUtilized
+@@ -263,6 +262,25 @@
+                                 }
+                                 continue;
+                         }
++                        String NName=N.getLocalName();
++                        if (isOutputElement && !isVisible(N) && NName!=XMLNS) {
++                        ns.removeMappingIfNotRender(NName);
++                        continue;
++                }
++                        String NNodeValue=N.getNodeValue();
++
++                        if (!isOutputElement && isVisible(N) && _inclusiveNSSet.contains(NName) && !ns.removeMappingIfRender(NName)) {
++                                Node n=ns.addMappingAndRender(NName,NNodeValue,N);
++                                if (n!=null) {
++                                                result.add(n);
++                            if (C14nHelper.namespaceIsRelative(N)) {
++                               Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
++                               throw new CanonicalizationException(
++                                  "c14n.Canonicalizer.RelativeNamespace", exArgs);
++                           }
++                                 }
++                        }
++
+ 
+ 
+                         if (ns.addMapping(NName, NNodeValue,N)) {
+@@ -306,18 +324,20 @@
+                                 }
+                                 result.add(key);
+                         }
+-                } else /*if (_circunvented)*/ {
+-                        Iterator it=this._inclusiveNSSet.iterator();
+-                        while (it.hasNext()) {
+-                                String s=(String)it.next();
+-                                Attr key=ns.getMappingWithoutRendered(s);
+-                                if (key==null) {
+-                                        continue;
+-                                }
+-                                result.add(key);
+-                        }
+                 }
+ 
+                 return result.iterator();
+         }
++        void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException {
++                if (!input.isNeedsToBeExpanded() || _inclusiveNSSet.isEmpty())
++                        return;
++                Document doc = null;
++               if (input.getSubNode() != null) {
++                   doc=XMLUtils.getOwnerDocument(input.getSubNode());
++               } else {
++                   doc=XMLUtils.getOwnerDocument(input.getNodeSet());
++               }
++
++                XMLUtils.circumventBug2650(doc);
++           }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclWithComments.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclWithComments.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclWithComments.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315ExclWithComments.java
+@@ -28,6 +28,7 @@
+ /**
+  * Class Canonicalizer20010315ExclWithComments
+  *
++ * @version $Revision: 1.5 $
+  */
+ public class Canonicalizer20010315ExclWithComments
+         extends Canonicalizer20010315Excl {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315WithComments.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315WithComments.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315WithComments.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315WithComments.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
+@@ -27,9 +27,11 @@
+ import java.io.OutputStream;
+ import java.io.UnsupportedEncodingException;
+ import java.util.ArrayList;
++import java.util.HashMap;
+ import java.util.Iterator;
+ import java.util.List;
+ import java.util.ListIterator;
++import java.util.Map;
+ import java.util.Set;
+ 
+ import javax.xml.parsers.DocumentBuilderFactory;
+@@ -45,7 +47,6 @@
+ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import org.w3c.dom.Attr;
+ import org.w3c.dom.Comment;
+-import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.NamedNodeMap;
+ import org.w3c.dom.Node;
+@@ -57,6 +58,7 @@
+  * Abstract base class for canonicalization algorithms.
+  *
+  * @author Christian Geuer-Pollmann <geuerp@apache.org>
++ * @version $Revision: 1.5 $
+  */
+ public abstract class CanonicalizerBase extends CanonicalizerSpi {
+    //Constants to be outputed, In char array form, so
+@@ -123,6 +125,18 @@
+                 return engineCanonicalizeSubTree(rootNode,(Node)null);
+    }
+    /**
++    * Method engineCanonicalizeXPathNodeSet
++    * @inheritDoc
++    * @param xpathNodeSet
++    * @throws CanonicalizationException
++    */
++   public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
++           throws CanonicalizationException {
++           this._xpathNodeSet = xpathNodeSet;
++           return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet));
++   }
++
++   /**
+     * Canonicalizes a Subtree node.
+     * @param input the root of the subtree to canicalize
+     * @return The canonicalize stream.
+@@ -143,15 +157,8 @@
+                                 return bytes;
+                         } else if (input.isNodeSet()) {
+                                 nodeFilter=input.getNodeFilters();
+-                                Document doc = null;
+-                                if (input.getSubNode() != null) {
+-                                    doc=XMLUtils.getOwnerDocument(input.getSubNode());
+-                                } else {
+-                                    doc=XMLUtils.getOwnerDocument(input.getNodeSet());
+-                                }
+-                                if (input.isNeedsToBeExpanded()) {
+-                                        XMLUtils.circumventBug2650(doc);
+-                                }
++
++                circumventBugIfNeeded(input);
+ 
+                                 if (input.getSubNode() != null) {
+                                     bytes = engineCanonicalizeXPathNodeSetInternal(input.getSubNode());
+@@ -173,6 +180,13 @@
+                 }
+    }
+    /**
++    * @param _writer The _writer to set.
++    */
++    public void setWriter(OutputStream _writer) {
++        this._writer = _writer;
++    }
++
++    /**
+          * Canonicalizes a Subtree node.
+          *
+          * @param rootNode
+@@ -187,11 +201,13 @@
+         this._excludeNode = excludeNode;
+         try {
+          NameSpaceSymbTable ns=new NameSpaceSymbTable();
++         int nodeLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
+          if (rootNode != null && rootNode.getNodeType() == Node.ELEMENT_NODE) {
+                 //Fills the nssymbtable with the definitions of the parent of the root subnode
+                 getParentNameSpaces((Element)rootNode,ns);
++                nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+          }
+-         this.canonicalizeSubTree(rootNode,ns,rootNode);
++         this.canonicalizeSubTree(rootNode,ns,rootNode,nodeLevel);
+          this._writer.close();
+          if (this._writer instanceof ByteArrayOutputStream) {
+             byte []result=((ByteArrayOutputStream)this._writer).toByteArray();
+@@ -199,6 +215,12 @@
+                 ((ByteArrayOutputStream)this._writer).reset();
+             }
+                 return result;
++         }  else if (this._writer instanceof UnsyncByteArrayOutputStream) {
++                 byte []result=((UnsyncByteArrayOutputStream)this._writer).toByteArray();
++             if (reset) {
++                 ((UnsyncByteArrayOutputStream)this._writer).reset();
++             }
++                 return result;
+          }
+          return null;
+ 
+@@ -219,13 +241,17 @@
+     * @throws CanonicalizationException
+     * @throws IOException
+     */
+-    final void canonicalizeSubTree(Node currentNode, NameSpaceSymbTable ns,Node endnode)
++    final void canonicalizeSubTree(Node currentNode, NameSpaceSymbTable ns,Node endnode,
++                int documentLevel)
+     throws CanonicalizationException, IOException {
++        if (isVisibleInt(currentNode)==-1)
++                return;
+         Node sibling=null;
+         Node parentNode=null;
+         final OutputStream writer=this._writer;
+         final Node excludeNode=this._excludeNode;
+         final boolean includeComments=this._includeComments;
++        Map cache=new HashMap();
+         do {
+                 switch (currentNode.getNodeType()) {
+ 
+@@ -242,18 +268,17 @@
+             case Node.DOCUMENT_FRAGMENT_NODE :
+                 case Node.DOCUMENT_NODE :
+                         ns.outputNodePush();
+-                        //currentNode = currentNode.getFirstChild();
+                         sibling= currentNode.getFirstChild();
+                         break;
+ 
+                 case Node.COMMENT_NODE :
+                         if (includeComments) {
+-                                outputCommentToWriter((Comment) currentNode, writer);
++                                outputCommentToWriter((Comment) currentNode, writer, documentLevel);
+                         }
+                         break;
+ 
+                 case Node.PROCESSING_INSTRUCTION_NODE :
+-                        outputPItoWriter((ProcessingInstruction) currentNode, writer);
++                        outputPItoWriter((ProcessingInstruction) currentNode, writer, documentLevel);
+                         break;
+ 
+                 case Node.TEXT_NODE :
+@@ -262,6 +287,7 @@
+                         break;
+ 
+                 case Node.ELEMENT_NODE :
++                        documentLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+                         if (currentNode==excludeNode) {
+                                 break;
+                         }
+@@ -270,27 +296,27 @@
+                         ns.outputNodePush();
+                         writer.write('<');
+                         String name=currentElement.getTagName();
+-                        writeStringToUtf8(name,writer);
++                        UtfHelpper.writeByte(name,writer,cache);
+ 
+                         Iterator attrs = this.handleAttributesSubtree(currentElement,ns);
+                         if (attrs!=null) {
+                                 //we output all Attrs which are available
+                                 while (attrs.hasNext()) {
+                                         Attr attr = (Attr) attrs.next();
+-                                        outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer);
++                                        outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
+                                 }
+                         }
+                         writer.write('>');
+                         sibling= currentNode.getFirstChild();
+                         if (sibling==null) {
+                                 writer.write(_END_TAG);
+-                                writeStringToUtf8(name,writer);
++                                UtfHelpper.writeStringToUtf8(name,writer);
+                                 writer.write('>');
+                                 //We fineshed with this level, pop to the previous definitions.
+                                 ns.outputNodePop();
+-                                if (parentNode != null) {
++                                    if (parentNode != null) {
+                                         sibling= currentNode.getNextSibling();
+-                                }
++                                    }
+                         } else {
+                                 parentNode=currentElement;
+                         }
+@@ -298,7 +324,7 @@
+                 }
+                 while (sibling==null  && parentNode!=null) {
+                         writer.write(_END_TAG);
+-                        writeStringToUtf8(((Element)parentNode).getTagName(),writer);
++                        UtfHelpper.writeByte(((Element)parentNode).getTagName(),writer,cache);
+                         writer.write('>');
+                         //We fineshed with this level, pop to the previous definitions.
+                         ns.outputNodePop();
+@@ -307,6 +333,7 @@
+                         sibling=parentNode.getNextSibling();
+                         parentNode=parentNode.getParentNode();
+                         if (parentNode !=null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
++                                documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
+                                 parentNode=null;
+                         }
+                 }
+@@ -317,47 +344,8 @@
+         } while(true);
+     }
+ 
+-   /**
+-    * Checks whether a Comment or ProcessingInstruction is before or after the
+-    * document element. This is needed for prepending or appending "\n"s.
+-    *
+-    * @param currentNode comment or pi to check
+-    * @return NODE_BEFORE_DOCUMENT_ELEMENT, NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT or NODE_AFTER_DOCUMENT_ELEMENT
+-    * @see #NODE_BEFORE_DOCUMENT_ELEMENT
+-    * @see #NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT
+-    * @see #NODE_AFTER_DOCUMENT_ELEMENT
+-    */
+-   final static int getPositionRelativeToDocumentElement(Node currentNode) {
+ 
+-      if ((currentNode == null) ||
+-            (currentNode.getParentNode().getNodeType() != Node.DOCUMENT_NODE) ) {
+-         return CanonicalizerBase.NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+-      }
+-      Element documentElement = currentNode.getOwnerDocument().getDocumentElement();
+-      if ( (documentElement == null)  || (documentElement == currentNode) ){
+-         return CanonicalizerBase.NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+-      }
+ 
+-      for (Node x = currentNode; x != null; x = x.getNextSibling()) {
+-         if (x == documentElement) {
+-            return CanonicalizerBase.NODE_BEFORE_DOCUMENT_ELEMENT;
+-         }
+-      }
+-
+-      return CanonicalizerBase.NODE_AFTER_DOCUMENT_ELEMENT;
+-   }
+-
+-   /**
+-    * Method engineCanonicalizeXPathNodeSet
+-    * @inheritDoc
+-    * @param xpathNodeSet
+-    * @throws CanonicalizationException
+-    */
+-   public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
+-           throws CanonicalizationException {
+-           this._xpathNodeSet = xpathNodeSet;
+-           return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet));
+-   }
+    private  byte[] engineCanonicalizeXPathNodeSetInternal(Node doc)
+            throws CanonicalizationException {
+ 
+@@ -370,6 +358,12 @@
+                 ((ByteArrayOutputStream)this._writer).reset();
+             }
+                 return sol;
++         }  else if (this._writer instanceof UnsyncByteArrayOutputStream) {
++                 byte []result=((UnsyncByteArrayOutputStream)this._writer).toByteArray();
++             if (reset) {
++                 ((UnsyncByteArrayOutputStream)this._writer).reset();
++             }
++                 return result;
+          }
+          return null;
+       } catch (UnsupportedEncodingException ex) {
+@@ -390,11 +384,17 @@
+     */
+    final void canonicalizeXPathNodeSet(Node currentNode,Node endnode )
+            throws CanonicalizationException, IOException {
+-           boolean currentNodeIsVisible = false;
+-           NameSpaceSymbTable ns=new  NameSpaceSymbTable();
++        if (isVisibleInt(currentNode)==-1)
++                return;
++        boolean currentNodeIsVisible = false;
++        NameSpaceSymbTable ns=new  NameSpaceSymbTable();
++        if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE)
++                getParentNameSpaces((Element)currentNode,ns);
+         Node sibling=null;
+         Node parentNode=null;
+         OutputStream writer=this._writer;
++        int documentLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
++        Map cache=new HashMap();
+         do {
+                 switch (currentNode.getNodeType()) {
+ 
+@@ -416,14 +416,14 @@
+                         break;
+ 
+                 case Node.COMMENT_NODE :
+-                        if (this._includeComments && isVisible(currentNode)) {
+-                                outputCommentToWriter((Comment) currentNode, writer);
++                        if (this._includeComments && (isVisibleDO(currentNode,ns.getLevel())==1)) {
++                                outputCommentToWriter((Comment) currentNode, writer, documentLevel);
+                         }
+                         break;
+ 
+                 case Node.PROCESSING_INSTRUCTION_NODE :
+                         if (isVisible(currentNode))
+-                                outputPItoWriter((ProcessingInstruction) currentNode, writer);
++                                outputPItoWriter((ProcessingInstruction) currentNode, writer, documentLevel);
+                         break;
+ 
+                 case Node.TEXT_NODE :
+@@ -436,12 +436,6 @@
+                         || (nextSibling.getNodeType()
+                             == Node.CDATA_SECTION_NODE));
+                     nextSibling = nextSibling.getNextSibling()) {
+-               /* The XPath data model allows to select only the first of a
+-                * sequence of mixed text and CDATA nodes. But we must output
+-                * them all, so we must search:
+-                *
+-                * @see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6329
+-                */
+                outputTextToWriter(nextSibling.getNodeValue(), writer);
+                currentNode=nextSibling;
+                sibling=currentNode.getNextSibling();
+@@ -451,15 +445,21 @@
+                         break;
+ 
+                 case Node.ELEMENT_NODE :
++                        documentLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
+                         Element currentElement = (Element) currentNode;
+                         //Add a level to the nssymbtable. So latter can be pop-back.
+                         String name=null;
+-                        currentNodeIsVisible=isVisible(currentNode);
++                        int i=isVisibleDO(currentNode,ns.getLevel());
++                        if (i==-1) {
++                                sibling= currentNode.getNextSibling();
++                                break;
++                        }
++                        currentNodeIsVisible=(i==1);
+                         if (currentNodeIsVisible) {
+                                 ns.outputNodePush();
+                                 writer.write('<');
+                                 name=currentElement.getTagName();
+-                                writeStringToUtf8(name,writer);
++                                UtfHelpper.writeByte(name,writer,cache);
+                         } else {
+                                 ns.push();
+                         }
+@@ -469,7 +469,7 @@
+                                 //we output all Attrs which are available
+                                 while (attrs.hasNext()) {
+                                         Attr attr = (Attr) attrs.next();
+-                                        outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer);
++                                        outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
+                                 }
+                         }
+                         if (currentNodeIsVisible) {
+@@ -480,7 +480,7 @@
+                         if (sibling==null) {
+                                 if (currentNodeIsVisible) {
+                                         writer.write(_END_TAG);
+-                                        writeStringToUtf8(name,writer);
++                                        UtfHelpper.writeByte(name,writer,cache);
+                                         writer.write('>');
+                                         //We fineshed with this level, pop to the previous definitions.
+                                         ns.outputNodePop();
+@@ -498,7 +498,7 @@
+                 while (sibling==null  && parentNode!=null) {
+                         if (isVisible(parentNode)) {
+                                 writer.write(_END_TAG);
+-                                writeStringToUtf8(((Element)parentNode).getTagName(),writer);
++                                UtfHelpper.writeByte(((Element)parentNode).getTagName(),writer,cache);
+                                 writer.write('>');
+                                 //We fineshed with this level, pop to the previous definitions.
+                                 ns.outputNodePop();
+@@ -511,6 +511,7 @@
+                         parentNode=parentNode.getParentNode();
+                         if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
+                                 parentNode=null;
++                                documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
+                         }
+                 }
+                 if (sibling==null)
+@@ -519,12 +520,38 @@
+                 sibling=currentNode.getNextSibling();
+         } while(true);
+    }
++   int isVisibleDO(Node currentNode,int level) {
++           if (nodeFilter!=null) {
++                        Iterator it=nodeFilter.iterator();
++                        while (it.hasNext()) {
++                                int i=((NodeFilter)it.next()).isNodeIncludeDO(currentNode,level);
++                                if (i!=1)
++                                        return i;
++                        }
++                   }
++           if ((this._xpathNodeSet!=null) && !this._xpathNodeSet.contains(currentNode))
++                        return 0;
++           return 1;
++   }
++   int isVisibleInt(Node currentNode) {
++           if (nodeFilter!=null) {
++                Iterator it=nodeFilter.iterator();
++                while (it.hasNext()) {
++                        int i=((NodeFilter)it.next()).isNodeInclude(currentNode);
++                        if (i!=1)
++                                return i;
++                }
++           }
++                if ((this._xpathNodeSet!=null) && !this._xpathNodeSet.contains(currentNode))
++                        return 0;
++                return 1;
++        }
+ 
+    boolean isVisible(Node currentNode) {
+            if (nodeFilter!=null) {
+                 Iterator it=nodeFilter.iterator();
+                 while (it.hasNext()) {
+-                        if (!((NodeFilter)it.next()).isNodeInclude(currentNode))
++                        if (((NodeFilter)it.next()).isNodeInclude(currentNode)!=1)
+                                 return false;
+                 }
+            }
+@@ -533,13 +560,36 @@
+                 return true;
+         }
+ 
++        void handleParent(Element e,NameSpaceSymbTable ns) {
++           if (!e.hasAttributes()) {
++                                return;
++                }
++                NamedNodeMap attrs = e.getAttributes();
++                int attrsLength = attrs.getLength();
++                for (int i = 0; i < attrsLength; i++) {
++                        Attr N = (Attr) attrs.item(i);
++                        if (Constants.NamespaceSpecNS!=N.getNamespaceURI()) {
++                                //Not a namespace definition, ignore.
++                                continue;
++                        }
++
++                        String NName=N.getLocalName();
++                        String NValue=N.getNodeValue();
++                        if (XML.equals(NName)
++               && Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
++                                        continue;
++                        }
++                        ns.addMapping(NName,NValue,N);
++                }
++   }
++
+         /**
+          * Adds to ns the definitons from the parent elements of el
+          * @param el
+          * @param ns
+          */
+-        final static void getParentNameSpaces(Element el,NameSpaceSymbTable ns)  {
+-                List parents=new ArrayList();
++        final void getParentNameSpaces(Element el,NameSpaceSymbTable ns)  {
++                List parents=new ArrayList(10);
+                 Node n1=el.getParentNode();
+                 if (n1 == null || n1.getNodeType() != Node.ELEMENT_NODE) {
+                         return;
+@@ -553,28 +603,9 @@
+                 //Visit them in reverse order.
+                 ListIterator it=parents.listIterator(parents.size());
+                 while (it.hasPrevious()) {
+-                Element ele=(Element)it.previous();
+-        if (!ele.hasAttributes()) {
+-                continue;
++                        Element ele=(Element)it.previous();
++                        handleParent(ele, ns);
+         }
+-                NamedNodeMap attrs = ele.getAttributes();
+-                int attrsLength = attrs.getLength();
+-                 for (int i = 0; i < attrsLength; i++) {
+-            Attr N = (Attr) attrs.item(i);
+-            if (!Constants.NamespaceSpecNS.equals(N.getNamespaceURI())) {
+-               //Not a namespace definition, ignore.
+-               continue;
+-            }
+-
+-            String NName=N.getLocalName();
+-            String NValue=N.getNodeValue();
+-            if (XML.equals(NName)
+-                    && Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
+-               continue;
+-            }
+-            ns.addMapping(NName,NValue,N);
+-                 }
+-                }
+         Attr nsprefix;
+         if (((nsprefix=ns.getMappingWithoutRendered("xmlns"))!=null)
+                 && "".equals(nsprefix.getValue())) {
+@@ -582,269 +613,6 @@
+         }
+         }
+    /**
+-    * Outputs an Attribute to the internal Writer.
+-    *
+-    * The string value of the node is modified by replacing
+-    * <UL>
+-    * <LI>all ampersands (&) with <CODE>&amp;amp;</CODE></LI>
+-    * <LI>all open angle brackets (<) with <CODE>&amp;lt;</CODE></LI>
+-    * <LI>all quotation mark characters with <CODE>&amp;quot;</CODE></LI>
+-    * <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD, with character
+-    * references. The character references are written in uppercase
+-    * hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE> is represented
+-    * by the character reference <CODE>&amp;#xD;</CODE>)</LI>
+-    * </UL>
+-    *
+-    * @param name
+-    * @param value
+-    * @param writer
+-    * @throws IOException
+-    */
+-   static final void outputAttrToWriter(final String name, final String value, final OutputStream writer) throws IOException {
+-      writer.write(' ');
+-      writeStringToUtf8(name,writer);
+-      writer.write(equalsStr);
+-      byte  []toWrite;
+-      final int length = value.length();
+-      for (int i=0;i < length; i++) {
+-         char c = value.charAt(i);
+-
+-         switch (c) {
+-
+-         case '&' :
+-                toWrite=_AMP_;
+-            //writer.write(_AMP_);
+-            break;
+-
+-         case '<' :
+-                toWrite=_LT_;
+-            //writer.write(_LT_);
+-            break;
+-
+-         case '"' :
+-                toWrite=_QUOT_;
+-            //writer.write(_QUOT_);
+-            break;
+-
+-         case 0x09 :    // '\t'
+-                toWrite=__X9_;
+-            //writer.write(__X9_);
+-            break;
+-
+-         case 0x0A :    // '\n'
+-                toWrite=__XA_;
+-            //writer.write(__XA_);
+-            break;
+-
+-         case 0x0D :    // '\r'
+-                toWrite=__XD_;
+-            //writer.write(__XD_);
+-            break;
+-
+-         default :
+-            writeCharToUtf8(c,writer);
+-            //this._writer.write(c);
+-            continue;
+-         }
+-         writer.write(toWrite);
+-      }
+-
+-      writer.write('\"');
+-   }
+-
+-   final static void writeCharToUtf8(final char c,final OutputStream out) throws IOException{
+-        char ch;
+-        if (/*(c >= 0x0001) &&*/ (c <= 0x007F)) {
+-        out.write(c);
+-        return;
+-    }
+-    int bias;
+-    int write;
+-    if (c > 0x07FF) {
+-        ch=(char)(c>>>12);
+-        write=0xE0;
+-        if (ch>0) {
+-            write |= ( ch & 0x0F);
+-        }
+-        out.write(write);
+-        write=0x80;
+-        bias=0x3F;
+-    } else {
+-        write=0xC0;
+-        bias=0x1F;
+-    }
+-    ch=(char)(c>>>6);
+-    if (ch>0) {
+-         write|= (ch & bias);
+-    }
+-    out.write(write);
+-    out.write(0x80 | ((c) & 0x3F));
+-
+-   }
+-
+-   final static void writeStringToUtf8(final String str,final OutputStream out) throws IOException{
+-        final int length=str.length();
+-        int i=0;
+-    char c;
+-        while (i<length) {
+-                c=str.charAt(i++);
+-        if (/*(c >= 0x0001) &&*/ (c <= 0x007F)) {
+-            out.write(c);
+-            continue;
+-        }
+-        char ch;
+-        int bias;
+-        int write;
+-        if (c > 0x07FF) {
+-            ch=(char)(c>>>12);
+-            write=0xE0;
+-            if (ch>0) {
+-                write |= ( ch & 0x0F);
+-            }
+-            out.write(write);
+-            write=0x80;
+-            bias=0x3F;
+-        } else {
+-                write=0xC0;
+-                bias=0x1F;
+-        }
+-        ch=(char)(c>>>6);
+-        if (ch>0) {
+-             write|= (ch & bias);
+-        }
+-        out.write(write);
+-        out.write(0x80 | ((c) & 0x3F));
+-        continue;
+-
+-        }
+-
+-   }
+-   /**
+-    * Outputs a PI to the internal Writer.
+-    *
+-    * @param currentPI
+-    * @param writer where to write the things
+-    * @throws IOException
+-    */
+-   static final void outputPItoWriter(ProcessingInstruction currentPI, OutputStream writer) throws IOException {
+-          final int position = getPositionRelativeToDocumentElement(currentPI);
+-
+-      if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
+-        writer.write('\n');
+-      }
+-      writer.write(_BEGIN_PI);
+-
+-      final String target = currentPI.getTarget();
+-      int length = target.length();
+-
+-      for (int i = 0; i < length; i++) {
+-         char c=target.charAt(i);
+-         if (c==0x0D) {
+-            writer.write(__XD_);
+-         } else {
+-            writeCharToUtf8(c,writer);
+-         }
+-      }
+-
+-      final String data = currentPI.getData();
+-
+-      length = data.length();
+-
+-      if (length > 0) {
+-         writer.write(' ');
+-
+-         for (int i = 0; i < length; i++) {
+-                char c=data.charAt(i);
+-            if (c==0x0D) {
+-               writer.write(__XD_);
+-            } else {
+-               writeCharToUtf8(c,writer);
+-            }
+-         }
+-      }
+-
+-      writer.write(_END_PI);
+-      if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
+-        writer.write('\n');
+-     }
+-   }
+-
+-   /**
+-    * Method outputCommentToWriter
+-    *
+-    * @param currentComment
+-    * @param writer writer where to write the things
+-    * @throws IOException
+-    */
+-   static final void outputCommentToWriter(Comment currentComment, OutputStream writer) throws IOException {
+-          final int position = getPositionRelativeToDocumentElement(currentComment);
+-          if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
+-                writer.write('\n');
+-          }
+-      writer.write(_BEGIN_COMM);
+-
+-      final String data = currentComment.getData();
+-      final int length = data.length();
+-
+-      for (int i = 0; i < length; i++) {
+-         char c=data.charAt(i);
+-         if (c==0x0D) {
+-            writer.write(__XD_);
+-         } else {
+-            writeCharToUtf8(c,writer);
+-         }
+-      }
+-
+-      writer.write(_END_COMM);
+-      if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
+-                writer.write('\n');
+-         }
+-   }
+-
+-   /**
+-    * Outputs a Text of CDATA section to the internal Writer.
+-    *
+-    * @param text
+-    * @param writer writer where to write the things
+-    * @throws IOException
+-    */
+-   static final void outputTextToWriter(final String text, final OutputStream writer) throws IOException {
+-      final int length = text.length();
+-      byte []toWrite;
+-      for (int i = 0; i < length; i++) {
+-         char c = text.charAt(i);
+-
+-         switch (c) {
+-
+-         case '&' :
+-                toWrite=_AMP_;
+-            //writer.write(_AMP_);
+-            break;
+-
+-         case '<' :
+-                toWrite=_LT_;
+-            //writer.write(_LT_);
+-            break;
+-
+-         case '>' :
+-                toWrite=_GT_;
+-            //writer.write(_GT_);
+-            break;
+-
+-         case 0xD :
+-                toWrite=__XD_;
+-            //writer.write(__XD_);
+-            break;
+-
+-         default :
+-            writeCharToUtf8(c,writer);
+-            continue;
+-         }
+-         writer.write(toWrite);
+-      }
+-   }
+-
+-   /**
+     * Obtain the attributes to output for this node in XPathNodeSet c14n.
+     *
+     * @param E
+@@ -866,13 +634,207 @@
+    abstract Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
+    throws CanonicalizationException;
+ 
++   abstract void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException;
+ 
++   /**
++            * Outputs an Attribute to the internal Writer.
++            *
++            * The string value of the node is modified by replacing
++            * <UL>
++            * <LI>all ampersands (&) with <CODE>&amp;amp;</CODE></LI>
++            * <LI>all open angle brackets (<) with <CODE>&amp;lt;</CODE></LI>
++            * <LI>all quotation mark characters with <CODE>&amp;quot;</CODE></LI>
++            * <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD, with character
++            * references. The character references are written in uppercase
++            * hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE> is represented
++            * by the character reference <CODE>&amp;#xD;</CODE>)</LI>
++            * </UL>
++            *
++            * @param name
++            * @param value
++            * @param writer
++            * @throws IOException
++            */
++           static final void outputAttrToWriter(final String name, final String value, final OutputStream writer,
++                                final Map cache) throws IOException {
++              writer.write(' ');
++              UtfHelpper.writeByte(name,writer,cache);
++              writer.write(equalsStr);
++              byte  []toWrite;
++              final int length = value.length();
++              int i=0;
++              while (i < length) {
++                 char c = value.charAt(i++);
+ 
+-    /**
+-     * @param _writer The _writer to set.
+-     */
+-    public void setWriter(OutputStream _writer) {
+-        this._writer = _writer;
+-    }
++                 switch (c) {
++
++                 case '&' :
++                        toWrite=_AMP_;
++                    break;
++
++                 case '<' :
++                        toWrite=_LT_;
++                    break;
++
++                 case '"' :
++                        toWrite=_QUOT_;
++                    break;
++
++                 case 0x09 :    // '\t'
++                        toWrite=__X9_;
++                    break;
++
++                 case 0x0A :    // '\n'
++                        toWrite=__XA_;
++                    break;
++
++                 case 0x0D :    // '\r'
++                        toWrite=__XD_;
++                    break;
++
++                 default :
++                        if (c < 0x80 ) {
++                                writer.write(c);
++                        } else {
++                                UtfHelpper.writeCharToUtf8(c,writer);
++                        };
++                    continue;
++                 }
++                 writer.write(toWrite);
++              }
++
++              writer.write('\"');
++           }
++
++        /**
++            * Outputs a PI to the internal Writer.
++            *
++            * @param currentPI
++            * @param writer where to write the things
++            * @throws IOException
++            */
++           static final void outputPItoWriter(ProcessingInstruction currentPI, OutputStream writer,int position) throws IOException {
++
++              if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
++                writer.write('\n');
++              }
++              writer.write(_BEGIN_PI);
++
++              final String target = currentPI.getTarget();
++              int length = target.length();
++
++              for (int i = 0; i < length; i++) {
++                 char c=target.charAt(i);
++                 if (c==0x0D) {
++                    writer.write(__XD_);
++                 } else {
++                         if (c < 0x80)  {
++                                writer.write(c);
++                        } else {
++                                UtfHelpper.writeCharToUtf8(c,writer);
++                        };
++                 }
++              }
++
++              final String data = currentPI.getData();
++
++              length = data.length();
++
++              if (length > 0) {
++                 writer.write(' ');
++
++                 for (int i = 0; i < length; i++) {
++                        char c=data.charAt(i);
++                    if (c==0x0D) {
++                       writer.write(__XD_);
++                    } else {
++                        UtfHelpper.writeCharToUtf8(c,writer);
++                    }
++                 }
++              }
++
++              writer.write(_END_PI);
++              if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
++                writer.write('\n');
++             }
++           }
++
++           /**
++            * Method outputCommentToWriter
++            *
++            * @param currentComment
++            * @param writer writer where to write the things
++            * @throws IOException
++            */
++           static final void outputCommentToWriter(Comment currentComment, OutputStream writer,int position) throws IOException {
++                  if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
++                        writer.write('\n');
++                  }
++              writer.write(_BEGIN_COMM);
++
++              final String data = currentComment.getData();
++              final int length = data.length();
++
++              for (int i = 0; i < length; i++) {
++                 char c=data.charAt(i);
++                 if (c==0x0D) {
++                    writer.write(__XD_);
++                 } else {
++                         if (c < 0x80)  {
++                                writer.write(c);
++                        } else {
++                                UtfHelpper.writeCharToUtf8(c,writer);
++                        };
++                 }
++              }
++
++              writer.write(_END_COMM);
++              if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
++                        writer.write('\n');
++                 }
++           }
++
++           /**
++            * Outputs a Text of CDATA section to the internal Writer.
++            *
++            * @param text
++            * @param writer writer where to write the things
++            * @throws IOException
++            */
++           static final void outputTextToWriter(final String text, final OutputStream writer) throws IOException {
++              final int length = text.length();
++              byte []toWrite;
++              for (int i = 0; i < length; i++) {
++                 char c = text.charAt(i);
++
++                 switch (c) {
++
++                 case '&' :
++                        toWrite=_AMP_;
++                    break;
++
++                 case '<' :
++                        toWrite=_LT_;
++                    break;
++
++                 case '>' :
++                        toWrite=_GT_;
++                    break;
++
++                 case 0xD :
++                        toWrite=__XD_;
++                    break;
++
++                 default :
++                         if (c < 0x80) {
++                                 writer.write(c);
++                         } else {
++                                 UtfHelpper.writeCharToUtf8(c,writer);
++                         };
++                    continue;
++                 }
++                 writer.write(toWrite);
++              }
++           }
+ 
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/NameSpaceSymbTable.java
+@@ -20,16 +20,10 @@
+  */
+ package com.sun.org.apache.xml.internal.security.c14n.implementations;
+ 
+-import java.lang.reflect.Array;
+-import java.util.AbstractList;
+ import java.util.ArrayList;
+-import java.util.Arrays;
+ import java.util.Collection;
+-import java.util.HashMap;
+ import java.util.Iterator;
+ import java.util.List;
+-import java.util.Map;
+-
+ 
+ 
+ import org.w3c.dom.Attr;
+@@ -46,21 +40,26 @@
+ public class NameSpaceSymbTable {
+ 
+         /**The map betwen prefix-> entry table. */
+-        SymbMap symb = new SymbMap();
++        SymbMap symb;
+         /**The level of nameSpaces (for Inclusive visibility).*/
+         int nameSpaces=0;
+         /**The stacks for removing the definitions when doing pop.*/
+-        List level = new ArrayList();
++        List level;
+     boolean cloned=true;
+         static final String XMLNS="xmlns";
++        final static SymbMap initialMap=new SymbMap();
++        static {
++                NameSpaceSymbEntry ne=new NameSpaceSymbEntry("",null,true,XMLNS);
++                ne.lastrendered="";
++                initialMap.put(XMLNS,ne);
++        }
+     /**
+      * Default constractor
+      **/
+     public NameSpaceSymbTable() {
++        level = new ArrayList(10);
+         //Insert the default binding for xmlns.
+-        NameSpaceSymbEntry ne=new NameSpaceSymbEntry("",null,true);
+-                ne.lastrendered="";
+-        symb.put(XMLNS,ne);
++        symb=(SymbMap) initialMap.clone();
+     }
+ 
+     /**
+@@ -75,8 +74,14 @@
+                         NameSpaceSymbEntry n=(NameSpaceSymbEntry)(it.next());
+                         //put them rendered?
+                         if ((!n.rendered) && (n.n!=null)) {
++                                n=(NameSpaceSymbEntry) n.clone();
++                needsClone();
++                symb.put(n.prefix,n);
++                n.lastrendered=n.uri;
++                n.rendered=true;
++
+                                 result.add(n.n);
+-                                n.rendered=true;
++
+                         }
+            }
+         }
+@@ -104,10 +109,6 @@
+      **/
+         public void push() {
+                 //Put the number of namespace definitions in the stack.
+-        /**if (cloned) {
+-                Object ob[]= {symb,cloned ? symb : null};
+-                level.add(ob);
+-        } **/
+         level.add(null);
+         cloned=false;
+         }
+@@ -124,7 +125,7 @@
+             if (size==0) {
+                cloned=false;
+             } else
+-            cloned=(level.get(size-1)!=symb);
++                cloned=(level.get(size-1)!=symb);
+         } else {
+                 cloned=false;
+         }
+@@ -134,8 +135,7 @@
+ 
+         final void needsClone() {
+                 if (!cloned) {
+-            level.remove(level.size()-1);
+-            level.add(symb);
++            level.set(level.size()-1,symb);
+                         symb=(SymbMap) symb.clone();
+             cloned=true;
+         }
+@@ -200,7 +200,7 @@
+                         return false;
+                 }
+                 //Creates and entry in the table for this new definition.
+-                NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,false);
++                NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,false,prefix);
+         needsClone();
+                 symb.put(prefix, ne);
+                 if (ob != null) {
+@@ -238,7 +238,7 @@
+             return null;
+         }
+ 
+-        NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,true);
++        NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,true,prefix);
+         ne.lastrendered=uri;
+         needsClone();
+         symb.put(prefix, ne);
+@@ -251,53 +251,38 @@
+         }
+         return ne.n;
+     }
+-        /**
+-     * Adds & gets(if needed) the attribute node that defines the binding for the prefix.
+-     * Take on account if the rules of rendering in the inclusive c14n.
+-     * For inclusive c14n.
+-     * @param prefix the prefix to obtain the attribute.
+-     * @param outputNode the container element is an output element.
+-     * @param uri the Uri of the definition
+-     * @param n the attribute that have the definition
+-     * @return null if there is no need to render the prefix. Otherwise the node of
+-     * definition.
+-     **/
+-        public Node addMappingAndRenderXNodeSet(String prefix, String uri,Attr n,boolean outputNode) {
++
++        public int getLevel() {
++                // TODO Auto-generated method stub
++                return level.size();
++        }
++
++        public void removeMapping(String prefix) {
+                 NameSpaceSymbEntry ob = symb.get(prefix);
+-                int visibleNameSpaces=nameSpaces;
+-                if ((ob!=null) && uri.equals(ob.uri)) {
+-                        if (!ob.rendered) {
+-                                ob=(NameSpaceSymbEntry)ob.clone();
+-                needsClone();
+-                symb.put(prefix,ob);
+-                                ob.rendered=true;
+-                                ob.level=visibleNameSpaces;
+-                                return ob.n;
+-                        }
+-            ob=(NameSpaceSymbEntry)ob.clone();
++
++        if (ob!=null) {
+             needsClone();
+-            symb.put(prefix,ob);
+-                        if (outputNode && (((visibleNameSpaces-ob.level)<2) || XMLNS.equals(prefix)) ) {
+-                                ob.level=visibleNameSpaces;
+-                                return null; //Already rendered, just return nulll
+-                        }
+-                        ob.level=visibleNameSpaces;
+-                        return ob.n;
+-                }
++            symb.put(prefix,null);
++        }
++        }
+ 
+-                NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,true);
+-                ne.level=nameSpaces;
+-                ne.rendered=true;
+-        needsClone();
+-                symb.put(prefix, ne);
+-                if (ob != null) {
+-                        ne.lastrendered=ob.lastrendered;
++        public void removeMappingIfNotRender(String prefix) {
++                NameSpaceSymbEntry ob = symb.get(prefix);
+ 
+-                        if ((ob.lastrendered!=null)&& (ob.lastrendered.equals(uri))) {
+-                                ne.rendered=true;
+-                        }
+-                }
+-                return ne.n;
++        if (ob!=null && !ob.rendered) {
++            needsClone();
++            symb.put(prefix,null);
++        }
++        }
++
++        public boolean removeMappingIfRender(String prefix) {
++                NameSpaceSymbEntry ob = symb.get(prefix);
++
++        if (ob!=null && ob.rendered) {
++            needsClone();
++            symb.put(prefix,null);
++        }
++        return false;
+         }
+ }
+ 
+@@ -305,10 +290,11 @@
+  * The internal structure of NameSpaceSymbTable.
+  **/
+ class NameSpaceSymbEntry implements Cloneable {
+-    NameSpaceSymbEntry(String name,Attr n,boolean rendered) {
++    NameSpaceSymbEntry(String name,Attr n,boolean rendered,String prefix) {
+         this.uri=name;
+         this.rendered=rendered;
+         this.n=n;
++        this.prefix=prefix;
+     }
+     /** @inheritDoc */
+     public Object clone() {
+@@ -320,6 +306,7 @@
+     }
+     /** The level where the definition was rendered(Only for inclusive) */
+     int level=0;
++    String prefix;
+     /**The URI that the prefix defines */
+     String uri;
+     /**The last output in the URI for this prefix (This for speed reason).*/
+@@ -330,53 +317,57 @@
+     Attr n;
+ };
+ 
+-class SymbMap implements Cloneable{
+-        int free=23;
+-        NameSpaceSymbEntry[] entries=new NameSpaceSymbEntry[free];
+-        String[] keys=new String[free];
+-
+-        void put(String key, NameSpaceSymbEntry value) {
++class SymbMap implements Cloneable {
++    int free=23;
++    NameSpaceSymbEntry[] entries;
++    String[] keys;
++        SymbMap() {
++                entries=new NameSpaceSymbEntry[free];
++                keys=new String[free];
++        }
++    void put(String key, NameSpaceSymbEntry value) {
+         int index = index(key);
+-                Object oldKey = keys[index];
+-                keys[index] = key;
+-                entries[index] = value;
++        Object oldKey = keys[index];
++        keys[index] = key;
++        entries[index] = value;
+         if (oldKey==null || !oldKey.equals(key)) {
+-                if (--free == 0) {
+-                                free=entries.length;
+-                    int newCapacity = free<<2;
+-                    rehash(newCapacity);
+-                }
++            if (--free == 0) {
++                free=entries.length;
++                int newCapacity = free<<2;
++                rehash(newCapacity);
++            }
+         }
+     }
+ 
+     List entrySet() {
+-                List a=new ArrayList();
+-                for (int i=0;i<entries.length;i++) {
+-                        if ((entries[i]!=null) && !("".equals(entries[i]))) {
+-                                a.add(entries[i]);
+-                        }
+-                }
+-                return a;
++        List a=new ArrayList();
++        for (int i=0;i<entries.length;i++) {
++                if ((entries[i]!=null) && !("".equals(entries[i].uri))) {
++                        a.add(entries[i]);
++            }
+         }
++        return a;
++    }
+ 
+-
+-        protected int index(Object obj) {
++    protected int index(Object obj) {
+         Object[] set = keys;
+-                int length = set.length;
+-                //abs of index
++        int length = set.length;
++        //abs of index
+         int index = (obj.hashCode() & 0x7fffffff) %  length;
+         Object cur = set[index];
+ 
+         if (cur == null || (cur.equals( obj))) {
+-                        return index;
++                return index;
+         }
++        length=length-1;
+         do {
+-                        index=index==length? 0:++index;
+-                        cur = set[index];
++                index=index==length? 0:++index;
++                cur = set[index];
+         } while (cur != null && (!cur.equals(obj)));
+         return index;
+     }
+-         /**
++
++    /**
+      * rehashes the map to the new capacity.
+      *
+      * @param newCapacity an <code>int</code> value
+@@ -384,37 +375,38 @@
+     protected void rehash(int newCapacity) {
+         int oldCapacity = keys.length;
+         String oldKeys[] = keys;
+-                NameSpaceSymbEntry oldVals[] = entries;
++        NameSpaceSymbEntry oldVals[] = entries;
+ 
+-                keys = new String[newCapacity];
+-                entries = new NameSpaceSymbEntry[newCapacity];
++        keys = new String[newCapacity];
++        entries = new NameSpaceSymbEntry[newCapacity];
+ 
+         for (int i = oldCapacity; i-- > 0;) {
+             if(oldKeys[i] != null) {
+                 String o = oldKeys[i];
+                 int index = index(o);
+-                                keys[index] = o;
+-                                entries[index] = oldVals[i];
++                keys[index] = o;
++                entries[index] = oldVals[i];
+             }
+         }
+     }
+-         NameSpaceSymbEntry get(String key) {
+-                return  entries[index(key)];
+-            }
+-         protected Object clone()  {
+-                // TODO Auto-generated method stub
+-                try {
+-                        SymbMap copy=(SymbMap) super.clone();
+-                        copy.entries=new NameSpaceSymbEntry[entries.length];
+-                        System.arraycopy(entries,0,copy.entries,0,entries.length);
+-                        copy.keys=new String[keys.length];
+-                        System.arraycopy(keys,0,copy.keys,0,keys.length);
+ 
+-                        return copy;
+-                } catch (CloneNotSupportedException e) {
+-                        // TODO Auto-generated catch block
+-                        e.printStackTrace();
+-                }
+-                return null;
++    NameSpaceSymbEntry get(String key) {
++        return  entries[index(key)];
++    }
++
++    protected Object clone()  {
++        try {
++                SymbMap copy=(SymbMap) super.clone();
++                copy.entries=new NameSpaceSymbEntry[entries.length];
++                System.arraycopy(entries,0,copy.entries,0,entries.length);
++                copy.keys=new String[keys.length];
++                System.arraycopy(keys,0,copy.keys,0,keys.length);
++
++                return copy;
++        } catch (CloneNotSupportedException e) {
++            // TODO Auto-generated catch block
++            e.printStackTrace();
+         }
++        return null;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java
+@@ -0,0 +1,155 @@
++package com.sun.org.apache.xml.internal.security.c14n.implementations;
++
++import java.io.IOException;
++import java.io.OutputStream;
++import java.util.Map;
++
++public class UtfHelpper {
++
++        final static void writeByte(final String str,final OutputStream out,Map cache) throws IOException {
++                   byte []result=(byte[]) cache.get(str);
++                   if (result==null) {
++                           result=getStringInUtf8(str);
++                           cache.put(str,result);
++                   }
++
++                   out.write(result);
++
++           }
++
++        final static void writeCharToUtf8(final char c,final OutputStream out) throws IOException{
++                if (c < 0x80) {
++                out.write(c);
++                return;
++            }
++                if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){
++                //No Surrogates in sun java
++                out.write(0x3f);
++                return;
++        }
++            int bias;
++            int write;
++            char ch;
++            if (c > 0x07FF) {
++                ch=(char)(c>>>12);
++                write=0xE0;
++                if (ch>0) {
++                    write |= ( ch & 0x0F);
++                }
++                out.write(write);
++                write=0x80;
++                bias=0x3F;
++            } else {
++                write=0xC0;
++                bias=0x1F;
++            }
++            ch=(char)(c>>>6);
++            if (ch>0) {
++                 write|= (ch & bias);
++            }
++            out.write(write);
++            out.write(0x80 | ((c) & 0x3F));
++
++           }
++
++        final static void writeStringToUtf8(final String str,final OutputStream out) throws IOException{
++                final int length=str.length();
++                int i=0;
++            char c;
++                while (i<length) {
++                        c=str.charAt(i++);
++                if (c < 0x80)  {
++                    out.write(c);
++                    continue;
++                }
++                if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){
++                        //No Surrogates in sun java
++                        out.write(0x3f);
++                        continue;
++                }
++                char ch;
++                int bias;
++                int write;
++                if (c > 0x07FF) {
++                    ch=(char)(c>>>12);
++                    write=0xE0;
++                    if (ch>0) {
++                        write |= ( ch & 0x0F);
++                    }
++                    out.write(write);
++                    write=0x80;
++                    bias=0x3F;
++                } else {
++                        write=0xC0;
++                        bias=0x1F;
++                }
++                ch=(char)(c>>>6);
++                if (ch>0) {
++                     write|= (ch & bias);
++                }
++                out.write(write);
++                out.write(0x80 | ((c) & 0x3F));
++
++                }
++
++           }
++        public final static byte[] getStringInUtf8(final String str) {
++                   final int length=str.length();
++                   boolean expanded=false;
++                   byte []result=new byte[length];
++                        int i=0;
++                        int out=0;
++                    char c;
++                        while (i<length) {
++                                c=str.charAt(i++);
++                        if ( c < 0x80 ) {
++                            result[out++]=(byte)c;
++                            continue;
++                        }
++                        if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){
++                                   //No Surrogates in sun java
++                                   result[out++]=0x3f;
++
++                                continue;
++                        }
++                        if (!expanded) {
++                                byte newResult[]=new byte[3*length];
++                                        System.arraycopy(result, 0, newResult, 0, out);
++                                        result=newResult;
++                                        expanded=true;
++                        }
++                        char ch;
++                        int bias;
++                        byte write;
++                        if (c > 0x07FF) {
++                            ch=(char)(c>>>12);
++                            write=(byte)0xE0;
++                            if (ch>0) {
++                                write |= ( ch & 0x0F);
++                            }
++                            result[out++]=write;
++                            write=(byte)0x80;
++                            bias=0x3F;
++                        } else {
++                                write=(byte)0xC0;
++                                bias=0x1F;
++                        }
++                        ch=(char)(c>>>6);
++                        if (ch>0) {
++                             write|= (ch & bias);
++                        }
++                        result[out++]=write;
++                        result[out++]=(byte)(0x80 | ((c) & 0x3F));/**/
++
++                        }
++                        if (expanded) {
++                                byte newResult[]=new byte[out];
++                                System.arraycopy(result, 0, newResult, 0, out);
++                                result=newResult;
++                        }
++                        return result;
++           }
++
++
++
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java
+@@ -22,6 +22,7 @@
+ 
+ 
+ import java.io.ByteArrayOutputStream;
++import java.io.InputStream;
+ import java.io.IOException;
+ import java.io.StringReader;
+ import java.io.UnsupportedEncodingException;
+@@ -30,6 +31,7 @@
+ import java.security.Key;
+ import java.security.NoSuchAlgorithmException;
+ import java.security.NoSuchProviderException;
++import java.util.HashMap;
+ import java.util.Iterator;
+ import java.util.LinkedList;
+ import java.util.List;
+@@ -204,7 +206,7 @@
+      * @since 1.0.
+      */
+     private XMLCipher() {
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Constructing XMLCipher...");
++        logger.log(java.util.logging.Level.FINE, "Constructing XMLCipher...");
+ 
+         _factory = new Factory();
+         _serializer = new Serializer();
+@@ -266,7 +268,7 @@
+     public static XMLCipher getInstance(String transformation) throws
+             XMLEncryptionException {
+         // sanity checks
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Getting XMLCipher...");
++        logger.log(java.util.logging.Level.FINE, "Getting XMLCipher...");
+         if (null == transformation)
+             logger.log(java.util.logging.Level.SEVERE, "Transformation unexpectedly null...");
+         if(!isValidEncryptionAlgorithm(transformation))
+@@ -294,7 +296,7 @@
+ 
+                 try {
+             instance._contextCipher = Cipher.getInstance(jceAlgorithm);
+-            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "cihper.algoritm = " +
++            logger.log(java.util.logging.Level.FINE, "cihper.algoritm = " +
+                 instance._contextCipher.getAlgorithm());
+         } catch (NoSuchAlgorithmException nsae) {
+             throw new XMLEncryptionException("empty", nsae);
+@@ -305,49 +307,6 @@
+         return (instance);
+     }
+ 
+-    public static XMLCipher getInstance(String transformation,Cipher cipher) throws
+-            XMLEncryptionException {
+-        // sanity checks
+-        logger.log(java.util.logging.Level.FINE, "Getting XMLCipher...");
+-        if (null == transformation)
+-            logger.log(java.util.logging.Level.SEVERE, "Transformation unexpectedly null...");
+-        if(!isValidEncryptionAlgorithm(transformation))
+-            logger.log(java.util.logging.Level.WARNING, "Algorithm non-standard, expected one of " + ENC_ALGORITHMS);
+-
+-        XMLCipher instance = new XMLCipher();
+-
+-        instance._algorithm = transformation;
+-        instance._key = null;
+-        instance._kek = null;
+-
+-
+-                /* Create a canonicaliser - used when serialising DOM to octets
+-                 * prior to encryption (and for the reverse) */
+-
+-        try {
+-            instance._canon = Canonicalizer.getInstance
+-                    (Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS);
+-
+-        } catch (InvalidCanonicalizerException ice) {
+-            throw new XMLEncryptionException("empty", ice);
+-        }
+-
+-        String jceAlgorithm = JCEMapper.translateURItoJCEID(transformation);
+-
+-        try {
+-            instance._contextCipher = cipher;
+-            //Cipher.getInstance(jceAlgorithm);
+-            logger.log(java.util.logging.Level.FINE, "cihper.algoritm = " +
+-                    instance._contextCipher.getAlgorithm());
+-        }catch(Exception ex) {
+-            throw new XMLEncryptionException("empty", ex);
+-        }
+-
+-        return (instance);
+-    }
+-
+-
+-
+         /**
+          * Returns an <code>XMLCipher</code> that implements the specified
+          * transformation, operates on the specified context document and serializes
+@@ -380,6 +339,45 @@
+                 return instance;
+         }
+ 
++    public static XMLCipher getInstance(String transformation,Cipher cipher) throws XMLEncryptionException {
++        // sanity checks
++        logger.log(java.util.logging.Level.FINE, "Getting XMLCipher...");
++        if (null == transformation)
++            logger.log(java.util.logging.Level.SEVERE, "Transformation unexpectedly null...");
++        if(!isValidEncryptionAlgorithm(transformation))
++            logger.log(java.util.logging.Level.WARNING, "Algorithm non-standard, expected one of " + ENC_ALGORITHMS);
++
++        XMLCipher instance = new XMLCipher();
++
++        instance._algorithm = transformation;
++        instance._key = null;
++        instance._kek = null;
++
++
++        /* Create a canonicaliser - used when serialising DOM to octets
++         * prior to encryption (and for the reverse) */
++
++        try {
++            instance._canon = Canonicalizer.getInstance
++                    (Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS);
++
++        } catch (InvalidCanonicalizerException ice) {
++            throw new XMLEncryptionException("empty", ice);
++        }
++
++        String jceAlgorithm = JCEMapper.translateURItoJCEID(transformation);
++
++        try {
++            instance._contextCipher = cipher;
++            //Cipher.getInstance(jceAlgorithm);
++            logger.log(java.util.logging.Level.FINE, "cihper.algoritm = " +
++                    instance._contextCipher.getAlgorithm());
++        }catch(Exception ex) {
++            throw new XMLEncryptionException("empty", ex);
++        }
++
++        return (instance);
++    }
+ 
+     /**
+      * Returns an <code>XMLCipher</code> that implements the specified
+@@ -396,7 +394,7 @@
+     public static XMLCipher getProviderInstance(String transformation, String provider)
+             throws XMLEncryptionException {
+         // sanity checks
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Getting XMLCipher...");
++        logger.log(java.util.logging.Level.FINE, "Getting XMLCipher...");
+         if (null == transformation)
+             logger.log(java.util.logging.Level.SEVERE, "Transformation unexpectedly null...");
+         if(null == provider)
+@@ -429,9 +427,9 @@
+ 
+             instance._contextCipher = Cipher.getInstance(jceAlgorithm, provider);
+ 
+-            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "cipher._algorithm = " +
++            logger.log(java.util.logging.Level.FINE, "cipher._algorithm = " +
+                 instance._contextCipher.getAlgorithm());
+-            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "provider.name = " + provider);
++            logger.log(java.util.logging.Level.FINE, "provider.name = " + provider);
+         } catch (NoSuchAlgorithmException nsae) {
+             throw new XMLEncryptionException("empty", nsae);
+         } catch (NoSuchProviderException nspre) {
+@@ -490,7 +488,7 @@
+     public static XMLCipher getInstance()
+             throws XMLEncryptionException {
+         // sanity checks
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Getting XMLCipher for no transformation...");
++        logger.log(java.util.logging.Level.FINE, "Getting XMLCipher for no transformation...");
+ 
+                 XMLCipher instance = new XMLCipher();
+ 
+@@ -532,7 +530,7 @@
+             throws XMLEncryptionException {
+         // sanity checks
+ 
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Getting XMLCipher, provider but no transformation");
++        logger.log(java.util.logging.Level.FINE, "Getting XMLCipher, provider but no transformation");
+         if(null == provider)
+             logger.log(java.util.logging.Level.SEVERE, "Provider unexpectedly null..");
+         if("" == provider)
+@@ -578,7 +576,7 @@
+      */
+     public void init(int opmode, Key key) throws XMLEncryptionException {
+         // sanity checks
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Initializing XMLCipher...");
++        logger.log(java.util.logging.Level.FINE, "Initializing XMLCipher...");
+ 
+                 _ek = null;
+                 _ed = null;
+@@ -586,18 +584,18 @@
+                 switch (opmode) {
+ 
+                 case ENCRYPT_MODE :
+-                        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "opmode = ENCRYPT_MODE");
++                        logger.log(java.util.logging.Level.FINE, "opmode = ENCRYPT_MODE");
+                         _ed = createEncryptedData(CipherData.VALUE_TYPE, "NO VALUE YET");
+                         break;
+                 case DECRYPT_MODE :
+-                        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "opmode = DECRYPT_MODE");
++                        logger.log(java.util.logging.Level.FINE, "opmode = DECRYPT_MODE");
+                         break;
+                 case WRAP_MODE :
+-                        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "opmode = WRAP_MODE");
++                        logger.log(java.util.logging.Level.FINE, "opmode = WRAP_MODE");
+                         _ek = createEncryptedKey(CipherData.VALUE_TYPE, "NO VALUE YET");
+                         break;
+                 case UNWRAP_MODE :
+-                        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "opmode = UNWRAP_MODE");
++                        logger.log(java.util.logging.Level.FINE, "opmode = UNWRAP_MODE");
+                         break;
+                 default :
+                         logger.log(java.util.logging.Level.SEVERE, "Mode unexpectedly invalid");
+@@ -622,7 +620,7 @@
+         public EncryptedData getEncryptedData() {
+ 
+                 // Sanity checks
+-                if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Returning EncryptedData");
++                logger.log(java.util.logging.Level.FINE, "Returning EncryptedData");
+                 return _ed;
+ 
+         }
+@@ -640,7 +638,7 @@
+         public EncryptedKey getEncryptedKey() {
+ 
+                 // Sanity checks
+-                if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Returning EncryptedKey");
++                logger.log(java.util.logging.Level.FINE, "Returning EncryptedKey");
+                 return _ek;
+         }
+ 
+@@ -750,11 +748,11 @@
+      */
+ 
+     private Document encryptElement(Element element) throws Exception{
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Encrypting element...");
++        logger.log(java.util.logging.Level.FINE, "Encrypting element...");
+         if(null == element)
+             logger.log(java.util.logging.Level.SEVERE, "Element unexpectedly null...");
+         if(_cipherMode != ENCRYPT_MODE)
+-            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in ENCRYPT_MODE...");
++            logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in ENCRYPT_MODE...");
+ 
+                 if (_algorithm == null) {
+                 throw new XMLEncryptionException("XMLCipher instance without transformation specified");
+@@ -785,11 +783,11 @@
+      */
+     private Document encryptElementContent(Element element) throws
+             /* XMLEncryption */Exception {
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Encrypting element content...");
++        logger.log(java.util.logging.Level.FINE, "Encrypting element content...");
+         if(null == element)
+             logger.log(java.util.logging.Level.SEVERE, "Element unexpectedly null...");
+         if(_cipherMode != ENCRYPT_MODE)
+-            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in ENCRYPT_MODE...");
++            logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in ENCRYPT_MODE...");
+ 
+                 if (_algorithm == null) {
+                 throw new XMLEncryptionException("XMLCipher instance without transformation specified");
+@@ -815,7 +813,7 @@
+      */
+     public Document doFinal(Document context, Document source) throws
+             /* XMLEncryption */Exception {
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Processing source document...");
++        logger.log(java.util.logging.Level.FINE, "Processing source document...");
+         if(null == context)
+             logger.log(java.util.logging.Level.SEVERE, "Context document unexpectedly null...");
+         if(null == source)
+@@ -855,7 +853,7 @@
+      */
+     public Document doFinal(Document context, Element element) throws
+             /* XMLEncryption */Exception {
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Processing source element...");
++        logger.log(java.util.logging.Level.FINE, "Processing source element...");
+         if(null == context)
+             logger.log(java.util.logging.Level.SEVERE, "Context document unexpectedly null...");
+         if(null == element)
+@@ -898,7 +896,7 @@
+      */
+     public Document doFinal(Document context, Element element, boolean content)
+             throws /* XMLEncryption*/ Exception {
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Processing source element...");
++        logger.log(java.util.logging.Level.FINE, "Processing source element...");
+         if(null == context)
+             logger.log(java.util.logging.Level.SEVERE, "Context document unexpectedly null...");
+         if(null == element)
+@@ -954,6 +952,34 @@
+ 
+     /**
+      * Returns an <code>EncryptedData</code> interface. Use this operation if
++     * you want to have full control over the serialization of the element
++     * or element content.
++     *
++     * This does not change the source document in any way.
++     *
++     * @param context the context <code>Document</code>.
++     * @param type a URI identifying type information about the plaintext form
++     *    of the encrypted content (may be <code>null</code>)
++     * @param serializedData the serialized data
++     * @return the <code>EncryptedData</code>
++     * @throws Exception
++     */
++    public EncryptedData encryptData(Document context, String type,
++        InputStream serializedData) throws Exception {
++
++        logger.log(java.util.logging.Level.FINE, "Encrypting element...");
++        if (null == context)
++            logger.log(java.util.logging.Level.SEVERE, "Context document unexpectedly null...");
++        if (null == serializedData)
++            logger.log(java.util.logging.Level.SEVERE, "Serialized data unexpectedly null...");
++        if (_cipherMode != ENCRYPT_MODE)
++            logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in ENCRYPT_MODE...");
++
++        return encryptData(context, null, type, serializedData);
++    }
++
++    /**
++     * Returns an <code>EncryptedData</code> interface. Use this operation if
+      * you want to have full control over the contents of the
+      * <code>EncryptedData</code> structure.
+      *
+@@ -966,160 +992,60 @@
+      * @return the <code>EncryptedData</code>
+      * @throws Exception
+      */
+-    public EncryptedData encryptData(Document context, Element element, boolean contentMode) throws
+-            /* XMLEncryption */ Exception {
+-                if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Encrypting element...");
+-                if (null == context)
+-                        logger.log(java.util.logging.Level.SEVERE, "Context document unexpectedly null...");
+-                if (null == element)
+-                        logger.log(java.util.logging.Level.SEVERE, "Element unexpectedly null...");
+-                if (_cipherMode != ENCRYPT_MODE)
+-                        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in ENCRYPT_MODE...");
+-
+-                _contextDocument = context;
+-
+-                if (_algorithm == null) {
+-                        throw new XMLEncryptionException("XMLCipher instance without transformation specified");
+-                }
+-
+-                String serializedOctets = null;
+-                if (contentMode) {
+-                        NodeList children = element.getChildNodes();
+-                        if ((null != children)) {
+-                                serializedOctets = _serializer.serialize(children);
+-                        } else {
+-                                Object exArgs[] = { "Element has no content." };
+-                                throw new XMLEncryptionException("empty", exArgs);
+-                        }
+-                } else {
+-                        serializedOctets = _serializer.serialize(element);
+-                }
+-                if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Serialized octets:\n" + serializedOctets);
+-
+-        byte[] encryptedBytes = null;
+-
+-                // Now create the working cipher if none was created already
+-                Cipher c;
+-                if (_contextCipher == null) {
+-                        String jceAlgorithm =
+-                                JCEMapper.translateURItoJCEID(_algorithm);
+-
+-                        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "alg = " + jceAlgorithm);
+-
+-                        try {
+-                            if (_requestedJCEProvider == null)
+-                                c = Cipher.getInstance(jceAlgorithm);
+-                            else
+-                                c = Cipher.getInstance(jceAlgorithm, _requestedJCEProvider);
+-                        } catch (NoSuchAlgorithmException nsae) {
+-                                throw new XMLEncryptionException("empty", nsae);
+-                        } catch (NoSuchProviderException nspre) {
+-                                throw new XMLEncryptionException("empty", nspre);
+-                        } catch (NoSuchPaddingException nspae) {
+-                                throw new XMLEncryptionException("empty", nspae);
+-                        }
+-                }
+-                else {
+-                        c = _contextCipher;
+-                }
+-                // Now perform the encryption
+-
+-                try {
+-                        // Should internally generate an IV
+-                        // todo - allow user to set an IV
+-                        c.init(_cipherMode, _key);
+-                } catch (InvalidKeyException ike) {
+-                        throw new XMLEncryptionException("empty", ike);
+-                }
+-
+-        try {
+-            encryptedBytes =
+-                c.doFinal(serializedOctets.getBytes("UTF-8"));
+-
+-            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Expected cipher.outputSize = " +
+-                Integer.toString(c.getOutputSize(
+-                    serializedOctets.getBytes().length)));
+-            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Actual cipher.outputSize = " +
+-                Integer.toString(encryptedBytes.length));
+-        } catch (IllegalStateException ise) {
+-            throw new XMLEncryptionException("empty", ise);
+-        } catch (IllegalBlockSizeException ibse) {
+-            throw new XMLEncryptionException("empty", ibse);
+-        } catch (BadPaddingException bpe) {
+-            throw new XMLEncryptionException("empty", bpe);
+-        } catch (UnsupportedEncodingException uee) {
+-                        throw new XMLEncryptionException("empty", uee);
+-                }
+-
+-                // Now build up to a properly XML Encryption encoded octet stream
+-                // IvParameterSpec iv;
+-
+-                byte[] iv = c.getIV();
+-                byte[] finalEncryptedBytes =
+-                        new byte[iv.length + encryptedBytes.length];
+-                System.arraycopy(iv, 0, finalEncryptedBytes, 0,
+-                                                 iv.length);
+-                System.arraycopy(encryptedBytes, 0, finalEncryptedBytes,
+-                                                 iv.length,
+-                                                 encryptedBytes.length);
+-
+-        String base64EncodedEncryptedOctets = Base64.encode(finalEncryptedBytes);
+-
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Encrypted octets:\n" + base64EncodedEncryptedOctets);
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Encrypted octets length = " +
+-            base64EncodedEncryptedOctets.length());
+-
+-                try {
+-                        CipherData cd = _ed.getCipherData();
+-                        CipherValue cv = cd.getCipherValue();
+-                        // cv.setValue(base64EncodedEncryptedOctets.getBytes());
+-                        cv.setValue(base64EncodedEncryptedOctets);
+-
+-                        if (contentMode) {
+-                                _ed.setType(
+-                                        new URI(EncryptionConstants.TYPE_CONTENT).toString());
+-                        } else {
+-                                _ed.setType(
+-                                        new URI(EncryptionConstants.TYPE_ELEMENT).toString());
+-                        }
+-                        EncryptionMethod method =
+-                                _factory.newEncryptionMethod(new URI(_algorithm).toString());
+-                        _ed.setEncryptionMethod(method);
+-                } catch (URI.MalformedURIException mfue) {
+-                        throw new XMLEncryptionException("empty", mfue);
+-                }
+-        return (_ed);
+-    }
+-
+-
+-
+-    public EncryptedData encryptData(Document context, byte [] serializedOctets, boolean contentMode) throws
+-            /* XMLEncryption */ Exception {
++    public EncryptedData encryptData(
++        Document context, Element element, boolean contentMode)
++        throws /* XMLEncryption */ Exception {
++
+         logger.log(java.util.logging.Level.FINE, "Encrypting element...");
+         if (null == context)
+             logger.log(java.util.logging.Level.SEVERE, "Context document unexpectedly null...");
+-        if (null == serializedOctets)
+-            logger.log(java.util.logging.Level.SEVERE, "Canonicalized Data is unexpectedly null...");
++        if (null == element)
++            logger.log(java.util.logging.Level.SEVERE, "Element unexpectedly null...");
+         if (_cipherMode != ENCRYPT_MODE)
+             logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in ENCRYPT_MODE...");
+ 
++        if (contentMode) {
++            return encryptData
++                (context, element, EncryptionConstants.TYPE_CONTENT, null);
++        } else {
++            return encryptData
++                (context, element, EncryptionConstants.TYPE_ELEMENT, null);
++        }
++    }
++
++    private EncryptedData encryptData(
++        Document context, Element element, String type,
++        InputStream serializedData) throws /* XMLEncryption */ Exception {
++
+         _contextDocument = context;
+ 
+         if (_algorithm == null) {
+-            throw new XMLEncryptionException("XMLCipher instance without transformation specified");
++            throw new XMLEncryptionException
++                ("XMLCipher instance without transformation specified");
+         }
+ 
+-
+-        logger.log(java.util.logging.Level.FINE, "Serialized octets:\n" + serializedOctets);
++        String serializedOctets = null;
++        if (serializedData == null) {
++            if (type == EncryptionConstants.TYPE_CONTENT) {
++                NodeList children = element.getChildNodes();
++                if (null != children) {
++                    serializedOctets = _serializer.serialize(children);
++                } else {
++                    Object exArgs[] = { "Element has no content." };
++                    throw new XMLEncryptionException("empty", exArgs);
++                }
++            } else {
++                serializedOctets = _serializer.serialize(element);
++            }
++            logger.log(java.util.logging.Level.FINE, "Serialized octets:\n" + serializedOctets);
++        }
+ 
+         byte[] encryptedBytes = null;
+ 
+         // Now create the working cipher if none was created already
+         Cipher c;
+         if (_contextCipher == null) {
+-            String jceAlgorithm =
+-                    JCEMapper.translateURItoJCEID(_algorithm);
+-
++            String jceAlgorithm = JCEMapper.translateURItoJCEID(_algorithm);
+             logger.log(java.util.logging.Level.FINE, "alg = " + jceAlgorithm);
+ 
+             try {
+@@ -1148,41 +1074,47 @@
+         }
+ 
+         try {
+-            encryptedBytes =
+-                    c.doFinal(serializedOctets);
+-
+-            logger.log(java.util.logging.Level.FINE, "Expected cipher.outputSize = " +
++            if (serializedData != null) {
++                int numBytes;
++                byte[] buf = new byte[8192];
++                ByteArrayOutputStream baos = new ByteArrayOutputStream();
++                while ((numBytes = serializedData.read(buf)) != -1) {
++                    byte[] data = c.update(buf, 0, numBytes);
++                    baos.write(data);
++                }
++                baos.write(c.doFinal());
++                encryptedBytes = baos.toByteArray();
++            } else {
++                encryptedBytes = c.doFinal(serializedOctets.getBytes("UTF-8"));
++                logger.log(java.util.logging.Level.FINE, "Expected cipher.outputSize = " +
+                     Integer.toString(c.getOutputSize(
+-                    serializedOctets.length)));
++                        serializedOctets.getBytes().length)));
++            }
+             logger.log(java.util.logging.Level.FINE, "Actual cipher.outputSize = " +
+-                    Integer.toString(encryptedBytes.length));
++                Integer.toString(encryptedBytes.length));
+         } catch (IllegalStateException ise) {
+             throw new XMLEncryptionException("empty", ise);
+         } catch (IllegalBlockSizeException ibse) {
+             throw new XMLEncryptionException("empty", ibse);
+         } catch (BadPaddingException bpe) {
+             throw new XMLEncryptionException("empty", bpe);
+-        } catch (Exception uee) {
++        } catch (UnsupportedEncodingException uee) {
+             throw new XMLEncryptionException("empty", uee);
+         }
+ 
+         // Now build up to a properly XML Encryption encoded octet stream
+         // IvParameterSpec iv;
+-
+         byte[] iv = c.getIV();
+         byte[] finalEncryptedBytes =
+                 new byte[iv.length + encryptedBytes.length];
+-        System.arraycopy(iv, 0, finalEncryptedBytes, 0,
+-                iv.length);
+-        System.arraycopy(encryptedBytes, 0, finalEncryptedBytes,
+-                iv.length,
+-                encryptedBytes.length);
+-
++        System.arraycopy(iv, 0, finalEncryptedBytes, 0, iv.length);
++        System.arraycopy(encryptedBytes, 0, finalEncryptedBytes, iv.length,
++                         encryptedBytes.length);
+         String base64EncodedEncryptedOctets = Base64.encode(finalEncryptedBytes);
+ 
+         logger.log(java.util.logging.Level.FINE, "Encrypted octets:\n" + base64EncodedEncryptedOctets);
+         logger.log(java.util.logging.Level.FINE, "Encrypted octets length = " +
+-                base64EncodedEncryptedOctets.length());
++            base64EncodedEncryptedOctets.length());
+ 
+         try {
+             CipherData cd = _ed.getCipherData();
+@@ -1190,15 +1122,11 @@
+             // cv.setValue(base64EncodedEncryptedOctets.getBytes());
+             cv.setValue(base64EncodedEncryptedOctets);
+ 
+-            if (contentMode) {
+-                _ed.setType(
+-                        new URI(EncryptionConstants.TYPE_CONTENT).toString());
+-            } else {
+-                _ed.setType(
+-                        new URI(EncryptionConstants.TYPE_ELEMENT).toString());
++            if (type != null) {
++                _ed.setType(new URI(type).toString());
+             }
+             EncryptionMethod method =
+-                    _factory.newEncryptionMethod(new URI(_algorithm).toString());
++                _factory.newEncryptionMethod(new URI(_algorithm).toString());
+             _ed.setEncryptionMethod(method);
+         } catch (URI.MalformedURIException mfue) {
+             throw new XMLEncryptionException("empty", mfue);
+@@ -1206,7 +1134,6 @@
+         return (_ed);
+     }
+ 
+-
+     /**
+      * Returns an <code>EncryptedData</code> interface. Use this operation if
+      * you want to load an <code>EncryptedData</code> structure from a DOM
+@@ -1219,7 +1146,7 @@
+      */
+     public EncryptedData loadEncryptedData(Document context, Element element)
+                 throws XMLEncryptionException {
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Loading encrypted element...");
++        logger.log(java.util.logging.Level.FINE, "Loading encrypted element...");
+         if(null == context)
+             logger.log(java.util.logging.Level.SEVERE, "Context document unexpectedly null...");
+         if(null == element)
+@@ -1246,13 +1173,13 @@
+ 
+     public EncryptedKey loadEncryptedKey(Document context, Element element)
+                 throws XMLEncryptionException {
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Loading encrypted key...");
++        logger.log(java.util.logging.Level.FINE, "Loading encrypted key...");
+         if(null == context)
+             logger.log(java.util.logging.Level.SEVERE, "Context document unexpectedly null...");
+         if(null == element)
+             logger.log(java.util.logging.Level.SEVERE, "Element unexpectedly null...");
+         if(_cipherMode != UNWRAP_MODE && _cipherMode != DECRYPT_MODE)
+-            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in UNWRAP_MODE or DECRYPT_MODE...");
++            logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in UNWRAP_MODE or DECRYPT_MODE...");
+ 
+         _contextDocument = context;
+         _ek = _factory.newEncryptedKey(element);
+@@ -1290,12 +1217,12 @@
+     public EncryptedKey encryptKey(Document doc, Key key) throws
+             XMLEncryptionException {
+ 
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Encrypting key ...");
++        logger.log(java.util.logging.Level.FINE, "Encrypting key ...");
+ 
+         if(null == key)
+             logger.log(java.util.logging.Level.SEVERE, "Key unexpectedly null...");
+         if(_cipherMode != WRAP_MODE)
+-            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in WRAP_MODE...");
++            logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in WRAP_MODE...");
+ 
+                 if (_algorithm == null) {
+ 
+@@ -1313,7 +1240,7 @@
+                         String jceAlgorithm =
+                                 JCEMapper.translateURItoJCEID(_algorithm);
+ 
+-                        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "alg = " + jceAlgorithm);
++                        logger.log(java.util.logging.Level.FINE, "alg = " + jceAlgorithm);
+ 
+                         try {
+                             if (_requestedJCEProvider == null)
+@@ -1345,8 +1272,8 @@
+ 
+         String base64EncodedEncryptedOctets = Base64.encode(encryptedBytes);
+ 
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Encrypted key octets:\n" + base64EncodedEncryptedOctets);
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Encrypted key octets length = " +
++        logger.log(java.util.logging.Level.FINE, "Encrypted key octets:\n" + base64EncodedEncryptedOctets);
++        logger.log(java.util.logging.Level.FINE, "Encrypted key octets length = " +
+             base64EncodedEncryptedOctets.length());
+ 
+                 CipherValue cv = _ek.getCipherData().getCipherValue();
+@@ -1376,10 +1303,10 @@
+         public Key decryptKey(EncryptedKey encryptedKey, String algorithm) throws
+                     XMLEncryptionException {
+ 
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Decrypting key from previously loaded EncryptedKey...");
++        logger.log(java.util.logging.Level.FINE, "Decrypting key from previously loaded EncryptedKey...");
+ 
+         if(_cipherMode != UNWRAP_MODE)
+-            if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in UNWRAP_MODE...");
++            logger.log(java.util.logging.Level.FINE, "XMLCipher unexpectedly not in UNWRAP_MODE...");
+ 
+                 if (algorithm == null) {
+                         throw new XMLEncryptionException("Cannot decrypt a key without knowing the algorithm");
+@@ -1387,7 +1314,7 @@
+ 
+                 if (_key == null) {
+ 
+-                        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Trying to find a KEK via key resolvers");
++                        logger.log(java.util.logging.Level.FINE, "Trying to find a KEK via key resolvers");
+ 
+                         KeyInfo ki = encryptedKey.getKeyInfo();
+                         if (ki != null) {
+@@ -1418,7 +1345,7 @@
+                                 JCEMapper.translateURItoJCEID(
+                                         encryptedKey.getEncryptionMethod().getAlgorithm());
+ 
+-                        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "JCE Algorithm = " + jceAlgorithm);
++                        logger.log(java.util.logging.Level.FINE, "JCE Algorithm = " + jceAlgorithm);
+ 
+                         try {
+                             if (_requestedJCEProvider == null)
+@@ -1448,7 +1375,7 @@
+                         throw new XMLEncryptionException("empty", nsae);
+                 }
+ 
+-                if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Decryption of key type " + algorithm + " OK");
++                logger.log(java.util.logging.Level.FINE, "Decryption of key type " + algorithm + " OK");
+ 
+                 return ret;
+ 
+@@ -1478,14 +1405,9 @@
+      *
+      * @param node the <code>Node</code> to clear.
+      */
+-    private void removeContent(Node node) {
+-        NodeList list = node.getChildNodes();
+-        if (list.getLength() > 0) {
+-            Node n = list.item(0);
+-            if (null != n) {
+-                n.getParentNode().removeChild(n);
+-            }
+-            removeContent(node);
++    private static void removeContent(Node node) {
++       while (node.hasChildNodes()) {
++            node.removeChild(node.getFirstChild());
+         }
+     }
+ 
+@@ -1499,7 +1421,7 @@
+     private Document decryptElement(Element element) throws
+             XMLEncryptionException {
+ 
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Decrypting element...");
++        logger.log(java.util.logging.Level.FINE, "Decrypting element...");
+ 
+         if(_cipherMode != DECRYPT_MODE)
+             logger.log(java.util.logging.Level.SEVERE, "XMLCipher unexpectedly not in DECRYPT_MODE...");
+@@ -1512,7 +1434,7 @@
+                 }
+ 
+ 
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Decrypted octets:\n" + octets);
++        logger.log(java.util.logging.Level.FINE, "Decrypted octets:\n" + octets);
+ 
+         Node sourceParent =  element.getParentNode();
+ 
+@@ -1573,7 +1495,7 @@
+         public byte[] decryptToByteArray(Element element)
+                 throws XMLEncryptionException {
+ 
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Decrypting to ByteArray...");
++        logger.log(java.util.logging.Level.FINE, "Decrypting to ByteArray...");
+ 
+         if(_cipherMode != DECRYPT_MODE)
+             logger.log(java.util.logging.Level.SEVERE, "XMLCipher unexpectedly not in DECRYPT_MODE...");
+@@ -2226,7 +2148,7 @@
+         AgreementMethod newAgreementMethod(Element element) throws
+                 XMLEncryptionException {
+             if (null == element) {
+-                //complain
++                throw new NullPointerException("element is null");
+             }
+ 
+             String algorithm = element.getAttributeNS(null,
+@@ -2292,7 +2214,7 @@
+         CipherData newCipherData(Element element) throws
+                 XMLEncryptionException {
+             if (null == element) {
+-                // complain
++                throw new NullPointerException("element is null");
+             }
+ 
+             int type = 0;
+@@ -2352,7 +2274,7 @@
+                                 (Element) transformsElements.item(0);
+ 
+                         if (transformsElement != null) {
+-                                if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Creating a DSIG based Transforms element");
++                                logger.log(java.util.logging.Level.FINE, "Creating a DSIG based Transforms element");
+                                 try {
+                                         result.setTransforms(new TransformsImpl(transformsElement));
+                                 }
+@@ -2411,34 +2333,28 @@
+                         XMLEncryptionException {
+             EncryptedData result = null;
+ 
+-                        NodeList dataElements = element.getElementsByTagNameNS(
+-                    EncryptionConstants.EncryptionSpecNS,
+-                    EncryptionConstants._TAG_CIPHERDATA);
+-
+-                        // Need to get the last CipherData found, as earlier ones will
+-                        // be for elements in the KeyInfo lists
++            NodeList dataElements = element.getElementsByTagNameNS(
++                EncryptionConstants.EncryptionSpecNS,
++                EncryptionConstants._TAG_CIPHERDATA);
++
++            // Need to get the last CipherData found, as earlier ones will
++            // be for elements in the KeyInfo lists
+ 
+             Element dataElement =
+-                                (Element) dataElements.item(dataElements.getLength() - 1);
++                (Element) dataElements.item(dataElements.getLength() - 1);
+ 
+             CipherData data = newCipherData(dataElement);
+ 
+             result = newEncryptedData(data);
+ 
+-            try {
+-                result.setId(element.getAttributeNS(
+-                    null, EncryptionConstants._ATT_ID));
+-                result.setType(new URI(
+-                    element.getAttributeNS(
+-                        null, EncryptionConstants._ATT_TYPE)).toString());
+-                result.setMimeType(element.getAttributeNS(
+-                    null, EncryptionConstants._ATT_MIMETYPE));
+-                result.setEncoding(new URI(
+-                    element.getAttributeNS(
+-                        null, Constants._ATT_ENCODING)).toString());
+-            } catch (URI.MalformedURIException mfue) {
+-                // do nothing
+-            }
++            result.setId(element.getAttributeNS(
++                null, EncryptionConstants._ATT_ID));
++            result.setType(
++                element.getAttributeNS(null, EncryptionConstants._ATT_TYPE));
++            result.setMimeType(element.getAttributeNS(
++                null, EncryptionConstants._ATT_MIMETYPE));
++            result.setEncoding(
++                element.getAttributeNS(null, Constants._ATT_ENCODING));
+ 
+             Element encryptionMethodElement =
+                 (Element) element.getElementsByTagNameNS(
+@@ -2450,18 +2366,18 @@
+             }
+ 
+             // BFL 16/7/03 - simple implementation
+-                        // TODO: Work out how to handle relative URI
++            // TODO: Work out how to handle relative URI
+ 
+             Element keyInfoElement =
+                 (Element) element.getElementsByTagNameNS(
+                     Constants.SignatureSpecNS, Constants._TAG_KEYINFO).item(0);
+             if (null != keyInfoElement) {
+-                                try {
+-                                        result.setKeyInfo(new KeyInfo(keyInfoElement, null));
+-                                } catch (XMLSecurityException xse) {
+-                                        throw new XMLEncryptionException("Error loading Key Info",
+-                                                                                                         xse);
+-                                }
++                try {
++                    result.setKeyInfo(new KeyInfo(keyInfoElement, null));
++                } catch (XMLSecurityException xse) {
++                    throw new XMLEncryptionException("Error loading Key Info",
++                                                     xse);
++                }
+             }
+ 
+             // TODO: Implement
+@@ -2511,31 +2427,25 @@
+         EncryptedKey newEncryptedKey(Element element) throws
+                 XMLEncryptionException {
+             EncryptedKey result = null;
+-                        NodeList dataElements = element.getElementsByTagNameNS(
+-                    EncryptionConstants.EncryptionSpecNS,
+-                    EncryptionConstants._TAG_CIPHERDATA);
++            NodeList dataElements = element.getElementsByTagNameNS(
++                EncryptionConstants.EncryptionSpecNS,
++                EncryptionConstants._TAG_CIPHERDATA);
+             Element dataElement =
+-                                (Element) dataElements.item(dataElements.getLength() - 1);
++                (Element) dataElements.item(dataElements.getLength() - 1);
+ 
+             CipherData data = newCipherData(dataElement);
+             result = newEncryptedKey(data);
+ 
+-            try {
+-                result.setId(element.getAttributeNS(
+-                    null, EncryptionConstants._ATT_ID));
+-                result.setType(new URI(
+-                    element.getAttributeNS(
+-                        null, EncryptionConstants._ATT_TYPE)).toString());
+-                result.setMimeType(element.getAttributeNS(
+-                    null, EncryptionConstants._ATT_MIMETYPE));
+-                result.setEncoding(new URI(
+-                    element.getAttributeNS(
+-                        null, Constants._ATT_ENCODING)).toString());
+-                result.setRecipient(element.getAttributeNS(
+-                    null, EncryptionConstants._ATT_RECIPIENT));
+-            } catch (URI.MalformedURIException mfue) {
+-                // do nothing
+-            }
++            result.setId(element.getAttributeNS(
++                null, EncryptionConstants._ATT_ID));
++            result.setType(
++                element.getAttributeNS(null, EncryptionConstants._ATT_TYPE));
++            result.setMimeType(element.getAttributeNS(
++                null, EncryptionConstants._ATT_MIMETYPE));
++            result.setEncoding(
++                element.getAttributeNS(null, Constants._ATT_ENCODING));
++            result.setRecipient(element.getAttributeNS(
++                null, EncryptionConstants._ATT_RECIPIENT));
+ 
+             Element encryptionMethodElement =
+                 (Element) element.getElementsByTagNameNS(
+@@ -2550,12 +2460,12 @@
+                 (Element) element.getElementsByTagNameNS(
+                     Constants.SignatureSpecNS, Constants._TAG_KEYINFO).item(0);
+             if (null != keyInfoElement) {
+-                                try {
+-                                        result.setKeyInfo(new KeyInfo(keyInfoElement, null));
+-                                } catch (XMLSecurityException xse) {
+-                                        throw new XMLEncryptionException("Error loading Key Info",
+-                                                                                                         xse);
+-                                }
++                try {
++                    result.setKeyInfo(new KeyInfo(keyInfoElement, null));
++                } catch (XMLSecurityException xse) {
++                    throw new XMLEncryptionException
++                        ("Error loading Key Info", xse);
++                }
+             }
+ 
+             // TODO: Implement
+@@ -2581,7 +2491,8 @@
+                     EncryptionConstants.EncryptionSpecNS,
+                     EncryptionConstants._TAG_CARRIEDKEYNAME).item(0);
+             if (null != carriedNameElement) {
+-                result.setCarriedName(carriedNameElement.getNodeValue());
++                result.setCarriedName
++                    (carriedNameElement.getFirstChild().getNodeValue());
+             }
+ 
+             return (result);
+@@ -2680,13 +2591,8 @@
+         EncryptionProperty newEncryptionProperty(Element element) {
+             EncryptionProperty result = newEncryptionProperty();
+ 
+-            try {
+-                result.setTarget(new URI(
+-                    element.getAttributeNS(
+-                        null, EncryptionConstants._ATT_TARGET)).toString());
+-            } catch (URI.MalformedURIException mfue) {
+-                // do nothing
+-            }
++            result.setTarget(
++                element.getAttributeNS(null, EncryptionConstants._ATT_TARGET));
+             result.setId(element.getAttributeNS(
+                 null, EncryptionConstants._ATT_ID));
+             // TODO: Make this lot work...
+@@ -2943,7 +2849,7 @@
+                 } catch (URI.MalformedURIException mfue) {
+                     //complain
+                 }
+-                algorithm = tmpAlgorithm.toString();
++                algorithmURI = tmpAlgorithm.toString();
+             }
+ 
+             // <element name="AgreementMethod" type="xenc:AgreementMethodType"/>
+@@ -3183,7 +3089,7 @@
+                     _contextDocument, EncryptionConstants.EncryptionSpecNS,
+                     EncryptionConstants._TAG_CIPHERVALUE);
+                 result.appendChild(_contextDocument.createTextNode(
+-                    new String(cipherValue)));
++                    cipherValue));
+ 
+                 return (result);
+             }
+@@ -3247,8 +3153,7 @@
+                 }
+                 if (null != super.getType()) {
+                     result.setAttributeNS(
+-                        null, EncryptionConstants._ATT_TYPE,
+-                        super.getType().toString());
++                        null, EncryptionConstants._ATT_TYPE, super.getType());
+                 }
+                 if (null != super.getMimeType()) {
+                     result.setAttributeNS(
+@@ -3258,7 +3163,7 @@
+                 if (null != super.getEncoding()) {
+                     result.setAttributeNS(
+                         null, EncryptionConstants._ATT_ENCODING,
+-                        super.getEncoding().toString());
++                        super.getEncoding());
+                 }
+                 if (null != super.getEncryptionMethod()) {
+                     result.appendChild(((EncryptionMethodImpl)
+@@ -3383,8 +3288,7 @@
+                 }
+                 if (null != super.getType()) {
+                     result.setAttributeNS(
+-                        null, EncryptionConstants._ATT_TYPE,
+-                        super.getType().toString());
++                        null, EncryptionConstants._ATT_TYPE, super.getType());
+                 }
+                 if (null != super.getMimeType()) {
+                     result.setAttributeNS(null,
+@@ -3392,7 +3296,7 @@
+                 }
+                 if (null != super.getEncoding()) {
+                     result.setAttributeNS(null, Constants._ATT_ENCODING,
+-                        super.getEncoding().toString());
++                        super.getEncoding());
+                 }
+                 if (null != getRecipient()) {
+                     result.setAttributeNS(null,
+@@ -3468,13 +3372,17 @@
+              * @param type
+              */
+             public void setType(String type) {
+-                URI tmpType = null;
+-                try {
+-                    tmpType = new URI(type);
+-                } catch (URI.MalformedURIException mfue) {
+-                    // complain
++                if (type == null || type.length() == 0) {
++                    this.type = null;
++                } else {
++                    URI tmpType = null;
++                    try {
++                        tmpType = new URI(type);
++                    } catch (URI.MalformedURIException mfue) {
++                        // complain
++                    }
++                    this.type = tmpType.toString();
+                 }
+-                this.type = tmpType.toString();
+             }
+             /**
+              *
+@@ -3502,13 +3410,17 @@
+              * @param encoding
+              */
+             public void setEncoding(String encoding) {
+-                URI tmpEncoding = null;
+-                try {
+-                    tmpEncoding = new URI(encoding);
+-                } catch (URI.MalformedURIException mfue) {
+-                    // complain
++                if (encoding == null || encoding.length() == 0) {
++                    this.encoding = null;
++                } else {
++                    URI tmpEncoding = null;
++                    try {
++                        tmpEncoding = new URI(encoding);
++                    } catch (URI.MalformedURIException mfue) {
++                        // complain
++                    }
++                    this.encoding = tmpEncoding.toString();
+                 }
+-                this.encoding = tmpEncoding.toString();
+             }
+             /**
+              *
+@@ -3635,7 +3547,7 @@
+                     _contextDocument, EncryptionConstants.EncryptionSpecNS,
+                     EncryptionConstants._TAG_ENCRYPTIONMETHOD);
+                 result.setAttributeNS(null, EncryptionConstants._ATT_ALGORITHM,
+-                    algorithm.toString());
++                    algorithm);
+                 if (keySize > 0) {
+                     result.appendChild(
+                         ElementProxy.createElementForFamily(_contextDocument,
+@@ -3735,8 +3647,7 @@
+         private class EncryptionPropertyImpl implements EncryptionProperty {
+             private String target = null;
+             private String id = null;
+-            private String attributeName = null;
+-            private String attributeValue = null;
++            private HashMap attributeMap = new HashMap();
+             private List encryptionInformation = null;
+ 
+             /**
+@@ -3752,13 +3663,24 @@
+             }
+             /** @inheritDoc */
+             public void setTarget(String target) {
+-                URI tmpTarget = null;
+-                try {
+-                    tmpTarget = new URI(target);
+-                } catch (URI.MalformedURIException mfue) {
+-                    // complain
++                if (target == null || target.length() == 0) {
++                    this.target = null;
++                } else if (target.startsWith("#")) {
++                    /*
++                     * This is a same document URI reference. Do not parse,
++                     * because com.sun.org.apache.xml.internal.utils.URI considers this an
++                     * illegal URI because it has no scheme.
++                     */
++                    this.target = target;
++                } else {
++                    URI tmpTarget = null;
++                    try {
++                        tmpTarget = new URI(target);
++                    } catch (URI.MalformedURIException mfue) {
++                        // complain
++                    }
++                    this.target = tmpTarget.toString();
+                 }
+-                this.target = tmpTarget.toString();
+             }
+             /** @inheritDoc */
+             public String getId() {
+@@ -3770,12 +3692,11 @@
+             }
+             /** @inheritDoc */
+             public String getAttribute(String attribute) {
+-                return (attributeValue);
++                return (String) attributeMap.get(attribute);
+             }
+             /** @inheritDoc */
+             public void setAttribute(String attribute, String value) {
+-                attributeName = attribute;
+-                attributeValue = value;
++                attributeMap.put(attribute, value);
+             }
+             /** @inheritDoc */
+             public Iterator getEncryptionInformation() {
+@@ -3805,7 +3726,7 @@
+                     EncryptionConstants._TAG_ENCRYPTIONPROPERTY);
+                 if (null != target) {
+                     result.setAttributeNS(null, EncryptionConstants._ATT_TARGET,
+-                        target.toString());
++                        target);
+                 }
+                 if (null != id) {
+                     result.setAttributeNS(null, EncryptionConstants._ATT_ID,
+@@ -3839,7 +3760,13 @@
+                          * @param doc
+                          */
+                         public TransformsImpl(Document doc) {
+-                                super(doc);
++                                if (doc == null) {
++                                 throw new RuntimeException("Document is null");
++                              }
++
++                              this._doc = doc;
++                              this._constructionElement =  createElementForFamilyLocal(this._doc,
++                                          this.getBaseNamespace(), this.getBaseLocalName());
+                         }
+                         /**
+              *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipherInput.java b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipherInput.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipherInput.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipherInput.java
+@@ -108,84 +108,78 @@
+                 return null;
+         }
+ 
+-        /**
+-         * Internal method to get bytes in decryption mode
++    /**
++     * Internal method to get bytes in decryption mode
+      * @return the decripted bytes
+      * @throws XMLEncryptionException
+-         */
++     */
++    private byte[] getDecryptBytes() throws XMLEncryptionException {
+ 
+-        private byte[] getDecryptBytes() throws XMLEncryptionException {
+-
+-                String base64EncodedEncryptedOctets = null;
++        String base64EncodedEncryptedOctets = null;
+ 
+         if (_cipherData.getDataType() == CipherData.REFERENCE_TYPE) {
+-                        // Fun time!
+-                        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Found a reference type CipherData");
+-                        CipherReference cr = _cipherData.getCipherReference();
++            // Fun time!
++            logger.log(java.util.logging.Level.FINE, "Found a reference type CipherData");
++            CipherReference cr = _cipherData.getCipherReference();
+ 
+-                        // Need to wrap the uri in an Attribute node so that we can
+-                        // Pass to the resource resolvers
++            // Need to wrap the uri in an Attribute node so that we can
++            // Pass to the resource resolvers
+ 
+-                        Attr uriAttr = cr.getURIAsAttr();
+-                        XMLSignatureInput input = null;
++            Attr uriAttr = cr.getURIAsAttr();
++            XMLSignatureInput input = null;
+ 
+-                        try {
+-                                ResourceResolver resolver =
+-                                        ResourceResolver.getInstance(uriAttr, null);
+-                                input = resolver.resolve(uriAttr, null);
+-                        } catch (ResourceResolverException ex) {
+-                                throw new XMLEncryptionException("empty", ex);
+-                        }
++            try {
++                ResourceResolver resolver =
++                    ResourceResolver.getInstance(uriAttr, null);
++                input = resolver.resolve(uriAttr, null);
++            } catch (ResourceResolverException ex) {
++                throw new XMLEncryptionException("empty", ex);
++            }
+ 
+-                        if (input != null) {
+-                                if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Managed to resolve URI \"" + cr.getURI() + "\"");
+-                        }
+-                        else {
+-                                if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Failed to resolve URI \"" + cr.getURI() + "\"");
+-                        }
++            if (input != null) {
++                logger.log(java.util.logging.Level.FINE, "Managed to resolve URI \"" + cr.getURI() + "\"");
++            } else {
++                logger.log(java.util.logging.Level.FINE, "Failed to resolve URI \"" + cr.getURI() + "\"");
++            }
+ 
+-                        // Lets see if there are any transforms
+-                        Transforms transforms = cr.getTransforms();
+-                        if (transforms != null) {
+-                                if (logger.isLoggable(java.util.logging.Level.FINE))                                  logger.log(java.util.logging.Level.FINE, "Have transforms in cipher reference");
+-                                try {
+-                                    com.sun.org.apache.xml.internal.security.transforms.Transforms dsTransforms =
+-                                                transforms.getDSTransforms();
+-                                    input =     dsTransforms.performTransforms(input);
+-                                } catch (TransformationException ex) {
+-                                        throw new XMLEncryptionException("empty", ex);
+-                                }
+-                        }
++            // Lets see if there are any transforms
++            Transforms transforms = cr.getTransforms();
++            if (transforms != null) {
++                logger.log(java.util.logging.Level.FINE, "Have transforms in cipher reference");
++                try {
++                    com.sun.org.apache.xml.internal.security.transforms.Transforms dsTransforms =
++                        transforms.getDSTransforms();
++                    input = dsTransforms.performTransforms(input);
++                } catch (TransformationException ex) {
++                    throw new XMLEncryptionException("empty", ex);
++                }
++            }
+ 
+-                        try {
+-                                return input.getBytes();
+-                        }
+-                        catch (IOException ex) {
+-                                throw new XMLEncryptionException("empty", ex);
+-                        } catch (CanonicalizationException ex) {
+-                                throw new XMLEncryptionException("empty", ex);
+-                        }
++            try {
++                return input.getBytes();
++            } catch (IOException ex) {
++                throw new XMLEncryptionException("empty", ex);
++            } catch (CanonicalizationException ex) {
++                throw new XMLEncryptionException("empty", ex);
++            }
+ 
+-            // retrieve the cipher text
++        // retrieve the cipher text
+         } else if (_cipherData.getDataType() == CipherData.VALUE_TYPE) {
+-            CipherValue cv = _cipherData.getCipherValue();
+-            base64EncodedEncryptedOctets = new String(cv.getValue());
++            base64EncodedEncryptedOctets =
++                _cipherData.getCipherValue().getValue();
+         } else {
+-                        throw new XMLEncryptionException("CipherData.getDataType() returned unexpected value");
+-                }
++            throw new XMLEncryptionException("CipherData.getDataType() returned unexpected value");
++        }
+ 
+-        if (logger.isLoggable(java.util.logging.Level.FINE))                                     logger.log(java.util.logging.Level.FINE, "Encrypted octets:\n" + base64EncodedEncryptedOctets);
++        logger.log(java.util.logging.Level.FINE, "Encrypted octets:\n" + base64EncodedEncryptedOctets);
+ 
+         byte[] encryptedBytes = null;
+-
+         try {
+-                        encryptedBytes = Base64.decode(base64EncodedEncryptedOctets);
++            encryptedBytes = Base64.decode(base64EncodedEncryptedOctets);
+         } catch (Base64DecodingException bde) {
+             throw new XMLEncryptionException("empty", bde);
+         }
+ 
+-                return (encryptedBytes);
+-
+-        }
+-
++        return (encryptedBytes);
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/ContentHandlerAlreadyRegisteredException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/ContentHandlerAlreadyRegisteredException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/ContentHandlerAlreadyRegisteredException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/ContentHandlerAlreadyRegisteredException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -28,7 +27,7 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class ContentHandlerAlreadyRegisteredException
+         extends XMLSecurityException {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java
+@@ -25,6 +25,8 @@
+ import java.security.PublicKey;
+ import java.security.cert.X509Certificate;
+ import java.util.ArrayList;
++import java.util.Collections;
++import java.util.Iterator;
+ import java.util.List;
+ 
+ import javax.crypto.SecretKey;
+@@ -88,15 +90,22 @@
+  * The <CODE>containsXXX()</CODE> methods return <I>whether</I> the KeyInfo
+  * contains the corresponding type.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class KeyInfo extends SignatureElementProxy {
+ 
+    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(KeyInfo.class.getName());
++    List x509Datas=null;
++    List encryptedKeys=null;
+ 
+-
++    static final List nullList;
++    static {
++        List list = new ArrayList();
++        list.add(null);
++        nullList = Collections.unmodifiableList(list);
++    }
+ 
+    /**
+     * Constructor KeyInfo
+@@ -108,7 +117,6 @@
+ 
+       XMLUtils.addReturnToElement(this._constructionElement);
+ 
+-
+    }
+ 
+    /**
+@@ -119,8 +127,8 @@
+     * @throws XMLSecurityException
+     */
+    public KeyInfo(Element element, String BaseURI) throws XMLSecurityException {
+-
+       super(element, BaseURI);
++     // _storageResolvers.add(null);
+ 
+    }
+ 
+@@ -131,7 +139,7 @@
+     */
+    public void setId(String Id) {
+ 
+-      if ((this._state == MODE_SIGN) && (Id != null)) {
++      if ((Id != null)) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
+          IdResolver.registerElementById(this._constructionElement, Id);
+       }
+@@ -162,10 +170,8 @@
+     */
+    public void add(KeyName keyname) {
+ 
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(keyname.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -219,11 +225,8 @@
+     * @param keyvalue
+     */
+    public void add(KeyValue keyvalue) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(keyvalue.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -241,11 +244,8 @@
+     * @param mgmtdata
+     */
+    public void add(MgmtData mgmtdata) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(mgmtdata.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -254,11 +254,8 @@
+     * @param pgpdata
+     */
+    public void add(PGPData pgpdata) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(pgpdata.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -279,11 +276,8 @@
+     * @param retrievalmethod
+     */
+    public void add(RetrievalMethod retrievalmethod) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(retrievalmethod.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -292,11 +286,8 @@
+     * @param spkidata
+     */
+    public void add(SPKIData spkidata) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(spkidata.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -305,11 +296,11 @@
+     * @param x509data
+     */
+    public void add(X509Data x509data) {
+-
+-      if (this._state == MODE_SIGN) {
++          if (x509Datas==null)
++                  x509Datas=new ArrayList();
++          x509Datas.add(x509data);
+          this._constructionElement.appendChild(x509data.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+         /**
+@@ -321,12 +312,11 @@
+ 
+         public void add(EncryptedKey encryptedKey)
+                 throws XMLEncryptionException {
+-
+-                if (this._state == MODE_SIGN) {
++                        if (encryptedKeys==null)
++                                encryptedKeys=new ArrayList();
++                        encryptedKeys.add(encryptedKey);
+                         XMLCipher cipher = XMLCipher.getInstance();
+                         this._constructionElement.appendChild(cipher.martial(encryptedKey));
+-                }
+-
+         }
+ 
+    /**
+@@ -335,11 +325,8 @@
+     * @param element
+     */
+    public void addUnknownElement(Element element) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(element);
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -403,6 +390,9 @@
+     *@return the number of the X509Data tags
+     */
+    public int lengthX509Data() {
++           if (x509Datas!=null) {
++                   return x509Datas.size();
++           }
+       return this.length(Constants.SignatureSpecNS, Constants._TAG_X509DATA);
+    }
+ 
+@@ -550,7 +540,9 @@
+     * @throws XMLSecurityException
+     */
+    public X509Data itemX509Data(int i) throws XMLSecurityException {
+-
++           if (x509Datas!=null) {
++                   return (X509Data) x509Datas.get(i);
++           }
+       Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+                                                 Constants._TAG_X509DATA,i);
+ 
+@@ -569,7 +561,9 @@
+         */
+ 
+         public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException {
+-
++                if (encryptedKeys!=null) {
++                        return (EncryptedKey) encryptedKeys.get(i);
++                }
+                 Element e =
+                         XMLUtils.selectXencNode(this._constructionElement.getFirstChild(),
+                                                                                   EncryptionConstants._TAG_ENCRYPTEDKEY,i);
+@@ -707,20 +701,20 @@
+       PublicKey pk = this.getPublicKeyFromInternalResolvers();
+ 
+       if (pk != null) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I could find a key using the per-KeyInfo key resolvers");
++         log.log(java.util.logging.Level.FINE, "I could find a key using the per-KeyInfo key resolvers");
+ 
+          return pk;
+       }
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I couldn't find a key using the per-KeyInfo key resolvers");
++      log.log(java.util.logging.Level.FINE, "I couldn't find a key using the per-KeyInfo key resolvers");
+ 
+       pk = this.getPublicKeyFromStaticResolvers();
+ 
+       if (pk != null) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I could find a key using the system-wide key resolvers");
++         log.log(java.util.logging.Level.FINE, "I could find a key using the system-wide key resolvers");
+ 
+          return pk;
+       }
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I couldn't find a key using the system-wide key resolvers");
++      log.log(java.util.logging.Level.FINE, "I couldn't find a key using the system-wide key resolvers");
+ 
+       return null;
+    }
+@@ -732,46 +726,29 @@
+     * @throws KeyResolverException
+     */
+    PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
+-
+-      for (int i = 0; i < KeyResolver.length(); i++) {
+-         KeyResolver keyResolver = KeyResolver.item(i);
++          int length=KeyResolver.length();
++          int storageLength=this._storageResolvers.size();
++          Iterator it= KeyResolver.iterator();
++      for (int i = 0; i < length; i++) {
++         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+          Node currentChild=this._constructionElement.getFirstChild();
++         String uri= this.getBaseURI();
+          while (currentChild!=null)      {
+             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+-               if (this._storageResolvers.size() == 0) {
+-
+-                  // if we do not have storage resolvers, we verify with null
+-                  StorageResolver storage = null;
+-
+-                  if (keyResolver.canResolve((Element) currentChild,
+-                                             this.getBaseURI(), storage)) {
+-                     PublicKey pk =
+-                        keyResolver.resolvePublicKey((Element) currentChild,
+-                                                     this.getBaseURI(),
+-                                                     storage);
+-
+-                     if (pk != null) {
+-                        return pk;
+-                     }
+-                  }
+-               } else {
+-                  for (int k = 0; k < this._storageResolvers.size(); k++) {
++                  for (int k = 0; k < storageLength; k++) {
+                      StorageResolver storage =
+                         (StorageResolver) this._storageResolvers.get(k);
+ 
+-                     if (keyResolver.canResolve((Element) currentChild,
+-                                                this.getBaseURI(), storage)) {
+-                        PublicKey pk =
+-                           keyResolver.resolvePublicKey((Element) currentChild,
+-                                                        this.getBaseURI(),
++                     PublicKey pk =
++                           keyResolver.engineLookupAndResolvePublicKey((Element) currentChild,
++                                                       uri,
+                                                         storage);
+ 
+-                        if (pk != null) {
+-                           return pk;
+-                        }
++                     if (pk != null) {
++                         KeyResolver.hit(it);
++                         return pk;
+                      }
+                   }
+-               }
+             }
+             currentChild=currentChild.getNextSibling();
+          }
+@@ -786,50 +763,27 @@
+     * @throws KeyResolverException
+     */
+    PublicKey getPublicKeyFromInternalResolvers() throws KeyResolverException {
+-
+-      for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
++          int length=lengthInternalKeyResolver();
++          int storageLength=this._storageResolvers.size();
++      for (int i = 0; i < length; i++) {
+          KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
+ 
+          Node currentChild=this._constructionElement.getFirstChild();
++         String uri=this.getBaseURI();
+          while (currentChild!=null)      {
+             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+-               if (this._storageResolvers.size() == 0) {
+-
+-                  // if we do not have storage resolvers, we verify with null
+-                  StorageResolver storage = null;
+-
+-                  if (keyResolver.engineCanResolve((Element) currentChild,
+-                                                   this.getBaseURI(),
+-                                                   storage)) {
+-                     PublicKey pk =
+-                        keyResolver
+-                           .engineResolvePublicKey((Element) currentChild, this
+-                              .getBaseURI(), storage);
++               for (int k = 0; k < storageLength; k++) {
++                   StorageResolver storage =
++                      (StorageResolver) this._storageResolvers.get(k);
++                   PublicKey pk = keyResolver
++                           .engineLookupAndResolvePublicKey((Element) currentChild, uri, storage);
+ 
+                      if (pk != null) {
+-                        return pk;
++                         return pk;
+                      }
+                   }
+-               } else {
+-                  for (int k = 0; k < this._storageResolvers.size(); k++) {
+-                     StorageResolver storage =
+-                        (StorageResolver) this._storageResolvers.get(k);
+-
+-                     if (keyResolver.engineCanResolve((Element) currentChild,
+-                                                      this.getBaseURI(),
+-                                                      storage)) {
+-                        PublicKey pk = keyResolver
+-                           .engineResolvePublicKey((Element) currentChild, this
+-                              .getBaseURI(), storage);
+-
+-                        if (pk != null) {
+-                           return pk;
+-                        }
+-                     }
+-                  }
+-               }
+             }
+             currentChild=currentChild.getNextSibling();
+          }
+@@ -850,12 +804,12 @@
+       X509Certificate cert = this.getX509CertificateFromInternalResolvers();
+ 
+       if (cert != null) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE,
++         log.log(java.util.logging.Level.FINE,
+             "I could find a X509Certificate using the per-KeyInfo key resolvers");
+ 
+          return cert;
+       }
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE,
++      log.log(java.util.logging.Level.FINE,
+             "I couldn't find a X509Certificate using the per-KeyInfo key resolvers");
+ 
+ 
+@@ -863,12 +817,12 @@
+       cert = this.getX509CertificateFromStaticResolvers();
+ 
+       if (cert != null) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE,
++         log.log(java.util.logging.Level.FINE,
+             "I could find a X509Certificate using the system-wide key resolvers");
+ 
+          return cert;
+       }
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE,
++      log.log(java.util.logging.Level.FINE,
+             "I couldn't find a X509Certificate using the system-wide key resolvers");
+ 
+ 
+@@ -885,53 +839,44 @@
+     */
+    X509Certificate getX509CertificateFromStaticResolvers()
+            throws KeyResolverException {
+-      if (true)
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromStaticResolvers() with "
++      if (log.isLoggable(java.util.logging.Level.FINE))
++        log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromStaticResolvers() with "
+                 + KeyResolver.length() + " resolvers");
++      String uri=this.getBaseURI();
++      int length= KeyResolver.length();
++      int storageLength=this._storageResolvers.size();
++      Iterator it = KeyResolver.iterator();
++      for (int i = 0; i <length; i++) {
++         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
++         X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
++         if (cert!=null) {
++                 KeyResolver.hit(it);
++                 return cert;
++         }
++      }
++      return null;
++   }
+ 
+-      for (int i = 0; i < KeyResolver.length(); i++) {
+-         KeyResolver keyResolver = KeyResolver.item(i);
+-         Node currentChild=this._constructionElement.getFirstChild();
+-         while (currentChild!=null)      {
+-            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+-               if (this._storageResolvers.size() == 0) {
++   private X509Certificate applyCurrentResolver(String uri, int storageLength, KeyResolverSpi keyResolver) throws KeyResolverException {
++           Node currentChild=this._constructionElement.getFirstChild();
++           while (currentChild!=null)      {
++                   if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
++               for (int k = 0; k < storageLength; k++) {
++                   StorageResolver storage =
++                      (StorageResolver) this._storageResolvers.get(k);
+ 
+-                  // if we do not have storage resolvers, we verify with null
+-                  StorageResolver storage = null;
++                   X509Certificate cert = keyResolver
++                        .engineLookupResolveX509Certificate((Element) currentChild, uri,
++                                        storage);
+ 
+-                  if (keyResolver.canResolve((Element) currentChild,
+-                                             this.getBaseURI(), storage)) {
+-                     X509Certificate cert =
+-                        keyResolver
+-                           .resolveX509Certificate((Element) currentChild, this
+-                              .getBaseURI(), storage);
+-
+-                     if (cert != null) {
+-                        return cert;
+-                     }
+-                  }
+-               } else {
+-                  for (int k = 0; k < this._storageResolvers.size(); k++) {
+-                     StorageResolver storage =
+-                        (StorageResolver) this._storageResolvers.get(k);
+-
+-                     if (keyResolver.canResolve((Element) currentChild,
+-                                                this.getBaseURI(), storage)) {
+-                        X509Certificate cert = keyResolver
+-                           .resolveX509Certificate((Element) currentChild, this
+-                              .getBaseURI(), storage);
+-
+-                        if (cert != null) {
+-                           return cert;
+-                        }
+-                     }
++                   if (cert != null) {
++                       return cert;
+                   }
+                }
+             }
+             currentChild=currentChild.getNextSibling();
+          }
+-      }
+-      return null;
++         return null;
+    }
+ 
+    /**
+@@ -942,55 +887,18 @@
+     */
+    X509Certificate getX509CertificateFromInternalResolvers()
+            throws KeyResolverException {
+-      if (true)
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromInternalResolvers() with "
++      if (log.isLoggable(java.util.logging.Level.FINE))
++        log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromInternalResolvers() with "
+                 + this.lengthInternalKeyResolver() + " resolvers");
+-
++      String uri=this.getBaseURI();
++      int storageLength=this._storageResolvers.size();
+       for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
+          KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
+-
+-         Node currentChild=this._constructionElement.getFirstChild();
+-         while (currentChild!=null)      {
+-            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+-               if (this._storageResolvers.size() == 0) {
+-
+-                  // if we do not have storage resolvers, we verify with null
+-                  StorageResolver storage = null;
+-
+-                  if (keyResolver.engineCanResolve((Element) currentChild,
+-                                                   this.getBaseURI(),
+-                                                   storage)) {
+-                     X509Certificate cert =
+-                        keyResolver.engineResolveX509Certificate(
+-                           (Element) currentChild, this.getBaseURI(), storage);
+-
+-                     if (cert != null) {
+-                        return cert;
+-                     }
+-                  }
+-               } else {
+-                  for (int k = 0; k < this._storageResolvers.size(); k++) {
+-                     StorageResolver storage =
+-                        (StorageResolver) this._storageResolvers.get(k);
+-
+-                     if (keyResolver.engineCanResolve((Element) currentChild,
+-                                                      this.getBaseURI(),
+-                                                      storage)) {
+-                        X509Certificate cert =
+-                           keyResolver.engineResolveX509Certificate(
+-                              (Element) currentChild, this.getBaseURI(),
+-                              storage);
+-
+-                        if (cert != null) {
+-                           return cert;
+-                        }
+-                     }
+-                  }
+-               }
+-            }
+-            currentChild=currentChild.getNextSibling();
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
++         X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
++         if (cert!=null) {
++                 return cert;
+          }
+       }
+ 
+@@ -1006,21 +914,21 @@
+       SecretKey sk = this.getSecretKeyFromInternalResolvers();
+ 
+       if (sk != null) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I could find a secret key using the per-KeyInfo key resolvers");
++         log.log(java.util.logging.Level.FINE, "I could find a secret key using the per-KeyInfo key resolvers");
+ 
+          return sk;
+       }
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I couldn't find a secret key using the per-KeyInfo key resolvers");
++      log.log(java.util.logging.Level.FINE, "I couldn't find a secret key using the per-KeyInfo key resolvers");
+ 
+ 
+       sk = this.getSecretKeyFromStaticResolvers();
+ 
+       if (sk != null) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I could find a secret key using the system-wide key resolvers");
++         log.log(java.util.logging.Level.FINE, "I could find a secret key using the system-wide key resolvers");
+ 
+          return sk;
+       }
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I couldn't find a secret key using the system-wide key resolvers");
++      log.log(java.util.logging.Level.FINE, "I couldn't find a secret key using the system-wide key resolvers");
+ 
+ 
+       return null;
+@@ -1034,47 +942,29 @@
+     */
+ 
+    SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException {
+-
+-      for (int i = 0; i < KeyResolver.length(); i++) {
+-         KeyResolver keyResolver = KeyResolver.item(i);
++          final int length=KeyResolver.length();
++          int storageLength=this._storageResolvers.size();
++          Iterator it = KeyResolver.iterator();
++      for (int i = 0; i < length; i++) {
++         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+ 
+          Node currentChild=this._constructionElement.getFirstChild();
++         String uri=this.getBaseURI();
+          while (currentChild!=null)      {
+             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+-               if (this._storageResolvers.size() == 0) {
++                  for (int k = 0; k < storageLength; k++) {
++                     StorageResolver storage =
++                        (StorageResolver) this._storageResolvers.get(k);
+ 
+-                  // if we do not have storage resolvers, we verify with null
+-                  StorageResolver storage = null;
+-
+-                  if (keyResolver.canResolve((Element) currentChild,
+-                                             this.getBaseURI(), storage)) {
+-                     SecretKey sk  =
+-                        keyResolver.resolveSecretKey((Element) currentChild,
+-                                                     this.getBaseURI(),
+-                                                     storage);
++                     SecretKey sk =
++                           keyResolver.engineLookupAndResolveSecretKey((Element) currentChild,
++                                                        uri,
++                                                        storage);
+ 
+                      if (sk != null) {
+                         return sk;
+                      }
+                   }
+-               } else {
+-                  for (int k = 0; k < this._storageResolvers.size(); k++) {
+-                     StorageResolver storage =
+-                        (StorageResolver) this._storageResolvers.get(k);
+-
+-                     if (keyResolver.canResolve((Element) currentChild,
+-                                                this.getBaseURI(), storage)) {
+-                        SecretKey sk =
+-                           keyResolver.resolveSecretKey((Element) currentChild,
+-                                                        this.getBaseURI(),
+-                                                        storage);
+-
+-                        if (sk != null) {
+-                           return sk;
+-                        }
+-                     }
+-                  }
+-               }
+             }
+             currentChild=currentChild.getNextSibling();
+          }
+@@ -1090,51 +980,28 @@
+     */
+ 
+    SecretKey getSecretKeyFromInternalResolvers() throws KeyResolverException {
+-
++           int storageLength=this._storageResolvers.size();
+       for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
+          KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
+ 
+          Node currentChild=this._constructionElement.getFirstChild();
++         String uri=this.getBaseURI();
+          while (currentChild!=null)      {
+             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+-               if (this._storageResolvers.size() == 0) {
++               for (int k = 0; k < storageLength; k++) {
++                     StorageResolver storage =
++                        (StorageResolver) this._storageResolvers.get(k);
+ 
+-                  // if we do not have storage resolvers, we verify with null
+-                  StorageResolver storage = null;
+-
+-                  if (keyResolver.engineCanResolve((Element) currentChild,
+-                                                   this.getBaseURI(),
+-                                                   storage)) {
+-                     SecretKey sk =
+-                        keyResolver
+-                           .engineResolveSecretKey((Element) currentChild, this
+-                              .getBaseURI(), storage);
++                     SecretKey sk = keyResolver
++                           .engineLookupAndResolveSecretKey((Element) currentChild, uri, storage);
+ 
+                      if (sk != null) {
+                         return sk;
+                      }
+-                  }
+-               } else {
+-                  for (int k = 0; k < this._storageResolvers.size(); k++) {
+-                     StorageResolver storage =
+-                        (StorageResolver) this._storageResolvers.get(k);
+-
+-                     if (keyResolver.engineCanResolve((Element) currentChild,
+-                                                      this.getBaseURI(),
+-                                                      storage)) {
+-                        SecretKey sk = keyResolver
+-                           .engineResolveSecretKey((Element) currentChild, this
+-                              .getBaseURI(), storage);
+-
+-                        if (sk != null) {
+-                           return sk;
+-                        }
+-                     }
+-                  }
+-               }
+-            }
++                }
++             }
+             currentChild=currentChild.getNextSibling();
+          }
+       }
+@@ -1145,7 +1012,7 @@
+    /**
+     * Stores the individual (per-KeyInfo) {@link KeyResolver}s
+     */
+-   List _internalKeyResolvers = new ArrayList();
++   List _internalKeyResolvers = null;
+ 
+    /**
+     * This method is used to add a custom {@link KeyResolverSpi} to a KeyInfo
+@@ -1154,6 +1021,9 @@
+     * @param realKeyResolver
+     */
+    public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) {
++           if (_internalKeyResolvers==null) {
++                   _internalKeyResolvers=new ArrayList();
++           }
+       this._internalKeyResolvers.add(realKeyResolver);
+    }
+ 
+@@ -1162,6 +1032,8 @@
+     * @return the length of the key
+     */
+    int lengthInternalKeyResolver() {
++           if (_internalKeyResolvers==null)
++                   return 0;
+       return this._internalKeyResolvers.size();
+    }
+ 
+@@ -1176,7 +1048,7 @@
+    }
+ 
+    /** Field _storageResolvers */
+-   List _storageResolvers = new ArrayList();
++   List _storageResolvers = nullList;
+ 
+    /**
+     * Method addStorageResolver
+@@ -1184,19 +1056,11 @@
+     * @param storageResolver
+     */
+    public void addStorageResolver(StorageResolver storageResolver) {
++           if  (_storageResolvers == nullList  ){
++                   _storageResolvers=new ArrayList();
++           }
++         this._storageResolvers.add(storageResolver);
+ 
+-      if (storageResolver != null) {
+-         this._storageResolvers.add(storageResolver);
+-      }
+-   }
+-
+-   /**
+-    * Method getStorageResolvers
+-    *
+-    * @return the internalStorages
+-    */
+-   List getStorageResolvers() {
+-      return this._storageResolvers;
+    }
+ 
+    //J-
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyUtils.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyUtils.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyUtils.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyUtils.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -36,7 +35,7 @@
+ /**
+  * Utility class for for <CODE>com.sun.org.apache.xml.internal.security.keys</CODE> package.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class KeyUtils {
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyInfoContent.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyInfoContent.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyInfoContent.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyInfoContent.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -28,7 +27,7 @@
+ /**
+  * Empty interface just to identify Elements that can be cildren of ds:KeyInfo.
+  *
+- * @author $Author: blautenb $
++ * @author $Author: mullan $
+  */
+ public interface KeyInfoContent {
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyName.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyName.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyName.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyName.java
+@@ -20,25 +20,18 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content;
+ 
+-
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class KeyName extends SignatureElementProxy implements KeyInfoContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(KeyName.class.getName());
+-
+    /**
+     * Constructor KeyName
+     *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/KeyValue.java
+@@ -20,11 +20,8 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content;
+ 
+-
+-
+ import java.security.PublicKey;
+ 
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.DSAKeyValue;
+ import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue;
+@@ -34,140 +31,131 @@
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  * The KeyValue element contains a single public key that may be useful in
+  * validating the signature. Structured formats for defining DSA (REQUIRED)
+  * and RSA (RECOMMENDED) public keys are defined in Signature Algorithms
+  * (section 6.4). The KeyValue element may include externally defined public
+- * keys values represented as PCDATA or element types from an external namespace.
++ * keys values represented as PCDATA or element types from an external
++ * namespace.
+  *
+- * @author $Author: vishal $
++ * @author $Author: mullan $
+  */
+ public class KeyValue extends SignatureElementProxy implements KeyInfoContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(KeyValue.class.getName());
++    /**
++     * Constructor KeyValue
++     *
++     * @param doc
++     * @param dsaKeyValue
++     */
++    public KeyValue(Document doc, DSAKeyValue dsaKeyValue) {
+ 
+-   /**
+-    * Constructor KeyValue
+-    *
+-    * @param doc
+-    * @param dsaKeyValue
+-    */
+-   public KeyValue(Document doc, DSAKeyValue dsaKeyValue) {
++        super(doc);
+ 
+-      super(doc);
++        XMLUtils.addReturnToElement(this._constructionElement);
++        this._constructionElement.appendChild(dsaKeyValue.getElement());
++        XMLUtils.addReturnToElement(this._constructionElement);
++    }
+ 
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-      this._constructionElement.appendChild(dsaKeyValue.getElement());
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-   }
++    /**
++     * Constructor KeyValue
++     *
++     * @param doc
++     * @param rsaKeyValue
++     */
++    public KeyValue(Document doc, RSAKeyValue rsaKeyValue) {
+ 
+-   /**
+-    * Constructor KeyValue
+-    *
+-    * @param doc
+-    * @param rsaKeyValue
+-    */
+-   public KeyValue(Document doc, RSAKeyValue rsaKeyValue) {
++        super(doc);
+ 
+-      super(doc);
++        XMLUtils.addReturnToElement(this._constructionElement);
++        this._constructionElement.appendChild(rsaKeyValue.getElement());
++        XMLUtils.addReturnToElement(this._constructionElement);
++    }
+ 
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-      this._constructionElement.appendChild(rsaKeyValue.getElement());
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-   }
++    /**
++     * Constructor KeyValue
++     *
++     * @param doc
++     * @param unknownKeyValue
++     */
++    public KeyValue(Document doc, Element unknownKeyValue) {
+ 
+-   /**
+-    * Constructor KeyValue
+-    *
+-    * @param doc
+-    * @param unknownKeyValue
+-    */
+-   public KeyValue(Document doc, Element unknownKeyValue) {
++        super(doc);
+ 
+-      super(doc);
++        XMLUtils.addReturnToElement(this._constructionElement);
++        this._constructionElement.appendChild(unknownKeyValue);
++        XMLUtils.addReturnToElement(this._constructionElement);
++    }
+ 
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-      this._constructionElement.appendChild(unknownKeyValue);
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-   }
++    /**
++     * Constructor KeyValue
++     *
++     * @param doc
++     * @param pk
++     */
++    public KeyValue(Document doc, PublicKey pk) {
+ 
+-   /**
+-    * Constructor KeyValue
+-    *
+-    * @param doc
+-    * @param pk
+-    */
+-   public KeyValue(Document doc, PublicKey pk) {
++        super(doc);
+ 
+-      super(doc);
++        XMLUtils.addReturnToElement(this._constructionElement);
+ 
+-      XMLUtils.addReturnToElement(this._constructionElement);
++        if (pk instanceof java.security.interfaces.DSAPublicKey) {
++            DSAKeyValue dsa = new DSAKeyValue(this._doc, pk);
+ 
+-      if (pk instanceof java.security.interfaces.DSAPublicKey) {
+-         DSAKeyValue dsa = new DSAKeyValue(this._doc, pk);
++            this._constructionElement.appendChild(dsa.getElement());
++            XMLUtils.addReturnToElement(this._constructionElement);
++        } else if (pk instanceof java.security.interfaces.RSAPublicKey) {
++            RSAKeyValue rsa = new RSAKeyValue(this._doc, pk);
+ 
+-         this._constructionElement.appendChild(dsa.getElement());
+-         XMLUtils.addReturnToElement(this._constructionElement);
+-      } else if (pk instanceof java.security.interfaces.RSAPublicKey) {
+-         RSAKeyValue rsa = new RSAKeyValue(this._doc, pk);
++            this._constructionElement.appendChild(rsa.getElement());
++            XMLUtils.addReturnToElement(this._constructionElement);
++        }
++    }
+ 
+-         this._constructionElement.appendChild(rsa.getElement());
+-         XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+-   }
++    /**
++     * Constructor KeyValue
++     *
++     * @param element
++     * @param BaseURI
++     * @throws XMLSecurityException
++     */
++    public KeyValue(Element element, String BaseURI)
++           throws XMLSecurityException {
++        super(element, BaseURI);
++    }
+ 
+-   /**
+-    * Constructor KeyValue
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @throws XMLSecurityException
+-    */
+-   public KeyValue(Element element, String BaseURI)
+-           throws XMLSecurityException {
+-      super(element, BaseURI);
+-   }
++    /**
++     * Method getPublicKey
++     *
++     * @return the public key
++     * @throws XMLSecurityException
++     */
++    public PublicKey getPublicKey() throws XMLSecurityException {
+ 
+-   /**
+-    * Method getPublicKey
+-    *
+-    * @return the public key
+-    * @throws XMLSecurityException
+-    */
+-   public PublicKey getPublicKey() throws XMLSecurityException {
++        Element rsa = XMLUtils.selectDsNode
++            (this._constructionElement.getFirstChild(),
++             Constants._TAG_RSAKEYVALUE,0);
+ 
++        if (rsa != null) {
++            RSAKeyValue kv = new RSAKeyValue(rsa, this._baseURI);
++            return kv.getPublicKey();
++        }
+ 
+-         Element rsa = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-                                        Constants._TAG_RSAKEYVALUE,0);
++        Element dsa = XMLUtils.selectDsNode
++            (this._constructionElement.getFirstChild(),
++             Constants._TAG_DSAKEYVALUE,0);
+ 
+-         if (rsa != null) {
+-            RSAKeyValue kv = new RSAKeyValue(rsa,
+-                                             this._baseURI);
++        if (dsa != null) {
++            DSAKeyValue kv = new DSAKeyValue(dsa, this._baseURI);
++            return kv.getPublicKey();
++        }
+ 
+-            return kv.getPublicKey();
+-         }
++        return null;
++    }
+ 
+-         Element dsa = XMLUtils.selectDsNode(this._constructionElement,
+-                         Constants._TAG_DSAKEYVALUE,0);
+-
+-
+-         if (dsa != null) {
+-            DSAKeyValue kv = new DSAKeyValue(dsa,
+-                                             this._baseURI);
+-
+-            return kv.getPublicKey();
+-         }
+-
+-
+-      return null;
+-   }
+-
+-   /** @inheritDoc */
+-   public String getBaseLocalName() {
+-      return Constants._TAG_KEYVALUE;
+-   }
++    /** @inheritDoc */
++    public String getBaseLocalName() {
++        return Constants._TAG_KEYVALUE;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/MgmtData.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/MgmtData.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/MgmtData.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/MgmtData.java
+@@ -20,25 +20,18 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content;
+ 
+-
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class MgmtData extends SignatureElementProxy implements KeyInfoContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(MgmtData.class.getName());
+-
+    /**
+     * Constructor MgmtData
+     *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/PGPData.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/PGPData.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/PGPData.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/PGPData.java
+@@ -20,25 +20,18 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content;
+ 
+-
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  * $todo$ Implement
+  */
+ public class PGPData extends SignatureElementProxy implements KeyInfoContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(PGPData.class.getName());
+-
+    /**
+     * Constructor PGPData
+     *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/RetrievalMethod.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/RetrievalMethod.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/RetrievalMethod.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/RetrievalMethod.java
+@@ -20,9 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content;
+ 
+-
+-
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+@@ -33,17 +30,13 @@
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class RetrievalMethod extends SignatureElementProxy
+         implements KeyInfoContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(RetrievalMethod.class.getName());
+    //J-
+     /** DSA retrieval */
+    public static final String TYPE_DSA     = Constants.SignatureSpecNS + "DSAKeyValue";
+@@ -133,7 +126,7 @@
+ 
+       try {
+        Element transformsElem =
+-             XMLUtils.selectDsNode(this._constructionElement,
++             XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+                                                 Constants
+                                                    ._TAG_TRANSFORMS, 0);
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/SPKIData.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/SPKIData.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/SPKIData.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/SPKIData.java
+@@ -20,25 +20,18 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content;
+ 
+-
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  * $todo$ implement
+  */
+ public class SPKIData extends SignatureElementProxy implements KeyInfoContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(SPKIData.class.getName());
+-
+    /**
+     * Constructor SPKIData
+     *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/X509Data.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/X509Data.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/X509Data.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/X509Data.java
+@@ -41,7 +41,7 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class X509Data extends SignatureElementProxy implements KeyInfoContent {
+ 
+@@ -72,60 +72,17 @@
+            throws XMLSecurityException {
+ 
+       super(element, BaseURI);
+-
+-      boolean noElements=true;
+       Node sibling=this._constructionElement.getFirstChild();
+       while (sibling!=null) {
+          if (sibling.getNodeType()!=Node.ELEMENT_NODE) {
+                 sibling=sibling.getNextSibling();
+             continue;
+          }
+-        noElements=false;
+-         Element currentElem = (Element) sibling;
+-         sibling=sibling.getNextSibling();
+-         String localname = currentElem.getLocalName();
+-
+-         if (currentElem.getNamespaceURI().equals(Constants.SignatureSpecNS)) {
+-            if (localname.equals(Constants._TAG_X509ISSUERSERIAL)) {
+-               XMLX509IssuerSerial is = new XMLX509IssuerSerial(currentElem,
+-                                           BaseURI);
+-
+-               this.add(is);
+-            } else if (localname.equals(Constants._TAG_X509SKI)) {
+-               XMLX509SKI ski = new XMLX509SKI(currentElem, BaseURI);
+-
+-               this.add(ski);
+-            } else if (localname.equals(Constants._TAG_X509SUBJECTNAME)) {
+-               XMLX509SubjectName sn = new XMLX509SubjectName(currentElem,
+-                                          BaseURI);
+-
+-               this.add(sn);
+-            } else if (localname.equals(Constants._TAG_X509CERTIFICATE)) {
+-               XMLX509Certificate cert = new XMLX509Certificate(currentElem,
+-                                            BaseURI);
+-
+-               this.add(cert);
+-            } else if (localname.equals(Constants._TAG_X509CRL)) {
+-               XMLX509CRL crl = new XMLX509CRL(currentElem, BaseURI);
+-
+-               this.add(crl);
+-            } else {
+-               log.log(java.util.logging.Level.WARNING, "Found a " + currentElem.getTagName() + " element in "
+-                        + Constants._TAG_X509DATA);
+-               this.addUnknownElement(currentElem);
+-            }
+-         } else {
+-            log.log(java.util.logging.Level.WARNING, "Found a " + currentElem.getTagName() + " element in "
+-                     + Constants._TAG_X509DATA);
+-            this.addUnknownElement(currentElem);
+-         }
++         return;
+       }
+-      if (noElements) {
+-        Object exArgs[] = { "Elements", Constants._TAG_X509DATA };
+-
+-        throw new XMLSecurityException("xml.WrongContent", exArgs);
+-     }
+-
++      /* No Elements found */
++      Object exArgs[] = { "Elements", Constants._TAG_X509DATA };
++      throw new XMLSecurityException("xml.WrongContent", exArgs);
+    }
+ 
+    /**
+@@ -169,11 +126,9 @@
+     */
+    public void add(XMLX509IssuerSerial xmlX509IssuerSerial) {
+ 
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement
+             .appendChild(xmlX509IssuerSerial.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -202,11 +157,8 @@
+     * @param xmlX509SKI
+     */
+    public void add(XMLX509SKI xmlX509SKI) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(xmlX509SKI.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -233,11 +185,8 @@
+     * @param xmlX509SubjectName
+     */
+    public void add(XMLX509SubjectName xmlX509SubjectName) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(xmlX509SubjectName.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -266,11 +215,8 @@
+     * @param xmlX509Certificate
+     */
+    public void add(XMLX509Certificate xmlX509Certificate) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(xmlX509Certificate.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -288,11 +234,8 @@
+     * @param xmlX509CRL
+     */
+    public void add(XMLX509CRL xmlX509CRL) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(xmlX509CRL.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -301,11 +244,8 @@
+     * @param element
+     */
+    public void addUnknownElement(Element element) {
+-
+-      if (this._state == MODE_SIGN) {
+          this._constructionElement.appendChild(element);
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -479,7 +419,7 @@
+     * TODO implement
+     **/
+    public Element itemUnknownElement(int i) {
+-          if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "itemUnknownElement not implemented:"+i);
++          log.log(java.util.logging.Level.FINE, "itemUnknownElement not implemented:"+i);
+       return null;
+    }
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/DSAKeyValue.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/DSAKeyValue.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/DSAKeyValue.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/DSAKeyValue.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content.keyvalues;
+ 
+-
+-
+ import java.math.BigInteger;
+ import java.security.Key;
+ import java.security.KeyFactory;
+@@ -39,18 +37,13 @@
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class DSAKeyValue extends SignatureElementProxy
+         implements KeyValueContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(DSAKeyValue.class.getName());
+-
+    /**
+     * Constructor DSAKeyValue
+     *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/KeyValueContent.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/KeyValueContent.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/KeyValueContent.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/KeyValueContent.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -32,7 +31,7 @@
+  *
+  *
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  *
+  */
+ public interface KeyValueContent {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/RSAKeyValue.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/RSAKeyValue.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/RSAKeyValue.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/keyvalues/RSAKeyValue.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content.keyvalues;
+ 
+-
+-
+ import java.math.BigInteger;
+ import java.security.Key;
+ import java.security.KeyFactory;
+@@ -39,19 +37,13 @@
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class RSAKeyValue extends SignatureElementProxy
+         implements KeyValueContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(
+-                        RSAKeyValue.class.getName());
+-
+    /**
+     * Constructor RSAKeyValue
+     *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509CRL.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509CRL.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509CRL.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509CRL.java
+@@ -20,30 +20,20 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content.x509;
+ 
+-
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  *
+- *
+- *
+- *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  *
+  */
+ public class XMLX509CRL extends SignatureElementProxy
+         implements XMLX509DataContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(XMLX509CRL.class.getName());
+-
+    /**
+     * Constructor XMLX509CRL
+     *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Certificate.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Certificate.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Certificate.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509Certificate.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content.x509;
+ 
+-
+-
+ import java.io.ByteArrayInputStream;
+ import java.security.PublicKey;
+ import java.security.cert.CertificateException;
+@@ -34,18 +32,13 @@
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class XMLX509Certificate extends SignatureElementProxy
+         implements XMLX509DataContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(XMLX509Certificate.class.getName());
+-
+    /** Field JCA_CERT_ID */
+    public static final String JCA_CERT_ID = "X.509";
+ 
+@@ -146,23 +139,25 @@
+       return null;
+    }
+ 
+-   /** @inheritDoc */
+-   public boolean equals(Object obj) {
++    /** @inheritDoc */
++    public boolean equals(Object obj) {
+ 
+-      try {
+-         if (!obj.getClass().getName().equals(this.getClass().getName())) {
++        if (obj == null) {
+             return false;
+-         }
++        }
++        if (!this.getClass().getName().equals(obj.getClass().getName())) {
++            return false;
++        }
++        XMLX509Certificate other = (XMLX509Certificate) obj;
++        try {
+ 
+-         XMLX509Certificate other = (XMLX509Certificate) obj;
+-
+-         /** $todo$ or should be create X509Certificates and use the equals() from the Certs */
+-         return java.security.MessageDigest.isEqual(other.getCertificateBytes(),
+-                                        this.getCertificateBytes());
+-      } catch (XMLSecurityException ex) {
+-         return false;
+-      }
+-   }
++            /** $todo$ or should be create X509Certificates and use the equals() from the Certs */
++            return java.security.MessageDigest.isEqual
++                (other.getCertificateBytes(), this.getCertificateBytes());
++        } catch (XMLSecurityException ex) {
++            return false;
++        }
++    }
+ 
+    /** @inheritDoc */
+    public String getBaseLocalName() {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509DataContent.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509DataContent.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509DataContent.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509DataContent.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -28,7 +27,7 @@
+ /**
+  * Just used for tagging contents that are allowed inside a ds:X509Data Element.
+  *
+- * @author $Author: blautenb $
++ * @author $Author: mullan $
+  */
+ public interface XMLX509DataContent {
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509IssuerSerial.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509IssuerSerial.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509IssuerSerial.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509IssuerSerial.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content.x509;
+ 
+-
+-
+ import java.math.BigInteger;
+ import java.security.cert.X509Certificate;
+ 
+@@ -33,148 +31,139 @@
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class XMLX509IssuerSerial extends SignatureElementProxy
+         implements XMLX509DataContent {
+ 
+-   /** {@link java.util.logging} logging facility */
++    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(
+                     XMLX509IssuerSerial.class.getName());
+ 
+-   /**
+-    * Constructor XMLX509IssuerSerial
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @throws XMLSecurityException
+-    */
+-   public XMLX509IssuerSerial(Element element, String BaseURI)
++    /**
++     * Constructor XMLX509IssuerSerial
++     *
++     * @param element
++     * @param baseURI
++     * @throws XMLSecurityException
++     */
++    public XMLX509IssuerSerial(Element element, String baseURI)
+            throws XMLSecurityException {
+-      super(element, BaseURI);
+-   }
++        super(element, baseURI);
++    }
+ 
+-   /**
+-    * Constructor XMLX509IssuerSerial
+-    *
+-    * @param doc
+-    * @param X509IssuerName
+-    * @param X509SerialNumber
+-    */
+-   public XMLX509IssuerSerial(Document doc, String X509IssuerName,
+-                              BigInteger X509SerialNumber) {
++    /**
++     * Constructor XMLX509IssuerSerial
++     *
++     * @param doc
++     * @param x509IssuerName
++     * @param x509SerialNumber
++     */
++    public XMLX509IssuerSerial(Document doc, String x509IssuerName,
++                               BigInteger x509SerialNumber) {
+ 
+-      super(doc);
++        super(doc);
++        XMLUtils.addReturnToElement(this._constructionElement);
++        addTextElement(x509IssuerName, Constants._TAG_X509ISSUERNAME);
++        addTextElement(x509SerialNumber.toString(), Constants._TAG_X509SERIALNUMBER);
++    }
+ 
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-      this.addTextElement(X509IssuerName, Constants._TAG_X509ISSUERNAME);
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-      this.addTextElement(X509SerialNumber.toString(), Constants._TAG_X509SERIALNUMBER);
+-   }
++    /**
++     * Constructor XMLX509IssuerSerial
++     *
++     * @param doc
++     * @param x509IssuerName
++     * @param x509SerialNumber
++     */
++    public XMLX509IssuerSerial(Document doc, String x509IssuerName,
++                               String x509SerialNumber) {
++        this(doc, x509IssuerName, new BigInteger(x509SerialNumber));
++    }
+ 
+-   /**
+-    * Constructor XMLX509IssuerSerial
+-    *
+-    * @param doc
+-    * @param X509IssuerName
+-    * @param X509SerialNumber
+-    */
+-   public XMLX509IssuerSerial(Document doc, String X509IssuerName,
+-                              String X509SerialNumber) {
+-      this(doc, X509IssuerName, new BigInteger(X509SerialNumber));
+-   }
++    /**
++     * Constructor XMLX509IssuerSerial
++     *
++     * @param doc
++     * @param x509IssuerName
++     * @param x509SerialNumber
++     */
++    public XMLX509IssuerSerial(Document doc, String x509IssuerName,
++                               int x509SerialNumber) {
++        this(doc, x509IssuerName,
++             new BigInteger(Integer.toString(x509SerialNumber)));
++    }
+ 
+-   /**
+-    * Constructor XMLX509IssuerSerial
+-    *
+-    * @param doc
+-    * @param X509IssuerName
+-    * @param X509SerialNumber
+-    */
+-   public XMLX509IssuerSerial(Document doc, String X509IssuerName,
+-                              int X509SerialNumber) {
+-      this(doc, X509IssuerName,
+-           new BigInteger(Integer.toString(X509SerialNumber)));
+-   }
++    /**
++     * Constructor XMLX509IssuerSerial
++     *
++     * @param doc
++     * @param x509certificate
++     */
++    public XMLX509IssuerSerial(Document doc, X509Certificate x509certificate) {
+ 
+-   /**
+-    * Constructor XMLX509IssuerSerial
+-    *
+-    * @param doc
+-    * @param x509certificate
+-    */
+-   public XMLX509IssuerSerial(Document doc, X509Certificate x509certificate) {
++        this(doc,
++             RFC2253Parser.normalize(x509certificate.getIssuerDN().getName()),
++             x509certificate.getSerialNumber());
++    }
+ 
+-      this(doc,
+-           RFC2253Parser.normalize(x509certificate.getIssuerDN().getName()),
+-           x509certificate.getSerialNumber());
+-   }
++    /**
++     * Method getSerialNumber
++     *
++     * @return the serial number
++     */
++    public BigInteger getSerialNumber() {
+ 
+-   /**
+-    * Method getSerialNumber
+-    *
+-    *
+-    * @return the serial number
+-    */
+-   public BigInteger getSerialNumber() {
++        String text = this.getTextFromChildElement
++            (Constants._TAG_X509SERIALNUMBER, Constants.SignatureSpecNS);
++        if (log.isLoggable(java.util.logging.Level.FINE))
++            log.log(java.util.logging.Level.FINE, "X509SerialNumber text: " + text);
+ 
+-      String text =
+-         this.getTextFromChildElement(Constants._TAG_X509SERIALNUMBER,
+-                                      Constants.SignatureSpecNS);
+-      if (true)
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "In dem X509SerialNumber wurde gefunden: " + text);
++        return new BigInteger(text);
++    }
+ 
+-      return new BigInteger(text);
+-   }
++    /**
++     * Method getSerialNumberInteger
++     *
++     * @return the serial number as plain int
++     */
++    public int getSerialNumberInteger() {
++        return this.getSerialNumber().intValue();
++    }
+ 
+-   /**
+-    * Method getSerialNumberInteger
+-    *
+-    *
+-    * @return the serial number as plain int
+-    */
+-   public int getSerialNumberInteger() {
+-      return this.getSerialNumber().intValue();
+-   }
++    /**
++     * Method getIssuerName
++     *
++     * @return the issuer name
++     */
++    public String getIssuerName()  {
+ 
+-   /**
+-    * Method getIssuerName
+-    *
+-    *
+-    * @return the issuer name
+-    */
+-   public String getIssuerName()  {
++        return RFC2253Parser
++           .normalize(this
++              .getTextFromChildElement(Constants._TAG_X509ISSUERNAME,
++                                       Constants.SignatureSpecNS));
++    }
+ 
+-      return RFC2253Parser
+-         .normalize(this
+-            .getTextFromChildElement(Constants._TAG_X509ISSUERNAME,
+-                                     Constants.SignatureSpecNS));
+-   }
++    /** @inheritDoc */
++    public boolean equals(Object obj) {
+ 
+-   /** @inheritDoc */
+-   public boolean equals(Object obj) {
++        if (obj == null) {
++            return false;
++        }
++        if (!this.getClass().getName().equals(obj.getClass().getName())) {
++            return false;
++        }
+ 
+-      if (!obj.getClass().getName().equals(this.getClass().getName())) {
+-         return false;
+-      }
++        XMLX509IssuerSerial other = (XMLX509IssuerSerial) obj;
+ 
+-      XMLX509IssuerSerial other = (XMLX509IssuerSerial) obj;
++        return this.getSerialNumber().equals(other.getSerialNumber())
++               && this.getIssuerName().equals(other.getIssuerName());
++    }
+ 
+-
+-      if (other.getSerialNumber().equals(this.getSerialNumber())
+-                 && other.getIssuerName().equals(this.getIssuerName())) {
+-           return true;
+-      }
+-
+-       return false;
+-   }
+-
+-   /** @inheritDoc */
+-   public String getBaseLocalName() {
+-      return Constants._TAG_X509ISSUERSERIAL;
+-   }
++    /** @inheritDoc */
++    public String getBaseLocalName() {
++        return Constants._TAG_X509ISSUERSERIAL;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SKI.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content.x509;
+ 
+-
+-
+ import java.io.IOException;
+ import java.io.ByteArrayInputStream;
+ import java.io.InputStream;
+@@ -36,192 +34,143 @@
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-import sun.security.util.DerValue;
+-
+-
+ /**
+  * Handles SubjectKeyIdentifier (SKI) for X.509v3.
+  *
+- * @author $Author: raul $
+- * @see <A HREF="http://java.sun.com/products/jdk/1.2/docs/api/java/security/cert/X509Extension.html">Interface X509Extension</A>
++ * @author $Author: mullan $
++ * @see <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/security/cert/X509Extension.html">Interface X509Extension</A>
+  */
+ public class XMLX509SKI extends SignatureElementProxy
+         implements XMLX509DataContent {
+ 
+-   /** {@link java.util.logging} logging facility */
++    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(XMLX509SKI.class.getName());
+ 
+-   /**
+-    * <CODE>SubjectKeyIdentifier (id-ce-subjectKeyIdentifier) (2.5.29.14)</CODE>:
+-    * This extension identifies the public key being certified. It enables
+-    * distinct keys used by the same subject to be differentiated
+-    * (e.g., as key updating occurs).
+-    * <BR />
+-    * A key identifer shall be unique with respect to all key identifiers
+-    * for the subject with which it is used. This extension is always non-critical.
+-    */
+-   public static final String SKI_OID = "2.5.29.14";
++    /**
++     * <CODE>SubjectKeyIdentifier (id-ce-subjectKeyIdentifier) (2.5.29.14)</CODE>:
++     * This extension identifies the public key being certified. It enables
++     * distinct keys used by the same subject to be differentiated
++     * (e.g., as key updating occurs).
++     * <BR />
++     * A key identifer shall be unique with respect to all key identifiers
++     * for the subject with which it is used. This extension is always non-critical.
++     */
++    public static final String SKI_OID = "2.5.29.14";
+ 
+-   /**
+-    * Constructor X509SKI
+-    *
+-    * @param doc
+-    * @param skiBytes
+-    */
+-   public XMLX509SKI(Document doc, byte[] skiBytes) {
++    /**
++     * Constructor X509SKI
++     *
++     * @param doc
++     * @param skiBytes
++     */
++    public XMLX509SKI(Document doc, byte[] skiBytes) {
++        super(doc);
++        this.addBase64Text(skiBytes);
++    }
+ 
+-      super(doc);
++    /**
++     * Constructor XMLX509SKI
++     *
++     * @param doc
++     * @param x509certificate
++     * @throws XMLSecurityException
++     */
++    public XMLX509SKI(Document doc, X509Certificate x509certificate)
++           throws XMLSecurityException {
++        super(doc);
++        this.addBase64Text(XMLX509SKI.getSKIBytesFromCert(x509certificate));
++    }
+ 
+-      this.addBase64Text(skiBytes);
+-   }
++    /**
++     * Constructor XMLX509SKI
++     *
++     * @param element
++     * @param BaseURI
++     * @throws XMLSecurityException
++     */
++    public XMLX509SKI(Element element, String BaseURI)
++           throws XMLSecurityException {
++        super(element, BaseURI);
++    }
+ 
+-   /**
+-    * Constructor XMLX509SKI
+-    *
+-    * @param doc
+-    * @param x509certificate
+-    * @throws XMLSecurityException
+-    */
+-   public XMLX509SKI(Document doc, X509Certificate x509certificate)
+-           throws XMLSecurityException {
++    /**
++     * Method getSKIBytes
++     *
++     * @return the skibytes
++     * @throws XMLSecurityException
++     */
++    public byte[] getSKIBytes() throws XMLSecurityException {
++        return this.getBytesFromTextChild();
++    }
+ 
+-      super(doc);
++    /**
++     * Method getSKIBytesFromCert
++     *
++     * @param cert
++     * @return ski bytes from the given certificate
++     *
++     * @throws XMLSecurityException
++     * @see java.security.cert.X509Extension#getExtensionValue(java.lang.String)
++     */
++    public static byte[] getSKIBytesFromCert(X509Certificate cert)
++        throws XMLSecurityException {
+ 
+-      this.addBase64Text(XMLX509SKI.getSKIBytesFromCert(x509certificate));
+-   }
+-
+-   /**
+-    * Constructor XMLX509SKI
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @throws XMLSecurityException
+-    */
+-   public XMLX509SKI(Element element, String BaseURI)
+-           throws XMLSecurityException {
+-      super(element, BaseURI);
+-   }
+-
+-   /**
+-    * Method getSKIBytes
+-    *
+-    * @return the skibytes
+-    * @throws XMLSecurityException
+-    */
+-   public byte[] getSKIBytes() throws XMLSecurityException {
+-      return this.getBytesFromTextChild();
+-   }
+-
+-   /**
+-    * Method getSKIBytesFromCert
+-    *
+-    * @param cert
+-    * @return sky bytes from the given certificate
+-    *
+-    * @throws XMLSecurityException
+-    * @see java.security.cert.X509Extension#getExtensionValue(java.lang.String)
+-    */
+-   public static byte[] getSKIBytesFromCert(X509Certificate cert)
+-           throws XMLSecurityException {
+-
+-      try {
+-
+-         /*
+-          * Gets the DER-encoded OCTET string for the extension value (extnValue)
+-          * identified by the passed-in oid String. The oid string is
+-          * represented by a set of positive whole numbers separated by periods.
+-          */
+-         byte[] derEncodedValue = cert.getExtensionValue(XMLX509SKI.SKI_OID);
+-
+-         if (cert.getVersion() < 3) {
++        if (cert.getVersion() < 3) {
+             Object exArgs[] = { new Integer(cert.getVersion()) };
+-
+             throw new XMLSecurityException("certificate.noSki.lowVersion",
+                                            exArgs);
+-         }
++        }
+ 
+-          byte[] extensionValue = null;
++        /*
++         * Gets the DER-encoded OCTET string for the extension value
++         * (extnValue) identified by the passed-in oid String. The oid
++         * string is represented by a set of positive whole numbers
++         * separated by periods.
++         */
++        byte[] extensionValue = cert.getExtensionValue(XMLX509SKI.SKI_OID);
++        if (extensionValue == null) {
++            throw new XMLSecurityException("certificate.noSki.null");
++        }
+ 
+-          /**
+-           * Use sun.security.util.DerValue if it is present.
+-           */
+-          try {
+-                  DerValue dervalue = new DerValue(derEncodedValue);
+-                  if (dervalue == null) {
+-                      throw new XMLSecurityException("certificate.noSki.null");
+-                  }
+-                  if (dervalue.tag != DerValue.tag_OctetString) {
+-                      throw new XMLSecurityException("certificate.noSki.notOctetString");
+-                  }
+-                  extensionValue = dervalue.getOctetString();
+-          } catch (NoClassDefFoundError e) {
+-          }
++        /**
++         * Strip away first four bytes from the extensionValue
++         * The first two bytes are the tag and length of the extensionValue
++         * OCTET STRING, and the next two bytes are the tag and length of
++         * the skid OCTET STRING.
++         */
++        byte skidValue[] = new byte[extensionValue.length - 4];
+ 
+-          /**
+-           * Fall back to org.bouncycastle.asn1.DERInputStream
+-           */
+-          if (extensionValue == null) {
+-              try {
+-                  Class clazz = Class.forName("org.bouncycastle.asn1.DERInputStream");
+-                  if (clazz != null) {
+-                      Constructor constructor = clazz.getConstructor(new Class[]{InputStream.class});
+-                      InputStream is = (InputStream) constructor.newInstance(new Object[]{new ByteArrayInputStream(derEncodedValue)});
+-                      Method method = clazz.getMethod("readObject", new Class[]{});
+-                      Object obj = method.invoke(is, new Object[]{});
+-                      if (obj == null) {
+-                          throw new XMLSecurityException("certificate.noSki.null");
+-                      }
+-                      Class clazz2 = Class.forName("org.bouncycastle.asn1.ASN1OctetString");
+-                      if (!clazz2.isInstance(obj)) {
+-                          throw new XMLSecurityException("certificate.noSki.notOctetString");
+-                      }
+-                      Method method2 = clazz2.getMethod("getOctets", new Class[]{});
+-                      extensionValue = (byte[]) method2.invoke(obj, new Object[]{});
+-                  }
+-              } catch (Throwable t) {
+-              }
+-          }
++        System.arraycopy(extensionValue, 4, skidValue, 0, skidValue.length);
+ 
+-         /**
+-          * Strip away first two bytes from the DerValue (tag and length)
+-          */
+-         byte abyte0[] = new byte[extensionValue.length - 2];
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Base64 of SKI is " + Base64.encode(skidValue));
++        }
+ 
+-         System.arraycopy(extensionValue, 2, abyte0, 0, abyte0.length);
++        return skidValue;
++    }
+ 
+-         /*
+-         byte abyte0[] = new byte[derEncodedValue.length - 4];
+-         System.arraycopy(derEncodedValue, 4, abyte0, 0, abyte0.length);
+-         */
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Base64 of SKI is " + Base64.encode(abyte0));
++    /** @inheritDoc */
++    public boolean equals(Object obj) {
++        if (obj == null) {
++            return false;
++        }
++        if (!this.getClass().getName().equals(obj.getClass().getName())) {
++            return false;
++        }
+ 
+-         return abyte0;
+-      } catch (IOException ex) {
+-         throw new XMLSecurityException("generic.EmptyMessage", ex);
+-      }
+-   }
++        XMLX509SKI other = (XMLX509SKI) obj;
+ 
+-   /** @inheritDoc */
+-   public boolean equals(Object obj) {
++        try {
++            return java.security.MessageDigest.isEqual(other.getSKIBytes(),
++                                        this.getSKIBytes());
++        } catch (XMLSecurityException ex) {
++            return false;
++        }
++    }
+ 
+-      if (!obj.getClass().getName().equals(this.getClass().getName())) {
+-         return false;
+-      }
+-
+-      XMLX509SKI other = (XMLX509SKI) obj;
+-
+-      try {
+-         return java.security.MessageDigest.isEqual(other.getSKIBytes(),
+-                                        this.getSKIBytes());
+-      } catch (XMLSecurityException ex) {
+-         return false;
+-      }
+-   }
+-
+-   /** @inheritDoc */
+-   public String getBaseLocalName() {
+-      return Constants._TAG_X509SKI;
+-   }
++    /** @inheritDoc */
++    public String getBaseLocalName() {
++        return Constants._TAG_X509SKI;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SubjectName.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SubjectName.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SubjectName.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/content/x509/XMLX509SubjectName.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.content.x509;
+ 
+-
+-
+ import java.security.cert.X509Certificate;
+ 
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+@@ -33,15 +31,11 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class XMLX509SubjectName extends SignatureElementProxy
+         implements XMLX509DataContent {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(XMLX509SubjectName.class.getName());
+-
+    /**
+     * Constructor X509SubjectName
+     *
+@@ -88,23 +82,21 @@
+       return RFC2253Parser.normalize(this.getTextFromTextChild());
+    }
+ 
+-   /** @inheritDoc */
+-   public boolean equals(Object obj) {
++    /** @inheritDoc */
++    public boolean equals(Object obj) {
++        if (obj == null) {
++            return false;
++        }
+ 
+-      if (!obj.getClass().getName().equals(this.getClass().getName())) {
+-         return false;
+-      }
++        if (!this.getClass().getName().equals(obj.getClass().getName())) {
++            return false;
++        }
+ 
+-      XMLX509SubjectName other = (XMLX509SubjectName) obj;
+-      String otherSubject = other.getSubjectName();
+-      String thisSubject = this.getSubjectName();
++        XMLX509SubjectName other = (XMLX509SubjectName) obj;
++        String otherSubject = other.getSubjectName();
++        String thisSubject = this.getSubjectName();
+ 
+-      if (otherSubject.equals(thisSubject)) {
+-            return true;
+-      }
+-
+-       return false;
+-
++        return thisSubject.equals(otherSubject);
+    }
+ 
+    /** @inheritDoc */
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/InvalidKeyResolverException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/InvalidKeyResolverException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/InvalidKeyResolverException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/InvalidKeyResolverException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -29,7 +28,7 @@
+ /**
+  *
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class InvalidKeyResolverException extends XMLSecurityException {
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -26,6 +25,7 @@
+ import java.security.PublicKey;
+ import java.security.cert.X509Certificate;
+ import java.util.ArrayList;
++import java.util.Iterator;
+ import java.util.List;
+ 
+ import javax.crypto.SecretKey;
+@@ -39,7 +39,8 @@
+  * KeyResolver is factory class for subclass of KeyResolverSpi that
+  * represent child element of KeyInfo.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
++ * @version %I%, %G%
+  */
+ public class KeyResolver {
+ 
+@@ -72,6 +73,7 @@
+                   InstantiationException {
+       this._resolverSpi =
+          (KeyResolverSpi) Class.forName(className).newInstance();
++      this._resolverSpi.setGlobalResolver(true);
+    }
+ 
+    /**
+@@ -83,21 +85,17 @@
+       return KeyResolver._resolverVector.size();
+    }
+ 
+-   /**
+-    * Method item
+-    *
+-    * @param i
+-    * @return the number i resolver registerd
+-    * @throws KeyResolverException
+-    */
+-   public static KeyResolver item(int i) throws KeyResolverException {
+-
+-           KeyResolver resolver = (KeyResolver) KeyResolver._resolverVector.get(i);
+-      if (resolver==null) {
+-         throw new KeyResolverException("utils.resolver.noClass");
+-      }
+-
+-      return resolver;
++   public static void hit(Iterator hintI) {
++           ResolverIterator hint = (ResolverIterator) hintI;
++           int i = hint.i;
++           if (i!=1 && hint.res ==_resolverVector) {
++                   List resolverVector=(List)((ArrayList)_resolverVector).clone();
++                Object ob=resolverVector.remove(i-1);
++                resolverVector.add(0,ob);
++                 _resolverVector=resolverVector;
++         } else {
++                 //System.out.println("KeyResolver hitting");
++         }
+    }
+ 
+    /**
+@@ -106,17 +104,19 @@
+     * @param element
+     * @param BaseURI
+     * @param storage
+-    * @return the instance that happends to implement the thing.
++    * @return The certificate represented by the element.
+     *
+     * @throws KeyResolverException
+     */
+-   public static final KeyResolver getInstance(
++   public static final X509Certificate getX509Certificate(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
+ 
+-      for (int i = 0; i < KeyResolver._resolverVector.size(); i++) {
++          // use the old vector to not be hit by updates
++          List resolverVector = KeyResolver._resolverVector;
++      for (int i = 0; i < resolverVector.size(); i++) {
+                   KeyResolver resolver=
+-            (KeyResolver) KeyResolver._resolverVector.get(i);
++            (KeyResolver) resolverVector.get(i);
+ 
+                   if (resolver==null) {
+             Object exArgs[] = {
+@@ -127,11 +127,63 @@
+ 
+             throw new KeyResolverException("utils.resolver.noClass", exArgs);
+          }
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass());
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass());
+ 
+-         if (resolver.canResolve(element, BaseURI, storage)) {
+-            return resolver;
++         X509Certificate cert=resolver.resolveX509Certificate(element, BaseURI, storage);
++         if (cert!=null) {
++            return cert;
++         }
++      }
++
++      Object exArgs[] = {
++         (((element != null) && (element.getNodeType() == Node.ELEMENT_NODE))
++          ? element.getTagName()
++          : "null") };
++
++      throw new KeyResolverException("utils.resolver.noClass", exArgs);
++   }
++   /**
++    * Method getInstance
++    *
++    * @param element
++    * @param BaseURI
++    * @param storage
++    * @return the public key contained in the element
++    *
++    * @throws KeyResolverException
++    */
++   public static final PublicKey getPublicKey(
++           Element element, String BaseURI, StorageResolver storage)
++              throws KeyResolverException {
++
++          List resolverVector = KeyResolver._resolverVector;
++      for (int i = 0; i < resolverVector.size(); i++) {
++                  KeyResolver resolver=
++            (KeyResolver) resolverVector.get(i);
++
++                  if (resolver==null) {
++            Object exArgs[] = {
++               (((element != null)
++                 && (element.getNodeType() == Node.ELEMENT_NODE))
++                ? element.getTagName()
++                : "null") };
++
++            throw new KeyResolverException("utils.resolver.noClass", exArgs);
++         }
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass());
++
++         PublicKey cert=resolver.resolvePublicKey(element, BaseURI, storage);
++         if (cert!=null) {
++                 if (i!=0 && resolverVector==_resolverVector) {
++                         //update resolver.
++                         resolverVector=(List)((ArrayList)_resolverVector).clone();
++                                 Object ob=resolverVector.remove(i);
++                                 resolverVector.add(0,ob);
++                                 _resolverVector=resolverVector;
++                 }
++                 return cert;
+          }
+       }
+ 
+@@ -182,34 +234,6 @@
+       KeyResolver._resolverVector.add(0, className);
+    }
+ 
+-   /*
+-    * Method resolve
+-    *
+-    * @param element
+-    *
+-    * @throws KeyResolverException
+-    */
+-
+-   /**
+-    * Method resolveStatic
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    * @return resolve from the static register an element
+-    *
+-    * @throws KeyResolverException
+-    */
+-   public static PublicKey resolveStatic(
+-           Element element, String BaseURI, StorageResolver storage)
+-              throws KeyResolverException {
+-
+-      KeyResolver myResolver = KeyResolver.getInstance(element, BaseURI,
+-                                  storage);
+-
+-      return myResolver.resolvePublicKey(element, BaseURI, storage);
+-   }
+-
+    /**
+     * Method resolve
+     *
+@@ -223,7 +247,7 @@
+    public PublicKey resolvePublicKey(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
+-      return this._resolverSpi.engineResolvePublicKey(element, BaseURI, storage);
++      return this._resolverSpi.engineLookupAndResolvePublicKey(element, BaseURI, storage);
+    }
+ 
+    /**
+@@ -239,7 +263,7 @@
+    public X509Certificate resolveX509Certificate(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
+-      return this._resolverSpi.engineResolveX509Certificate(element, BaseURI,
++      return this._resolverSpi.engineLookupResolveX509Certificate(element, BaseURI,
+               storage);
+    }
+ 
+@@ -253,7 +277,7 @@
+    public SecretKey resolveSecretKey(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
+-      return this._resolverSpi.engineResolveSecretKey(element, BaseURI,
++      return this._resolverSpi.engineLookupAndResolveSecretKey(element, BaseURI,
+               storage);
+    }
+ 
+@@ -277,14 +301,6 @@
+       return this._resolverSpi.engineGetProperty(key);
+    }
+ 
+-   /**
+-    * Method getPropertyKeys
+-    *
+-    * @return the properties key registerd in this resolver
+-    */
+-   public String[] getPropertyKeys() {
+-      return this._resolverSpi.engineGetPropertyKeys();
+-   }
+ 
+    /**
+     * Method understandsProperty
+@@ -296,18 +312,6 @@
+       return this._resolverSpi.understandsProperty(propertyToTest);
+    }
+ 
+-   /**
+-    * Method canResolve
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    * @return true if can resolve the key in the element
+-    */
+-   public boolean canResolve(Element element, String BaseURI,
+-                             StorageResolver storage) {
+-      return this._resolverSpi.engineCanResolve(element, BaseURI, storage);
+-   }
+ 
+    /**
+     * Method resolverClassName
+@@ -317,4 +321,37 @@
+    public String resolverClassName() {
+       return this._resolverSpi.getClass().getName();
+    }
++
++   static class ResolverIterator implements Iterator {
++           List res;
++                Iterator it;
++                int i;
++           public ResolverIterator(List list) {
++                res = list;
++                it = res.iterator();
++        }
++                public boolean hasNext() {
++                        // TODO Auto-generated method stub
++                        return it.hasNext();
++                }
++
++                public Object next() {
++                        i++;
++                        KeyResolver resolver = (KeyResolver) it.next();
++                      if (resolver==null) {
++                         throw new RuntimeException("utils.resolver.noClass");
++                      }
++
++                      return resolver._resolverSpi;
++                }
++
++                public void remove() {
++                        // TODO Auto-generated method stub
++
++                }
++
++        };
++        public static Iterator iterator() {
++                return new ResolverIterator(_resolverVector);
++   }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -31,7 +30,7 @@
+  *
+  *
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  *
+  */
+ public class KeyResolverException extends XMLSecurityException {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java
+@@ -20,17 +20,15 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.keyresolver;
+ 
+-
+-
+ import java.security.PublicKey;
+ import java.security.cert.X509Certificate;
++import java.util.HashMap;
+ 
+ import javax.crypto.SecretKey;
+ 
+ import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  * This class is abstract class for a child KeyInfo Elemnet.
+  *
+@@ -41,14 +39,10 @@
+  *   JAVACLASS="MyPackage.MyKeyValueImpl"//gt;
+  * </PRE>
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
++ * @version $Revision: 1.5 $
+  */
+ public abstract class KeyResolverSpi {
+-
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(KeyResolverSpi.class.getName());
+-
+    /**
+     * This method helps the {@link com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver} to decide whether a
+     * {@link com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverSpi} is able to perform the requested action.
+@@ -56,10 +50,12 @@
+     * @param element
+     * @param BaseURI
+     * @param storage
+-    * @return true if can resolve the key in the element
++    * @return
+     */
+-   abstract public boolean engineCanResolve(Element element, String BaseURI,
+-                                            StorageResolver storage);
++   public boolean engineCanResolve(Element element, String BaseURI,
++                                                    StorageResolver storage) {
++           throw new UnsupportedOperationException();
++   }
+ 
+    /**
+     * Method engineResolvePublicKey
+@@ -71,9 +67,60 @@
+     *
+     * @throws KeyResolverException
+     */
+-   abstract public PublicKey engineResolvePublicKey(
++   public PublicKey engineResolvePublicKey(
+       Element element, String BaseURI, StorageResolver storage)
+-         throws KeyResolverException;
++         throws KeyResolverException {
++           throw new UnsupportedOperationException();
++    };
++
++   /**
++    * Method engineResolvePublicKey
++    *
++    * @param element
++    * @param BaseURI
++    * @param storage
++    * @return resolved public key from the registered from the element.
++    *
++    * @throws KeyResolverException
++    */
++    public PublicKey engineLookupAndResolvePublicKey(
++      Element element, String BaseURI, StorageResolver storage)
++         throws KeyResolverException {
++        KeyResolverSpi tmp = cloneIfNeeded();
++        if (!tmp.engineCanResolve(element, BaseURI, storage))
++                return null;
++            return tmp.engineResolvePublicKey(element, BaseURI, storage);
++    }
++
++    private KeyResolverSpi cloneIfNeeded() throws KeyResolverException {
++        KeyResolverSpi tmp=this;
++        if (globalResolver) {
++                try {
++                        tmp = (KeyResolverSpi) getClass().newInstance();
++                } catch (InstantiationException e) {
++                        throw new KeyResolverException("",e);
++                } catch (IllegalAccessException e) {
++                        throw new KeyResolverException("",e);
++                }
++        }
++        return tmp;
++    }
++
++    /**
++     * Method engineResolveCertificate
++     *
++     * @param element
++     * @param BaseURI
++     * @param storage
++     * @return resolved X509Certificate key from the registered from the elements
++     *
++     * @throws KeyResolverException
++     */
++    public X509Certificate engineResolveX509Certificate(
++       Element element, String BaseURI, StorageResolver storage)
++          throws KeyResolverException{
++                   throw new UnsupportedOperationException();
++    };
+ 
+    /**
+     * Method engineResolveCertificate
+@@ -85,9 +132,30 @@
+     *
+     * @throws KeyResolverException
+     */
+-   abstract public X509Certificate engineResolveX509Certificate(
++    public X509Certificate engineLookupResolveX509Certificate(
+       Element element, String BaseURI, StorageResolver storage)
+-         throws KeyResolverException;
++         throws KeyResolverException {
++        KeyResolverSpi tmp = cloneIfNeeded();
++        if (!tmp.engineCanResolve(element, BaseURI, storage))
++                return null;
++        return tmp.engineResolveX509Certificate(element, BaseURI, storage);
++
++    }
++    /**
++     * Method engineResolveSecretKey
++     *
++     * @param element
++     * @param BaseURI
++     * @param storage
++     * @return resolved SecretKey key from the registered from the elements
++     *
++     * @throws KeyResolverException
++     */
++    public SecretKey engineResolveSecretKey(
++       Element element, String BaseURI, StorageResolver storage)
++          throws KeyResolverException{
++                   throw new UnsupportedOperationException();
++    };
+ 
+    /**
+     * Method engineResolveSecretKey
+@@ -99,12 +167,19 @@
+     *
+     * @throws KeyResolverException
+     */
+-   abstract public SecretKey engineResolveSecretKey(
++   public SecretKey engineLookupAndResolveSecretKey(
+       Element element, String BaseURI, StorageResolver storage)
+-         throws KeyResolverException;
++         throws KeyResolverException {
++           KeyResolverSpi tmp = cloneIfNeeded();
++           if (!tmp.engineCanResolve(element, BaseURI, storage))
++                   return null;
++                return tmp.engineResolveSecretKey(element, BaseURI, storage);
++   }
+ 
+    /** Field _properties */
+-   protected java.util.Map _properties = new java.util.HashMap(10);
++   protected java.util.Map _properties = null;
++
++   protected boolean globalResolver=false;
+ 
+    /**
+     * Method engineSetProperty
+@@ -113,19 +188,8 @@
+     * @param value
+     */
+    public void engineSetProperty(String key, String value) {
+-
+-      java.util.Iterator i = this._properties.keySet().iterator();
+-
+-      while (i.hasNext()) {
+-         String c = (String) i.next();
+-
+-         if (c.equals(key)) {
+-            key = c;
+-
+-            break;
+-         }
+-      }
+-
++           if (_properties==null)
++                   _properties=new HashMap();
+       this._properties.put(key, value);
+    }
+ 
+@@ -136,49 +200,26 @@
+     * @return obtain the property appointed by key
+     */
+    public String engineGetProperty(String key) {
+-
+-      java.util.Iterator i = this._properties.keySet().iterator();
+-
+-      while (i.hasNext()) {
+-         String c = (String) i.next();
+-
+-         if (c.equals(key)) {
+-            key = c;
+-
+-            break;
+-         }
+-      }
++           if (_properties==null)
++                   return null;
+ 
+       return (String) this._properties.get(key);
+    }
+ 
+    /**
+-    * Method engineGetPropertyKeys
+-    *
+-    * @return the keys of properties known by this resolver
+-    */
+-   public String[] engineGetPropertyKeys() {
+-      return new String[0];
+-   }
+-
+-   /**
+     * Method understandsProperty
+     *
+     * @param propertyToTest
+     * @return true if understood the property
+     */
+    public boolean understandsProperty(String propertyToTest) {
++           if (_properties==null)
++                   return false;
+ 
+-      String[] understood = this.engineGetPropertyKeys();
++      return  this._properties.get(propertyToTest)!=null;
++   }
++   public void setGlobalResolver(boolean globalResolver) {
++        this.globalResolver = globalResolver;
++   }
+ 
+-      if (understood != null) {
+-         for (int i = 0; i < understood.length; i++) {
+-            if (understood[i].equals(propertyToTest)) {
+-               return true;
+-            }
+-         }
+-      }
+-
+-      return false;
+-   }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/DSAKeyValueResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/DSAKeyValueResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/DSAKeyValueResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/DSAKeyValueResolver.java
+@@ -37,46 +37,10 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class DSAKeyValueResolver extends KeyResolverSpi {
+ 
+-   /** Field _dsaKeyElement */
+-   private Element _dsaKeyElement = null;
+-
+-   /** @inheritDoc */
+-   public boolean engineCanResolve(Element element, String BaseURI,
+-                                   StorageResolver storage) {
+-
+-      if (element == null) {
+-         return false;
+-      }
+-
+-      boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
+-                              Constants._TAG_KEYVALUE);
+-      boolean isDSAKeyValue = XMLUtils.elementIsInSignatureSpace(element,
+-                                 Constants._TAG_DSAKEYVALUE);
+-
+-      if (isKeyValue) {
+-
+-            this._dsaKeyElement =
+-                XMLUtils.selectDsNode(element.getFirstChild(),Constants._TAG_DSAKEYVALUE,0);
+-
+-            if (this._dsaKeyElement != null) {
+-               return true;
+-            }
+-      } else if (isDSAKeyValue) {
+-
+-         // this trick is needed to allow the RetrievalMethodResolver to eat a
+-         // ds:DSAKeyValue directly (without KeyValue)
+-         this._dsaKeyElement = element;
+-
+-         return true;
+-      }
+-
+-      return false;
+-   }
+-
+    /**
+     * Method engineResolvePublicKey
+     *
+@@ -85,20 +49,30 @@
+     * @param storage
+     * @return null if no {@link PublicKey} could be obtained
+     */
+-   public PublicKey engineResolvePublicKey(
++   public PublicKey engineLookupAndResolvePublicKey(
+            Element element, String BaseURI, StorageResolver storage) {
++            if (element == null) {
++                 return null;
++            }
++            Element dsaKeyElement=null;
++            boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
++                                      Constants._TAG_KEYVALUE);
++            if (isKeyValue) {
++                dsaKeyElement =
++                        XMLUtils.selectDsNode(element.getFirstChild(),Constants._TAG_DSAKEYVALUE,0);
++       } else if (XMLUtils.elementIsInSignatureSpace(element,
++               Constants._TAG_DSAKEYVALUE)) {
++                 // this trick is needed to allow the RetrievalMethodResolver to eat a
++                 // ds:DSAKeyValue directly (without KeyValue)
++                 dsaKeyElement = element;
++            }
+ 
+-      if (this._dsaKeyElement == null) {
+-         boolean weCanResolve = this.engineCanResolve(element, BaseURI,
+-                                   storage);
+-
+-         if (!weCanResolve || (this._dsaKeyElement == null)) {
+-            return null;
+-         }
++      if (dsaKeyElement == null) {
++                    return null;
+       }
+ 
+       try {
+-         DSAKeyValue dsaKeyValue = new DSAKeyValue(this._dsaKeyElement,
++         DSAKeyValue dsaKeyValue = new DSAKeyValue(dsaKeyElement,
+                                                    BaseURI);
+          PublicKey pk = dsaKeyValue.getPublicKey();
+ 
+@@ -112,13 +86,13 @@
+ 
+ 
+    /** @inheritDoc */
+-   public X509Certificate engineResolveX509Certificate(
++   public X509Certificate engineLookupResolveX509Certificate(
+            Element element, String BaseURI, StorageResolver storage) {
+       return null;
+    }
+ 
+    /** @inheritDoc */
+-   public javax.crypto.SecretKey engineResolveSecretKey(
++   public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+            Element element, String BaseURI, StorageResolver storage){
+       return null;
+    }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/EncryptedKeyResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/EncryptedKeyResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/EncryptedKeyResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/EncryptedKeyResolver.java
+@@ -56,7 +56,6 @@
+                         RSAKeyValueResolver.class.getName());
+ 
+ 
+-        Key _key;
+         Key _kek;
+         String _algorithm;
+ 
+@@ -66,7 +65,6 @@
+          * @param algorithm
+          */
+         public EncryptedKeyResolver(String algorithm) {
+-                _key = null;
+                 _kek = null;
+         _algorithm=algorithm;
+         }
+@@ -78,64 +76,49 @@
+          */
+ 
+         public EncryptedKeyResolver(String algorithm, Key kek) {
+-                _key = null;
+                 _algorithm = algorithm;
+                 _kek = kek;
+ 
+         }
+ 
+-        /**
+-         * Method engineCanResolve
+-         *
+-         * @param element
+-         * @param BaseURI
+-         * @param storage
+-         * @return true if can resolve the key in the element
+-         *
+-         */
+-
+-        public boolean engineCanResolve(Element element, String BaseURI,
+-                                   StorageResolver storage) {
+-          if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "EncryptedKeyResolver - Can I resolve " + element.getTagName());
+-
+-      if (element == null) {
+-         return false;
+-      }
+-
+-      boolean isEncryptedKey = XMLUtils.elementIsInEncryptionSpace(element,
+-                              EncryptionConstants._TAG_ENCRYPTEDKEY);
+-
+-      if (isEncryptedKey) {
+-                  if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Passed an Encrypted Key");
+-                  try {
+-                          XMLCipher cipher = XMLCipher.getInstance();
+-                          cipher.init(XMLCipher.UNWRAP_MODE, _kek);
+-                          EncryptedKey ek = cipher.loadEncryptedKey(element);
+-                          _key = cipher.decryptKey(ek, _algorithm);
+-                  }
+-                  catch (Exception e) {}
+-      }
+-
+-      return (_key != null);
+-   }
+-
+     /** @inheritDoc */
+-   public PublicKey engineResolvePublicKey(
++   public PublicKey engineLookupAndResolvePublicKey(
+            Element element, String BaseURI, StorageResolver storage) {
+ 
+            return null;
+    }
+ 
+    /** @inheritDoc */
+-   public X509Certificate engineResolveX509Certificate(
++   public X509Certificate engineLookupResolveX509Certificate(
+            Element element, String BaseURI, StorageResolver storage) {
+       return null;
+    }
+ 
+    /** @inheritDoc */
+-   public javax.crypto.SecretKey engineResolveSecretKey(
++   public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+            Element element, String BaseURI, StorageResolver storage) {
+-      return (SecretKey) _key;
++           SecretKey key=null;
++           if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "EncryptedKeyResolver - Can I resolve " + element.getTagName());
++
++              if (element == null) {
++                 return null;
++              }
++
++              boolean isEncryptedKey = XMLUtils.elementIsInEncryptionSpace(element,
++                                      EncryptionConstants._TAG_ENCRYPTEDKEY);
++
++              if (isEncryptedKey) {
++                          log.log(java.util.logging.Level.FINE, "Passed an Encrypted Key");
++                          try {
++                                  XMLCipher cipher = XMLCipher.getInstance();
++                                  cipher.init(XMLCipher.UNWRAP_MODE, _kek);
++                                  EncryptedKey ek = cipher.loadEncryptedKey(element);
++                                  key = (SecretKey) cipher.decryptKey(ek, _algorithm);
++                          }
++                          catch (Exception e) {}
++              }
++
++      return key;
+    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RSAKeyValueResolver.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -38,7 +37,7 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class RSAKeyValueResolver extends KeyResolverSpi {
+ 
+@@ -48,75 +47,55 @@
+                         RSAKeyValueResolver.class.getName());
+ 
+    /** Field _rsaKeyElement */
+-   private Element _rsaKeyElement = null;
++
+ 
+    /** @inheritDoc */
+-   public boolean engineCanResolve(Element element, String BaseURI,
+-                                   StorageResolver storage) {
+-          if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
+-
++   public PublicKey engineLookupAndResolvePublicKey(
++           Element element, String BaseURI, StorageResolver storage) {
++           if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
+       if (element == null) {
+-         return false;
++         return null;
+       }
+ 
+-      boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
+-                              Constants._TAG_KEYVALUE);
+-      boolean isRSAKeyValue = XMLUtils.elementIsInSignatureSpace(element,
+-                                 Constants._TAG_RSAKEYVALUE);
+-
+-      if (isKeyValue) {
+-            this._rsaKeyElement = XMLUtils.selectDsNode(element.getFirstChild(),
+-                    Constants._TAG_RSAKEYVALUE, 0);
+-
+-            if (this._rsaKeyElement != null) {
+-               return true;
+-            }
+-      } else if (isRSAKeyValue) {
+-
++          boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
++                                              Constants._TAG_KEYVALUE);
++          Element rsaKeyElement=null;
++          if (isKeyValue) {
++                   rsaKeyElement = XMLUtils.selectDsNode(element.getFirstChild(),
++                                    Constants._TAG_RSAKEYVALUE, 0);
++          } else if (XMLUtils.elementIsInSignatureSpace(element,
++              Constants._TAG_RSAKEYVALUE)) {
+          // this trick is needed to allow the RetrievalMethodResolver to eat a
+          // ds:RSAKeyValue directly (without KeyValue)
+-         this._rsaKeyElement = element;
++         rsaKeyElement = element;
++          }
+ 
+-         return true;
+-      }
+ 
+-      return false;
+-   }
+-
+-   /** @inheritDoc */
+-   public PublicKey engineResolvePublicKey(
+-           Element element, String BaseURI, StorageResolver storage) {
+-
+-      if (this._rsaKeyElement == null) {
+-         boolean weCanResolve = this.engineCanResolve(element, BaseURI,
+-                                   storage);
+-
+-         if (!weCanResolve || (this._rsaKeyElement == null)) {
+-            return null;
+-         }
++      if (rsaKeyElement == null) {
++         return null;
+       }
+ 
+       try {
+-         RSAKeyValue rsaKeyValue = new RSAKeyValue(this._rsaKeyElement,
++         RSAKeyValue rsaKeyValue = new RSAKeyValue(rsaKeyElement,
+                                                    BaseURI);
+ 
+          return rsaKeyValue.getPublicKey();
+       } catch (XMLSecurityException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
++         log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
+       }
+ 
+       return null;
+    }
+ 
+    /** @inheritDoc */
+-   public X509Certificate engineResolveX509Certificate(
++   public X509Certificate engineLookupResolveX509Certificate(
+            Element element, String BaseURI, StorageResolver storage) {
+       return null;
+    }
+ 
+    /** @inheritDoc */
+-   public javax.crypto.SecretKey engineResolveSecretKey(
++   public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+            Element element, String BaseURI, StorageResolver storage) {
+       return null;
+    }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
+@@ -28,7 +28,15 @@
+ import java.security.cert.CertificateException;
+ import java.security.cert.CertificateFactory;
+ import java.security.cert.X509Certificate;
++import java.util.ArrayList;
++import java.util.Iterator;
++import java.util.List;
++import java.util.ListIterator;
++import java.util.Set;
+ 
++import javax.xml.parsers.ParserConfigurationException;
++
++import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.keys.content.RetrievalMethod;
+ import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Certificate;
+@@ -44,6 +52,7 @@
+ import org.w3c.dom.Attr;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
++import org.xml.sax.SAXException;
+ 
+ 
+ /**
+@@ -55,7 +64,7 @@
+  * RetrievalMethodResolver cannot handle itself, resolving of the extracted
+  * element is delegated back to the KeyResolver mechanism.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $ modified by Dave Garcia
+  */
+ public class RetrievalMethodResolver extends KeyResolverSpi {
+ 
+@@ -65,26 +74,6 @@
+                         RetrievalMethodResolver.class.getName());
+ 
+    /**
+-    * Method engineCanResolve
+-    * @inheritDoc
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    *
+-    */
+-   public boolean engineCanResolve(Element element, String BaseURI,
+-                                   StorageResolver storage) {
+-
+-      if
+-         (!XMLUtils.elementIsInSignatureSpace(element,
+-                 Constants._TAG_RETRIEVALMETHOD)) {
+-         return false;
+-      }
+-
+-      return true;
+-   }
+-
+-   /**
+     * Method engineResolvePublicKey
+     * @inheritDoc
+     * @param element
+@@ -92,82 +81,59 @@
+     * @param storage
+     *
+     */
+-   public PublicKey engineResolvePublicKey(
++   public PublicKey engineLookupAndResolvePublicKey(
+            Element element, String BaseURI, StorageResolver storage)
+               {
++           if  (!XMLUtils.elementIsInSignatureSpace(element,
++               Constants._TAG_RETRIEVALMETHOD)) {
++                   return null;
++           }
+ 
+       try {
+-         RetrievalMethod rm = new RetrievalMethod(element, BaseURI);
+-         Attr uri = rm.getURIAttr();
++                   //Create a retrieval method over the given element
++                   RetrievalMethod rm = new RetrievalMethod(element, BaseURI);
++               String type = rm.getType();
++                   XMLSignatureInput resource=resolveInput(rm,BaseURI);
++           if (RetrievalMethod.TYPE_RAWX509.equals(type)) {
++                //a raw certificate, direct parsing is done!
++                X509Certificate cert=getRawCertificate(resource);
++                                if (cert != null) {
++                                 return cert.getPublicKey();
++                            }
++                                return null;
++            };
++                        Element e = obtainRefrenceElement(resource);
++                        return resolveKey(e,BaseURI,storage);
++          } catch (XMLSecurityException ex) {
++         log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
++      } catch (CertificateException ex) {
++         log.log(java.util.logging.Level.FINE, "CertificateException", ex);
++      } catch (IOException ex) {
++         log.log(java.util.logging.Level.FINE, "IOException", ex);
++      } catch (ParserConfigurationException e) {
++                  log.log(java.util.logging.Level.FINE, "ParserConfigurationException", e);
++          } catch (SAXException e) {
++                 log.log(java.util.logging.Level.FINE, "SAXException", e);
++          }
++      return null;
++   }
+ 
+-         // type can be null because it's optional
+-         String type = rm.getType();
+-         Transforms transforms = rm.getTransforms();
+-         ResourceResolver resRes = ResourceResolver.getInstance(uri, BaseURI);
+-
+-         if (resRes != null) {
+-            XMLSignatureInput resource = resRes.resolve(uri, BaseURI);
+-            if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Before applying Transforms, resource has "
+-                      + resource.getBytes().length + "bytes");
+-
+-            if (transforms != null) {
+-               if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "We have Transforms");
+-
+-               resource = transforms.performTransforms(resource);
+-            }
+-            if (true) {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "After applying Transforms, resource has "
+-                      + resource.getBytes().length + "bytes");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Resolved to resource " + resource.getSourceURI());
+-            }
+-
+-            byte inputBytes[] = resource.getBytes();
+-
+-            if ((type != null) && type.equals(RetrievalMethod.TYPE_RAWX509)) {
+-
+-               // if the resource stores a raw certificate, we have to handle it
+-               CertificateFactory certFact =
+-                  CertificateFactory
+-                     .getInstance(XMLX509Certificate.JCA_CERT_ID);
+-               X509Certificate cert =
+-                  (X509Certificate) certFact
+-                     .generateCertificate(new ByteArrayInputStream(inputBytes));
+-
+-               if (cert != null) {
+-                  return cert.getPublicKey();
+-               }
+-            } else {
+-
+-               // otherwise, we parse the resource, create an Element and delegate
+-                if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "we have to parse " + inputBytes.length + " bytes");
+-
+-               Element e = this.getDocFromBytes(inputBytes);
+-               if (true)
+-                    if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Now we have a {" + e.getNamespaceURI() + "}"
+-                         + e.getLocalName() + " Element");
+-
+-               if (e != null) {
+-                  KeyResolver newKeyResolver = KeyResolver.getInstance(getFirstElementChild(e),
+-                                                  BaseURI, storage);
+-
+-                  if (newKeyResolver != null) {
+-                     return newKeyResolver.resolvePublicKey(getFirstElementChild(e), BaseURI,
+-                                                            storage);
+-                  }
+-               }
+-            }
+-         }
+-      } catch (XMLSecurityException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
+-      } catch (CertificateException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "CertificateException", ex);
+-      } catch (IOException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "IOException", ex);
+-      }
+-
+-      return null;
++   static private Element obtainRefrenceElement(XMLSignatureInput resource) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException, KeyResolverException {
++           Element e;
++           if (resource.isElement()){
++                   e=(Element) resource.getSubNode();
++           } else if (resource.isNodeSet()) {
++                   //Retrieved resource is a nodeSet
++                   e=getDocumentElement(resource.getNodeSet());
++           } else {
++                   //Retrieved resource is an inputStream
++                   byte inputBytes[] = resource.getBytes();
++                   e = getDocFromBytes(inputBytes);
++                   //otherwise, we parse the resource, create an Element and delegate
++                   if (log.isLoggable(java.util.logging.Level.FINE))
++                           log.log(java.util.logging.Level.FINE, "we have to parse " + inputBytes.length + " bytes");
++           }
++           return e;
+    }
+ 
+    /**
+@@ -178,85 +144,100 @@
+     * @param storage
+     *
+     */
+-   public X509Certificate engineResolveX509Certificate(
++   public X509Certificate engineLookupResolveX509Certificate(
+            Element element, String BaseURI, StorageResolver storage)
+               {
++           if  (!XMLUtils.elementIsInSignatureSpace(element,
++               Constants._TAG_RETRIEVALMETHOD)) {
++                   return null;
++           }
+ 
+-      try {
++           try {
+          RetrievalMethod rm = new RetrievalMethod(element, BaseURI);
+-         Attr uri = rm.getURIAttr();
+-         Transforms transforms = rm.getTransforms();
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Asked to resolve URI " + uri);
++                 String type = rm.getType();
++                 XMLSignatureInput resource=resolveInput(rm,BaseURI);
++                 if (RetrievalMethod.TYPE_RAWX509.equals(type)) {
++                X509Certificate cert=getRawCertificate(resource);
++            return cert;
++                 }
++                 Element e = obtainRefrenceElement(resource);
++                 return resolveCertificate(e,BaseURI,storage);
++      } catch (XMLSecurityException ex) {
++         log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
++      } catch (CertificateException ex) {
++         log.log(java.util.logging.Level.FINE, "CertificateException", ex);
++      } catch (IOException ex) {
++         log.log(java.util.logging.Level.FINE, "IOException", ex);
++          } catch (ParserConfigurationException e) {
++                  log.log(java.util.logging.Level.FINE, "ParserConfigurationException", e);
++          } catch (SAXException e) {
++                 log.log(java.util.logging.Level.FINE, "SAXException", e);
++          }
++      return null;
++   }
+ 
+-         ResourceResolver resRes = ResourceResolver.getInstance(uri, BaseURI);
++   /**
++    * Retrieves a x509Certificate from the given information
++    * @param e
++    * @param BaseURI
++    * @param storage
++    * @return
++    * @throws KeyResolverException
++    */
++   static private X509Certificate resolveCertificate(Element e,String BaseURI,StorageResolver storage) throws KeyResolverException{
++                  if (log.isLoggable(java.util.logging.Level.FINE))
++                          log.log(java.util.logging.Level.FINE, "Now we have a {" + e.getNamespaceURI() + "}"+ e.getLocalName() + " Element");
++                  //An element has been provided
++          if (e != null) {
++                          return KeyResolver.getX509Certificate(e,BaseURI, storage);
++                  }
++                  return null;
++   }
+ 
+-         if (resRes != null) {
+-            XMLSignatureInput resource = resRes.resolve(uri, BaseURI);
+-            if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Before applying Transforms, resource has "
+-                      + resource.getBytes().length + "bytes");
++   /**
++    * Retrieves a x509Certificate from the given information
++    * @param e
++    * @param BaseURI
++    * @param storage
++    * @return
++    * @throws KeyResolverException
++    */
++   static private PublicKey resolveKey(Element e,String BaseURI,StorageResolver storage) throws KeyResolverException{
++                  if (log.isLoggable(java.util.logging.Level.FINE))
++                          log.log(java.util.logging.Level.FINE, "Now we have a {" + e.getNamespaceURI() + "}"+ e.getLocalName() + " Element");
++                  //An element has been provided
++          if (e != null) {
++                          return KeyResolver.getPublicKey(e,BaseURI, storage);
++                  }
++                  return null;
++   }
+ 
+-            if (transforms != null) {
+-               if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "We have Transforms");
+-
+-               resource = transforms.performTransforms(resource);
+-            }
+-
+-            if (true) {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "After applying Transforms, resource has "
+-                      + resource.getBytes().length + "bytes");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Resolved to resource " + resource.getSourceURI());
+-            }
+-
+-            byte inputBytes[] = resource.getBytes();
+-
+-            if ((rm.getType() != null)
+-                    && rm.getType().equals(RetrievalMethod.TYPE_RAWX509)) {
+-
+-               // if the resource stores a raw certificate, we have to handle it
+-               CertificateFactory certFact =
+-                  CertificateFactory
+-                     .getInstance(XMLX509Certificate.JCA_CERT_ID);
+-               X509Certificate cert =
+-                  (X509Certificate) certFact
+-                     .generateCertificate(new ByteArrayInputStream(inputBytes));
+-
+-               if (cert != null) {
+-                  return cert;
+-               }
+-            } else {
+-
+-               // otherwise, we parse the resource, create an Element and delegate
+-                if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "we have to parse " + inputBytes.length + " bytes");
+-
+-               Element e = this.getDocFromBytes(inputBytes);
+-
+-               if (true)
+-                    if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Now we have a {" + e.getNamespaceURI() + "}"
+-                         + e.getLocalName() + " Element");
+-
+-               if (e != null) {
+-                  KeyResolver newKeyResolver = KeyResolver.getInstance(getFirstElementChild(e),
+-                                                  BaseURI, storage);
+-
+-                  if (newKeyResolver != null) {
+-                     return newKeyResolver.resolveX509Certificate(getFirstElementChild(e), BaseURI,
+-                             storage);
+-                  }
+-               }
+-            }
+-         }
+-      } catch (XMLSecurityException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
+-      } catch (CertificateException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "CertificateException", ex);
+-      } catch (IOException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "IOException", ex);
+-      }
+-
+-      return null;
++   static private X509Certificate getRawCertificate(XMLSignatureInput resource) throws CanonicalizationException, IOException, CertificateException{
++           byte inputBytes[] = resource.getBytes();
++       // if the resource stores a raw certificate, we have to handle it
++       CertificateFactory certFact =CertificateFactory.getInstance(XMLX509Certificate.JCA_CERT_ID);
++       X509Certificate cert =(X509Certificate) certFact.generateCertificate(new ByteArrayInputStream(inputBytes));
++       return cert;
++   }
++   /**
++    * Resolves the input from the given retrieval method
++    * @return
++    * @throws XMLSecurityException
++    */
++   static private XMLSignatureInput resolveInput(RetrievalMethod rm,String BaseURI) throws XMLSecurityException{
++       Attr uri = rm.getURIAttr();
++           //Apply the trnasforms
++       Transforms transforms = rm.getTransforms();
++       ResourceResolver resRes = ResourceResolver.getInstance(uri, BaseURI);
++       if (resRes != null) {
++          XMLSignatureInput resource = resRes.resolve(uri, BaseURI);
++          if (transforms != null) {
++                  log.log(java.util.logging.Level.FINE, "We have Transforms");
++                          resource = transforms.performTransforms(resource);
++          }
++                  return resource;
++       }
++           return null;
+    }
+ 
+    /**
+@@ -266,18 +247,13 @@
+     * @return the Document Element after parsing bytes
+     * @throws KeyResolverException if something goes wrong
+     */
+-   Element getDocFromBytes(byte[] bytes) throws KeyResolverException {
+-
++   static Element getDocFromBytes(byte[] bytes) throws KeyResolverException {
+       try {
+-         javax.xml.parsers.DocumentBuilderFactory dbf =
+-            javax.xml.parsers.DocumentBuilderFactory.newInstance();
+-
++         javax.xml.parsers.DocumentBuilderFactory dbf =javax.xml.parsers.DocumentBuilderFactory.newInstance();
+          dbf.setNamespaceAware(true);
+-
+          javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
+          org.w3c.dom.Document doc =
+             db.parse(new java.io.ByteArrayInputStream(bytes));
+-
+          return doc.getDocumentElement();
+       } catch (org.xml.sax.SAXException ex) {
+          throw new KeyResolverException("empty", ex);
+@@ -296,16 +272,43 @@
+     * @param storage
+     *
+     */
+-   public javax.crypto.SecretKey engineResolveSecretKey(
++   public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+            Element element, String BaseURI, StorageResolver storage)
+    {
+       return null;
+    }
+-   static Element getFirstElementChild(Element e){
+-            Node n=e.getFirstChild();
+-            while (n!=null && n.getNodeType()!=Node.ELEMENT_NODE) {
+-                n=n.getNextSibling();
+-            }
+-                return (Element)n;
++
++   static Element getDocumentElement(Set set) {
++           Iterator it=set.iterator();
++           Element e=null;
++           while (it.hasNext()) {
++                   Node currentNode=(Node)it.next();
++                   if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE) {
++                           e=(Element)currentNode;
++                           break;
++                   }
++
++           }
++           List parents=new ArrayList(10);
++
++                //Obtain all the parents of the elemnt
++                while (e != null) {
++                        parents.add(e);
++                        Node n=e.getParentNode();
++                        if (n == null || n.getNodeType() != Node.ELEMENT_NODE) {
++                                break;
++                        }
++                        e=(Element)n;
++                }
++                //Visit them in reverse order.
++                ListIterator it2=parents.listIterator(parents.size()-1);
++                Element ele=null;
++                while (it2.hasPrevious()) {
++                        ele=(Element)it2.previous();
++                        if (set.contains(ele)) {
++                                return ele;
++                        }
++        }
++                return null;
+    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509CertificateResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509CertificateResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509CertificateResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509CertificateResolver.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -41,7 +40,7 @@
+  * Resolves Certificates which are directly contained inside a
+  * <CODE>ds:X509Certificate</CODE> Element.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class X509CertificateResolver extends KeyResolverSpi {
+ 
+@@ -49,47 +48,7 @@
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(X509CertificateResolver.class.getName());
+ 
+-   /** Field _dsaKeyElement */
+-   Element[] _x509CertKeyElements = null;
+ 
+-   /**
+-    * Method engineCanResolve
+-    * @inheritDoc
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    *
+-    */
+-   public boolean engineCanResolve(Element element, String BaseURI,
+-                                   StorageResolver storage) {
+-          if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
+-
+-      if (!XMLUtils.elementIsInSignatureSpace(element,
+-                 Constants._TAG_X509DATA)) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");
+-
+-         return false;
+-      }
+-
+-
+-         this._x509CertKeyElements = XMLUtils.selectDsNodes(element.getFirstChild(),
+-                 Constants._TAG_X509CERTIFICATE);
+-
+-         if ((this._x509CertKeyElements != null)
+-                 && (this._x509CertKeyElements.length > 0)) {
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Yes Sir, I can");
+-
+-            return true;
+-         }
+-
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");
+-
+-      return false;
+-   }
+-
+-   /** Field _x509certObject[] */
+-   XMLX509Certificate _x509certObject[] = null;
+ 
+    /**
+     * Method engineResolvePublicKey
+@@ -100,11 +59,11 @@
+     *
+     * @throws KeyResolverException
+     */
+-   public PublicKey engineResolvePublicKey(
++   public PublicKey engineLookupAndResolvePublicKey(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
+ 
+-      X509Certificate cert = this.engineResolveX509Certificate(element,
++      X509Certificate cert = this.engineLookupResolveX509Certificate(element,
+                                 BaseURI, storage);
+ 
+       if (cert != null) {
+@@ -123,43 +82,33 @@
+     *
+     * @throws KeyResolverException
+     */
+-   public X509Certificate engineResolveX509Certificate(
++   public X509Certificate engineLookupResolveX509Certificate(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
+ 
+       try {
+-         if ((this._x509CertKeyElements == null)
+-                 || (this._x509CertKeyElements.length == 0)) {
+-            boolean weCanResolve = this.engineCanResolve(element, BaseURI,
+-                                      storage);
++          Element[] els=XMLUtils.selectDsNodes(element.getFirstChild(),
++                  Constants._TAG_X509CERTIFICATE);
++         if ((els == null) || (els.length == 0)) {
++                 Element el=XMLUtils.selectDsNode(element.getFirstChild(),
++                     Constants._TAG_X509DATA,0);
++             if (el!=null) {
++                 return engineLookupResolveX509Certificate(el, BaseURI, storage);
++             }
++                 return null;
++         }
+ 
+-            if (!weCanResolve || (this._x509CertKeyElements == null)
+-                    || (this._x509CertKeyElements.length == 0)) {
+-               return null;
++         // populate Object array
++         for (int i = 0; i < els.length; i++) {
++                 XMLX509Certificate xmlCert=new XMLX509Certificate(els[i], BaseURI);
++                 X509Certificate cert = xmlCert.getX509Certificate();
++            if (cert!=null) {
++                return cert;
+             }
+          }
+-
+-         this._x509certObject =
+-            new XMLX509Certificate[this._x509CertKeyElements.length];
+-
+-         // populate Object array
+-         for (int i = 0; i < this._x509CertKeyElements.length; i++) {
+-            this._x509certObject[i] =
+-               new XMLX509Certificate(this._x509CertKeyElements[i]
+-                  , BaseURI);
+-         }
+-
+-         for (int i = 0; i < this._x509certObject.length; i++) {
+-            X509Certificate cert = this._x509certObject[i].getX509Certificate();
+-
+-            if (cert != null) {
+-               return cert;
+-            }
+-         }
+-
+          return null;
+       } catch (XMLSecurityException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
++         log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
+ 
+          throw new KeyResolverException("generic.EmptyMessage", ex);
+       }
+@@ -173,7 +122,7 @@
+     * @param storage
+     *
+     */
+-   public javax.crypto.SecretKey engineResolveSecretKey(
++   public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+            Element element, String BaseURI, StorageResolver storage)
+    {
+       return null;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -39,7 +38,7 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class X509IssuerSerialResolver extends KeyResolverSpi {
+ 
+@@ -48,44 +47,13 @@
+         java.util.logging.Logger.getLogger(
+                     X509IssuerSerialResolver.class.getName());
+ 
+-    /** @inheritDoc */
+-   public boolean engineCanResolve(Element element, String BaseURI,
+-                                   StorageResolver storage) {
+-      if (true)
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
+-
+-      X509Data x509data = null;
+-      try {
+-         x509data = new X509Data(element, BaseURI);
+-      } catch (XMLSignatureException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");
+-
+-         return false;
+-      } catch (XMLSecurityException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");
+-
+-         return false;
+-      }
+-
+-      if (x509data == null) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");
+-         return false;
+-      }
+-
+-      if (x509data.containsIssuerSerial()) {
+-            return true;
+-      }
+-
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");
+-      return false;
+-   }
+ 
+    /** @inheritDoc */
+-   public PublicKey engineResolvePublicKey(
++   public PublicKey engineLookupAndResolvePublicKey(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
+ 
+-      X509Certificate cert = this.engineResolveX509Certificate(element,
++      X509Certificate cert = this.engineLookupResolveX509Certificate(element,
+                                 BaseURI, storage);
+ 
+       if (cert != null) {
+@@ -96,10 +64,31 @@
+    }
+ 
+    /** @inheritDoc */
+-   public X509Certificate engineResolveX509Certificate(
++   public X509Certificate engineLookupResolveX509Certificate(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
+ 
++          X509Data x509data = null;
++          try {
++             x509data = new X509Data(element, BaseURI);
++           } catch (XMLSignatureException ex) {
++              log.log(java.util.logging.Level.FINE, "I can't");
++         return null;
++           } catch (XMLSecurityException ex) {
++              log.log(java.util.logging.Level.FINE, "I can't");
++          return null;
++           }
++
++           if (x509data == null) {
++              log.log(java.util.logging.Level.FINE, "I can't");
++              return null;
++           }
++
++           if (!x509data.containsIssuerSerial()) {
++                    return null;
++           }
+       try {
+          if (storage == null) {
+             Object exArgs[] = { Constants._TAG_X509ISSUERSERIAL };
+@@ -107,53 +96,52 @@
+                new KeyResolverException("KeyResolver.needStorageResolver",
+                                         exArgs);
+ 
+-            if (log.isLoggable(java.util.logging.Level.INFO))                                  log.log(java.util.logging.Level.INFO, "", ex);
++            log.log(java.util.logging.Level.INFO, "", ex);
+             throw ex;
+          }
+ 
+-         X509Data x509data = new X509Data(element, BaseURI);
+          int noOfISS = x509data.lengthIssuerSerial();
+ 
+          while (storage.hasNext()) {
+             X509Certificate cert = storage.next();
+             XMLX509IssuerSerial certSerial = new XMLX509IssuerSerial(element.getOwnerDocument(), cert);
+ 
+-            if (true) {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Found Certificate Issuer: "
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, "Found Certificate Issuer: "
+                       + certSerial.getIssuerName());
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Found Certificate Serial: "
++                log.log(java.util.logging.Level.FINE, "Found Certificate Serial: "
+                       + certSerial.getSerialNumber().toString());
+             }
+ 
+             for (int i=0; i<noOfISS; i++) {
+                XMLX509IssuerSerial xmliss = x509data.itemIssuerSerial(i);
+ 
+-               if (true) {
+-                    if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Found Element Issuer:     "
++               if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, "Found Element Issuer:     "
+                          + xmliss.getIssuerName());
+-                    if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Found Element Serial:     "
++                    log.log(java.util.logging.Level.FINE, "Found Element Serial:     "
+                          + xmliss.getSerialNumber().toString());
+                }
+ 
+                if (certSerial.equals(xmliss)) {
+-                  if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "match !!! ");
++                  log.log(java.util.logging.Level.FINE, "match !!! ");
+ 
+                   return cert;
+                }
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "no match...");
++                log.log(java.util.logging.Level.FINE, "no match...");
+             }
+          }
+ 
+          return null;
+       } catch (XMLSecurityException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
++         log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
+ 
+          throw new KeyResolverException("generic.EmptyMessage", ex);
+       }
+    }
+ 
+    /** @inheritDoc */
+-   public javax.crypto.SecretKey engineResolveSecretKey(
++   public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+            Element element, String BaseURI, StorageResolver storage) {
+       return null;
+    }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SKIResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SKIResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SKIResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SKIResolver.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -40,7 +39,7 @@
+ /**
+  *
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class X509SKIResolver extends KeyResolverSpi {
+ 
+@@ -48,50 +47,6 @@
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(X509SKIResolver.class.getName());
+ 
+-   /** Field _x509childNodes */
+-   private Element _x509childNodes[] = null;
+-
+-   /** Field _x509childObject[] */
+-   private XMLX509SKI _x509childObject[] = null;
+-
+-   /**
+-    * Method engineCanResolve
+-    * @inheritDoc
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    *
+-    */
+-   public boolean engineCanResolve(Element element, String BaseURI,
+-                                   StorageResolver storage) {
+-      if (true) {
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
+-      }
+-
+-         if (!XMLUtils.elementIsInSignatureSpace(element,
+-                 Constants._TAG_X509DATA)) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");
+-
+-         return false;
+-      }
+-
+-
+-
+-
+-         this._x509childNodes = XMLUtils.selectDsNodes(element,
+-                  Constants._TAG_X509SKI);
+-
+-         if ((this._x509childNodes != null)
+-                 && (this._x509childNodes.length > 0)) {
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Yes Sir, I can");
+-
+-            return true;
+-         }
+-
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");
+-
+-      return false;
+-   }
+ 
+    /**
+     * Method engineResolvePublicKey
+@@ -102,11 +57,11 @@
+     * @return null if no {@link PublicKey} could be obtained
+     * @throws KeyResolverException
+     */
+-   public PublicKey engineResolvePublicKey(
++   public PublicKey engineLookupAndResolvePublicKey(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
+ 
+-      X509Certificate cert = this.engineResolveX509Certificate(element,
++      X509Certificate cert = this.engineLookupResolveX509Certificate(element,
+                                 BaseURI, storage);
+ 
+       if (cert != null) {
+@@ -125,46 +80,55 @@
+     *
+     * @throws KeyResolverException
+     */
+-   public X509Certificate engineResolveX509Certificate(
++   public X509Certificate engineLookupResolveX509Certificate(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
++           if (log.isLoggable(java.util.logging.Level.FINE)) {
++             log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
++           }
++           if (!XMLUtils.elementIsInSignatureSpace(element,
++              Constants._TAG_X509DATA)) {
++                 log.log(java.util.logging.Level.FINE, "I can't");
++                 return null;
++           }
++           /** Field _x509childObject[] */
++           XMLX509SKI x509childObject[] = null;
+ 
+-      try {
+-         if (this._x509childNodes == null) {
+-            boolean weCanResolve = this.engineCanResolve(element, BaseURI,
+-                                      storage);
++           Element x509childNodes[] = null;
++           x509childNodes = XMLUtils.selectDsNodes(element.getFirstChild(),
++                          Constants._TAG_X509SKI);
+ 
+-            if (!weCanResolve || (this._x509childNodes == null)) {
+-               return null;
+-            }
+-         }
+-
++           if (!((x509childNodes != null)
++                         && (x509childNodes.length > 0))) {
++                   log.log(java.util.logging.Level.FINE, "I can't");
++                return null;
++           }
++           try {
+          if (storage == null) {
+             Object exArgs[] = { Constants._TAG_X509SKI };
+             KeyResolverException ex =
+                new KeyResolverException("KeyResolver.needStorageResolver",
+                                         exArgs);
+ 
+-            if (log.isLoggable(java.util.logging.Level.INFO))                                  log.log(java.util.logging.Level.INFO, "", ex);
++            log.log(java.util.logging.Level.INFO, "", ex);
+ 
+             throw ex;
+          }
+ 
+-         this._x509childObject =
+-            new XMLX509SKI[this._x509childNodes.length];
++         x509childObject = new XMLX509SKI[x509childNodes.length];
+ 
+-         for (int i = 0; i < this._x509childNodes.length; i++) {
+-            this._x509childObject[i] =
+-               new XMLX509SKI(this._x509childNodes[i], BaseURI);
++         for (int i = 0; i < x509childNodes.length; i++) {
++            x509childObject[i] =
++               new XMLX509SKI(x509childNodes[i], BaseURI);
+          }
+ 
+          while (storage.hasNext()) {
+             X509Certificate cert = storage.next();
+             XMLX509SKI certSKI = new XMLX509SKI(element.getOwnerDocument(), cert);
+ 
+-            for (int i = 0; i < this._x509childObject.length; i++) {
+-               if (certSKI.equals(this._x509childObject[i])) {
+-                  if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Return PublicKey from "
++            for (int i = 0; i < x509childObject.length; i++) {
++               if (certSKI.equals(x509childObject[i])) {
++                  log.log(java.util.logging.Level.FINE, "Return PublicKey from "
+                             + cert.getSubjectDN().getName());
+ 
+                   return cert;
+@@ -186,7 +150,7 @@
+     * @param storage
+     *
+     */
+-   public javax.crypto.SecretKey engineResolveSecretKey(
++   public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+            Element element, String BaseURI, StorageResolver storage)
+     {
+       return null;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SubjectNameResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
+@@ -38,7 +38,7 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class X509SubjectNameResolver extends KeyResolverSpi {
+ 
+@@ -47,50 +47,6 @@
+         java.util.logging.Logger.getLogger(
+                     X509SubjectNameResolver.class.getName());
+ 
+-   /** Field _x509childNodes */
+-   private Element[] _x509childNodes = null;
+-
+-   /** Field _x509childObject[] */
+-   private XMLX509SubjectName _x509childObject[] = null;
+-
+-   /**
+-    * Method engineCanResolve
+-    * @inheritDoc
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    *
+-    */
+-   public boolean engineCanResolve(Element element, String BaseURI,
+-                                   StorageResolver storage) {
+-      if (true)
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
+-
+-
+-       if (!XMLUtils.elementIsInSignatureSpace(element,
+-                 Constants._TAG_X509DATA) ) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");
+-
+-         return false;
+-      }
+-
+-
+-
+-         this._x509childNodes = XMLUtils.selectDsNodes(element,
+-                 Constants._TAG_X509SUBJECTNAME);
+-
+-         if ((this._x509childNodes != null)
+-                 && (this._x509childNodes.length > 0)) {
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Yes Sir, I can");
+-
+-            return true;
+-         }
+-
+-
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I can't");
+-
+-      return false;
+-   }
+ 
+    /**
+     * Method engineResolvePublicKey
+@@ -101,11 +57,11 @@
+     * @return null if no {@link PublicKey} could be obtained
+     * @throws KeyResolverException
+     */
+-   public PublicKey engineResolvePublicKey(
++   public PublicKey engineLookupAndResolvePublicKey(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
+ 
+-      X509Certificate cert = this.engineResolveX509Certificate(element,
++      X509Certificate cert = this.engineLookupResolveX509Certificate(element,
+                                 BaseURI, storage);
+ 
+       if (cert != null) {
+@@ -124,37 +80,46 @@
+     *
+     * @throws KeyResolverException
+     */
+-   public X509Certificate engineResolveX509Certificate(
++   public X509Certificate engineLookupResolveX509Certificate(
+            Element element, String BaseURI, StorageResolver storage)
+               throws KeyResolverException {
++           if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
++           Element[] x509childNodes = null;
++           XMLX509SubjectName x509childObject[] = null;
++
++           if (!XMLUtils.elementIsInSignatureSpace(element,
++                         Constants._TAG_X509DATA) ) {
++                        log.log(java.util.logging.Level.FINE, "I can't");
++                 return null;
++           }
++       x509childNodes = XMLUtils.selectDsNodes(element.getFirstChild(),
++                 Constants._TAG_X509SUBJECTNAME);
++
++        if (!((x509childNodes != null)
++                && (x509childNodes.length > 0))) {
++                    log.log(java.util.logging.Level.FINE, "I can't");
++                    return null;
++            }
+ 
+       try {
+-         if (this._x509childNodes == null) {
+-            boolean weCanResolve = this.engineCanResolve(element, BaseURI,
+-                                      storage);
+-
+-            if (!weCanResolve || (this._x509childNodes == null)) {
+-               return null;
+-            }
+-         }
+-
+          if (storage == null) {
+             Object exArgs[] = { Constants._TAG_X509SUBJECTNAME };
+             KeyResolverException ex =
+                new KeyResolverException("KeyResolver.needStorageResolver",
+                                         exArgs);
+ 
+-            if (log.isLoggable(java.util.logging.Level.INFO))                                  log.log(java.util.logging.Level.INFO, "", ex);
++            log.log(java.util.logging.Level.INFO, "", ex);
+ 
+             throw ex;
+          }
+ 
+-         this._x509childObject =
+-            new XMLX509SubjectName[this._x509childNodes.length];
++         x509childObject =
++            new XMLX509SubjectName[x509childNodes.length];
+ 
+-         for (int i = 0; i < this._x509childNodes.length; i++) {
+-            this._x509childObject[i] =
+-               new XMLX509SubjectName(this._x509childNodes[i],
++         for (int i = 0; i < x509childNodes.length; i++) {
++            x509childObject[i] =
++               new XMLX509SubjectName(x509childNodes[i],
+                                       BaseURI);
+          }
+ 
+@@ -163,24 +128,24 @@
+             XMLX509SubjectName certSN =
+                new XMLX509SubjectName(element.getOwnerDocument(), cert);
+ 
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Found Certificate SN: " + certSN.getSubjectName());
++            log.log(java.util.logging.Level.FINE, "Found Certificate SN: " + certSN.getSubjectName());
+ 
+-            for (int i = 0; i < this._x509childObject.length; i++) {
+-               if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Found Element SN:     "
+-                         + this._x509childObject[i].getSubjectName());
++            for (int i = 0; i < x509childObject.length; i++) {
++               log.log(java.util.logging.Level.FINE, "Found Element SN:     "
++                         + x509childObject[i].getSubjectName());
+ 
+-               if (certSN.equals(this._x509childObject[i])) {
+-                  if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "match !!! ");
++               if (certSN.equals(x509childObject[i])) {
++                  log.log(java.util.logging.Level.FINE, "match !!! ");
+ 
+                   return cert;
+                }
+-               if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "no match...");
++               log.log(java.util.logging.Level.FINE, "no match...");
+             }
+          }
+ 
+          return null;
+       } catch (XMLSecurityException ex) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
++         log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
+ 
+          throw new KeyResolverException("generic.EmptyMessage", ex);
+       }
+@@ -194,7 +159,7 @@
+     * @param storage
+     *
+     */
+-   public javax.crypto.SecretKey engineResolveSecretKey(
++   public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+            Element element, String BaseURI, StorageResolver storage)
+    {
+       return null;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolver.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -21,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.storage;
+ 
+-
+-
+ import java.security.KeyStore;
+ import java.security.cert.X509Certificate;
+ import java.util.ArrayList;
+@@ -36,7 +33,7 @@
+ /**
+  * This class collects customized resolvers for Certificates.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class StorageResolver {
+ 
+@@ -45,7 +42,7 @@
+         java.util.logging.Logger.getLogger(StorageResolver.class.getName());
+ 
+    /** Field _storageResolvers */
+-   List _storageResolvers = new ArrayList();
++   List _storageResolvers = null;
+ 
+    /** Field _iterator */
+    Iterator _iterator = null;
+@@ -71,7 +68,8 @@
+     * @param resolver
+     */
+    public void add(StorageResolverSpi resolver) {
+-
++           if (_storageResolvers==null)
++                   _storageResolvers=new ArrayList();
+       this._storageResolvers.add(resolver);
+ 
+       this._iterator = null;
+@@ -126,6 +124,8 @@
+    public Iterator getIterator() {
+ 
+       if (this._iterator == null) {
++         if (_storageResolvers==null)
++                   _storageResolvers=new ArrayList();
+          this._iterator = new StorageResolverIterator(this._storageResolvers.iterator());
+       }
+ 
+@@ -140,6 +140,8 @@
+    public boolean hasNext() {
+ 
+       if (this._iterator == null) {
++          if (_storageResolvers==null)
++                   _storageResolvers=new ArrayList();
+          this._iterator = new StorageResolverIterator(this._storageResolvers.iterator());
+       }
+ 
+@@ -158,15 +160,13 @@
+    /**
+     * Class StorageResolverIterator
+     *
+-    * @author $Author: raul $
++    * @author $Author: mullan $
++    * @version $Revision: 1.5 $
+     */
+-   class StorageResolverIterator implements Iterator {
++   static class StorageResolverIterator implements Iterator {
+ 
+       /** Field _resolvers */
+-           Iterator _resolvers = null;
+-
+-      /** Field _currentResolver */
+-      int _currentResolver = 0;
++      Iterator _resolvers = null;
+ 
+       /**
+        * Constructor FilesystemIterator
+@@ -179,17 +179,16 @@
+ 
+       /** @inheritDoc */
+       public boolean hasNext() {
+-                  return _resolvers.hasNext();
++          return _resolvers.hasNext();
+       }
+ 
+       /** @inheritDoc */
+       public Object next() {
+-                  return _resolvers.next();
++          return _resolvers.next();
+       }
+ 
+       /**
+        * Method remove
+-       *
+        */
+       public void remove() {
+          throw new UnsupportedOperationException(
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -28,7 +27,7 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class StorageResolverException extends XMLSecurityException {
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -28,7 +27,7 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public abstract class StorageResolverSpi {
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/CertsInFilesystemDirectoryResolver.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -21,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.storage.implementations;
+ 
+-
+-
+ import java.io.File;
+ import java.io.FileInputStream;
+ import java.io.FileNotFoundException;
+@@ -40,12 +37,11 @@
+ import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolverSpi;
+ import com.sun.org.apache.xml.internal.security.utils.Base64;
+ 
+-
+ /**
+  * This {@link StorageResolverSpi} makes all raw (binary) {@link X509Certificate}s
+  * which reside as files in a single directory available to the {@link com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver}.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class CertsInFilesystemDirectoryResolver extends StorageResolverSpi {
+ 
+@@ -131,20 +127,20 @@
+             dn = cert.getSubjectDN().getName();
+             added = true;
+          } catch (FileNotFoundException ex) {
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
++            log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
+          } catch (IOException ex) {
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
++            log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
+          } catch (CertificateNotYetValidException ex) {
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
++            log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
+          } catch (CertificateExpiredException ex) {
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
++            log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
+          } catch (CertificateException ex) {
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
++            log.log(java.util.logging.Level.FINE, "Could not add certificate from file " + filename, ex);
+          }
+ 
+          if (added) {
+-            if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Added certificate: " + dn);
++            if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Added certificate: " + dn);
+          }
+       }
+    }
+@@ -157,9 +153,10 @@
+    /**
+     * Class FilesystemIterator
+     *
+-    * @author $Author: raul $
++    * @author $Author: mullan $
++    * @version $Revision: 1.5 $
+     */
+-   class FilesystemIterator implements Iterator {
++   private static class FilesystemIterator implements Iterator {
+ 
+       /** Field _certs */
+       List _certs = null;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/KeyStoreResolver.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -21,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.storage.implementations;
+ 
+-
+-
+ import java.security.KeyStore;
+ import java.security.KeyStoreException;
+ import java.security.cert.X509Certificate;
+@@ -37,7 +34,7 @@
+  * Makes the Certificates from a JAVA {@link KeyStore} object available to the
+  * {@link com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver}.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class KeyStoreResolver extends StorageResolverSpi {
+ 
+@@ -66,9 +63,10 @@
+    /**
+     * Class KeyStoreIterator
+     *
+-    * @author $Author: raul $
++    * @author $Author: mullan $
++    * @version $Revision: 1.5 $
+     */
+-   class KeyStoreIterator implements Iterator {
++   static class KeyStoreIterator implements Iterator {
+ 
+       /** Field _keyStore */
+       KeyStore _keyStore = null;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/implementations/SingleCertificateResolver.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -21,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.keys.storage.implementations;
+ 
+-
+-
+ import java.security.cert.X509Certificate;
+ import java.util.Iterator;
+ 
+@@ -33,7 +30,7 @@
+  * This {@link StorageResolverSpi} makes a single {@link X509Certificate}
+  * available to the {@link com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver}.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class SingleCertificateResolver extends StorageResolverSpi {
+ 
+@@ -61,9 +58,10 @@
+    /**
+     * Class InternalIterator
+     *
+-    * @author $Author: raul $
++    * @author $Author: mullan $
++    * @version $Revision: 1.5 $
+     */
+-   class InternalIterator implements Iterator {
++   static class InternalIterator implements Iterator {
+ 
+       /** Field _alreadyReturned */
+       boolean _alreadyReturned = false;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml b/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/config.xml
+@@ -14,6 +14,10 @@
+                               JAVACLASS="com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclOmitComments"/>
+       <CanonicalizationMethod URI="http://www.w3.org/2001/10/xml-exc-c14n#WithComments"
+                               JAVACLASS="com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclWithComments"/>
++      <CanonicalizationMethod URI="http://www.w3.org/2006/12/xml-c14n11"
++                              JAVACLASS="com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_OmitComments"/>
++      <CanonicalizationMethod URI="http://www.w3.org/2006/12/xml-c14n11#WithComments"
++                              JAVACLASS="com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_WithComments"/>
+    </CanonicalizationMethods>
+    <TransformAlgorithms>
+       <!-- Base64 -->
+@@ -25,6 +29,12 @@
+       <!-- c14n with comments -->
+       <TransformAlgorithm URI="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"
+                           JAVACLASS="com.sun.org.apache.xml.internal.security.transforms.implementations.TransformC14NWithComments" />
++      <!-- c14n 1.1 omitting comments -->
++      <TransformAlgorithm URI="http://www.w3.org/2006/12/xml-c14n11"
++                          JAVACLASS="com.sun.org.apache.xml.internal.security.transforms.implementations.TransformC14N11" />
++      <!-- c14n 1.1 with comments -->
++      <TransformAlgorithm URI="http://www.w3.org/2006/12/xml-c14n11#WithComments"
++                          JAVACLASS="com.sun.org.apache.xml.internal.security.transforms.implementations.TransformC14N11_WithComments" />
+       <!-- exclusive c14n omitting comments -->
+       <TransformAlgorithm URI="http://www.w3.org/2001/10/xml-exc-c14n#"
+                           JAVACLASS="com.sun.org.apache.xml.internal.security.transforms.implementations.TransformC14NExclusive" />
+@@ -66,6 +76,8 @@
+                           JAVACLASS="com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureBaseRSA$SignatureRSASHA384" />
+       <SignatureAlgorithm URI="http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"
+                           JAVACLASS="com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureBaseRSA$SignatureRSASHA512" />
++      <SignatureAlgorithm URI="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"
++                          JAVACLASS="com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA$SignatureECDSASHA1" />
+ 
+       <SignatureAlgorithm URI="http://www.w3.org/2001/04/xmldsig-more#hmac-md5"
+                           JAVACLASS="com.sun.org.apache.xml.internal.security.algorithms.implementations.IntegrityHmac$IntegrityHmacMD5" />
+@@ -166,6 +178,13 @@
+                     RequirementLevel="OPTIONAL"
+                     SpecificationURL="http://www.ietf.org/internet-drafts/draft-eastlake-xmldsig-uri-02.txt"
+                     JCEName="SHA512withRSA"/>
++                    
++         <Algorithm URI="http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1"
++                    Description="ECDSA Signature with SHA-1 message digest"
++                    AlgorithmClass="Signature"
++                    RequirementLevel="OPTIONAL"
++                    SpecificationURL="http://www.ietf.org/internet-drafts/draft-eastlake-xmldsig-uri-02.txt"
++                    JCEName="ECDSAwithSHA1"/>
+ 
+          <!-- MAC Algorithms -->
+          <Algorithm URI="http://www.w3.org/2001/04/xmldsig-more#hmac-md5"
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.dtd b/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.dtd
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.dtd
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.dtd
+@@ -3,7 +3,7 @@
+     Joseph Reagle $last changed 20001215$
+ 
+     http://www.w3.org/2000/09/xmldsig#
+-    $Revision: 1.1 $ on $Date: 2002/02/08 20:32:26 $ by $Author: reagle $
++    $Revision: 1.6 $ on $Date: 2008/07/24 16:15:03 $ by $Author: mullan $
+ 
+     Copyright 2001 The Internet Society and W3C (Massachusetts Institute
+     of Technology, Institut National de Recherche en Informatique et en
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.xsd b/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.xsd
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.xsd
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/schema/xmldsig-core-schema.xsd
+@@ -11,7 +11,7 @@
+ 
+ <!-- Schema for XML Signatures
+     http://www.w3.org/2000/09/xmldsig#
+-    $Revision: 1.1 $ on $Date: 2002/02/08 20:32:26 $ by $Author: reagle $
++    $Revision: 1.6 $ on $Date: 2008/07/24 16:15:03 $ by $Author: mullan $
+ 
+     Copyright 2001 The Internet Society and W3C (Massachusetts Institute
+     of Technology, Institut National de Recherche en Informatique et en
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/InvalidDigestValueException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/InvalidDigestValueException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/InvalidDigestValueException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/InvalidDigestValueException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/InvalidSignatureValueException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/InvalidSignatureValueException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/InvalidSignatureValueException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/InvalidSignatureValueException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Manifest.java
+@@ -68,14 +68,11 @@
+    /** Field verificationResults[] */
+    private boolean verificationResults[] = null;
+ 
+-   /** Field _signedContents */
+-   List _signedContents = new ArrayList();
+-
+    /** Field _resolverProperties */
+-   HashMap _resolverProperties = new HashMap(10);
++   HashMap _resolverProperties = null;
+ 
+    /** Field _perManifestResolvers */
+-   List _perManifestResolvers = new ArrayList();
++   List _perManifestResolvers = null;
+ 
+    /**
+     * Consturts {@link Manifest}
+@@ -144,8 +141,6 @@
+            String BaseURI, String referenceURI, Transforms transforms, String digestURI, String ReferenceId, String ReferenceType)
+               throws XMLSignatureException {
+ 
+-      if (this._state == MODE_SIGN) {
+-
+          // the this._doc is handed implicitly by the this.getOwnerDocument()
+          Reference ref = new Reference(this._doc, BaseURI, referenceURI, this,
+                                        transforms, digestURI);
+@@ -164,7 +159,6 @@
+          // add the Element of the Reference object to the Manifest/SignedInfo
+          this._constructionElement.appendChild(ref.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+    }
+ 
+    /**
+@@ -178,7 +172,6 @@
+    public void generateDigestValues()
+            throws XMLSignatureException, ReferenceNotInitializedException {
+ 
+-      if (this._state == MODE_SIGN) {
+          for (int i = 0; i < this.getLength(); i++) {
+ 
+             // update the cached Reference object, the Element content is automatically updated
+@@ -186,7 +179,6 @@
+ 
+             currentRef.generateDigestValue();
+          }
+-      }
+    }
+ 
+    /**
+@@ -208,11 +200,6 @@
+     */
+    public Reference item(int i) throws XMLSecurityException {
+ 
+-      if (this._state == MODE_SIGN) {
+-
+-         // we already have real objects
+-         return (Reference) this._references.get(i);
+-      }
+          if (this._references.get(i) == null) {
+ 
+             // not yet constructed, so _we_ have to
+@@ -232,7 +219,7 @@
+     */
+    public void setId(String Id) {
+ 
+-      if ((this._state == MODE_SIGN) && (Id != null)) {
++      if (Id != null) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
+          IdResolver.registerElementById(this._constructionElement, Id);
+       }
+@@ -294,9 +281,9 @@
+             XMLUtils.selectDsNodes(this._constructionElement.getFirstChild(),
+                          Constants._TAG_REFERENCE);
+       }
+-          if (true) {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "verify " +_referencesEl.length + " References");
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I am " + (followManifests
++          if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, "verify " +_referencesEl.length + " References");
++        log.log(java.util.logging.Level.FINE, "I am " + (followManifests
+                            ? ""
+                            : "not") + " requested to follow nested Manifests");
+       }
+@@ -325,13 +312,13 @@
+             if (!currentRefVerified) {
+                verify = false;
+             }
+-            if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "The Reference has Type " + currentRef.getType());
++            if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "The Reference has Type " + currentRef.getType());
+ 
+             // was verification successful till now and do we want to verify the Manifest?
+             if (verify && followManifests
+                     && currentRef.typeIsReferenceToManifest()) {
+-               if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "We have to follow a nested Manifest");
++               log.log(java.util.logging.Level.FINE, "We have to follow a nested Manifest");
+ 
+                 try {
+                   XMLSignatureInput signedManifestNodes =
+@@ -381,7 +368,7 @@
+ 
+                      log.log(java.util.logging.Level.WARNING, "The nested Manifest was invalid (bad)");
+                   } else {
+-                     if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "The nested Manifest was valid (good)");
++                     log.log(java.util.logging.Level.FINE, "The nested Manifest was valid (good)");
+                   }
+                } catch (IOException ex) {
+                   throw new ReferenceNotInitializedException("empty", ex);
+@@ -458,9 +445,13 @@
+     */
+    public void addResourceResolver(ResourceResolver resolver) {
+ 
+-      if (resolver != null) {
+-         this._perManifestResolvers.add(resolver);
++      if (resolver == null) {
++          return;
+       }
++      if (_perManifestResolvers==null)
++          _perManifestResolvers = new ArrayList();
++      this._perManifestResolvers.add(resolver);
++
+    }
+ 
+    /**
+@@ -470,9 +461,13 @@
+     */
+    public void addResourceResolver(ResourceResolverSpi resolverSpi) {
+ 
+-      if (resolverSpi != null) {
+-         this._perManifestResolvers.add(new ResourceResolver(resolverSpi));
++      if (resolverSpi == null) {
++          return;
+       }
++      if (_perManifestResolvers==null)
++                  _perManifestResolvers = new ArrayList();
++      this._perManifestResolvers.add(new ResourceResolver(resolverSpi));
++
+    }
+ 
+    /**
+@@ -483,6 +478,9 @@
+     * @param value the value
+     */
+    public void setResolverProperty(String key, String value) {
++           if (_resolverProperties==null) {
++                   _resolverProperties=new HashMap(10);
++           }
+       this._resolverProperties.put(key, value);
+    }
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/MissingResourceFailureException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/MissingResourceFailureException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/MissingResourceFailureException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/MissingResourceFailureException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/NodeFilter.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/NodeFilter.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/NodeFilter.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/NodeFilter.java
+@@ -31,8 +31,23 @@
+         /**
+          * Tells if a node must be outputed in c14n.
+          * @param n
+-         * @return true if node must be outputed, false otherwise.
++         * @return 1 if the node should be outputed.
++         *                 0 if node must not be outputed,
++         *                -1 if the node and all it's child must not be output.
++         *
+          */
+-        public boolean isNodeInclude(Node n);
++        public int isNodeInclude(Node n);
++        /**
++         * Tells if a node must be outputed in a c14n.
++         * The caller must assured that this method is always call
++         * in document order. The implementations can use this
++         * restriction to optimize the transformation.
++         * @param n
++         * @param level the relative level in the tree
++         * @return 1 if the node should be outputed.
++         *                 0 if node must not be outputed,
++         *                -1 if the node and all it's child must not be output.
++         */
++        public int isNodeIncludeDO(Node n, int level);
+ 
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/ObjectContainer.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/ObjectContainer.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/ObjectContainer.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/ObjectContainer.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.signature;
+ 
+-
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.IdResolver;
+@@ -35,16 +33,11 @@
+  * Handles <code>&lt;ds:Object&gt;</code> elements
+  * <code>Object<code> {@link Element} supply facility which can contain any kind data
+  *
+- *
+  * @author Christian Geuer-Pollmann
+  * $todo$ if we remove childen, the boolean values are not updated
+  */
+ public class ObjectContainer extends SignatureElementProxy {
+ 
+-   /** {@link java.util.logging} logging facility */
+-   static java.util.logging.Logger log =
+-       java.util.logging.Logger.getLogger(ObjectContainer.class.getName());
+-
+    /**
+     * Constructs {@link ObjectContainer}
+     *
+@@ -75,7 +68,7 @@
+     */
+    public void setId(String Id) {
+ 
+-      if ((this._state == MODE_SIGN) && (Id != null)) {
++      if ((Id != null)) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
+          IdResolver.registerElementById(this._constructionElement, Id);
+       }
+@@ -97,7 +90,7 @@
+     */
+    public void setMimeType(String MimeType) {
+ 
+-      if ((this._state == MODE_SIGN) && (MimeType != null)) {
++      if ( (MimeType != null)) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_MIMETYPE,
+                                                 MimeType);
+       }
+@@ -119,7 +112,7 @@
+     */
+    public void setEncoding(String Encoding) {
+ 
+-      if ((this._state == MODE_SIGN) && (Encoding != null)) {
++      if ((Encoding != null)) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_ENCODING,
+                                                 Encoding);
+       }
+@@ -135,18 +128,16 @@
+    }
+ 
+    /**
+-    * Adds childe Node
++    * Adds child Node
+     *
+-    * @param node childe Node
++    * @param node child Node
+     * @return the new node in the tree.
+     */
+    public Node appendChild(Node node) {
+ 
+       Node result = null;
+ 
+-      if (this._state == MODE_SIGN) {
+-         result = this._constructionElement.appendChild(node);
+-      }
++      result = this._constructionElement.appendChild(node);
+ 
+       return result;
+    }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/Reference.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -25,6 +24,8 @@
+ 
+ import java.io.IOException;
+ import java.io.OutputStream;
++import java.security.AccessController;
++import java.security.PrivilegedAction;
+ import java.util.HashSet;
+ import java.util.Set;
+ 
+@@ -102,6 +103,32 @@
+  */
+ public class Reference extends SignatureElementProxy {
+ 
++   /**
++    * Look up useC14N11 system property. If true, an explicit C14N11 transform
++    * will be added if necessary when generating the signature. See section
++    * 3.1.1 of http://www.w3.org/2007/xmlsec/Drafts/xmldsig-core/ for more info.
++    */
++   private static boolean useC14N11 =
++      AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
++         public Boolean run() {
++            return Boolean.getBoolean
++               ("com.sun.org.apache.xml.internal.security.useC14N11");
++         }
++      });
++
++/*
++   static {
++      try {
++         useC14N11 = Boolean.getBoolean("com.sun.org.apache.xml.internal.security.useC14N11");
++      } catch (Exception e) {
++         // ignore exceptions
++      }
++   }
++*/
++
++   /** Field CacheSignedNodes */
++   public final static boolean CacheSignedNodes = false;
++
+    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(Reference.class.getName());
+@@ -118,6 +145,12 @@
+    XMLSignatureInput _transformsOutput;
+    //J+
+ 
++private Transforms transforms;
++
++private Element digestMethodElem;
++
++private Element digestValueElement;
++
+    /**
+     * Constructor Reference
+     *
+@@ -148,6 +181,7 @@
+       // this._manifest.appendChild(this._doc.createTextNode("\n"));
+ 
+       if (transforms != null) {
++          this.transforms=transforms;
+          this._constructionElement.appendChild(transforms.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+       }
+@@ -156,11 +190,12 @@
+             MessageDigestAlgorithm.getInstance(this._doc,
+                                                messageDigestAlgorithm);
+ 
+-         this._constructionElement.appendChild(mda.getElement());
++         digestMethodElem=mda.getElement();
++         this._constructionElement.appendChild(digestMethodElem);
+          XMLUtils.addReturnToElement(this._constructionElement);
+       }
+       {
+-         Element digestValueElement =
++         digestValueElement =
+             XMLUtils.createElementInSignatureSpace(this._doc,
+                                                    Constants._TAG_DIGESTVALUE);
+ 
+@@ -182,7 +217,15 @@
+            throws XMLSecurityException {
+ 
+       super(element, BaseURI);
+-
++      this._baseURI=BaseURI;
++      Element el=XMLUtils.getNextElement(element.getFirstChild());
++      if (Constants._TAG_TRANSFORMS.equals(el.getLocalName()) &&
++                  Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
++          transforms = new Transforms(el,this._baseURI);
++          el=XMLUtils.getNextElement(el.getNextSibling());
++      }
++      digestMethodElem = el;
++      digestValueElement =XMLUtils.getNextElement(digestMethodElem.getNextSibling());;
+       this._manifest = manifest;
+    }
+ 
+@@ -197,9 +240,6 @@
+    public MessageDigestAlgorithm getMessageDigestAlgorithm()
+            throws XMLSignatureException {
+ 
+-      Element digestMethodElem = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-            Constants._TAG_DIGESTMETHOD,0);
+-
+       if (digestMethodElem == null) {
+          return null;
+       }
+@@ -221,7 +261,7 @@
+     */
+    public void setURI(String URI) {
+ 
+-      if ((this._state == MODE_SIGN) && (URI != null)) {
++      if ( URI != null) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_URI,
+                                                   URI);
+       }
+@@ -243,7 +283,7 @@
+     */
+    public void setId(String Id) {
+ 
+-      if ((this._state == MODE_SIGN) && (Id != null)) {
++      if ( Id != null ) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
+          IdResolver.registerElementById(this._constructionElement, Id);
+       }
+@@ -265,7 +305,7 @@
+     */
+    public void setType(String Type) {
+ 
+-      if ((this._state == MODE_SIGN) && (Type != null)) {
++      if (Type != null) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_TYPE,
+                                                   Type);
+       }
+@@ -291,8 +331,7 @@
+     */
+    public boolean typeIsReferenceToObject() {
+ 
+-      if ((this.getType() != null)
+-              && this.getType().equals(Reference.OBJECT_URI)) {
++      if (Reference.OBJECT_URI.equals(this.getType())) {
+          return true;
+       }
+ 
+@@ -309,8 +348,7 @@
+     */
+    public boolean typeIsReferenceToManifest() {
+ 
+-      if ((this.getType() != null)
+-              && this.getType().equals(Reference.MANIFEST_URI)) {
++      if (Reference.MANIFEST_URI.equals(this.getType())) {
+          return true;
+       }
+ 
+@@ -324,10 +362,6 @@
+     */
+    private void setDigestValueElement(byte[] digestValue)
+    {
+-
+-      if (this._state == MODE_SIGN) {
+-         Element digestValueElement =XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-                 Constants._TAG_DIGESTVALUE,0);
+          Node n=digestValueElement.getFirstChild();
+          while (n!=null) {
+                digestValueElement.removeChild(n);
+@@ -338,7 +372,6 @@
+          Text t = this._doc.createTextNode(base64codedValue);
+ 
+          digestValueElement.appendChild(t);
+-      }
+    }
+ 
+    /**
+@@ -349,11 +382,7 @@
+     */
+    public void generateDigestValue()
+            throws XMLSignatureException, ReferenceNotInitializedException {
+-
+-      if (this._state == MODE_SIGN) {
+-
+-         this.setDigestValueElement(this.calculateDigest());
+-      }
++      this.setDigestValueElement(this.calculateDigest(false));
+    }
+ 
+    /**
+@@ -608,9 +637,12 @@
+           * but only preserve the octets, the memory footprint is dramatically
+           * reduced.
+           */
++         if (!Reference.CacheSignedNodes) {
+ 
+-         this._transformsOutput = output;
++            this._transformsOutput = output;//new XMLSignatureInput(output.getBytes());
+ 
++            //this._transformsOutput.setSourceURI(output.getSourceURI());
++         }
+          return output;
+       } catch (XMLSecurityException ex) {
+          throw new ReferenceNotInitializedException("empty", ex);
+@@ -630,16 +662,7 @@
+            throws XMLSignatureException, InvalidTransformException,
+                   TransformationException, XMLSecurityException {
+ 
+-      Element transformsElement = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-            Constants._TAG_TRANSFORMS,0);
+-
+-      if (transformsElement != null) {
+-         Transforms transforms = new Transforms(transformsElement,
+-                                                this._baseURI);
+-
+-         return transforms;
+-      }
+-       return null;
++      return transforms;
+    }
+ 
+    /**
+@@ -667,13 +690,14 @@
+ 
+ 
+    /**
+-    * Method resolverResult
++    * Method calculateDigest
+     *
++    * @param validating true if validating the reference
+     * @return reference Calculate the digest of this reference.
+     * @throws ReferenceNotInitializedException
+     * @throws XMLSignatureException
+     */
+-   private byte[] calculateDigest()
++   private byte[] calculateDigest(boolean validating)
+            throws ReferenceNotInitializedException, XMLSignatureException {
+ 
+       try {
+@@ -684,7 +708,20 @@
+          DigesterOutputStream diOs=new DigesterOutputStream(mda);
+          OutputStream os=new UnsyncBufferedOutputStream(diOs);
+          XMLSignatureInput output=this.dereferenceURIandPerformTransforms(os);
+-         output.updateOutputStream(os);
++         // if signing and c14n11 property == true explicitly add
++         // C14N11 transform if needed
++         if (this.useC14N11 && !validating &&
++             !output.isOutputStreamSet() && !output.isOctetStream()) {
++             if (transforms == null) {
++                 transforms = new Transforms(this._doc);
++                 this._constructionElement.insertBefore
++                     (transforms.getElement(), digestMethodElem);
++             }
++             transforms.addTransform(Transforms.TRANSFORM_C14N11_OMIT_COMMENTS);
++             output.updateOutputStream(os, true);
++         } else {
++             output.updateOutputStream(os);
++         }
+          os.flush();
+          //this.getReferencedBytes(diOs);
+          //mda.update(data);
+@@ -694,7 +731,7 @@
+          throw new ReferenceNotInitializedException("empty", ex);
+       } catch (IOException ex) {
+          throw new ReferenceNotInitializedException("empty", ex);
+-        }
++      }
+    }
+ 
+    /**
+@@ -702,12 +739,10 @@
+     *
+     * @return the digest value.
+     * @throws Base64DecodingException if Reference contains no proper base64 encoded data.
+-        * @throws XMLSecurityException if the Reference does not contain a DigestValue element
++    * @throws XMLSecurityException if the Reference does not contain a DigestValue element
+     */
+    public byte[] getDigestValue() throws Base64DecodingException, XMLSecurityException {
+-      Element digestValueElem = XMLUtils.selectDsNode(this._constructionElement.getFirstChild()
+-            ,Constants._TAG_DIGESTVALUE,0);
+-          if (digestValueElem == null) {
++      if (digestValueElement == null) {
+                   // The required element is not in the XML!
+                   Object[] exArgs ={ Constants._TAG_DIGESTVALUE,
+                                                          Constants.SignatureSpecNS };
+@@ -715,7 +750,7 @@
+                                         "signature.Verification.NoSignatureElement",
+                                         exArgs);
+           }
+-      byte[] elemDig = Base64.decode(digestValueElem);
++      byte[] elemDig = Base64.decode(digestValueElement);
+       return elemDig;
+    }
+ 
+@@ -731,13 +766,15 @@
+            throws ReferenceNotInitializedException, XMLSecurityException {
+ 
+       byte[] elemDig = this.getDigestValue();
+-      byte[] calcDig = this.calculateDigest();
++      byte[] calcDig = this.calculateDigest(true);
+       boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);
+ 
+       if (!equal) {
+          log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
++         log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
++         log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
+       } else {
+-         if (log.isLoggable(java.util.logging.Level.INFO))                                  log.log(java.util.logging.Level.INFO, "Verification successful for URI \"" + this.getURI() + "\"");
++         log.log(java.util.logging.Level.INFO, "Verification successful for URI \"" + this.getURI() + "\"");
+       }
+ 
+       return equal;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/ReferenceNotInitializedException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/ReferenceNotInitializedException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/ReferenceNotInitializedException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/ReferenceNotInitializedException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperties.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperties.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperties.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperties.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.signature;
+ 
+-
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.IdResolver;
+@@ -42,10 +40,6 @@
+  */
+ public class SignatureProperties extends SignatureElementProxy {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(SignatureProperties.class.getName());
+-
+    /**
+     * Constructor SignatureProperties
+     *
+@@ -115,7 +109,7 @@
+     */
+    public void setId(String Id) {
+ 
+-      if ((this._state == MODE_SIGN) && (Id != null)) {
++      if ((Id != null)) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
+          IdResolver.registerElementById(this._constructionElement, Id);
+       }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperty.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperty.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperty.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignatureProperty.java
+@@ -30,18 +30,13 @@
+ 
+ /**
+  * Handles <code>&lt;ds:SignatureProperty&gt;</code> elements
+- * Addittional information item concerning the generation of the signature(s) can
++ * Additional information item concerning the generation of the signature(s) can
+  * be placed in this Element
+  *
+  * @author Christian Geuer-Pollmann
+  */
+ public class SignatureProperty extends SignatureElementProxy {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(
+-                            SignatureProperty.class.getName());
+-
+    /**
+     * Constructs{@link SignatureProperty} using specified <code>Target</code> attribute
+     *
+@@ -85,7 +80,7 @@
+     */
+    public void setId(String Id) {
+ 
+-      if ((this._state == MODE_SIGN) && (Id != null)) {
++      if ((Id != null)) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
+          IdResolver.registerElementById(this._constructionElement, Id);
+       }
+@@ -107,7 +102,7 @@
+     */
+    public void setTarget(String Target) {
+ 
+-      if ((this._state == MODE_SIGN) && (Target != null)) {
++      if ((Target != null)) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_TARGET, Target);
+       }
+    }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java
+@@ -20,12 +20,9 @@
+  */
+ package com.sun.org.apache.xml.internal.security.signature;
+ 
+-
+-
+ import java.io.ByteArrayInputStream;
+ import java.io.IOException;
+ import java.io.OutputStream;
+-
+ import javax.crypto.SecretKey;
+ import javax.crypto.spec.SecretKeySpec;
+ import javax.xml.parsers.ParserConfigurationException;
+@@ -43,165 +40,174 @@
+ import org.w3c.dom.Node;
+ import org.xml.sax.SAXException;
+ 
+-
+ /**
+  * Handles <code>&lt;ds:SignedInfo&gt;</code> elements
+  * This <code>SignedInfo<code> element includes the canonicalization algorithm,
+- * a signature algorithm, and one or more references
++ * a signature algorithm, and one or more references.
++ *
+  * @author Christian Geuer-Pollmann
+  */
+ public class SignedInfo extends Manifest {
+ 
+-   /** Field _signatureAlgorithm */
+-   private SignatureAlgorithm _signatureAlgorithm = null;
++    /** Field _signatureAlgorithm */
++    private SignatureAlgorithm _signatureAlgorithm = null;
+ 
+-   /** Field _c14nizedBytes           */
+-   private byte[] _c14nizedBytes = null;
++    /** Field _c14nizedBytes           */
++    private byte[] _c14nizedBytes = null;
+ 
+-   /**
+-    * Overwrites {@link Manifest#addDocument} because it creates another Element.
+-    *
+-    * @param doc the {@link Document} in which <code>XMLsignature</code> will be placed
+-    * @throws XMLSecurityException
+-    */
+-   public SignedInfo(Document doc) throws XMLSecurityException {
+-      this(doc, XMLSignature.ALGO_ID_SIGNATURE_DSA, Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
+-   }
++    private Element c14nMethod;
++    private Element signatureMethod;
+ 
+-   /**
+-    * Constructs {@link SignedInfo} using given Canoicaliztion algorithm and Signature algorithm
+-    *
+-    * @param doc <code>SignedInfo</code> is placed in this document
+-    * @param CanonicalizationMethodURI URI representation of the Canonicalization method
+-    * @param SignatureMethodURI URI representation of the Digest and Signature algorithm
+-    * @throws XMLSecurityException
+-    */
+-   public SignedInfo(
+-           Document doc, String SignatureMethodURI, String CanonicalizationMethodURI)
++    /**
++     * Overwrites {@link Manifest#addDocument} because it creates another
++     * Element.
++     *
++     * @param doc the {@link Document} in which <code>XMLsignature</code> will
++     *    be placed
++     * @throws XMLSecurityException
++     */
++    public SignedInfo(Document doc) throws XMLSecurityException {
++        this(doc, XMLSignature.ALGO_ID_SIGNATURE_DSA,
++             Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
++    }
++
++    /**
++     * Constructs {@link SignedInfo} using given Canonicalization algorithm and
++     * Signature algorithm.
++     *
++     * @param doc <code>SignedInfo</code> is placed in this document
++     * @param signatureMethodURI URI representation of the Digest and
++     *    Signature algorithm
++     * @param canonicalizationMethodURI URI representation of the
++     *    Canonicalization method
++     * @throws XMLSecurityException
++     */
++    public SignedInfo(Document doc, String signatureMethodURI,
++        String canonicalizationMethodURI)
+               throws XMLSecurityException {
+-      this(doc, SignatureMethodURI, 0, CanonicalizationMethodURI);
+-   }
++        this(doc, signatureMethodURI, 0, canonicalizationMethodURI);
++    }
+ 
+-   /**
+-    * Constructor SignedInfo
+-    *
+-    * @param doc
+-    * @param CanonicalizationMethodURI
+-    * @param SignatureMethodURI
+-    * @param HMACOutputLength
+-    * @throws XMLSecurityException
+-    */
+-   public SignedInfo(
+-           Document doc, String SignatureMethodURI, int HMACOutputLength, String CanonicalizationMethodURI)
++    /**
++     * Constructor SignedInfo
++     *
++     * @param doc <code>SignedInfo</code> is placed in this document
++     * @param signatureMethodURI URI representation of the Digest and
++     *    Signature algorithm
++     * @param hMACOutputLength
++     * @param canonicalizationMethodURI URI representation of the
++     *    Canonicalization method
++     * @throws XMLSecurityException
++     */
++    public SignedInfo(Document doc, String signatureMethodURI,
++        int hMACOutputLength, String canonicalizationMethodURI)
+               throws XMLSecurityException {
+ 
+-      super(doc);
++        super(doc);
+ 
+-      // XMLUtils.addReturnToElement(this._constructionElement);
+-      {
+-         Element canonElem = XMLUtils.createElementInSignatureSpace(this._doc,
++        c14nMethod = XMLUtils.createElementInSignatureSpace(this._doc,
+                                 Constants._TAG_CANONICALIZATIONMETHOD);
+ 
+-         canonElem.setAttributeNS(null, Constants._ATT_ALGORITHM,
+-                                CanonicalizationMethodURI);
+-         this._constructionElement.appendChild(canonElem);
+-         XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+-      {
+-         if (HMACOutputLength > 0) {
++        c14nMethod.setAttributeNS(null, Constants._ATT_ALGORITHM,
++                                  canonicalizationMethodURI);
++        this._constructionElement.appendChild(c14nMethod);
++        XMLUtils.addReturnToElement(this._constructionElement);
++
++        if (hMACOutputLength > 0) {
+             this._signatureAlgorithm = new SignatureAlgorithm(this._doc,
+-                    SignatureMethodURI, HMACOutputLength);
+-         } else {
++                    signatureMethodURI, hMACOutputLength);
++        } else {
+             this._signatureAlgorithm = new SignatureAlgorithm(this._doc,
+-                    SignatureMethodURI);
+-         }
++                    signatureMethodURI);
++        }
+ 
+-         this._constructionElement
+-            .appendChild(this._signatureAlgorithm.getElement());
+-         XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+-   }
++        signatureMethod = this._signatureAlgorithm.getElement();
++        this._constructionElement.appendChild(signatureMethod);
++        XMLUtils.addReturnToElement(this._constructionElement);
++    }
+ 
+-   /**
+-    * @param doc
+-    * @param SignatureMethodElem
+-    * @param CanonicalizationMethodElem
+-    * @throws XMLSecurityException
+-    */
+-   public SignedInfo(
+-           Document doc, Element SignatureMethodElem, Element CanonicalizationMethodElem)
+-              throws XMLSecurityException {
++    /**
++     * @param doc
++     * @param signatureMethodElem
++     * @param canonicalizationMethodElem
++     * @throws XMLSecurityException
++     */
++    public SignedInfo(Document doc, Element signatureMethodElem,
++        Element canonicalizationMethodElem) throws XMLSecurityException {
+ 
+-      super(doc);
++        super(doc);
++        // Check this?
++        this.c14nMethod = canonicalizationMethodElem;
++        this._constructionElement.appendChild(c14nMethod);
++        XMLUtils.addReturnToElement(this._constructionElement);
+ 
+-      this._constructionElement.appendChild(CanonicalizationMethodElem);
+-      XMLUtils.addReturnToElement(this._constructionElement);
++        this._signatureAlgorithm =
++            new SignatureAlgorithm(signatureMethodElem, null);
+ 
+-      this._signatureAlgorithm = new SignatureAlgorithm(SignatureMethodElem, null);
++        signatureMethod = this._signatureAlgorithm.getElement();
++        this._constructionElement.appendChild(signatureMethod);
+ 
+-      this._constructionElement
+-         .appendChild(this._signatureAlgorithm.getElement());
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-   }
++        XMLUtils.addReturnToElement(this._constructionElement);
++    }
+ 
+-   /**
+-    * Build a {@link SignedInfo} from an {@link Element}
+-    *
+-    * @param element <code>SignedInfo</code>
+-    * @param BaseURI the URI of the resource where the XML instance was stored
+-    * @throws XMLSecurityException
+-    * @see <A HREF="http://lists.w3.org/Archives/Public/w3c-ietf-xmldsig/2001OctDec/0033.html">Question</A>
+-    * @see <A HREF="http://lists.w3.org/Archives/Public/w3c-ietf-xmldsig/2001OctDec/0054.html">Answer</A>
+-    */
+-   public SignedInfo(Element element, String BaseURI)
++    /**
++     * Build a {@link SignedInfo} from an {@link Element}
++     *
++     * @param element <code>SignedInfo</code>
++     * @param baseURI the URI of the resource where the XML instance was stored
++     * @throws XMLSecurityException
++     * @see <A HREF="http://lists.w3.org/Archives/Public/w3c-ietf-xmldsig/2001OctDec/0033.html">Question</A>
++     * @see <A HREF="http://lists.w3.org/Archives/Public/w3c-ietf-xmldsig/2001OctDec/0054.html">Answer</A>
++     */
++    public SignedInfo(Element element, String baseURI)
+            throws XMLSecurityException {
+ 
+-      // Parse the Reference children and Id attribute in the Manifest
+-      super(element, BaseURI);
++        // Parse the Reference children and Id attribute in the Manifest
++        super(element, baseURI);
+ 
+-      /* canonicalize ds:SignedInfo, reparse it into a new document
+-       * and replace the original not-canonicalized ds:SignedInfo by
+-       * the re-parsed canonicalized one.
+-       */
+-      String c14nMethodURI=this.getCanonicalizationMethodURI();
+-     if (!(c14nMethodURI.equals("http://www.w3.org/TR/2001/REC-xml-c14n-20010315") ||
+-                c14nMethodURI.equals("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments") ||
+-                        c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#") ||
+-                        c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#WithComments"))) {
+-        //The c14n is not a secure one and can rewrite the URIs or like that reparse the SignedInfo to be sure
+-      try {
+-         Canonicalizer c14nizer =
+-            Canonicalizer.getInstance(this.getCanonicalizationMethodURI());
++        /* canonicalize ds:SignedInfo, reparse it into a new document
++         * and replace the original not-canonicalized ds:SignedInfo by
++         * the re-parsed canonicalized one.
++         */
++        c14nMethod = XMLUtils.getNextElement(element.getFirstChild());
++        String c14nMethodURI = this.getCanonicalizationMethodURI();
++        if (!(c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS) ||
++              c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS) ||
++              c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS) ||
++              c14nMethodURI.equals(Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS))) {
++            // the c14n is not a secure one and can rewrite the URIs or like
++            // that reparse the SignedInfo to be sure
++            try {
++                Canonicalizer c14nizer =
++                Canonicalizer.getInstance(this.getCanonicalizationMethodURI());
+ 
+-         this._c14nizedBytes =
+-            c14nizer.canonicalizeSubtree(this._constructionElement);
+-         javax.xml.parsers.DocumentBuilderFactory dbf =
+-            javax.xml.parsers.DocumentBuilderFactory.newInstance();
++                this._c14nizedBytes =
++                    c14nizer.canonicalizeSubtree(this._constructionElement);
++                javax.xml.parsers.DocumentBuilderFactory dbf =
++                    javax.xml.parsers.DocumentBuilderFactory.newInstance();
++                dbf.setNamespaceAware(true);
++                javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
++                org.w3c.dom.Document newdoc =
++                    db.parse(new ByteArrayInputStream(this._c14nizedBytes));
++                Node imported =
++                    this._doc.importNode(newdoc.getDocumentElement(), true);
+ 
+-         dbf.setNamespaceAware(true);
++                this._constructionElement.getParentNode().replaceChild(imported,
++                    this._constructionElement);
+ 
+-         javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
+-         org.w3c.dom.Document newdoc =
+-            db.parse(new ByteArrayInputStream(this._c14nizedBytes));
+-         Node imported = this._doc.importNode(newdoc.getDocumentElement(),
+-                                              true);
+-
+-         this._constructionElement.getParentNode().replaceChild(imported,
+-                 this._constructionElement);
+-
+-         this._constructionElement = (Element) imported;
+-      } catch (ParserConfigurationException ex) {
+-         throw new XMLSecurityException("empty", ex);
+-      } catch (IOException ex) {
+-         throw new XMLSecurityException("empty", ex);
+-      } catch (SAXException ex) {
+-         throw new XMLSecurityException("empty", ex);
+-      }
+-      }
+-      this._signatureAlgorithm =
+-         new SignatureAlgorithm(this.getSignatureMethodElement(),
+-                                this.getBaseURI());
+-   }
++                this._constructionElement = (Element) imported;
++            } catch (ParserConfigurationException ex) {
++                throw new XMLSecurityException("empty", ex);
++            } catch (IOException ex) {
++                throw new XMLSecurityException("empty", ex);
++            } catch (SAXException ex) {
++                throw new XMLSecurityException("empty", ex);
++            }
++        }
++        signatureMethod = XMLUtils.getNextElement(c14nMethod.getNextSibling());
++        this._signatureAlgorithm =
++            new SignatureAlgorithm(signatureMethod, this.getBaseURI());
++    }
+ 
+    /**
+     * Tests core validation process
+@@ -294,12 +300,8 @@
+     */
+    public String getCanonicalizationMethodURI() {
+ 
+-    Element el= XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-     Constants._TAG_CANONICALIZATIONMETHOD,0);
+-     if (el==null) {
+-        return null;
+-     }
+-     return el.getAttributeNS(null, Constants._ATT_ALGORITHM);
++
++     return c14nMethod.getAttributeNS(null, Constants._ATT_ALGORITHM);
+    }
+ 
+    /**
+@@ -324,8 +326,7 @@
+     *
+     */
+    public Element getSignatureMethodElement() {
+-      return XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-        Constants._TAG_SIGNATUREMETHOD,0);
++           return signatureMethod;
+    }
+ 
+    /**
+@@ -343,6 +344,9 @@
+                                   .getJCEAlgorithmString());
+    }
+ 
++   protected SignatureAlgorithm getSignatureAlgorithm() {
++           return _signatureAlgorithm;
++   }
+    /**
+     * Method getBaseLocalName
+     * @inheritDoc
+@@ -354,21 +358,16 @@
+ 
+    public String getInclusiveNamespaces() {
+ 
+-    Element el= XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-     Constants._TAG_CANONICALIZATIONMETHOD,0);
+-     if (el==null) {
+-        return null;
+-     }
+ 
+-     String c14nMethodURI = el.getAttributeNS(null, Constants._ATT_ALGORITHM);
++
++     String c14nMethodURI = c14nMethod.getAttributeNS(null, Constants._ATT_ALGORITHM);
+      if(!(c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#") ||
+                         c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#WithComments"))) {
+                 return null;
+             }
+ 
+-     Element inclusiveElement = XMLUtils.selectNode(
+-             el.getFirstChild(),InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
+-        InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES,0);
++     Element inclusiveElement = XMLUtils.getNextElement(
++                 c14nMethod.getFirstChild());
+ 
+      if(inclusiveElement != null)
+      {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java
+@@ -75,7 +75,7 @@
+  * <li>sign and checkSignatureValue methods are used to sign and validate the
+  * signature. </li></ul>
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public final class XMLSignature extends SignatureElementProxy {
+ 
+@@ -115,6 +115,10 @@
+    public static final String ALGO_ID_MAC_HMAC_SHA384 = Constants.MoreAlgorithmsSpecNS + "hmac-sha384";
+    /** HMAC - Optional HMAC-SHA512 */
+    public static final String ALGO_ID_MAC_HMAC_SHA512 = Constants.MoreAlgorithmsSpecNS + "hmac-sha512";
++   /**Signature - Optional ECDSAwithSHA1 */
++   public static final String ALGO_ID_SIGNATURE_ECDSA_SHA1 = "http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1";
++
++
+    //J+
+ 
+    /** ds:Signature.ds:SignedInfo element */
+@@ -130,6 +134,8 @@
+     */
+    private boolean _followManifestsDuringValidation = false;
+ 
++private Element signatureValueElement;
++
+   /**
+     * This creates a new <CODE>ds:Signature</CODE> Element and adds an empty
+     * <CODE>ds:SignedInfo</CODE>.
+@@ -195,6 +201,15 @@
+ 
+       super(doc);
+ 
++      String xmlnsDsPrefix =
++         getDefaultPrefixBindings(Constants.SignatureSpecNS);
++      if (xmlnsDsPrefix == null) {
++         this._constructionElement.setAttributeNS
++            (Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS);
++      } else {
++         this._constructionElement.setAttributeNS
++            (Constants.NamespaceSpecNS, xmlnsDsPrefix, Constants.SignatureSpecNS);
++      }
+       XMLUtils.addReturnToElement(this._constructionElement);
+ 
+       this._baseURI = BaseURI;
+@@ -206,7 +221,7 @@
+       XMLUtils.addReturnToElement(this._constructionElement);
+ 
+       // create an empty SignatureValue; this is filled by setSignatureValueElement
+-      Element signatureValueElement =
++      signatureValueElement =
+          XMLUtils.createElementInSignatureSpace(this._doc,
+                                                 Constants._TAG_SIGNATUREVALUE);
+ 
+@@ -227,6 +242,15 @@
+ 
+       super(doc);
+ 
++      String xmlnsDsPrefix =
++         getDefaultPrefixBindings(Constants.SignatureSpecNS);
++      if (xmlnsDsPrefix == null) {
++         this._constructionElement.setAttributeNS
++            (Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS);
++      } else {
++         this._constructionElement.setAttributeNS
++            (Constants.NamespaceSpecNS, xmlnsDsPrefix, Constants.SignatureSpecNS);
++      }
+       XMLUtils.addReturnToElement(this._constructionElement);
+ 
+       this._baseURI = BaseURI;
+@@ -236,7 +260,7 @@
+       XMLUtils.addReturnToElement(this._constructionElement);
+ 
+       // create an empty SignatureValue; this is filled by setSignatureValueElement
+-      Element signatureValueElement =
++      signatureValueElement =
+          XMLUtils.createElementInSignatureSpace(this._doc,
+                                                 Constants._TAG_SIGNATUREVALUE);
+ 
+@@ -259,8 +283,8 @@
+       super(element, BaseURI);
+ 
+       // check out SignedInfo child
+-      Element signedInfoElem = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-                                  Constants._TAG_SIGNEDINFO,0);
++      Element signedInfoElem = XMLUtils.getNextElement(element.getFirstChild());// XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
++                                  //Constants._TAG_SIGNEDINFO,0);
+ 
+       // check to see if it is there
+       if (signedInfoElem == null) {
+@@ -274,8 +298,8 @@
+       this._signedInfo = new SignedInfo(signedInfoElem, BaseURI);
+ 
+       // check out SignatureValue child
+-      Element signatureValueElement = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-                                         Constants._TAG_SIGNATUREVALUE,0);
++      this.signatureValueElement =XMLUtils.getNextElement(signedInfoElem.getNextSibling()); //XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
++                                       //  Constants._TAG_SIGNATUREVALUE,0);
+ 
+       // check to see if it exists
+       if (signatureValueElement == null) {
+@@ -286,11 +310,12 @@
+       }
+ 
+       // <element ref="ds:KeyInfo" minOccurs="0"/>
+-      Element keyInfoElem =XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-                               Constants._TAG_KEYINFO,0);
++      Element keyInfoElem = XMLUtils.getNextElement(signatureValueElement.getNextSibling());//XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
++                              // Constants._TAG_KEYINFO,0);
+ 
+       // If it exists use it, but it's not mandatory
+-      if (keyInfoElem != null) {
++      if ((keyInfoElem != null) && (keyInfoElem.getNamespaceURI().equals(Constants.SignatureSpecNS) &&
++                  keyInfoElem.getLocalName().equals(Constants._TAG_KEYINFO)) ) {
+          this._keyInfo = new KeyInfo(keyInfoElem, BaseURI);
+       }
+    }
+@@ -302,7 +327,7 @@
+     */
+    public void setId(String Id) {
+ 
+-      if ((this._state == MODE_SIGN) && (Id != null)) {
++      if ( (Id != null)) {
+          this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
+          IdResolver.registerElementById(this._constructionElement, Id);
+       }
+@@ -336,9 +361,7 @@
+    public byte[] getSignatureValue() throws XMLSignatureException {
+ 
+       try {
+-         Element signatureValueElem = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-                                         Constants._TAG_SIGNATUREVALUE,0);
+-         byte[] signatureValue = Base64.decode(signatureValueElem);
++          byte[] signatureValue = Base64.decode(signatureValueElement);
+ 
+          return signatureValue;
+       } catch (Base64DecodingException ex) {
+@@ -346,33 +369,28 @@
+       }
+    }
+ 
+-   /**
+-    * Base64 encodes and sets the bytes as the content of the SignatureValue
+-    * Node.
+-    *
+-    * @param bytes bytes to be used by SignatureValue before Base64 encoding
+-    */
+-   private void setSignatureValueElement(byte[] bytes)
+-   {
++    /**
++     * Base64 encodes and sets the bytes as the content of the SignatureValue
++     * Node.
++     *
++     * @param bytes bytes to be used by SignatureValue before Base64 encoding
++     */
++    private void setSignatureValueElement(byte[] bytes) {
+ 
+-      if (this._state == MODE_SIGN) {
+-         Element signatureValueElem = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+-                                         Constants._TAG_SIGNATUREVALUE,0);
+-         while (signatureValueElem.hasChildNodes()) {
+-            signatureValueElem.removeChild(signatureValueElem.getFirstChild());
+-         }
++        while (signatureValueElement.hasChildNodes()) {
++            signatureValueElement.removeChild
++                (signatureValueElement.getFirstChild());
++        }
+ 
+-         String base64codedValue = Base64.encode(bytes);
++        String base64codedValue = Base64.encode(bytes);
+ 
+-         if (base64codedValue.length() > 76) {
++        if (base64codedValue.length() > 76 && !XMLUtils.ignoreLineBreaks()) {
+             base64codedValue = "\n" + base64codedValue + "\n";
+-         }
++        }
+ 
+-         Text t = this._doc.createTextNode(base64codedValue);
+-
+-         signatureValueElem.appendChild(t);
+-      }
+-   }
++        Text t = this._doc.createTextNode(base64codedValue);
++        signatureValueElement.appendChild(t);
++    }
+ 
+    /**
+     * Returns the KeyInfo child. If we are in signing mode and the KeyInfo
+@@ -385,7 +403,7 @@
+    public KeyInfo getKeyInfo() {
+ 
+       // check to see if we are signing and if we have to create a keyinfo
+-      if ((this._state == MODE_SIGN) && (this._keyInfo == null)) {
++      if ( (this._keyInfo == null)) {
+ 
+          // create the KeyInfo
+          this._keyInfo = new KeyInfo(this._doc);
+@@ -401,8 +419,7 @@
+                // add it before the object
+                this._constructionElement.insertBefore(keyInfoElement,
+                                                       firstObject);
+-               this._constructionElement
+-                  .insertBefore(this._doc.createTextNode("\n"), firstObject);
++               XMLUtils.addReturnBeforeChild(this._constructionElement, firstObject);
+             } else {
+ 
+                // add it as the last element to the signature
+@@ -425,17 +442,17 @@
+    public void appendObject(ObjectContainer object)
+            throws XMLSignatureException {
+ 
+-      try {
+-         if (this._state != MODE_SIGN) {
+-            throw new XMLSignatureException(
+-               "signature.operationOnlyBeforeSign");
+-         }
++      //try {
++         //if (this._state != MODE_SIGN) {
++           // throw new XMLSignatureException(
++             //  "signature.operationOnlyBeforeSign");
++         //}
+ 
+          this._constructionElement.appendChild(object.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+-      } catch (XMLSecurityException ex) {
+-         throw new XMLSignatureException("empty", ex);
+-      }
++      //} catch (XMLSecurityException ex) {
++        // throw new XMLSignatureException("empty", ex);
++      //}
+    }
+ 
+    /**
+@@ -481,23 +498,13 @@
+       }
+ 
+       try {
+-         if (this._state == MODE_SIGN) {
+-
+-            // XMLUtils.indentSignature(this._constructionElement, "   ", 0);
+-            // get the SignatureMethodElement
+-            Element signatureMethodElement =
+-               this._signedInfo.getSignatureMethodElement();
+-
++        // if (this._state == MODE_SIGN) {
+             //Create a SignatureAlgorithm object
+-            SignatureAlgorithm sa =
+-               new SignatureAlgorithm(signatureMethodElement,
+-                                      this.getBaseURI());
+-
++                SignedInfo si = this.getSignedInfo();
++            SignatureAlgorithm sa = si.getSignatureAlgorithm();
+             // initialize SignatureAlgorithm for signing
+             sa.initSign(signingKey);
+ 
+-            SignedInfo si = this.getSignedInfo();
+-
+             // generate digest values for all References in this SignedInfo
+             si.generateDigestValues();
+             OutputStream so=new UnsyncBufferedOutputStream(new SignerOutputStream(sa));
+@@ -513,7 +520,7 @@
+ 
+             // set them on the SignateValue element
+             this.setSignatureValueElement(jcebytes);
+-         }
++         //}
+       } catch (CanonicalizationException ex) {
+          throw new XMLSignatureException("empty", ex);
+       } catch (InvalidCanonicalizerException ex) {
+@@ -584,50 +591,45 @@
+ 
+          throw new XMLSignatureException("empty", exArgs);
+       }
+-
+       // all references inside the signedinfo need to be dereferenced and
+       // digested again to see if the outcome matches the stored value in the
+       // SignedInfo.
+       // If _followManifestsDuringValidation is true it will do the same for
+       // References inside a Manifest.
+       try {
+-         if (!this.getSignedInfo()
+-                 .verify(this._followManifestsDuringValidation)) {
+-            return false;
+-         }
+-
++         SignedInfo si=this.getSignedInfo();
+          //create a SignatureAlgorithms from the SignatureMethod inside
+          //SignedInfo. This is used to validate the signature.
+-         SignatureAlgorithm sa =
+-            new SignatureAlgorithm(this.getSignedInfo()
+-               .getSignatureMethodElement(), this.getBaseURI());
+-         if (true) {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "SignatureMethodURI = " + sa.getAlgorithmURI());
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "jceSigAlgorithm    = " + sa.getJCEAlgorithmString());
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "jceSigProvider     = " + sa.getJCEProviderName());
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "PublicKey = " + pk);
++         SignatureAlgorithm sa =si.getSignatureAlgorithm();
++         if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, "SignatureMethodURI = " + sa.getAlgorithmURI());
++                log.log(java.util.logging.Level.FINE, "jceSigAlgorithm    = " + sa.getJCEAlgorithmString());
++                log.log(java.util.logging.Level.FINE, "jceSigProvider     = " + sa.getJCEProviderName());
++                log.log(java.util.logging.Level.FINE, "PublicKey = " + pk);
+          }
+          sa.initVerify(pk);
+ 
+          // Get the canonicalized (normalized) SignedInfo
+          SignerOutputStream so=new SignerOutputStream(sa);
+          OutputStream bos=new UnsyncBufferedOutputStream(so);
+-         this._signedInfo.signInOctectStream(bos);
++         si.signInOctectStream(bos);
+          try {
+-                        bos.close();
+-                } catch (IOException e) {
+-                        //Imposible
+-                }
++                bos.close();
++         } catch (IOException e) {
++                //Imposible
++         }
+ 
+          //retrieve the byte[] from the stored signature
+          byte sigBytes[] = this.getSignatureValue();
+ 
+-
+          //Have SignatureAlgorithm sign the input bytes and compare them to the
+          //bytes that were stored in the signature.
+-         boolean verify = sa.verify(sigBytes);
++         if (!sa.verify(sigBytes)) {
++            log.log(java.util.logging.Level.WARNING, "Signature verification failed.");
++            return false;
++         }
+ 
+-         return verify;
++         return si.verify(this._followManifestsDuringValidation);
+       } catch (XMLSecurityException ex) {
+          throw new XMLSignatureException("empty", ex);
+       }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java
+@@ -2,9 +2,8 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+- * Copyright  1999-2004 The Apache Software Foundation.
++ * Copyright  1999-2008 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.
+@@ -21,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.signature;
+ 
+-
+-
+ import java.io.ByteArrayInputStream;
+ import java.io.ByteArrayOutputStream;
+ import java.io.IOException;
+@@ -39,7 +36,9 @@
+ import javax.xml.parsers.ParserConfigurationException;
+ 
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
++import com.sun.org.apache.xml.internal.security.c14n.implementations.CanonicalizerBase;
+ import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315OmitComments;
++import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_OmitComments;
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityRuntimeException;
+ import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
+ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+@@ -47,463 +46,483 @@
+ import org.w3c.dom.Node;
+ import org.xml.sax.SAXException;
+ 
+-
+ /**
+  * Class XMLSignatureInput
+  *
+  * @author Christian Geuer-Pollmann
+  * $todo$ check whether an XMLSignatureInput can be _both_, octet stream _and_ node set?
+  */
+-public class XMLSignatureInput  implements Cloneable {
+-         static java.util.logging.Logger log =
+-                java.util.logging.Logger.getLogger(XMLSignatureInput.class.getName());
++public class XMLSignatureInput implements Cloneable {
++    static java.util.logging.Logger log =
++        java.util.logging.Logger.getLogger
++            (XMLSignatureInput.class.getName());
+ 
+-        /*
++    /*
+      * The XMLSignature Input can be either:
+      *   A byteArray like with/or without InputStream.
+-     *   Or a  nodeSet like defined either:
+-     *                     * as a collection of nodes
+-     *                     * or as subnode excluding or not commets and excluding or
+-     *                            not other nodes.
+-         */
+-   /**
+-    * Some InputStreams do not support the {@link java.io.InputStream#reset}
+-    * method, so we read it in completely and work on our Proxy.
+-    */
+-   InputStream _inputOctetStreamProxy = null;
+-   /**
+-    * The original NodeSet for this XMLSignatureInput
+-    */
+-   Set _inputNodeSet = null;
+-   /**
+-    * The original Element
+-    */
+-   Node _subNode=null;
+-   /**
+-    * Exclude Node *for enveloped transformations*
+-    */
+-   Node excludeNode=null;
+-   /**
+-    *
+-    */
+-   boolean excludeComments=false;
++     *   Or a nodeSet like defined either:
++     *       * as a collection of nodes
++     *       * or as subnode excluding or not commets and excluding or
++     *         not other nodes.
++     */
+ 
+-   boolean isNodeSet=false;
+-   /**
+-    * A cached bytes
+-    */
+-   byte []bytes=null;
++    /**
++     * Some InputStreams do not support the {@link java.io.InputStream#reset}
++     * method, so we read it in completely and work on our Proxy.
++     */
++    InputStream _inputOctetStreamProxy = null;
++    /**
++     * The original NodeSet for this XMLSignatureInput
++     */
++    Set _inputNodeSet = null;
++    /**
++     * The original Element
++     */
++    Node _subNode=null;
++    /**
++     * Exclude Node *for enveloped transformations*
++     */
++    Node excludeNode=null;
++    /**
++     *
++     */
++    boolean excludeComments=false;
+ 
+-   /**
+-    * Some Transforms may require explicit MIME type, charset (IANA registered "character set"), or other such information concerning the data they are receiving from an earlier Transform or the source data, although no Transform algorithm specified in this document needs such explicit information. Such data characteristics are provided as parameters to the Transform algorithm and should be described in the specification for the algorithm.
+-    */
+-   private String _MIMEType = null;
++    boolean isNodeSet=false;
++    /**
++     * A cached bytes
++     */
++    byte []bytes=null;
+ 
+-   /**
+-    * Field _SourceURI
+-    */
+-   private String _SourceURI = null;
++    /**
++     * Some Transforms may require explicit MIME type, charset (IANA registered "character set"), or other such information concerning the data they are receiving from an earlier Transform or the source data, although no Transform algorithm specified in this document needs such explicit information. Such data characteristics are provided as parameters to the Transform algorithm and should be described in the specification for the algorithm.
++     */
++    private String _MIMEType = null;
+ 
+-   /**
+-    * Node Filter list.
+-    */
+-   List nodeFilters=new ArrayList();
++    /**
++     * Field _SourceURI
++     */
++    private String _SourceURI = null;
+ 
+-   boolean needsToBeExpanded=false;
+-   /**
+-    * Check if the structured is needed to be circumbented.
+-    * @return true if so.
+-    */
+-   public boolean isNeedsToBeExpanded() {
+-           return needsToBeExpanded;
+-   }
++    /**
++     * Node Filter list.
++     */
++    List nodeFilters=new ArrayList();
+ 
+-   /**
+-    * Set if the structured is needed to be circumbented.
+-    * @param needsToBeExpanded true if so.
+-    */
+-   public void setNeedsToBeExpanded(boolean needsToBeExpanded) {
++    boolean needsToBeExpanded=false;
++    OutputStream outputStream=null;
++
++    /**
++     * Check if the structured is needed to be circumbented.
++     * @return true if so.
++     */
++    public boolean isNeedsToBeExpanded() {
++        return needsToBeExpanded;
++    }
++
++    /**
++     * Set if the structured is needed to be circumbented.
++     * @param needsToBeExpanded true if so.
++     */
++    public void setNeedsToBeExpanded(boolean needsToBeExpanded) {
+         this.needsToBeExpanded = needsToBeExpanded;
+-   }
+-   OutputStream outputStream=null;
++    }
+ 
+-   /**
+-    * Construct a XMLSignatureInput from an octet array.
+-    * <p>
+-    * This is a comfort method, which internally converts the byte[] array into an InputStream
+-    * <p>NOTE: no defensive copy</p>
+-    * @param inputOctets an octet array which including XML document or node
+-    */
+-   public XMLSignatureInput(byte[] inputOctets) {
++    /**
++     * Construct a XMLSignatureInput from an octet array.
++     * <p>
++     * This is a comfort method, which internally converts the byte[] array into
++     * an InputStream
++     * <p>NOTE: no defensive copy</p>
++     * @param inputOctets an octet array which including XML document or node
++     */
++    public XMLSignatureInput(byte[] inputOctets) {
+ 
+-      // NO  defensive copy
++        // NO  defensive copy
+ 
+-      //this._inputOctetStreamProxy = new ByteArrayInputStream(inputOctets);
+-      this.bytes=inputOctets;
+-   }
++        //this._inputOctetStreamProxy = new ByteArrayInputStream(inputOctets);
++        this.bytes=inputOctets;
++    }
+ 
++    /**
++     * Constructs a <code>XMLSignatureInput</code> from an octet stream. The
++     * stream is directly read.
++     *
++     * @param inputOctetStream
++     */
++    public XMLSignatureInput(InputStream inputOctetStream)  {
++        this._inputOctetStreamProxy=inputOctetStream;
+ 
+-      /**
+-    * Constructs a <code>XMLSignatureInput</code> from an octet stream. The
+-    * stream is directly read.
+-    *
+-    * @param inputOctetStream
+-    */
+-   public XMLSignatureInput(InputStream inputOctetStream)  {
+-          this._inputOctetStreamProxy=inputOctetStream;
++        //this(JavaUtils.getBytesFromStream(inputOctetStream));
++    }
+ 
+-      //this(JavaUtils.getBytesFromStream(inputOctetStream));
++    /**
++     * Construct a XMLSignatureInput from a String.
++     * <p>
++     * This is a comfort method, which internally converts the String into a byte
++     * [] array using the {@link java.lang.String#getBytes()} method.
++     * @deprecated
++     * @param inputStr the input String which including XML document or node
++     */
++    public XMLSignatureInput(String inputStr) {
++        this(inputStr.getBytes());
++    }
+ 
+-   }
++    /**
++     * Construct a XMLSignatureInput from a String with a given encoding.
++     * <p>
++     * This is a comfort method, which internally converts the String into a byte
++     * [] array using the {@link java.lang.String#getBytes()} method.
++     *
++     * @deprecated
++     * @param inputStr the input String with encoding <code>encoding</code>
++     * @param encoding the encoding of <code>inputStr</code>
++     * @throws UnsupportedEncodingException
++     */
++    public XMLSignatureInput(String inputStr, String encoding)
++           throws UnsupportedEncodingException {
++        this(inputStr.getBytes(encoding));
++    }
+ 
+-   /**
+-    * Construct a XMLSignatureInput from a String.
+-    * <p>
+-    * This is a comfort method, which internally converts the String into a byte[] array using the {@link java.lang.String#getBytes()} method.
+-    * @deprecated
+-    * @param inputStr the input String which including XML document or node
+-    */
+-   public XMLSignatureInput(String inputStr) {
+-      this(inputStr.getBytes());
+-   }
++    /**
++     * Construct a XMLSignatureInput from a subtree rooted by rootNode. This
++     * method included the node and <I>all</I> his descendants in the output.
++     *
++     * @param rootNode
++     */
++    public XMLSignatureInput(Node rootNode)
++    {
++        this._subNode = rootNode;
++    }
+ 
+-   /**
+-    * Construct a XMLSignatureInput from a String with a given encoding.
+-    * <p>
+-    * This is a comfort method, which internally converts the String into a byte[] array using the {@link java.lang.String#getBytes()} method.
+-    *
+-    * @deprecated
+-    * @param inputStr the input String with encoding <code>encoding</code>
+-    * @param encoding the encoding of <code>inputStr</code>
+-    * @throws UnsupportedEncodingException
+-    */
+-   public XMLSignatureInput(String inputStr, String encoding)
+-           throws UnsupportedEncodingException {
+-      this(inputStr.getBytes(encoding));
+-   }
++    /**
++     * Constructor XMLSignatureInput
++     *
++     * @param inputNodeSet
++     * @param usedXPathAPI
++     */
++    public XMLSignatureInput(Set inputNodeSet) {
++        this._inputNodeSet = inputNodeSet;
++    }
+ 
+-   /**
+-    * Construct a XMLSignatureInput from a subtree rooted by rootNode. This
+-    * method included the node and <I>all</I> his descendants in the output.
+-    *
+-    * @param rootNode
+-    */
+-   public XMLSignatureInput(Node rootNode)
+-   {
+-      this._subNode = rootNode;
+-   }
++    /**
++     * Returns the node set from input which was specified as the parameter of
++     * {@link XMLSignatureInput} constructor
++     *
++     * @return the node set
++     * @throws SAXException
++     * @throws IOException
++     * @throws ParserConfigurationException
++     * @throws CanonicalizationException
++     */
++    public Set getNodeSet() throws CanonicalizationException,
++        ParserConfigurationException, IOException, SAXException {
++        return getNodeSet(false);
++    }
+ 
+-   /**
+-    * Constructor XMLSignatureInput
+-    *
+-    * @param inputNodeSet
+-    * @param usedXPathAPI
+-    */
+-   public XMLSignatureInput(Set inputNodeSet) {
+-       this._inputNodeSet = inputNodeSet;
+-   }
+-
+-   /**
+-    * Returns the node set from input which was specified as the parameter of {@link XMLSignatureInput} constructor
+-    *
+-    * @return the node set
+-    * @throws SAXException
+-    * @throws IOException
+-    * @throws ParserConfigurationException
+-    * @throws CanonicalizationException
+-    * @throws CanonicalizationException
+-    * @throws IOException
+-    * @throws ParserConfigurationException
+-    * @throws SAXException
+-    */
+-   public Set getNodeSet() throws CanonicalizationException, ParserConfigurationException, IOException, SAXException {
+-              return getNodeSet(false);
+-   }
+-   /**
+-    * Returns the node set from input which was specified as the parameter of {@link XMLSignatureInput} constructor
+-    * @param circunvent
+-    *
+-    * @return the node set
+-    * @throws SAXException
+-    * @throws IOException
+-    * @throws ParserConfigurationException
+-    * @throws CanonicalizationException
+-    * @throws CanonicalizationException
+-    * @throws IOException
+-    * @throws ParserConfigurationException
+-    * @throws SAXException
+-    */
+-   public Set getNodeSet(boolean circunvent)
++    /**
++     * Returns the node set from input which was specified as the parameter of
++     * {@link XMLSignatureInput} constructor
++     * @param circumvent
++     *
++     * @return the node set
++     * @throws SAXException
++     * @throws IOException
++     * @throws ParserConfigurationException
++     * @throws CanonicalizationException
++     */
++    public Set getNodeSet(boolean circumvent)
+            throws ParserConfigurationException, IOException, SAXException,
+                   CanonicalizationException {
+-      if (this._inputNodeSet!=null) {
+-          return this._inputNodeSet;
+-      }
+-          if (this.isElement()) {
++        if (this._inputNodeSet!=null) {
++            return this._inputNodeSet;
++        }
++        if ((this._inputOctetStreamProxy==null)&& (this._subNode!=null) ) {
+ 
+-                    if (circunvent) {
+-                        XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(_subNode));
++            if (circumvent) {
++                XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(_subNode));
+             }
+             this._inputNodeSet = new HashSet();
+             XMLUtils.getSet(_subNode,this._inputNodeSet, excludeNode, this.excludeComments);
+ 
+-                    return this._inputNodeSet;
+-          }
+-       else if (this.isOctetStream()) {
+-         convertToNodes();
+-         HashSet result=new HashSet();
+-         XMLUtils.getSet(_subNode, result,null,false);
++            return this._inputNodeSet;
++        } else if (this.isOctetStream()) {
++            convertToNodes();
++            HashSet result=new HashSet();
++            XMLUtils.getSet(_subNode, result,null,false);
+             //this._inputNodeSet=result;
+             return result;
+-      }
++        }
+ 
+-      throw new RuntimeException(
+-         "getNodeSet() called but no input data present");
+-   }
++        throw new RuntimeException(
++            "getNodeSet() called but no input data present");
++    }
+ 
+-   /**
+-    * Returns the Octect stream(byte Stream) from input which was specified as the parameter of {@link XMLSignatureInput} constructor
+-    *
+-    * @return the Octect stream(byte Stream) from input which was specified as the parameter of {@link XMLSignatureInput} constructor
+-    * @throws IOException
+-    */
+-   public InputStream getOctetStream()
+-           throws IOException  {
++    /**
++     * Returns the Octect stream(byte Stream) from input which was specified as
++     * the parameter of {@link XMLSignatureInput} constructor
++     *
++     * @return the Octect stream(byte Stream) from input which was specified as
++     * the parameter of {@link XMLSignatureInput} constructor
++     * @throws IOException
++     */
++    public InputStream getOctetStream() throws IOException  {
+ 
+-      return getResetableInputStream();
++        return getResetableInputStream();
++    }
+ 
+-   }
+-   /**
++    /**
+      * @return real octect stream
+      */
+     public InputStream getOctetStreamReal () {
+-       return this._inputOctetStreamProxy;
+-   }
+-   /**
+-    * Returns the byte array from input which was specified as the parameter of {@link XMLSignatureInput} constructor
+-    *
+-    * @return the byte[] from input which was specified as the parameter of {@link XMLSignatureInput} constructor
+-    *
+-    * @throws CanonicalizationException
+-    * @throws IOException
+-    */
+-   public byte[] getBytes()
+-           throws IOException, CanonicalizationException {
+-    if (bytes!=null) {
+-        return bytes;
+-      }
+-          InputStream is = getResetableInputStream();
+-          if (is!=null) {
+-        //reseatable can read again bytes.
+-                if (bytes==null) {
+-            is.reset();
+-            bytes=JavaUtils.getBytesFromStream(is);
+-                }
+-                return bytes;
+-      }
+-         Canonicalizer20010315OmitComments c14nizer =
+-                        new Canonicalizer20010315OmitComments();
++        return this._inputOctetStreamProxy;
++    }
++
++    /**
++     * Returns the byte array from input which was specified as the parameter of
++     * {@link XMLSignatureInput} constructor
++     *
++     * @return the byte[] from input which was specified as the parameter of
++     * {@link XMLSignatureInput} constructor
++     *
++     * @throws CanonicalizationException
++     * @throws IOException
++     */
++    public byte[] getBytes() throws IOException, CanonicalizationException {
++        if (bytes!=null) {
++            return bytes;
++        }
++        InputStream is = getResetableInputStream();
++        if (is!=null) {
++            //resetable can read again bytes.
++            if (bytes==null) {
++                is.reset();
++                bytes=JavaUtils.getBytesFromStream(is);
++            }
++            return bytes;
++        }
++        Canonicalizer20010315OmitComments c14nizer =
++                new Canonicalizer20010315OmitComments();
+         bytes=c14nizer.engineCanonicalize(this);
+         return bytes;
+-   }
++    }
+ 
++    /**
++     * Determines if the object has been set up with a Node set
++     *
++     * @return true if the object has been set up with a Node set
++     */
++    public boolean isNodeSet() {
++        return (( (this._inputOctetStreamProxy == null)
++              && (this._inputNodeSet != null) ) || isNodeSet);
++    }
+ 
+-   /**
+-    * Determines if the object has been set up with a Node set
+-    *
+-    * @return true is the object has been set up with a Node set
+-    */
+-   public boolean isNodeSet() {
+-      return (( (this._inputOctetStreamProxy == null)
+-              && (this._inputNodeSet != null) ) || isNodeSet);
+-   }
+-   /**
+-    * Determines if the object has been set up with an Element
+-    *
+-    * @return true is the object has been set up with a Node set
+-    */
+-   public boolean isElement() {
+-                return ((this._inputOctetStreamProxy==null)&& (this._subNode!=null)
+-                                && (this._inputNodeSet==null) && !isNodeSet
+-                                );
+-   }
++    /**
++     * Determines if the object has been set up with an Element
++     *
++     * @return true if the object has been set up with a Node set
++     */
++    public boolean isElement() {
++        return ((this._inputOctetStreamProxy==null)&& (this._subNode!=null)
++                && (this._inputNodeSet==null) && !isNodeSet);
++    }
+ 
+-   /**
+-    * Determines if the object has been set up with an octet stream
+-    *
+-    * @return true is the object has been set up with an octet stream
+-    */
+-   public boolean isOctetStream() {
+-      return ( ((this._inputOctetStreamProxy != null) || bytes!=null)
++    /**
++     * Determines if the object has been set up with an octet stream
++     *
++     * @return true if the object has been set up with an octet stream
++     */
++    public boolean isOctetStream() {
++        return ( ((this._inputOctetStreamProxy != null) || bytes!=null)
+               && ((this._inputNodeSet == null) && _subNode ==null));
+-   }
++    }
+ 
+-   /**
+-    * Determines if the object has been set up with a ByteArray
+-    *
+-    * @return true is the object has been set up with an octet stream
+-    */
+-   public boolean isByteArray() {
+-      return ( (bytes!=null)
++    /**
++     * Determines if {@link #setOutputStream} has been called with a
++     * non-null OutputStream.
++     *
++     * @return true if {@link #setOutputStream} has been called with a
++     * non-null OutputStream
++     */
++    public boolean isOutputStreamSet() {
++        return outputStream != null;
++    }
++
++    /**
++     * Determines if the object has been set up with a ByteArray
++     *
++     * @return true is the object has been set up with an octet stream
++     */
++    public boolean isByteArray() {
++        return ( (bytes!=null)
+               && ((this._inputNodeSet == null) && _subNode ==null));
+-   }
++    }
+ 
+-   /**
+-    * Is the object correctly set up?
+-    *
+-    * @return true if the object has been set up correctly
+-    */
+-   public boolean isInitialized() {
+-      return (this.isOctetStream() || this.isNodeSet());
+-   }
++    /**
++     * Is the object correctly set up?
++     *
++     * @return true if the object has been set up correctly
++     */
++    public boolean isInitialized() {
++        return (this.isOctetStream() || this.isNodeSet());
++    }
+ 
+-   /**
+-    * Returns MIMEType
+-    *
+-    * @return MIMEType
+-    */
+-   public String getMIMEType() {
+-      return this._MIMEType;
+-   }
++    /**
++     * Returns MIMEType
++     *
++     * @return MIMEType
++     */
++    public String getMIMEType() {
++        return this._MIMEType;
++    }
+ 
+-   /**
+-    * Sets MIMEType
+-    *
+-    * @param MIMEType
+-    */
+-   public void setMIMEType(String MIMEType) {
+-      this._MIMEType = MIMEType;
+-   }
++    /**
++     * Sets MIMEType
++     *
++     * @param MIMEType
++     */
++    public void setMIMEType(String MIMEType) {
++        this._MIMEType = MIMEType;
++    }
+ 
+-   /**
+-    * Return SourceURI
+-    *
+-    * @return SourceURI
+-    */
+-   public String getSourceURI() {
+-      return this._SourceURI;
+-   }
++    /**
++     * Return SourceURI
++     *
++     * @return SourceURI
++     */
++    public String getSourceURI() {
++        return this._SourceURI;
++    }
+ 
+-   /**
+-    * Sets SourceURI
+-    *
+-    * @param SourceURI
+-    */
+-   public void setSourceURI(String SourceURI) {
+-      this._SourceURI = SourceURI;
+-   }
++    /**
++     * Sets SourceURI
++     *
++     * @param SourceURI
++     */
++    public void setSourceURI(String SourceURI) {
++        this._SourceURI = SourceURI;
++    }
+ 
+-
+-   /**
+-    * Method toString
+-    * @inheritDoc
+-    *
+-    */
+-   public String toString() {
+-
+-      if (this.isNodeSet()) {
+-         return "XMLSignatureInput/NodeSet/" + this._inputNodeSet.size()
++    /**
++     * Method toString
++     * @inheritDoc
++     */
++    public String toString() {
++        if (this.isNodeSet()) {
++            return "XMLSignatureInput/NodeSet/" + this._inputNodeSet.size()
+                    + " nodes/" + this.getSourceURI();
+-      }
+-      if (this.isElement()) {
+-        return "XMLSignatureInput/Element/" + this._subNode
+-        + " exclude "+ this.excludeNode + " comments:" +
+-        this.excludeComments
+-        +"/" + this.getSourceURI();
+-      }
+-         try {
++        }
++        if (this.isElement()) {
++            return "XMLSignatureInput/Element/" + this._subNode
++                + " exclude "+ this.excludeNode + " comments:" +
++                this.excludeComments +"/" + this.getSourceURI();
++        }
++        try {
+             return "XMLSignatureInput/OctetStream/" + this.getBytes().length
+                    + " octets/" + this.getSourceURI();
+-         } catch (Exception ex) {
++        } catch (IOException iex) {
+             return "XMLSignatureInput/OctetStream//" + this.getSourceURI();
+-         }
++        } catch (CanonicalizationException cex) {
++            return "XMLSignatureInput/OctetStream//" + this.getSourceURI();
++        }
++    }
+ 
+-   }
++    /**
++     * Method getHTMLRepresentation
++     *
++     * @throws XMLSignatureException
++     * @return The HTML representation for this XMLSignature
++     */
++    public String getHTMLRepresentation() throws XMLSignatureException {
+ 
+-   /**
+-    * Method getHTMLRepresentation
+-    *
+-    * @throws XMLSignatureException
+-    * @return The HTML representation for this XMLSignature
+-    */
+-   public String getHTMLRepresentation() throws XMLSignatureException {
++        XMLSignatureInputDebugger db = new XMLSignatureInputDebugger(this);
+ 
+-      XMLSignatureInputDebugger db = new XMLSignatureInputDebugger(this);
++        return db.getHTMLRepresentation();
++    }
+ 
+-      return db.getHTMLRepresentation();
+-   }
+-
+-   /**
+-    * Method getHTMLRepresentation
+-    *
+-    * @param inclusiveNamespaces
+-    * @throws XMLSignatureException
+-    * @return The HTML representation for this XMLSignature
+-    */
+-   public String getHTMLRepresentation(Set inclusiveNamespaces)
++    /**
++     * Method getHTMLRepresentation
++     *
++     * @param inclusiveNamespaces
++     * @throws XMLSignatureException
++     * @return The HTML representation for this XMLSignature
++     */
++    public String getHTMLRepresentation(Set inclusiveNamespaces)
+            throws XMLSignatureException {
+ 
+-      XMLSignatureInputDebugger db = new XMLSignatureInputDebugger( this,
++        XMLSignatureInputDebugger db = new XMLSignatureInputDebugger( this,
+                                         inclusiveNamespaces);
+ 
+-      return db.getHTMLRepresentation();
+-   }
++        return db.getHTMLRepresentation();
++    }
+ 
+-   /**
+-    * Gets the exclude node of this XMLSignatureInput
+-    * @return Returns the excludeNode.
+-    */
++    /**
++     * Gets the exclude node of this XMLSignatureInput
++     * @return Returns the excludeNode.
++     */
+     public Node getExcludeNode() {
+-           return excludeNode;
++        return excludeNode;
+     }
+ 
+     /**
+      * Sets the exclude node of this XMLSignatureInput
+      * @param excludeNode The excludeNode to set.
+      */
+-     public void setExcludeNode(Node excludeNode) {
+-            this.excludeNode = excludeNode;
+-     }
++    public void setExcludeNode(Node excludeNode) {
++        this.excludeNode = excludeNode;
++    }
+ 
+-     /**
+-      * Gets the node of this XMLSignatureInput
+-      * @return The excludeNode set.
+-      */
+-     public Node getSubNode() {
+-            return _subNode;
+-     }
+-     /**
+-      * @return Returns the excludeComments.
+-      */
+-     public boolean isExcludeComments() {
++    /**
++     * Gets the node of this XMLSignatureInput
++     * @return The excludeNode set.
++     */
++    public Node getSubNode() {
++        return _subNode;
++    }
++
++    /**
++     * @return Returns the excludeComments.
++     */
++    public boolean isExcludeComments() {
+         return excludeComments;
+-     }
+-     /**
+-      * @param excludeComments The excludeComments to set.
+-      */
+-     public void setExcludeComments(boolean excludeComments) {
++    }
++
++    /**
++     * @param excludeComments The excludeComments to set.
++     */
++    public void setExcludeComments(boolean excludeComments) {
+         this.excludeComments = excludeComments;
+-     }
++    }
+ 
+-        /**
+-         * @param diOs
+-         * @throws IOException
+-         * @throws CanonicalizationException
+-         */
+-        public void updateOutputStream(OutputStream diOs) throws CanonicalizationException, IOException {
++    /**
++     * @param diOs
++     * @throws IOException
++     * @throws CanonicalizationException
++     */
++    public void updateOutputStream(OutputStream diOs)
++    throws CanonicalizationException, IOException {
++        updateOutputStream(diOs, false);
++    }
++
++    public void updateOutputStream(OutputStream diOs, boolean c14n11)
++    throws CanonicalizationException, IOException {
+         if (diOs==outputStream) {
+-                return;
++            return;
+         }
+         if (bytes!=null) {
+             diOs.write(bytes);
+             return;
+-         }else if (_inputOctetStreamProxy==null) {
+-             Canonicalizer20010315OmitComments c14nizer =
+-                    new Canonicalizer20010315OmitComments();
+-             c14nizer.setWriter(diOs);
++        } else if (_inputOctetStreamProxy==null) {
++            CanonicalizerBase c14nizer = null;
++            if (c14n11) {
++                c14nizer = new Canonicalizer11_OmitComments();
++            } else {
++                c14nizer = new Canonicalizer20010315OmitComments();
++            }
++            c14nizer.setWriter(diOs);
+             c14nizer.engineCanonicalize(this);
+             return;
+-          } else {
++        } else {
+             InputStream is = getResetableInputStream();
+             if (bytes!=null) {
+                 //already read write it, can be rea.
+@@ -516,25 +535,22 @@
+             while ((num=is.read(bytesT))>0) {
+                 diOs.write(bytesT,0,num);
+             }
++        }
++    }
+ 
+-          }
++    /**
++     * @param os
++     */
++    public void setOutputStream(OutputStream os) {
++        outputStream=os;
++    }
+ 
+-        }
+-
+-
+-        /**
+-         * @param os
+-         */
+-        public void setOutputStream(OutputStream os) {
+-                outputStream=os;
+-
+-        }
+     protected InputStream getResetableInputStream() throws IOException{
+         if ((_inputOctetStreamProxy instanceof ByteArrayInputStream) ) {
+             if (!_inputOctetStreamProxy.markSupported()) {
+                 throw new RuntimeException("Accepted as Markable but not truly been"+_inputOctetStreamProxy);
+             }
+-           return _inputOctetStreamProxy;
++            return _inputOctetStreamProxy;
+         }
+         if (bytes!=null) {
+             _inputOctetStreamProxy=new ByteArrayInputStream(bytes);
+@@ -543,7 +559,7 @@
+         if (_inputOctetStreamProxy ==null)
+             return null;
+         if (_inputOctetStreamProxy.markSupported()) {
+-            if (log.isLoggable(java.util.logging.Level.INFO))                                  log.log(java.util.logging.Level.INFO, "Mark Suported but not used as reset");
++            log.log(java.util.logging.Level.INFO, "Mark Suported but not used as reset");
+         }
+         bytes=JavaUtils.getBytesFromStream(_inputOctetStreamProxy);
+         _inputOctetStreamProxy.close();
+@@ -551,66 +567,63 @@
+         return _inputOctetStreamProxy;
+     }
+ 
++    /**
++     * @param filter
++     */
++    public void addNodeFilter(NodeFilter filter) {
++        if (isOctetStream()) {
++            try {
++                convertToNodes();
++            } catch (Exception e) {
++                throw new XMLSecurityRuntimeException("signature.XMLSignatureInput.nodesetReference",e);
++            }
++        }
++        nodeFilters.add(filter);
++    }
+ 
+-        /**
+-         * @param filter
+-         */
+-        public void addNodeFilter(NodeFilter filter) {
+-                if (isOctetStream()) {
+-                        try {
+-                                convertToNodes();
+-                        } catch (Exception e) {
+-                                throw new XMLSecurityRuntimeException("signature.XMLSignatureInput.nodesetReference",e);
+-                        }
+-                }
+-                nodeFilters.add(filter);
++    /**
++     * @return the node filters
++     */
++    public List getNodeFilters() {
++        // TODO Auto-generated method stub
++        return nodeFilters;
++    }
+ 
+-        }
++    /**
++     * @param b
++     */
++    public void setNodeSet(boolean b) {
++        isNodeSet=b;
++    }
+ 
+-        /**
+-         * @return the node filters
+-         */
+-        public List getNodeFilters() {
+-                // TODO Auto-generated method stub
+-                return nodeFilters;
+-        }
+-
+-        /**
+-         * @param b
+-         */
+-        public void setNodeSet(boolean b) {
+-                isNodeSet=b;
+-
+-        }
+-
+-        void convertToNodes() throws CanonicalizationException, ParserConfigurationException, IOException, SAXException{
+-                DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
++    void convertToNodes() throws CanonicalizationException,
++        ParserConfigurationException, IOException, SAXException {
++        DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+         dfactory.setValidating(false);
+         dfactory.setNamespaceAware(true);
+         DocumentBuilder db = dfactory.newDocumentBuilder();
+         // select all nodes, also the comments.
+         try {
+-           db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils
+-              .IgnoreAllErrorHandler());
++            db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils
++               .IgnoreAllErrorHandler());
+ 
+-           Document doc = db.parse(this.getOctetStream());
++            Document doc = db.parse(this.getOctetStream());
+ 
+-           XMLUtils.circumventBug2650(doc);
+-           this._subNode=doc.getDocumentElement();
++            this._subNode=doc.getDocumentElement();
+         } catch (SAXException ex) {
+ 
+-           // if a not-wellformed nodeset exists, put a container around it...
+-           ByteArrayOutputStream baos = new ByteArrayOutputStream();
++            // if a not-wellformed nodeset exists, put a container around it...
++            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ 
+-           baos.write("<container>".getBytes());
+-           baos.write(this.getBytes());
+-           baos.write("</container>".getBytes());
++            baos.write("<container>".getBytes());
++            baos.write(this.getBytes());
++            baos.write("</container>".getBytes());
+ 
+-           byte result[] = baos.toByteArray();
+-           Document document = db.parse(new ByteArrayInputStream(result));
+-           this._subNode=document.getDocumentElement().getFirstChild().getFirstChild();
++            byte result[] = baos.toByteArray();
++            Document document = db.parse(new ByteArrayInputStream(result));
++            this._subNode=document.getDocumentElement().getFirstChild().getFirstChild();
+         }
+         this._inputOctetStreamProxy=null;
+         this.bytes=null;
+-        }
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInputDebugger.java
+@@ -39,7 +39,8 @@
+ /**
+  * Class XMLSignatureInputDebugger
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
++ * @version $Revision: 1.3 $
+  */
+ public class XMLSignatureInputDebugger {
+ 
+@@ -599,23 +600,23 @@
+ 
+                 length = data.length();
+ 
+-                if ((data != null) && (length > 0)) {
+-                        this._writer.write(" ");
++                if (length > 0) {
++                    this._writer.write(" ");
+ 
+-                        for (int i = 0; i < length; i++) {
+-                                char c = data.charAt(i);
++                    for (int i = 0; i < length; i++) {
++                        char c = data.charAt(i);
+ 
+-                                switch (c) {
++                        switch (c) {
+ 
+-                                case 0x0D:
+-                                        this._writer.write("&amp;#xD;");
+-                                        break;
++                            case 0x0D:
++                                this._writer.write("&amp;#xD;");
++                                break;
+ 
+-                                default:
+-                                        this._writer.write(c);
+-                                        break;
+-                                }
++                            default:
++                                this._writer.write(c);
++                                break;
+                         }
++                    }
+                 }
+ 
+                 this._writer.write("?&gt;");
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/InvalidTransformException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/InvalidTransformException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/InvalidTransformException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/InvalidTransformException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
+@@ -20,14 +20,11 @@
+  */
+ package com.sun.org.apache.xml.internal.security.transforms;
+ 
+-
+-
+ import java.io.IOException;
+ import java.io.OutputStream;
+-import java.util.HashMap;
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
+-
++import java.util.HashMap;
+ import javax.xml.parsers.ParserConfigurationException;
+ 
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+@@ -38,17 +35,17 @@
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.HelperNodeList;
+ import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
++import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.NodeList;
+ import org.xml.sax.SAXException;
+ 
+-
+ /**
+  * Implements the behaviour of the <code>ds:Transform</code> element.
+  *
+- * This <code>Transform</code>(Factory) class role as the Factory and Proxy of
+- * implemanting class that have the functionality of <a
++ * This <code>Transform</code>(Factory) class acts as the Factory and Proxy of
++ * the implementing class that supports the functionality of <a
+  * href=http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg>a Transform
+  * algorithm</a>.
+  * Implements the Factory and Proxy pattern for ds:Transform algorithms.
+@@ -60,322 +57,311 @@
+  */
+ public final class Transform extends SignatureElementProxy {
+ 
+-   /** {@link java.util.logging} logging facility */
++    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(Transform.class.getName());
+ 
+-   /** Field _alreadyInitialized */
+-   static boolean _alreadyInitialized = false;
++    /** Field _alreadyInitialized */
++    private static boolean alreadyInitialized = false;
+ 
+-   /** All available Transform classes are registered here */
+-   static HashMap _transformHash = null;
++    /** All available Transform classes are registered here */
++    private static HashMap transformClassHash = null;
+ 
+-   /** Field transformSpi */
+-   protected TransformSpi transformSpi = null;
++    private static HashMap transformSpiHash = new HashMap();
+ 
+-   /**
+-    * Constructs {@link Transform}
+-    *
+-    * @param doc the {@link Document} in which <code>Transform</code> will be placed
+-    * @param algorithmURI URI representation of
+-    * <code>Transform algorithm</code> will be specified as parameter of
+-    * {@link #getInstance(Document, String)}, when generate. </br>
+-    * @param contextNodes the child node list of <code>Transform</code> element
+-    * @throws InvalidTransformException
+-    */
+-   public Transform(Document doc, String algorithmURI, NodeList contextNodes)
+-           throws InvalidTransformException {
++    private TransformSpi transformSpi = null;
+ 
+-      super(doc);
++    /**
++     * Constructs {@link Transform}
++     *
++     * @param doc the {@link Document} in which <code>Transform</code> will be
++     * placed
++     * @param algorithmURI URI representation of
++     * <code>Transform algorithm</code> which will be specified as parameter of
++     * {@link #getInstance(Document, String)}, when generated. </br>
++     * @param contextNodes the child node list of <code>Transform</code> element
++     * @throws InvalidTransformException
++     */
++    public Transform(Document doc, String algorithmURI, NodeList contextNodes)
++        throws InvalidTransformException {
+ 
+-      try {
+-         this._constructionElement.setAttributeNS(null, Constants._ATT_ALGORITHM,
+-                                                algorithmURI);
++        super(doc);
+ 
+-         Class implementingClass =
+-            Transform.getImplementingClass(algorithmURI);
++        this._constructionElement.setAttributeNS
++            (null, Constants._ATT_ALGORITHM, algorithmURI);
+ 
+-         if(implementingClass == null) {
++        transformSpi = getTransformSpi(algorithmURI);
++        if (transformSpi == null) {
+              Object exArgs[] = { algorithmURI };
+-
+              throw new InvalidTransformException(
+                 "signature.Transform.UnknownTransform", exArgs);
+-         }
+-         if (true) {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
+-                   + implementingClass + "\"");
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "The NodeList is " + contextNodes);
+-         }
++        }
+ 
+-         // create the custom Transform object
+-         this.transformSpi =
+-            (TransformSpi) implementingClass.newInstance();
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
++                   + transformSpi.getClass() + "\"");
++            log.log(java.util.logging.Level.FINE, "The NodeList is " + contextNodes);
++        }
+ 
+-         this.transformSpi.setTransform(this);
++        // give it to the current document
++        if (contextNodes != null) {
++            for (int i = 0; i < contextNodes.getLength(); i++) {
++               this._constructionElement.appendChild
++                   (contextNodes.item(i).cloneNode(true));
++            }
++        }
++    }
+ 
+-         // give it to the current document
+-         if (contextNodes != null) {
+-            /*
+-            while (contextNodes.getLength() > 0) {
+-               this._constructionElement.appendChild(contextNodes.item(0));
+-            }
+-            */
++    /**
++     * This constructor can only be called from the {@link Transforms} object,
++     * so it's protected.
++     *
++     * @param element <code>ds:Transform</code> element
++     * @param BaseURI the URI of the resource where the XML instance was stored
++     * @throws InvalidTransformException
++     * @throws TransformationException
++     * @throws XMLSecurityException
++     */
++    public Transform(Element element, String BaseURI)
++        throws InvalidTransformException, TransformationException,
++               XMLSecurityException {
+ 
+-            for (int i = 0; i < contextNodes.getLength(); i++) {
+-               this._constructionElement.appendChild(contextNodes.item(i).cloneNode(true));
+-            }
++        super(element, BaseURI);
+ 
+-         }
+-      } catch (IllegalAccessException ex) {
+-         Object exArgs[] = { algorithmURI };
++        // retrieve Algorithm Attribute from ds:Transform
++        String algorithmURI = element.getAttributeNS(null, Constants._ATT_ALGORITHM);
+ 
+-         throw new InvalidTransformException(
+-            "signature.Transform.UnknownTransform", exArgs, ex);
+-      } catch (InstantiationException ex) {
+-         Object exArgs[] = { algorithmURI };
++        if (algorithmURI == null || algorithmURI.length() == 0) {
++            Object exArgs[] = { Constants._ATT_ALGORITHM,
++                                Constants._TAG_TRANSFORM };
++            throw new TransformationException("xml.WrongContent", exArgs);
++        }
+ 
+-         throw new InvalidTransformException(
+-            "signature.Transform.UnknownTransform", exArgs, ex);
+-      }
+-   }
++        transformSpi = getTransformSpi(algorithmURI);
++        if (transformSpi == null) {
++            Object exArgs[] = { algorithmURI };
++            throw new InvalidTransformException(
++                "signature.Transform.UnknownTransform", exArgs);
++        }
++    }
+ 
+-   /**
+-    * This constructor can only be called from the {@link Transforms} object, so
+-    * it's protected.
+-    *
+-    * @param element <code>ds:Transform</code> element
+-    * @param BaseURI the URI of the resource where the XML instance was stored
+-    * @throws InvalidTransformException
+-    * @throws TransformationException
+-    * @throws XMLSecurityException
+-    */
+-   public Transform(Element element, String BaseURI)
+-           throws InvalidTransformException, TransformationException,
+-                  XMLSecurityException {
++    /**
++     * Generates a Transform object that implements the specified
++     * <code>Transform algorithm</code> URI.
++     *
++     * @param algorithmURI <code>Transform algorithm</code> URI representation,
++     * such as specified in
++     * <a href=http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg>Transform algorithm </a>
++     * @param doc the proxy {@link Document}
++     * @return <code>{@link Transform}</code> object
++     * @throws InvalidTransformException
++     */
++    public static Transform getInstance(
++        Document doc, String algorithmURI) throws InvalidTransformException {
++        return getInstance(doc, algorithmURI, (NodeList) null);
++    }
+ 
+-      super(element, BaseURI);
++    /**
++     * Generates a Transform object that implements the specified
++     * <code>Transform algorithm</code> URI.
++     *
++     * @param algorithmURI <code>Transform algorithm</code> URI representation,
++     * such as specified in
++     * <a href=http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg>Transform algorithm </a>
++     * @param contextChild the child element of <code>Transform</code> element
++     * @param doc the proxy {@link Document}
++     * @return <code>{@link Transform}</code> object
++     * @throws InvalidTransformException
++     */
++    public static Transform getInstance(
++        Document doc, String algorithmURI, Element contextChild)
++        throws InvalidTransformException {
+ 
+-      // retrieve Algorithm Attribute from ds:Transform
+-      String AlgorithmURI = element.getAttributeNS(null, Constants._ATT_ALGORITHM);
++        HelperNodeList contextNodes = new HelperNodeList();
+ 
+-      if ((AlgorithmURI == null) || (AlgorithmURI.length() == 0)) {
+-         Object exArgs[] = { Constants._ATT_ALGORITHM,
+-                             Constants._TAG_TRANSFORM };
++        XMLUtils.addReturnToElement(doc, contextNodes);
++        contextNodes.appendChild(contextChild);
++        XMLUtils.addReturnToElement(doc, contextNodes);
+ 
+-         throw new TransformationException("xml.WrongContent", exArgs);
+-      }
++        return getInstance(doc, algorithmURI, contextNodes);
++    }
+ 
+-      try {
+-         Class implementingClass = (Class) _transformHash.get(AlgorithmURI);
+-         this.transformSpi =
+-            (TransformSpi) implementingClass.newInstance();
++    /**
++     * Generates a Transform object that implements the specified
++     * <code>Transform algorithm</code> URI.
++     *
++     * @param algorithmURI <code>Transform algorithm</code> URI form, such as
++     * specified in <a href=http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg>
++     * Transform algorithm </a>
++     * @param contextNodes the child node list of <code>Transform</code> element
++     * @param doc the proxy {@link Document}
++     * @return <code>{@link Transform}</code> object
++     * @throws InvalidTransformException
++     */
++    public static Transform getInstance(
++        Document doc, String algorithmURI, NodeList contextNodes)
++        throws InvalidTransformException {
++        return new Transform(doc, algorithmURI, contextNodes);
++    }
+ 
+-         this.transformSpi.setTransform(this);
+-      } catch (IllegalAccessException e) {
+-         Object exArgs[] = { AlgorithmURI };
++    /**
++     * Initalizes for this {@link Transform}.
++     */
++    public static void init() {
++        if (!alreadyInitialized) {
++            transformClassHash = new HashMap(10);
++            // make sure builtin algorithms are all registered first
++            com.sun.org.apache.xml.internal.security.Init.init();
++            alreadyInitialized = true;
++        }
++    }
+ 
+-         throw new InvalidTransformException(
+-            "signature.Transform.UnknownTransform", exArgs);
+-      } catch (InstantiationException e) {
+-         Object exArgs[] = { AlgorithmURI };
++    /**
++     * Registers implementing class of the Transform algorithm with algorithmURI
++     *
++     * @param algorithmURI algorithmURI URI representation of
++     * <code>Transform algorithm</code> will be specified as parameter of
++     * {@link #getInstance(Document, String)}, when generate. </br>
++     * @param implementingClass <code>implementingClass</code> the implementing
++     * class of {@link TransformSpi}
++     * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI
++     * is already registered
++     */
++    public static void register(String algorithmURI, String implementingClass)
++        throws AlgorithmAlreadyRegisteredException {
+ 
+-         throw new InvalidTransformException(
+-            "signature.Transform.UnknownTransform", exArgs);
+-      } catch (NullPointerException e) {
+-                  Object exArgs[] = { AlgorithmURI };
+-
+-                 throw new InvalidTransformException(
+-                    "signature.Transform.UnknownTransform", exArgs);
+-        }
+-   }
+-
+-   /**
+-    * Generates a Transform object that implements the specified <code>Transform algorithm</code> URI.
+-    *
+-    * @param algorithmURI <code>Transform algorithm</code> URI representation, such as specified in <a href=http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg>Transform algorithm </a>
+-    * @param doc the proxy {@link Document}
+-    * @return <code>{@link Transform}</code> object
+-    * @throws InvalidTransformException
+-    */
+-   public static final Transform getInstance(
+-           Document doc, String algorithmURI) throws InvalidTransformException {
+-      return Transform.getInstance(doc, algorithmURI, (NodeList) null);
+-   }
+-
+-   /**
+-    * Generates a Transform object that implements the specified <code>Transform algorithm</code> URI.
+-    *
+-    * @param algorithmURI <code>Transform algorithm</code> URI representation, such as specified in <a href=http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg>Transform algorithm </a>
+-    * @param contextChild the child element of <code>Transform</code> element
+-    * @param doc the proxy {@link Document}
+-    * @return <code>{@link Transform}</code> object
+-    * @throws InvalidTransformException
+-    */
+-   public static final Transform getInstance(
+-           Document doc, String algorithmURI, Element contextChild)
+-              throws InvalidTransformException {
+-
+-      HelperNodeList contextNodes = new HelperNodeList();
+-
+-      contextNodes.appendChild(doc.createTextNode("\n"));
+-      contextNodes.appendChild(contextChild);
+-      contextNodes.appendChild(doc.createTextNode("\n"));
+-
+-      return Transform.getInstance(doc, algorithmURI, contextNodes);
+-   }
+-
+-   /**
+-    * Generates a Transform object that implements the specified <code>Transform algorithm</code> URI.
+-    *
+-    * @param algorithmURI <code>Transform algorithm</code> URI form, such as specified in <a href=http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg>Transform algorithm </a>
+-    * @param contextNodes the child node list of <code>Transform</code> element
+-    * @param doc the proxy {@link Document}
+-    * @return <code>{@link Transform}</code> object
+-    * @throws InvalidTransformException
+-    */
+-   public static final Transform getInstance(
+-           Document doc, String algorithmURI, NodeList contextNodes)
+-              throws InvalidTransformException {
+-      return new Transform(doc, algorithmURI, contextNodes);
+-   }
+-
+-   /**
+-    * Initalizes for this {@link Transform}
+-    *
+-    */
+-   public static void init() {
+-
+-      if (!_alreadyInitialized) {
+-         _transformHash = new HashMap(10);
+-         // make sure builtin algorithms are all registered first
+-         com.sun.org.apache.xml.internal.security.Init.init();
+-         _alreadyInitialized = true;
+-      }
+-   }
+-
+-   /**
+-    * Registers implementing class of the Transform algorithm with algorithmURI
+-    *
+-    * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>
+-    *  will be specified as parameter of {@link #getInstance(Document, String)}, when generate. </br>
+-    * @param implementingClass <code>implementingClass</code> the implementing class of {@link TransformSpi}
+-    * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
+-    */
+-   public static void register(String algorithmURI, String implementingClass)
+-           throws AlgorithmAlreadyRegisteredException {
+-
+-      {
+-
+-         // are we already registered?
+-         Class registeredClass = Transform.getImplementingClass(algorithmURI);
+-
+-         if ((registeredClass != null) ) {
++        // are we already registered?
++        Class registeredClass = getImplementingClass(algorithmURI);
++        if ((registeredClass != null) ) {
+             Object exArgs[] = { algorithmURI, registeredClass };
+-
+             throw new AlgorithmAlreadyRegisteredException(
+                "algorithm.alreadyRegistered", exArgs);
+-         }
++        }
+ 
+-         ClassLoader cl = Thread.currentThread().getContextClassLoader();
++        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ 
+-         try {
+-             Transform._transformHash.put
+-                 (algorithmURI, Class.forName(implementingClass, true, cl));
+-         } catch (ClassNotFoundException e) {
+-             throw new RuntimeException(e);
+-         }
+-      }
+-   }
++        try {
++            transformClassHash.put
++                (algorithmURI, Class.forName(implementingClass, true, cl));
++        } catch (ClassNotFoundException e) {
++            throw new RuntimeException(e);
++        }
++    }
+ 
+-   /**
+-    * Returns the URI representation of Transformation algorithm
+-    *
+-    * @return the URI representation of Transformation algorithm
+-    */
+-   public final String getURI() {
+-      return this._constructionElement.getAttributeNS(null, Constants._ATT_ALGORITHM);
+-   }
++    /**
++     * Returns the URI representation of Transformation algorithm
++     *
++     * @return the URI representation of Transformation algorithm
++     */
++    public String getURI() {
++        return this._constructionElement.getAttributeNS
++            (null, Constants._ATT_ALGORITHM);
++    }
+ 
+-   /**
+-    * Transforms the input, and generats {@link XMLSignatureInput} as output.
+-    * @param input input {@link XMLSignatureInput} which can supplied Octect Stream and NodeSet as Input of Transformation
+-    *
+-    * @return the {@link XMLSignatureInput} class as the result of transformation
+-    * @throws CanonicalizationException
+-    * @throws IOException
+-    * @throws InvalidCanonicalizerException
+-    * @throws TransformationException
+-    */
+-   public XMLSignatureInput performTransform(XMLSignatureInput input)
+-           throws IOException, CanonicalizationException,
+-                  InvalidCanonicalizerException, TransformationException {
++    /**
++     * Transforms the input, and generates {@link XMLSignatureInput} as output.
++     *
++     * @param input input {@link XMLSignatureInput} which can supplied Octet
++     * Stream and NodeSet as Input of Transformation
++     * @return the {@link XMLSignatureInput} class as the result of
++     * transformation
++     * @throws CanonicalizationException
++     * @throws IOException
++     * @throws InvalidCanonicalizerException
++     * @throws TransformationException
++     */
++    public XMLSignatureInput performTransform(XMLSignatureInput input)
++         throws IOException, CanonicalizationException,
++                InvalidCanonicalizerException, TransformationException {
+ 
+-      XMLSignatureInput result = null;
++        XMLSignatureInput result = null;
+ 
+-      try {
+-         result = transformSpi.enginePerformTransform(input);
+-      } catch (ParserConfigurationException ex) {
+-         Object exArgs[] = { this.getURI(), "ParserConfigurationException" };
++        try {
++            result = transformSpi.enginePerformTransform(input, this);
++        } catch (ParserConfigurationException ex) {
++            Object exArgs[] = { this.getURI(), "ParserConfigurationException" };
++            throw new CanonicalizationException(
++                "signature.Transform.ErrorDuringTransform", exArgs, ex);
++        } catch (SAXException ex) {
++            Object exArgs[] = { this.getURI(), "SAXException" };
++            throw new CanonicalizationException(
++                "signature.Transform.ErrorDuringTransform", exArgs, ex);
++        }
+ 
+-         throw new CanonicalizationException(
+-            "signature.Transform.ErrorDuringTransform", exArgs, ex);
+-      } catch (SAXException ex) {
+-         Object exArgs[] = { this.getURI(), "SAXException" };
++        return result;
++    }
+ 
+-         throw new CanonicalizationException(
+-            "signature.Transform.ErrorDuringTransform", exArgs, ex);
+-      }
++    /**
++     * Transforms the input, and generates {@link XMLSignatureInput} as output.
++     *
++     * @param input input {@link XMLSignatureInput} which can supplied Octet
++     * Stream and NodeSet as Input of Transformation
++     * @param os where to output the result of the last transformation
++     * @return the {@link XMLSignatureInput} class as the result of
++     * transformation
++     * @throws CanonicalizationException
++     * @throws IOException
++     * @throws InvalidCanonicalizerException
++     * @throws TransformationException
++     */
++    public XMLSignatureInput performTransform(XMLSignatureInput input,
++        OutputStream os) throws IOException, CanonicalizationException,
++        InvalidCanonicalizerException, TransformationException {
+ 
+-      return result;
+-   }
++        XMLSignatureInput result = null;
+ 
+-   /**
+-    * Transforms the input, and generats {@link XMLSignatureInput} as output.
+-    * @param input input {@link XMLSignatureInput} which can supplied Octect Stream and NodeSet as Input of Transformation
+-    * @param os where to output the result of the last transformation
+-    *
+-    * @return the {@link XMLSignatureInput} class as the result of transformation
+-    * @throws CanonicalizationException
+-    * @throws IOException
+-    * @throws InvalidCanonicalizerException
+-    * @throws TransformationException
+-    */
+-   public XMLSignatureInput performTransform(XMLSignatureInput input, OutputStream os)
+-   throws IOException, CanonicalizationException,
+-          InvalidCanonicalizerException, TransformationException {
++        try {
++            result = transformSpi.enginePerformTransform(input, os, this);
++        } catch (ParserConfigurationException ex) {
++            Object exArgs[] = { this.getURI(), "ParserConfigurationException" };
++            throw new CanonicalizationException(
++                "signature.Transform.ErrorDuringTransform", exArgs, ex);
++        } catch (SAXException ex) {
++            Object exArgs[] = { this.getURI(), "SAXException" };
++            throw new CanonicalizationException(
++                "signature.Transform.ErrorDuringTransform", exArgs, ex);
++        }
+ 
+-            XMLSignatureInput result = null;
++        return result;
++    }
+ 
+-            try {
+-                result = transformSpi.enginePerformTransform(input,os);
+-            } catch (ParserConfigurationException ex) {
+-                Object exArgs[] = { this.getURI(), "ParserConfigurationException" };
++    /**
++     * Method getImplementingClass
++     *
++     * @param URI
++     * @return The name of the class implementing the URI.
++     */
++    private static Class getImplementingClass(String URI) {
++        return (Class) transformClassHash.get(URI);
++    }
+ 
+-                throw new CanonicalizationException(
+-                                "signature.Transform.ErrorDuringTransform", exArgs, ex);
+-            } catch (SAXException ex) {
+-                Object exArgs[] = { this.getURI(), "SAXException" };
++    private static TransformSpi getTransformSpi(String URI)
++        throws InvalidTransformException {
++        try {
++            Object value = transformSpiHash.get(URI);
++            if (value != null) {
++                return (TransformSpi) value;
++            }
++            Class cl = (Class) transformClassHash.get(URI);
++            if (cl != null) {
++                TransformSpi tr = (TransformSpi) cl.newInstance();
++                transformSpiHash.put(URI, tr);
++                return tr;
++            }
++        } catch (InstantiationException ex) {
++            Object exArgs[] = { URI };
++            throw new InvalidTransformException(
++                "signature.Transform.UnknownTransform", exArgs, ex);
++        } catch (IllegalAccessException ex) {
++            Object exArgs[] = { URI };
++            throw new InvalidTransformException(
++                "signature.Transform.UnknownTransform", exArgs, ex);
++        }
++        return null;
++    }
+ 
+-                throw new CanonicalizationException(
+-                                "signature.Transform.ErrorDuringTransform", exArgs, ex);
+-            }
+-
+-            return result;
+-   }
+-
+-   /**
+-    * Method getImplementingClass
+-    *
+-    * @param URI
+-    * @return The name of the class implementing the URI.
+-    */
+-   private static Class getImplementingClass(String URI) {
+-       return (Class)Transform._transformHash.get(URI);
+-   }
+-
+-
+-   /** @inheritDoc */
+-   public String getBaseLocalName() {
+-      return Constants._TAG_TRANSFORM;
+-   }
++    /** @inheritDoc */
++    public String getBaseLocalName() {
++        return Constants._TAG_TRANSFORM;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformParam.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformParam.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformParam.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformParam.java
+@@ -23,7 +23,7 @@
+ 
+ /**
+  *
+- * @author $Author: blautenb $
++ * @author $Author: mullan $
+  */
+ 
+ public interface TransformParam {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformSpi.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -21,11 +20,8 @@
+  */
+ package com.sun.org.apache.xml.internal.security.transforms;
+ 
+-
+-
+ import java.io.IOException;
+ import java.io.OutputStream;
+-
+ import javax.xml.parsers.ParserConfigurationException;
+ 
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+@@ -33,68 +29,109 @@
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+ import org.xml.sax.SAXException;
+ 
+-
+ /**
+  * Base class which all Transform algorithms extend. The common methods that
+- * have to be overridden are the {@link #enginePerformTransform(XMLSignatureInput)} method.
++ * have to be overridden are the
++ * {@link #enginePerformTransform(XMLSignatureInput, Transform)} method.
+  *
+  * @author Christian Geuer-Pollmann
+  */
+ public abstract class TransformSpi {
++    /**
++     * For API compatibility not thread safe.
++     * @deprecated
++     */
++    protected Transform _transformObject = null;
++    /**
++     * Set the transform object.
++     * Depeprecated For API compatibility.
++     * @param transform the Transform
++     * @deprecated
++     */
++    protected void setTransform(Transform transform) {
++        this._transformObject = transform;
++    }
++    /**
++     * The mega method which MUST be implemented by the Transformation Algorithm.
++     *
++     * @param input {@link XMLSignatureInput} as the input of transformation
++     * @param os where to output this transformation.
++     * @param _transformObject the Transform
++     * @return {@link XMLSignatureInput} as the result of transformation
++     * @throws CanonicalizationException
++     * @throws IOException
++     * @throws InvalidCanonicalizerException
++     * @throws ParserConfigurationException
++     * @throws SAXException
++     * @throws TransformationException
++     */
++    protected XMLSignatureInput enginePerformTransform(
++        XMLSignatureInput input, OutputStream os, Transform _transformObject)
++        throws IOException,
++               CanonicalizationException, InvalidCanonicalizerException,
++               TransformationException, ParserConfigurationException,
++               SAXException {
++        return enginePerformTransform(input, _transformObject);
++    }
++    /**
++     * The mega method which MUST be implemented by the Transformation Algorithm.
++     * In order to be compatible with preexisting Transform implementations,
++     * by default this implementation invokes the deprecated, thread-unsafe
++     * methods. Subclasses should override this with a thread-safe
++     * implementation.
++     *
++     * @param input {@link XMLSignatureInput} as the input of transformation
++     * @param _transformObject the Transform
++     * @return {@link XMLSignatureInput} as the result of transformation
++     * @throws CanonicalizationException
++     * @throws IOException
++     * @throws InvalidCanonicalizerException
++     * @throws ParserConfigurationException
++     * @throws SAXException
++     * @throws TransformationException
++     */
++    protected XMLSignatureInput enginePerformTransform(
++        XMLSignatureInput input, Transform _transformObject)
++        throws IOException,
++               CanonicalizationException, InvalidCanonicalizerException,
++               TransformationException, ParserConfigurationException,
++               SAXException {
++        //Default implementation overide with a much better
++        try {
++                TransformSpi tmp = (TransformSpi) getClass().newInstance();
++            tmp.setTransform(_transformObject);
++            return tmp.enginePerformTransform(input);
++        } catch (InstantiationException e) {
++            throw new TransformationException("",e);
++        } catch (IllegalAccessException e) {
++            throw new TransformationException("",e);
++        }
++    }
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(TransformSpi.class.getName());
+-
+-   protected Transform _transformObject = null;
+-   protected void setTransform(Transform transform) {
+-      this._transformObject = transform;
+-   }
+-
+-   /**
+-    * The mega method which MUST be implemented by the Transformation Algorithm.
+-    *
+-    * @param input {@link XMLSignatureInput} as the input of transformation
+-    * @param os where to output this transformation.
+-    * @return {@link XMLSignatureInput} as the result of transformation
+-    * @throws CanonicalizationException
+-    * @throws IOException
+-    * @throws InvalidCanonicalizerException
+-    * @throws ParserConfigurationException
+-    * @throws SAXException
+-    * @throws TransformationException
+-    */
+-   protected XMLSignatureInput enginePerformTransform(
+-      XMLSignatureInput input, OutputStream os)
+-         throws IOException,
+-                CanonicalizationException, InvalidCanonicalizerException,
+-                TransformationException, ParserConfigurationException,
+-                SAXException {
+-            return enginePerformTransform(input);
+-   }
+-   /**
+-    * The mega method which MUST be implemented by the Transformation Algorithm.
+-    *
+-    * @param input {@link XMLSignatureInput} as the input of transformation
+-    * @return {@link XMLSignatureInput} as the result of transformation
+-    * @throws CanonicalizationException
+-    * @throws IOException
+-    * @throws InvalidCanonicalizerException
+-    * @throws ParserConfigurationException
+-    * @throws SAXException
+-    * @throws TransformationException
+-    */
+-   protected abstract XMLSignatureInput enginePerformTransform(
+-      XMLSignatureInput input)
+-         throws IOException,
+-                CanonicalizationException, InvalidCanonicalizerException,
+-                TransformationException, ParserConfigurationException,
+-                SAXException;
+-
+-   /**
+-    * Returns the URI representation of <code>Transformation algorithm</code>
+-    *
+-    * @return the URI representation of <code>Transformation algorithm</code>
+-    */
+-   protected abstract String engineGetURI();
++    /**
++     * The mega method which MUST be implemented by the Transformation Algorithm.
++     * @deprecated
++     * @param input {@link XMLSignatureInput} as the input of transformation
++     * @return {@link XMLSignatureInput} as the result of transformation
++     * @throws CanonicalizationException
++     * @throws IOException
++     * @throws InvalidCanonicalizerException
++     * @throws ParserConfigurationException
++     * @throws SAXException
++     * @throws TransformationException
++     */
++    protected XMLSignatureInput enginePerformTransform(
++        XMLSignatureInput input)
++        throws IOException,
++               CanonicalizationException, InvalidCanonicalizerException,
++               TransformationException, ParserConfigurationException,
++               SAXException {
++        throw new UnsupportedOperationException();
++    }
++    /**
++     * Returns the URI representation of <code>Transformation algorithm</code>
++     *
++     * @return the URI representation of <code>Transformation algorithm</code>
++     */
++    protected abstract String engineGetURI();
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformationException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformationException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformationException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/TransformationException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transforms.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transforms.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transforms.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transforms.java
+@@ -3,7 +3,7 @@
+  * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * Copyright  1999-2004 The Apache Software Foundation.
++ * Copyright  1999-2008 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.
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.transforms;
+ 
+-
+-
+ import java.io.IOException;
+ import java.io.OutputStream;
+ 
+@@ -39,11 +37,13 @@
+ import org.w3c.dom.Element;
+ import org.w3c.dom.NodeList;
+ 
+-
+ /**
+- * Holder of the {@link com.sun.org.apache.xml.internal.security.transforms.Transform} steps to be performed on the data.
+- * The input to the first Transform is the result of dereferencing the <code>URI</code> attribute of the <code>Reference</code> element.
+- * The output from the last Transform is the input for the <code>DigestMethod algorithm</code>
++ * Holder of the {@link com.sun.org.apache.xml.internal.security.transforms.Transform} steps to
++ * be performed on the data.
++ * The input to the first Transform is the result of dereferencing the
++ * <code>URI</code> attribute of the <code>Reference</code> element.
++ * The output from the last Transform is the input for the
++ * <code>DigestMethod algorithm</code>
+  *
+  * @author Christian Geuer-Pollmann
+  * @see Transform
+@@ -51,252 +51,273 @@
+  */
+ public class Transforms extends SignatureElementProxy {
+ 
+-   /** {@link java.util.logging} logging facility */
++    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(Transforms.class.getName());
+-   //J-
+-   /** Canonicalization - Required Canonical XML (omits comments) */
+-   public static final String TRANSFORM_C14N_OMIT_COMMENTS = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
+-   /** Canonicalization - Recommended Canonical XML with Comments */
+-   public static final String TRANSFORM_C14N_WITH_COMMENTS = Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS;
+-   /** Canonicalization - Required Exclusive Canonicalization (omits comments) */
+-   public static final String TRANSFORM_C14N_EXCL_OMIT_COMMENTS = Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS;
+-   /** Canonicalization - Recommended Exclusive Canonicalization with Comments */
+-   public static final String TRANSFORM_C14N_EXCL_WITH_COMMENTS = Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS;
+-   /** Transform - Optional XSLT */
+-   public static final String TRANSFORM_XSLT = "http://www.w3.org/TR/1999/REC-xslt-19991116";
+-   /** Transform - Required base64 decoding */
+-   public static final String TRANSFORM_BASE64_DECODE = Constants.SignatureSpecNS + "base64";
+-   /** Transform - Recommended XPath */
+-   public static final String TRANSFORM_XPATH = "http://www.w3.org/TR/1999/REC-xpath-19991116";
+-   /** Transform - Required Enveloped Signature */
+-   public static final String TRANSFORM_ENVELOPED_SIGNATURE = Constants.SignatureSpecNS + "enveloped-signature";
+-   /** Transform - XPointer */
+-   public static final String TRANSFORM_XPOINTER = "http://www.w3.org/TR/2001/WD-xptr-20010108";
+-   /** Transform - XPath Filter v2.0 */
+-   public static final String TRANSFORM_XPATH2FILTER04 = "http://www.w3.org/2002/04/xmldsig-filter2";
+-   /** Transform - XPath Filter */
+-   public static final String TRANSFORM_XPATH2FILTER = "http://www.w3.org/2002/06/xmldsig-filter2";
+-   /** Transform - XPath Filter  CHGP private*/
+-   public static final String TRANSFORM_XPATHFILTERCHGP = "http://www.nue.et-inf.uni-siegen.de/~geuer-pollmann/#xpathFilter";
+-   //J+
+-   Element []transforms;
+-   /**
+-    * Consturcts {@link Transforms}
+-    *
+-    * @param doc the {@link Document} in which <code>XMLsignature</code> will be placed
+-    */
+-   public Transforms(Document doc) {
++    /** Canonicalization - Required Canonical XML (omits comments) */
++    public static final String TRANSFORM_C14N_OMIT_COMMENTS
++        = Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
++    /** Canonicalization - Recommended Canonical XML with Comments */
++    public static final String TRANSFORM_C14N_WITH_COMMENTS
++        = Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS;
++    /** Canonicalization - Required Canonical XML 1.1 (omits comments) */
++    public static final String TRANSFORM_C14N11_OMIT_COMMENTS
++        = Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
++    /** Canonicalization - Recommended Canonical XML 1.1 with Comments */
++    public static final String TRANSFORM_C14N11_WITH_COMMENTS
++        = Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS;
++    /** Canonicalization - Required Exclusive Canonicalization (omits comments) */
++    public static final String TRANSFORM_C14N_EXCL_OMIT_COMMENTS
++        = Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS;
++    /** Canonicalization - Recommended Exclusive Canonicalization with Comments */
++    public static final String TRANSFORM_C14N_EXCL_WITH_COMMENTS
++        = Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS;
++    /** Transform - Optional XSLT */
++    public static final String TRANSFORM_XSLT
++        = "http://www.w3.org/TR/1999/REC-xslt-19991116";
++    /** Transform - Required base64 decoding */
++    public static final String TRANSFORM_BASE64_DECODE
++        = Constants.SignatureSpecNS + "base64";
++    /** Transform - Recommended XPath */
++    public static final String TRANSFORM_XPATH
++        = "http://www.w3.org/TR/1999/REC-xpath-19991116";
++    /** Transform - Required Enveloped Signature */
++    public static final String TRANSFORM_ENVELOPED_SIGNATURE
++        = Constants.SignatureSpecNS + "enveloped-signature";
++    /** Transform - XPointer */
++    public static final String TRANSFORM_XPOINTER
++        = "http://www.w3.org/TR/2001/WD-xptr-20010108";
++    /** Transform - XPath Filter v2.0 */
++    public static final String TRANSFORM_XPATH2FILTER04
++        = "http://www.w3.org/2002/04/xmldsig-filter2";
++    /** Transform - XPath Filter */
++    public static final String TRANSFORM_XPATH2FILTER
++        = "http://www.w3.org/2002/06/xmldsig-filter2";
++    /** Transform - XPath Filter  CHGP private */
++    public static final String TRANSFORM_XPATHFILTERCHGP
++        = "http://www.nue.et-inf.uni-siegen.de/~geuer-pollmann/#xpathFilter";
+ 
+-      super(doc);
++    Element []transforms;
+ 
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-   }
++    protected Transforms() { };
+ 
+-   /**
+-    * Consturcts {@link Transforms} from {@link Element} which is <code>Transforms</code> Element
+-    *
+-    * @param element  is <code>Transforms</code> element
+-    * @param BaseURI the URI where the XML instance was stored
+-    * @throws DOMException
+-    * @throws InvalidTransformException
+-    * @throws TransformationException
+-    * @throws XMLSecurityException
+-    * @throws XMLSignatureException
+-    */
+-   public Transforms(Element element, String BaseURI)
++    /**
++     * Constructs {@link Transforms}.
++     *
++     * @param doc the {@link Document} in which <code>XMLSignature</code> will
++     * be placed
++     */
++    public Transforms(Document doc) {
++        super(doc);
++        XMLUtils.addReturnToElement(this._constructionElement);
++    }
++
++    /**
++     * Constructs {@link Transforms} from {@link Element} which is
++     * <code>Transforms</code> Element
++     *
++     * @param element  is <code>Transforms</code> element
++     * @param BaseURI the URI where the XML instance was stored
++     * @throws DOMException
++     * @throws InvalidTransformException
++     * @throws TransformationException
++     * @throws XMLSecurityException
++     * @throws XMLSignatureException
++     */
++    public Transforms(Element element, String BaseURI)
+            throws DOMException, XMLSignatureException,
+                   InvalidTransformException, TransformationException,
+                   XMLSecurityException {
+ 
+-      super(element, BaseURI);
++        super(element, BaseURI);
+ 
+-      int numberOfTransformElems = this.getLength();
++        int numberOfTransformElems = this.getLength();
+ 
+-      if (numberOfTransformElems == 0) {
++        if (numberOfTransformElems == 0) {
+ 
+-         // At least ont Transform element must be present. Bad.
+-         Object exArgs[] = { Constants._TAG_TRANSFORM,
+-                             Constants._TAG_TRANSFORMS };
++            // At least one Transform element must be present. Bad.
++            Object exArgs[] = { Constants._TAG_TRANSFORM,
++                                Constants._TAG_TRANSFORMS };
+ 
+-         throw new TransformationException("xml.WrongContent", exArgs);
+-      }
+-   }
++            throw new TransformationException("xml.WrongContent", exArgs);
++        }
++    }
+ 
+-   /**
+-    * Adds the <code>Transform</code> with the specified <code>Transform algorithm URI</code>
+-    *
+-    * @param transformURI the URI form of transform that indicates which transformation is applied to data
+-    * @throws TransformationException
+-    */
+-   public void addTransform(String transformURI)
++    /**
++     * Adds the <code>Transform</code> with the specified <code>Transform
++     * algorithm URI</code>
++     *
++     * @param transformURI the URI form of transform that indicates which
++     * transformation is applied to data
++     * @throws TransformationException
++     */
++    public void addTransform(String transformURI)
+            throws TransformationException {
+ 
+-      try {
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transformURI + ")");
++        try {
++            if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transformURI + ")");
+ 
+-         Transform transform = Transform.getInstance(this._doc, transformURI);
++            Transform transform =
++                Transform.getInstance(this._doc, transformURI);
+ 
+-         this.addTransform(transform);
+-      } catch (InvalidTransformException ex) {
+-         throw new TransformationException("empty", ex);
+-      }
+-   }
++            this.addTransform(transform);
++        } catch (InvalidTransformException ex) {
++            throw new TransformationException("empty", ex);
++        }
++    }
+ 
+-   /**
+-    * Adds the <code>Transform</code> with the specified <code>Transform algorithm URI</code>
+-    *
+-    * @param transformURI the URI form of transform that indicates which transformation is applied to data
+-    * @param contextElement
+-    * @throws TransformationException
+-    * @see Transform#getInstance(Document doc, String algorithmURI, Element childElement)
+-    */
+-   public void addTransform(String transformURI, Element contextElement)
++    /**
++     * Adds the <code>Transform</code> with the specified <code>Transform
++     * algorithm URI</code>
++     *
++     * @param transformURI the URI form of transform that indicates which
++     * transformation is applied to data
++     * @param contextElement
++     * @throws TransformationException
++     * @see Transform#getInstance(Document doc, String algorithmURI, Element childElement)
++     */
++    public void addTransform(String transformURI, Element contextElement)
+            throws TransformationException {
+ 
+-      try {
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transformURI + ")");
++        try {
++            if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transformURI + ")");
+ 
+-         Transform transform = Transform.getInstance(this._doc, transformURI,
+-                                                     contextElement);
++            Transform transform =
++                Transform.getInstance(this._doc, transformURI, contextElement);
+ 
+-         this.addTransform(transform);
+-      } catch (InvalidTransformException ex) {
+-         throw new TransformationException("empty", ex);
+-      }
+-   }
++            this.addTransform(transform);
++        } catch (InvalidTransformException ex) {
++            throw new TransformationException("empty", ex);
++        }
++    }
+ 
+-   /**
+-    * Adds the <code>Transform</code> with the specified <code>Transform algorithm URI</code>
+-    *
+-    * @param transformURI the URI form of transform that indicates which transformation is applied to data
+-    * @param contextNodes
+-    * @throws TransformationException
+-    * @see Transform#getInstance(Document doc, String algorithmURI, NodeList contextNodes)
+-    */
+-   public void addTransform(String transformURI, NodeList contextNodes)
++    /**
++     * Adds the <code>Transform</code> with the specified <code>Transform
++     * algorithm URI</code>.
++     *
++     * @param transformURI the URI form of transform that indicates which
++     * transformation is applied to data
++     * @param contextNodes
++     * @throws TransformationException
++     * @see Transform#getInstance(Document doc, String algorithmURI, NodeList contextNodes)
++     */
++    public void addTransform(String transformURI, NodeList contextNodes)
+            throws TransformationException {
+ 
+-      try {
+-         Transform transform = Transform.getInstance(this._doc, transformURI,
+-                                                     contextNodes);
++        try {
++            Transform transform =
++                Transform.getInstance(this._doc, transformURI, contextNodes);
++            this.addTransform(transform);
++        } catch (InvalidTransformException ex) {
++            throw new TransformationException("empty", ex);
++        }
++    }
+ 
+-         this.addTransform(transform);
+-      } catch (InvalidTransformException ex) {
+-         throw new TransformationException("empty", ex);
+-      }
+-   }
++    /**
++     * Adds a user-provided Transform step.
++     *
++     * @param transform {@link Transform} object
++     */
++    private void addTransform(Transform transform) {
++        if (log.isLoggable(java.util.logging.Level.FINE))
++            log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transform.getURI() + ")");
+ 
+-   /**
+-    * Adds a user-provided Transform step.
+-    *
+-    * @param transform {@link Transform} object
+-    */
+-   private void addTransform(Transform transform) {
+-      if (true)
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transform.getURI() + ")");
++        Element transformElement = transform.getElement();
+ 
+-      Element transformElement = transform.getElement();
++        this._constructionElement.appendChild(transformElement);
++        XMLUtils.addReturnToElement(this._constructionElement);
++    }
+ 
+-      this._constructionElement.appendChild(transformElement);
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-   }
++    /**
++     * Applies all included <code>Transform</code>s to xmlSignatureInput and
++     * returns the result of these transformations.
++     *
++     * @param xmlSignatureInput the input for the <code>Transform</code>s
++     * @return the result of the <code>Transforms</code>
++     * @throws TransformationException
++     */
++    public XMLSignatureInput performTransforms(
++        XMLSignatureInput xmlSignatureInput) throws TransformationException {
++        return performTransforms(xmlSignatureInput, null);
++    }
+ 
+-   /**
+-    * Applies all included <code>Transform</code>s to xmlSignatureInput and returns the result of these transformations.
+-    *
+-    * @param xmlSignatureInput the input for the <code>Transform</code>s
+-    * @return the result of the <code>Transforms</code>
+-    * @throws TransformationException
+-    */
+-   public XMLSignatureInput performTransforms(
+-           XMLSignatureInput xmlSignatureInput) throws TransformationException {
+-             return performTransforms(xmlSignatureInput,null);
+-   }
++    /**
++     * Applies all included <code>Transform</code>s to xmlSignatureInput and
++     * returns the result of these transformations.
++     *
++     * @param xmlSignatureInput the input for the <code>Transform</code>s
++     * @param os where to output the last transformation.
++     * @return the result of the <code>Transforms</code>
++     * @throws TransformationException
++     */
++    public XMLSignatureInput performTransforms(
++        XMLSignatureInput xmlSignatureInput, OutputStream os)
++        throws TransformationException {
+ 
+-   /**
+-    * Applies all included <code>Transform</code>s to xmlSignatureInput and returns the result of these transformations.
+-    *
+-    * @param xmlSignatureInput the input for the <code>Transform</code>s
+-    * @param os where to output the last transformation.
+-    * @return the result of the <code>Transforms</code>
+-    * @throws TransformationException
+-    */
+-    public XMLSignatureInput performTransforms(
+-            XMLSignatureInput xmlSignatureInput,OutputStream os) throws TransformationException {
++        try {
++            int last=this.getLength()-1;
++            for (int i = 0; i < last; i++) {
++                Transform t = this.item(i);
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, "Perform the (" + i + ")th " + t.getURI()
++                        + " transform");
++                }
++                xmlSignatureInput = t.performTransform(xmlSignatureInput);
++            }
++            if (last>=0) {
++                Transform t = this.item(last);
++                xmlSignatureInput = t.performTransform(xmlSignatureInput, os);
++            }
+ 
+-      try {
+-        int last=this.getLength()-1;
+-         for (int i = 0; i < last; i++) {
+-            Transform t = this.item(i);
+-            if (true) {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Preform the (" + i + ")th " + t.getURI() + " transform");
++            return xmlSignatureInput;
++        } catch (IOException ex) {
++            throw new TransformationException("empty", ex);
++        } catch (CanonicalizationException ex) {
++            throw new TransformationException("empty", ex);
++        } catch (InvalidCanonicalizerException ex) {
++            throw new TransformationException("empty", ex);
++        }
++    }
++
++    /**
++     * Return the nonnegative number of transformations.
++     *
++     * @return the number of transformations
++     */
++    public int getLength()
++    {
++        if (transforms == null) {
++            transforms = XMLUtils.selectDsNodes
++                (this._constructionElement.getFirstChild(), "Transform");
++        }
++        return transforms.length;
++    }
++
++    /**
++     * Return the <it>i</it><sup>th</sup> <code>{@link Transform}</code>.
++     * Valid <code>i</code> values are 0 to <code>{@link #getLength}-1</code>.
++     *
++     * @param i index of {@link Transform} to return
++     * @return the <it>i</it><sup>th</sup> Transform
++     * @throws TransformationException
++     */
++    public Transform item(int i) throws TransformationException {
++
++        try {
++            if (transforms == null) {
++                transforms = XMLUtils.selectDsNodes
++                    (this._constructionElement.getFirstChild(), "Transform");
+             }
+-                        xmlSignatureInput = t.performTransform(xmlSignatureInput);
+-         }
+-         if (last>=0) {
+-                        Transform t = this.item(last);
+-            xmlSignatureInput = t.performTransform(xmlSignatureInput, os);
+-         }
++            return new Transform(transforms[i], this._baseURI);
++        } catch (XMLSecurityException ex) {
++            throw new TransformationException("empty", ex);
++        }
++    }
+ 
+-
+-         return xmlSignatureInput;
+-      } catch (IOException ex) {
+-         throw new TransformationException("empty", ex);
+-      // } catch (ParserConfigurationException ex) { throw new TransformationException("empty", ex);
+-      // } catch (SAXException ex) { throw new TransformationException("empty", ex);
+-      } catch (CanonicalizationException ex) {
+-         throw new TransformationException("empty", ex);
+-      } catch (InvalidCanonicalizerException ex) {
+-         throw new TransformationException("empty", ex);
+-      }
+-   }
+-
+-   /**
+-    * Return the nonnegative number of transformations.
+-    *
+-    * @return the number of transformations
+-    */
+-   public int getLength()
+-   {
+-                /*Element nscontext = XMLUtils.createDSctx(this._doc, "ds",
+-                                                      Constants.SignatureSpecNS);
+-             NodeList transformElems =
+-                XPathAPI.selectNodeList(this._constructionElement,
+-                                        "./ds:Transform", nscontext);
+-             return transformElems.getLength();*/
+-       if (transforms==null) {
+-        transforms=XMLUtils.selectDsNodes(this._constructionElement.getFirstChild(),
+-           "Transform");
+-       }
+-       return transforms.length;
+-  }
+-
+-   /**
+-    * Return the <it>i</it><sup>th</sup> <code>{@link Transform}</code>.
+-    * Valid <code>i</code> values are 0 to <code>{@link #getLength}-1</code>.
+-    *
+-    * @param i index of {@link Transform} to return
+-    * @return the <it>i</it><sup>th</sup> transforms
+-    * @throws TransformationException
+-    */
+-   public Transform item(int i) throws TransformationException {
+-
+-                try {
+-                        if (transforms==null) {
+-                                transforms=XMLUtils.selectDsNodes(this._constructionElement.getFirstChild(),
+-                                "Transform");
+-                        }
+-                        return new Transform(transforms[i], this._baseURI);
+-                } catch (XMLSecurityException ex) {
+-                        throw new TransformationException("empty", ex);
+-                }
+-   }
+-
+-   /** @inheritDoc */
+-   public String getBaseLocalName() {
+-      return Constants._TAG_TRANSFORMS;
+-   }
++    /** @inheritDoc */
++    public String getBaseLocalName() {
++        return Constants._TAG_TRANSFORMS;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHereContext.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHereContext.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHereContext.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/FuncHereContext.java
+@@ -62,7 +62,7 @@
+  * -scott
+  * </PRE>
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  * @see com.sun.org.apache.xml.internal.security.transforms.implementations.FuncHere
+  * @see com.sun.org.apache.xml.internal.security.utils.XPathFuncHereAPI
+  * @see <A HREF="http://www.w3.org/Signature/Drafts/xmldsig-core/Overview.html#function-here">XML Signature - The here() function</A>
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -33,6 +32,7 @@
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+ import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformationException;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+@@ -43,7 +43,6 @@
+ import org.w3c.dom.Text;
+ import org.xml.sax.SAXException;
+ 
+-
+ /**
+  * Implements the <CODE>http://www.w3.org/2000/09/xmldsig#base64</CODE> decoding
+  * transform.
+@@ -95,13 +94,15 @@
+     * @throws IOException
+     * @throws TransformationException
+     */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
++   protected XMLSignatureInput enginePerformTransform
++        (XMLSignatureInput input, Transform _transformObject)
+            throws IOException, CanonicalizationException,
+                   TransformationException {
+-        return enginePerformTransform(input,null);
++        return enginePerformTransform(input, null, _transformObject);
+    }
++
+     protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,
+-            OutputStream os)
++            OutputStream os, Transform _transformObject)
+     throws IOException, CanonicalizationException,
+            TransformationException {
+          try {
+@@ -116,7 +117,7 @@
+                 byte[] decodedBytes = Base64.decode(sb.toString());
+                 return new XMLSignatureInput(decodedBytes);
+          }
+-                Base64.decode(sb.toString().getBytes(),os);
++                Base64.decode(sb.toString(),os);
+             XMLSignatureInput output=new XMLSignatureInput((byte[])null);
+             output.setOutputStream(os);
+             return output;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14N.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14N.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14N.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14N.java
+@@ -20,17 +20,15 @@
+  */
+ package com.sun.org.apache.xml.internal.security.transforms.implementations;
+ 
+-
+-
+ import java.io.OutputStream;
+ 
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+ import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315OmitComments;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+ 
+-
+ /**
+  * Implements the <CODE>http://www.w3.org/TR/2001/REC-xml-c14n-20010315</CODE>
+  * transform.
+@@ -54,18 +52,19 @@
+    /**
+     *  @inheritDoc
+     */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
++   protected XMLSignatureInput enginePerformTransform
++        (XMLSignatureInput input, Transform _transformObject)
+            throws CanonicalizationException {
+-            return enginePerformTransform(input,null);
++            return enginePerformTransform(input, null, _transformObject);
+    }
+-    protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os)
++
++    protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os, Transform _transformObject)
+     throws CanonicalizationException {
+          Canonicalizer20010315OmitComments c14n = new Canonicalizer20010315OmitComments();
+          if (os!=null) {
+                 c14n.setWriter(os);
+          }
+          byte[] result = null;
+-         input.setNeedsToBeExpanded(true);
+          result=c14n.engineCanonicalize(input);
+          XMLSignatureInput output=new XMLSignatureInput(result);
+          if (os!=null) {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14N11.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14N11.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14N11.java
+@@ -0,0 +1,65 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2008 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.
++ *
++ */
++package com.sun.org.apache.xml.internal.security.transforms.implementations;
++
++import java.io.OutputStream;
++
++import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
++import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_OmitComments;
++import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
++import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
++import com.sun.org.apache.xml.internal.security.transforms.Transforms;
++
++/**
++ * Implements the <CODE>http://www.w3.org/2006/12/xml-c14n11</CODE>
++ * (C14N 1.1) transform.
++ *
++ * @author Sean Mullan
++ */
++public class TransformC14N11 extends TransformSpi {
++
++    protected String engineGetURI() {
++        return Transforms.TRANSFORM_C14N11_OMIT_COMMENTS;
++    }
++
++    protected XMLSignatureInput enginePerformTransform
++        (XMLSignatureInput input, Transform transform)
++        throws CanonicalizationException {
++        return enginePerformTransform(input, null, transform);
++    }
++
++    protected XMLSignatureInput enginePerformTransform
++        (XMLSignatureInput input, OutputStream os, Transform transform)
++        throws CanonicalizationException {
++        Canonicalizer11_OmitComments c14n = new Canonicalizer11_OmitComments();
++        if (os != null) {
++            c14n.setWriter(os);
++        }
++        byte[] result = null;
++        result = c14n.engineCanonicalize(input);
++        XMLSignatureInput output = new XMLSignatureInput(result);
++        if (os != null) {
++            output.setOutputStream(os);
++        }
++        return output;
++    }
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14N11_WithComments.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14N11_WithComments.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14N11_WithComments.java
+@@ -0,0 +1,67 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2008 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.
++ *
++ */
++package com.sun.org.apache.xml.internal.security.transforms.implementations;
++
++import java.io.OutputStream;
++
++import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
++import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_WithComments;
++import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
++import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
++import com.sun.org.apache.xml.internal.security.transforms.Transforms;
++
++/**
++ * Implements the <CODE>http://www.w3.org/2006/12/xml-c14n-11#WithComments</CODE>
++ * (C14N 1.1 With Comments) transform.
++ *
++ * @author Sean Mullan
++ */
++public class TransformC14N11_WithComments extends TransformSpi {
++
++    protected String engineGetURI() {
++        return Transforms.TRANSFORM_C14N11_WITH_COMMENTS;
++    }
++
++    protected XMLSignatureInput enginePerformTransform
++        (XMLSignatureInput input, Transform transform)
++        throws CanonicalizationException {
++        return enginePerformTransform(input, null, transform);
++    }
++
++    protected XMLSignatureInput enginePerformTransform
++        (XMLSignatureInput input, OutputStream os, Transform transform)
++        throws CanonicalizationException {
++
++        Canonicalizer11_WithComments c14n = new Canonicalizer11_WithComments();
++        if (os != null) {
++            c14n.setWriter(os);
++        }
++
++        byte[] result = null;
++        result = c14n.engineCanonicalize(input);
++        XMLSignatureInput output = new XMLSignatureInput(result);
++        if (os != null) {
++            output.setOutputStream(os);
++        }
++        return output;
++    }
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NExclusive.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NExclusive.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NExclusive.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NExclusive.java
+@@ -20,25 +20,24 @@
+  */
+ package com.sun.org.apache.xml.internal.security.transforms.implementations;
+ 
+-
+-
+ import java.io.OutputStream;
+ 
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+ import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclOmitComments;
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+ import com.sun.org.apache.xml.internal.security.transforms.params.InclusiveNamespaces;
+ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  * Class TransformC14NExclusive
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
++ * @version $Revision: 1.5 $
+  */
+ public class TransformC14NExclusive extends TransformSpi {
+ 
+@@ -46,7 +45,6 @@
+    public static final String implementedTransformURI =
+       Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS;
+ 
+-
+    /**
+     * Method engineGetURI
+     *
+@@ -63,27 +61,29 @@
+     * @return the transformed of the input
+     * @throws CanonicalizationException
+     */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
++   protected XMLSignatureInput enginePerformTransform
++        (XMLSignatureInput input, Transform _transformObject)
+            throws CanonicalizationException {
+-            return enginePerformTransform(input,null);
++            return enginePerformTransform(input, null, _transformObject);
+    }
+-    protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os)
++
++    protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os, Transform _transformObject)
+     throws CanonicalizationException {
+       try {
+          String inclusiveNamespaces = null;
+ 
+-         if (this._transformObject
++         if (_transformObject
+                  .length(InclusiveNamespaces
+                     .ExclusiveCanonicalizationNamespace, InclusiveNamespaces
+                     ._TAG_EC_INCLUSIVENAMESPACES) == 1) {
+             Element inclusiveElement =
+                 XMLUtils.selectNode(
+-               this._transformObject.getElement().getFirstChild(),
++               _transformObject.getElement().getFirstChild(),
+                   InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
+                   InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES,0);
+ 
+             inclusiveNamespaces = new InclusiveNamespaces(inclusiveElement,
+-                    this._transformObject.getBaseURI()).getInclusiveNamespaces();
++                    _transformObject.getBaseURI()).getInclusiveNamespaces();
+          }
+ 
+          Canonicalizer20010315ExclOmitComments c14n =
+@@ -92,7 +92,6 @@
+             c14n.setWriter(os);
+          }
+          byte []result;
+-         input.setNeedsToBeExpanded(true);
+          result =c14n.engineCanonicalize(input, inclusiveNamespaces);
+ 
+          XMLSignatureInput output=new XMLSignatureInput(result);
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NExclusiveWithComments.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NExclusiveWithComments.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NExclusiveWithComments.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NExclusiveWithComments.java
+@@ -20,21 +20,19 @@
+  */
+ package com.sun.org.apache.xml.internal.security.transforms.implementations;
+ 
+-
+-
+ import java.io.OutputStream;
+ 
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+ import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclWithComments;
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+ import com.sun.org.apache.xml.internal.security.transforms.params.InclusiveNamespaces;
+ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  * Implements the <CODE>http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments</CODE>
+  * transform.
+@@ -47,7 +45,6 @@
+    public static final String implementedTransformURI =
+       Transforms.TRANSFORM_C14N_EXCL_WITH_COMMENTS;
+ 
+-
+    /**
+     * Method engineGetURI
+     *@inheritDoc
+@@ -60,27 +57,29 @@
+    /**
+     * @inheritDoc
+     */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
++   protected XMLSignatureInput enginePerformTransform
++        (XMLSignatureInput input, Transform _transformObject)
+            throws CanonicalizationException {
+-            return enginePerformTransform(input,null);
++            return enginePerformTransform(input, null, _transformObject);
+    }
+-    protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os)
++
++    protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os, Transform _transformObject)
+     throws CanonicalizationException {
+      try {
+         String inclusiveNamespaces = null;
+ 
+-        if (this._transformObject
++        if (_transformObject
+                 .length(InclusiveNamespaces
+                    .ExclusiveCanonicalizationNamespace, InclusiveNamespaces
+                    ._TAG_EC_INCLUSIVENAMESPACES) == 1) {
+            Element inclusiveElement =
+                XMLUtils.selectNode(
+-              this._transformObject.getElement().getFirstChild(),
++              _transformObject.getElement().getFirstChild(),
+                  InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
+                  InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES,0);
+ 
+            inclusiveNamespaces = new InclusiveNamespaces(inclusiveElement,
+-                   this._transformObject.getBaseURI()).getInclusiveNamespaces();
++                   _transformObject.getBaseURI()).getInclusiveNamespaces();
+         }
+ 
+         Canonicalizer20010315ExclWithComments c14n =
+@@ -88,7 +87,6 @@
+         if (os!=null) {
+            c14n.setWriter( os);
+         }
+-        input.setNeedsToBeExpanded(true);
+         byte []result;
+         result =c14n.engineCanonicalize(input, inclusiveNamespaces);
+         XMLSignatureInput output=new XMLSignatureInput(result);
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NWithComments.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NWithComments.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NWithComments.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformC14NWithComments.java
+@@ -20,17 +20,15 @@
+  */
+ package com.sun.org.apache.xml.internal.security.transforms.implementations;
+ 
+-
+-
+ import java.io.OutputStream;
+ 
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+ import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315WithComments;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+ 
+-
+ /**
+  * Implements the <CODE>http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments</CODE>
+  * transform.
+@@ -43,18 +41,20 @@
+    public static final String implementedTransformURI =
+       Transforms.TRANSFORM_C14N_WITH_COMMENTS;
+ 
+-
+    /** @inheritDoc */
+    protected String engineGetURI() {
+       return implementedTransformURI;
+    }
++
+    /** @inheritDoc */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
+-   throws CanonicalizationException {
+-            return enginePerformTransform(input,null);
++   protected XMLSignatureInput enginePerformTransform
++        (XMLSignatureInput input, Transform _transformObject)
++        throws CanonicalizationException {
++            return enginePerformTransform(input, null, _transformObject);
+    }
++
+    /** @inheritDoc */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os)
++   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream os, Transform _transformObject)
+            throws CanonicalizationException {
+ 
+         Canonicalizer20010315WithComments c14n = new Canonicalizer20010315WithComments();
+@@ -63,7 +63,6 @@
+         }
+ 
+          byte[] result = null;
+-         input.setNeedsToBeExpanded(true);
+          result=c14n.engineCanonicalize(input);
+          XMLSignatureInput output=new XMLSignatureInput(result);
+          if (os!=null) {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformEnvelopedSignature.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformEnvelopedSignature.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformEnvelopedSignature.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformEnvelopedSignature.java
+@@ -20,10 +20,9 @@
+  */
+ package com.sun.org.apache.xml.internal.security.transforms.implementations;
+ 
+-
+-
+ import com.sun.org.apache.xml.internal.security.signature.NodeFilter;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformationException;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+@@ -32,7 +31,6 @@
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+ 
+-
+ /**
+  * Implements the <CODE>http://www.w3.org/2000/09/xmldsig#enveloped-signature</CODE>
+  * transform.
+@@ -57,7 +55,7 @@
+    /**
+     * @inheritDoc
+     */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
++   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input, Transform _transformObject)
+            throws TransformationException {
+ 
+ 
+@@ -74,14 +72,7 @@
+           * (including comments) in the node-set representing the octet stream.
+           */
+ 
+-         /*
+-         if (input.isOctetStream()) {
+-            input.setNodesetXPath(Canonicalizer.XPATH_C14N_WITH_COMMENTS);
+-         }
+-         */
+-
+-         Element transformElement = this._transformObject.getElement();
+-         Node signatureElement = transformElement;
++         Node signatureElement = _transformObject.getElement();
+ 
+ 
+          signatureElement = searchSignatureElement(signatureElement);
+@@ -124,18 +115,24 @@
+             }
+             return signatureElement;
+     }
+-    class EnvelopedNodeFilter implements NodeFilter {
++    static class EnvelopedNodeFilter implements NodeFilter {
+         Node exclude;
+         EnvelopedNodeFilter(Node n) {
+-                exclude=n;
++            exclude=n;
+         }
+-                /**
+-                 * @see com.sun.org.apache.xml.internal.security.signature.NodeFilter#isNodeInclude(org.w3c.dom.Node)
+-                 */
+-                public boolean isNodeInclude(Node n) {
+-                        // TODO Optimize me.
+-                        return !XMLUtils.isDescendantOrSelf(exclude,n);
+-                }
+-
++    public int isNodeIncludeDO(Node n, int level) {
++        if ((n==exclude))
++                        return -1;
++        return 1;
++    }
++        /**
++         * @see com.sun.org.apache.xml.internal.security.signature.NodeFilter#isNodeInclude(org.w3c.dom.Node)
++         */
++        public int isNodeInclude(Node n) {
++                if ((n==exclude) || XMLUtils.isDescendantOrSelf(exclude,n))
++                        return -1;
++                return 1;
++            //return !XMLUtils.isDescendantOrSelf(exclude,n);
++        }
+     }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath.java
+@@ -20,13 +20,12 @@
+  */
+ package com.sun.org.apache.xml.internal.security.transforms.implementations;
+ 
+-
+-
+ import javax.xml.transform.TransformerException;
+ 
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityRuntimeException;
+ import com.sun.org.apache.xml.internal.security.signature.NodeFilter;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformationException;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+@@ -40,7 +39,6 @@
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+ 
+-
+ /**
+  * Class TransformXPath
+  *
+@@ -53,15 +51,10 @@
+  */
+ public class TransformXPath extends TransformSpi {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(TransformXPath.class.getName());
+-
+    /** Field implementedTransformURI */
+    public static final String implementedTransformURI =
+       Transforms.TRANSFORM_XPATH;
+ 
+-
+    /**
+     * Method engineGetURI
+     *
+@@ -78,7 +71,7 @@
+     *
+     * @throws TransformationException
+     */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
++   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input, Transform _transformObject)
+            throws TransformationException {
+ 
+       try {
+@@ -94,12 +87,12 @@
+           * The evaluation of this expression includes all of the document's nodes
+           * (including comments) in the node-set representing the octet stream.
+           */
+-                  CachedXPathAPIHolder.setDoc(this._transformObject.getElement().getOwnerDocument());
++                  CachedXPathAPIHolder.setDoc(_transformObject.getElement().getOwnerDocument());
+ 
+ 
+ 
+          Element xpathElement =XMLUtils.selectDsNode(
+-            this._transformObject.getElement().getFirstChild(),
++            _transformObject.getElement().getFirstChild(),
+                Constants._TAG_XPATH,0);
+ 
+          if (xpathElement == null) {
+@@ -129,42 +122,47 @@
+     * @return true if needs to be circunvent for bug.
+     */
+     private boolean needsCircunvent(String str) {
+-        return true;
+-        //return str.contains("namespace");
++        //return true;
++        //return false;
++        return (str.indexOf("namespace") != -1) || (str.indexOf("name()") != -1);
++    }
+ 
+-    }
+-    class XPathNodeFilter implements NodeFilter {
+-         PrefixResolverDefault prefixResolver;
+-         CachedXPathFuncHereAPI xPathFuncHereAPI =
+-             new CachedXPathFuncHereAPI(CachedXPathAPIHolder.getCachedXPathAPI());
+-          ;
++    static class XPathNodeFilter implements NodeFilter {
++        PrefixResolverDefault prefixResolver;
++        CachedXPathFuncHereAPI xPathFuncHereAPI =
++            new CachedXPathFuncHereAPI(CachedXPathAPIHolder.getCachedXPathAPI());
+         Node xpathnode;
+         String str;
+         XPathNodeFilter(Element xpathElement,
+                         Node xpathnode, String str) {
+-                this.xpathnode=xpathnode;
+-                this.str=str;
+-                prefixResolver =new PrefixResolverDefault(xpathElement);
++            this.xpathnode=xpathnode;
++            this.str=str;
++            prefixResolver =new PrefixResolverDefault(xpathElement);
+         }
+ 
+-
+-                /**
+-                 * @see com.sun.org.apache.xml.internal.security.signature.NodeFilter#isNodeInclude(org.w3c.dom.Node)
+-                 */
+-                public boolean isNodeInclude(Node currentNode) {
+-                        XObject includeInResult;
+-                        try {
+-                                includeInResult = xPathFuncHereAPI.eval(currentNode,
+-                                        xpathnode, str,prefixResolver);
+-                                return includeInResult.bool();
+-                        } catch (TransformerException e) {
++        /**
++         * @see com.sun.org.apache.xml.internal.security.signature.NodeFilter#isNodeInclude(org.w3c.dom.Node)
++         */
++        public int isNodeInclude(Node currentNode) {
++            XObject includeInResult;
++            try {
++                includeInResult = xPathFuncHereAPI.eval(currentNode,
++                                xpathnode, str,prefixResolver);
++                if (includeInResult.bool())
++                        return 1;
++                return 0;
++            } catch (TransformerException e) {
+                 Object[] eArgs = {currentNode};
+-                                throw new XMLSecurityRuntimeException("signature.Transform.node", eArgs, e);
+-                        }
+-                        catch (Exception e) {
++                throw new XMLSecurityRuntimeException
++                    ("signature.Transform.node", eArgs, e);
++            } catch (Exception e) {
+                 Object[] eArgs = {currentNode, new Short(currentNode.getNodeType())};
+-                                throw new XMLSecurityRuntimeException("signature.Transform.nodeAndType",eArgs, e);
+-                        }
+-                }
++                throw new XMLSecurityRuntimeException
++                    ("signature.Transform.nodeAndType",eArgs, e);
++            }
++        }
++        public int isNodeIncludeDO(Node n, int level) {
++                return isNodeInclude(n);
++        }
+     }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPath2Filter.java
+@@ -24,7 +24,10 @@
+ 
+ import java.io.IOException;
+ import java.util.ArrayList;
++import java.util.HashSet;
++import java.util.Iterator;
+ import java.util.List;
++import java.util.Set;
+ 
+ import javax.xml.parsers.ParserConfigurationException;
+ import javax.xml.transform.TransformerException;
+@@ -34,6 +37,7 @@
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.signature.NodeFilter;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformationException;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+@@ -88,9 +92,9 @@
+     *
+     * @throws TransformationException
+     */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
++   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input, Transform _transformObject)
+            throws TransformationException {
+-          CachedXPathAPIHolder.setDoc(this._transformObject.getElement().getOwnerDocument());
++          CachedXPathAPIHolder.setDoc(_transformObject.getElement().getOwnerDocument());
+       try {
+           List unionNodes=new ArrayList();
+            List substractNodes=new ArrayList();
+@@ -101,7 +105,7 @@
+ 
+ 
+          Element []xpathElements =XMLUtils.selectNodes(
+-                this._transformObject.getElement().getFirstChild(),
++                _transformObject.getElement().getFirstChild(),
+                    XPath2FilterContainer.XPathFilter2NS,
+                    XPath2FilterContainer._TAG_XPATH2);
+          int noOfSteps = xpathElements.length;
+@@ -122,7 +126,7 @@
+ 
+          for (int i = 0; i < noOfSteps; i++) {
+             Element xpathElement =XMLUtils.selectNode(
+-               this._transformObject.getElement().getFirstChild(),
++               _transformObject.getElement().getFirstChild(),
+                   XPath2FilterContainer.XPathFilter2NS,
+                   XPath2FilterContainer._TAG_XPATH2,i);
+             XPath2FilterContainer xpathContainer =
+@@ -143,9 +147,9 @@
+              }
+          }
+ 
+-         input.setNeedsToBeExpanded(true);
+ 
+-         input.addNodeFilter(new XPath2NodeFilter(unionNodes,substractNodes,intersectNodes));
++         input.addNodeFilter(new XPath2NodeFilter(convertNodeListToSet(unionNodes),
++                         convertNodeListToSet(substractNodes),convertNodeListToSet(intersectNodes)));
+          input.setNodeSet(true);
+          return input;
+       } catch (TransformerException ex) {
+@@ -166,37 +170,110 @@
+          throw new TransformationException("empty", ex);
+       }
+    }
++   static Set convertNodeListToSet(List l){
++           Set result=new HashSet();
++           for (int j=0;j<l.size();j++) {
++                   NodeList rootNodes=(NodeList) l.get(j);
++               int length = rootNodes.getLength();
++
++               for (int i = 0; i < length; i++) {
++                    Node rootNode = rootNodes.item(i);
++                    result.add(rootNode);
++
++                 }
++
++           }
++           return result;
++   }
+ }
+ 
+ class XPath2NodeFilter implements NodeFilter {
+-        XPath2NodeFilter(List unionNodes, List substractNodes,
+-                        List intersectNodes) {
++        boolean hasUnionNodes;
++        boolean hasSubstractNodes;
++        boolean hasIntersectNodes;
++        XPath2NodeFilter(Set unionNodes, Set substractNodes,
++                        Set intersectNodes) {
+                 this.unionNodes=unionNodes;
++                hasUnionNodes=!unionNodes.isEmpty();
+                 this.substractNodes=substractNodes;
++                hasSubstractNodes=!substractNodes.isEmpty();
+                 this.intersectNodes=intersectNodes;
++                hasIntersectNodes=!intersectNodes.isEmpty();
+         }
+-        List unionNodes=new ArrayList();
+-        List substractNodes=new ArrayList();
+-        List intersectNodes=new ArrayList();
++        Set unionNodes;
++        Set substractNodes;
++        Set intersectNodes;
+ 
+ 
+    /**
+     * @see com.sun.org.apache.xml.internal.security.signature.NodeFilter#isNodeInclude(org.w3c.dom.Node)
+     */
+-   public boolean isNodeInclude(Node currentNode) {
+-           boolean notIncluded=false;
+-           if (rooted(currentNode,substractNodes)) {
+-                   notIncluded=true;
+-           } else if (!rooted(currentNode,intersectNodes)) {
+-                   notIncluded=true;
+-           }
+-           if (notIncluded && rooted(currentNode,unionNodes)) {
+-                   notIncluded=false;
++   public int isNodeInclude(Node currentNode) {
++           int result=1;
++
++           if (hasSubstractNodes && rooted(currentNode, substractNodes)) {
++                      result = -1;
++           } else if (hasIntersectNodes && !rooted(currentNode, intersectNodes)) {
++                   result = 0;
+            }
+ 
+-      return !notIncluded;
++          //TODO OPTIMIZE
++      if (result==1)
++          return 1;
++      if (hasUnionNodes) {
++          if (rooted(currentNode, unionNodes)) {
++                   return 1;
++          }
++          result=0;
++      }
++      return result;
+ 
+    }
++   int inSubstract=-1;
++   int inIntersect=-1;
++   int inUnion=-1;
++   public int isNodeIncludeDO(Node n, int level) {
++           int result=1;
++           if (hasSubstractNodes) {
++                   if ((inSubstract==-1) || (level<=inSubstract)) {
++                           if (inList(n,  substractNodes)) {
++                                   inSubstract=level;
++                           } else {
++                                   inSubstract=-1;
++                           }
++                   }
++                   if (inSubstract!=-1){
++                           result=-1;
++                   }
++           }
++           if (result!=-1){
++                   if (hasIntersectNodes) {
++                   if ((inIntersect==-1) || (level<=inIntersect)) {
++                           if (!inList(n,  intersectNodes)) {
++                                   inIntersect=-1;
++                                   result=0;
++                           } else {
++                                   inIntersect=level;
++                           }
++                   }
++                   }
++           }
++
++          if (level<=inUnion)
++                   inUnion=-1;
++      if (result==1)
++          return 1;
++      if (hasUnionNodes) {
++          if ((inUnion==-1) && inList(n,  unionNodes)) {
++                  inUnion=level;
++          }
++          if (inUnion!=-1)
++                  return 1;
++          result=0;
++      }
++
++      return result;
++   }
+ 
+    /**
+     * Method rooted
+@@ -205,20 +282,28 @@
+     *
+     * @return if rooted bye the rootnodes
+     */
+-   boolean rooted(Node currentNode, List nodeList ) {
+-           for (int j=0;j<nodeList.size();j++) {
+-                   NodeList rootNodes=(NodeList) nodeList.get(j);
+-      int length = rootNodes.getLength();
+-
+-      for (int i = 0; i < length; i++) {
+-         Node rootNode = rootNodes.item(i);
+-
+-         if (XMLUtils.isDescendantOrSelf(rootNode,currentNode)) {
+-            return true;
+-         }
+-      }
+-
++   static boolean  rooted(Node currentNode, Set nodeList ) {
++           if (nodeList.contains(currentNode)) {
++                   return true;
++           }
++           Iterator it=nodeList.iterator();
++           while (it.hasNext()) {
++                        Node rootNode = (Node) it.next();
++                        if (XMLUtils.isDescendantOrSelf(rootNode,currentNode)) {
++                                   return true;
++                        }
+            }
+            return false;
+    }
++
++      /**
++       * Method rooted
++       * @param currentNode
++       * @param nodeList
++       *
++       * @return if rooted bye the rootnodes
++       */
++      static boolean  inList(Node currentNode, Set nodeList ) {
++              return nodeList.contains(currentNode);
++      }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPointer.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPointer.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPointer.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXPointer.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -25,6 +24,7 @@
+ 
+ 
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformationException;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+@@ -56,7 +56,7 @@
+     * @throws TransformationException
+     *
+     */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
++   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input, Transform _transformObject)
+            throws  TransformationException {
+ 
+       Object exArgs[] = { implementedTransformURI };
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java
+@@ -2,9 +2,8 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+- * Copyright  1999-2004 The Apache Software Foundation.
++ * Copyright 1999-2007 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.
+@@ -21,14 +20,12 @@
+  */
+ package com.sun.org.apache.xml.internal.security.transforms.implementations;
+ 
+-
+-
+ import java.io.ByteArrayInputStream;
+ import java.io.ByteArrayOutputStream;
+ import java.io.IOException;
+ import java.io.OutputStream;
++import java.lang.reflect.Method;
+ 
+-import javax.xml.XMLConstants;
+ import javax.xml.transform.Source;
+ import javax.xml.transform.Transformer;
+ import javax.xml.transform.TransformerConfigurationException;
+@@ -40,13 +37,13 @@
+ 
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformSpi;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformationException;
+ import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+  * Class TransformXSLT
+  *
+@@ -65,6 +62,17 @@
+    static final String defaultXSLTSpecNSprefix = "xslt";
+    static final String XSLTSTYLESHEET          = "stylesheet";
+ 
++   // check for secure processing feature
++   private static Class xClass = null;
++   static {
++      try {
++         xClass = Class.forName("javax.xml.XMLConstants");
++      } catch (Exception e) {}
++   }
++
++   static java.util.logging.Logger log =
++      java.util.logging.Logger.getLogger(
++         TransformXSLT.class.getName());
+ 
+    /**
+     * Method engineGetURI
+@@ -83,16 +91,22 @@
+     * @throws IOException
+     * @throws TransformationException
+     */
+-   protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input)
++   protected XMLSignatureInput enginePerformTransform
++        (XMLSignatureInput input, Transform _transformObject)
+            throws IOException,
+                   TransformationException {
+-        return enginePerformTransform(input,null);
++        return enginePerformTransform(input, null, _transformObject);
+    }
+-    protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream baos)
++
++    protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream baos, Transform _transformObject)
+     throws IOException,
+            TransformationException {
++      if (xClass == null) {
++         Object exArgs[] = { "SECURE_PROCESSING_FEATURE not supported" };
++         throw new TransformationException("generic.EmptyMessage", exArgs);
++      }
+       try {
+-         Element transformElement = this._transformObject.getElement();
++         Element transformElement = _transformObject.getElement();
+ 
+          Element _xsltElement =
+             XMLUtils.selectNode(transformElement.getFirstChild(),
+@@ -105,8 +119,10 @@
+          }
+ 
+          TransformerFactory tFactory = TransformerFactory.newInstance();
++         Class c = tFactory.getClass();
++         Method m = c.getMethod("setFeature", new Class[] {String.class, boolean.class});
+          // Process XSLT stylesheets in a secure manner
+-         tFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
++         m.invoke(tFactory, new Object[] {"http://javax.xml.XMLConstants/feature/secure-processing", Boolean.TRUE});
+ 
+          /*
+           * This transform requires an octet stream as input. If the actual
+@@ -139,12 +155,25 @@
+          }
+ 
+          Transformer transformer = tFactory.newTransformer(stylesheet);
++
++         // Force Xalan to use \n as line separator on all OSes. This
++         // avoids OS specific signature validation failures due to line
++         // separator differences in the transformed output. Unfortunately,
++         // this is not a standard JAXP property so will not work with non-Xalan
++         // implementations.
++         try {
++            transformer.setOutputProperty
++               ("{http://xml.apache.org/xalan}line-separator", "\n");
++         } catch (Exception e) {
++            log.log(java.util.logging.Level.WARNING, "Unable to set Xalan line-separator property: "
++               + e.getMessage());
++         }
++
+          if (baos==null) {
+-                    ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
+-               StreamResult outputTarget = new StreamResult(baos1);
+-               transformer.transform(xmlSource, outputTarget);
+-               return new XMLSignatureInput(baos1.toByteArray());
+-
++            ByteArrayOutputStream baos1 = new ByteArrayOutputStream();
++            StreamResult outputTarget = new StreamResult(baos1);
++            transformer.transform(xmlSource, outputTarget);
++            return new XMLSignatureInput(baos1.toByteArray());
+          }
+          StreamResult outputTarget = new StreamResult(baos);
+ 
+@@ -164,6 +193,18 @@
+          Object exArgs[] = { ex.getMessage() };
+ 
+          throw new TransformationException("generic.EmptyMessage", exArgs, ex);
++      } catch (NoSuchMethodException ex) {
++         Object exArgs[] = { ex.getMessage() };
++
++         throw new TransformationException("generic.EmptyMessage", exArgs, ex);
++      } catch (IllegalAccessException ex) {
++         Object exArgs[] = { ex.getMessage() };
++
++         throw new TransformationException("generic.EmptyMessage", exArgs, ex);
++      } catch (java.lang.reflect.InvocationTargetException ex) {
++         Object exArgs[] = { ex.getMessage() };
++
++         throw new TransformationException("generic.EmptyMessage", exArgs, ex);
+       }
+    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPath2FilterContainer.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPath2FilterContainer.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPath2FilterContainer.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPath2FilterContainer.java
+@@ -26,6 +26,7 @@
+ import com.sun.org.apache.xml.internal.security.transforms.TransformParam;
+ import com.sun.org.apache.xml.internal.security.utils.ElementProxy;
+ import com.sun.org.apache.xml.internal.security.utils.HelperNodeList;
++import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+@@ -36,7 +37,7 @@
+  * Implements the parameters for the <A
+  * HREF="http://www.w3.org/TR/xmldsig-filter2/">XPath Filter v2.0</A>.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  * @see <A HREF="http://www.w3.org/TR/xmldsig-filter2/">XPath Filter v2.0 (TR)</A>
+  * @see <A HREF="http://www.w3.org/Signature/Drafts/xmldsig-xfilter2/">XPath Filter v2.0 (editors copy)</A>
+  */
+@@ -188,7 +189,7 @@
+ 
+       HelperNodeList nl = new HelperNodeList();
+ 
+-      nl.appendChild(doc.createTextNode("\n"));
++      XMLUtils.addReturnToElement(doc, nl);
+ 
+       for (int i = 0; i < params.length; i++) {
+          String type = params[i][0];
+@@ -207,7 +208,7 @@
+          XPath2FilterContainer c = new XPath2FilterContainer(doc, xpath, type);
+ 
+          nl.appendChild(c.getElement());
+-         nl.appendChild(doc.createTextNode("\n"));
++         XMLUtils.addReturnToElement(doc, nl);
+       }
+ 
+       return nl;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPath2FilterContainer04.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPath2FilterContainer04.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPath2FilterContainer04.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPath2FilterContainer04.java
+@@ -25,6 +25,7 @@
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.transforms.TransformParam;
+ import com.sun.org.apache.xml.internal.security.utils.ElementProxy;
++import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+@@ -35,7 +36,7 @@
+  * Implements the parameters for the <A
+  * HREF="http://www.w3.org/TR/xmldsig-filter2/">XPath Filter v2.0</A>.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  * @see <A HREF="http://www.w3.org/TR/xmldsig-filter2/">XPath Filter v2.0 (TR)</A>
+  * @see <A HREF="http://www.w3.org/Signature/Drafts/xmldsig-xfilter2/">XPath Filter v2.0 (editors copy)</A>
+  */
+@@ -87,8 +88,9 @@
+ 
+       if ((xpath2filter.length() > 2)
+               && (!Character.isWhitespace(xpath2filter.charAt(0)))) {
+-         this._constructionElement.appendChild(doc.createTextNode("\n"
+-                 + xpath2filter + "\n"));
++         XMLUtils.addReturnToElement(this._constructionElement);
++         this._constructionElement.appendChild(doc.createTextNode(xpath2filter));
++         XMLUtils.addReturnToElement(this._constructionElement);
+       } else {
+          this._constructionElement
+             .appendChild(doc.createTextNode(xpath2filter));
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPathFilterCHGPContainer.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPathFilterCHGPContainer.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPathFilterCHGPContainer.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/params/XPathFilterCHGPContainer.java
+@@ -36,7 +36,7 @@
+  * Implements the parameters for a custom Transform which has a better performance
+  * thatn the xfilter2.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class XPathFilterCHGPContainer extends ElementProxy
+         implements TransformParam {
+@@ -104,7 +104,7 @@
+          includeButSearchElem
+             .appendChild(this._doc
+                .createTextNode(indentXPathText(includeButSearch)));
+-         this._constructionElement.appendChild(doc.createTextNode("\n"));
++         XMLUtils.addReturnToElement(this._constructionElement);
+          this._constructionElement.appendChild(includeButSearchElem);
+       }
+ 
+@@ -118,7 +118,7 @@
+          excludeButSearchElem
+             .appendChild(this._doc
+                .createTextNode(indentXPathText(excludeButSearch)));
+-         this._constructionElement.appendChild(doc.createTextNode("\n"));
++         XMLUtils.addReturnToElement(this._constructionElement);
+          this._constructionElement.appendChild(excludeButSearchElem);
+       }
+ 
+@@ -129,11 +129,11 @@
+ 
+          excludeElem
+             .appendChild(this._doc.createTextNode(indentXPathText(exclude)));
+-         this._constructionElement.appendChild(doc.createTextNode("\n"));
++         XMLUtils.addReturnToElement(this._constructionElement);
+          this._constructionElement.appendChild(excludeElem);
+       }
+ 
+-      this._constructionElement.appendChild(doc.createTextNode("\n"));
++      XMLUtils.addReturnToElement(this._constructionElement);
+    }
+ 
+    /**
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Base64.java
+@@ -20,24 +20,17 @@
+  */
+ package com.sun.org.apache.xml.internal.security.utils;
+ 
+-
+-
+ import java.io.BufferedReader;
+ import java.io.IOException;
+ import java.io.InputStream;
+ import java.io.OutputStream;
+-import java.io.StringReader;
+ import java.math.BigInteger;
+ 
+-import javax.xml.parsers.DocumentBuilder;
+-import javax.xml.parsers.DocumentBuilderFactory;
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+ import org.w3c.dom.Text;
+-import org.xml.sax.InputSource;
+ 
+ 
+ /**
+@@ -53,17 +46,10 @@
+  */
+ public class Base64 {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(Base64.class.getName());
+-
+ 
+    /** Field BASE64DEFAULTLENGTH */
+    public static final int BASE64DEFAULTLENGTH = 76;
+ 
+-   /** Field _base64length */
+-   static int _base64length = Base64.BASE64DEFAULTLENGTH;
+-
+    private Base64() {
+      // we don't allow instantiation
+    }
+@@ -79,7 +65,7 @@
+     * @param bitlen <code>int<code> the desired length in bits of the representation
+     * @return a byte array with <code>bitlen</code> bits of <code>big</code>
+     */
+-   static byte[] getBytes(BigInteger big, int bitlen) {
++   static final byte[] getBytes(BigInteger big, int bitlen) {
+ 
+       //round bitlen
+       bitlen = ((bitlen + 7) >> 3) << 3;
+@@ -121,7 +107,7 @@
+     * @param big
+     * @return String with Base64 encoding
+     */
+-   public static String encode(BigInteger big) {
++   public static final String encode(BigInteger big) {
+       return encode(getBytes(big, big.bitLength()));
+    }
+ 
+@@ -136,7 +122,7 @@
+     * @param bitlen <code>int<code> the desired length in bits of the representation
+     * @return a byte array with <code>bitlen</code> bits of <code>big</code>
+     */
+-   public static byte[] encode(BigInteger big, int bitlen) {
++   public static final  byte[] encode(BigInteger big, int bitlen) {
+ 
+       //round bitlen
+       bitlen = ((bitlen + 7) >> 3) << 3;
+@@ -179,7 +165,7 @@
+     * @return the biginter obtained from the node
+     * @throws Base64DecodingException
+     */
+-   public static BigInteger decodeBigIntegerFromElement(Element element) throws Base64DecodingException
++   public static final BigInteger decodeBigIntegerFromElement(Element element) throws Base64DecodingException
+    {
+       return new BigInteger(1, Base64.decode(element));
+    }
+@@ -191,7 +177,7 @@
+     * @return the biginter obtained from the text node
+     * @throws Base64DecodingException
+     */
+-   public static BigInteger decodeBigIntegerFromText(Text text) throws Base64DecodingException
++   public static final BigInteger decodeBigIntegerFromText(Text text) throws Base64DecodingException
+    {
+       return new BigInteger(1, Base64.decode(text.getData()));
+    }
+@@ -203,7 +189,7 @@
+     * @param element
+     * @param biginteger
+     */
+-   public static void fillElementWithBigInteger(Element element,
++   public static final void fillElementWithBigInteger(Element element,
+            BigInteger biginteger) {
+ 
+       String encodedInt = encode(biginteger);
+@@ -229,7 +215,7 @@
+     * $todo$ not tested yet
+     * @throws Base64DecodingException
+     */
+-   public static byte[] decode(Element element) throws Base64DecodingException {
++   public static final byte[] decode(Element element) throws Base64DecodingException {
+ 
+       Node sibling = element.getFirstChild();
+       StringBuffer sb = new StringBuffer();
+@@ -255,7 +241,7 @@
+     * @return an Element with the base64 encoded in the text.
+     *
+     */
+-   public static Element encodeToElement(Document doc, String localName,
++   public static final Element encodeToElement(Document doc, String localName,
+                                          byte[] bytes) {
+ 
+       Element el = XMLUtils.createElementInSignatureSpace(doc, localName);
+@@ -275,20 +261,23 @@
+     * @throws Base64DecodingException
+     *
+     */
+-   public static byte[] decode(byte[] base64) throws Base64DecodingException  {
+-         return decodeInternal(base64);
++   public final static byte[] decode(byte[] base64) throws Base64DecodingException  {
++         return decodeInternal(base64, -1);
+    }
+ 
+ 
+ 
+    /**
+-    * Encode a byte array and fold lines at the standard 76th character.
++    * Encode a byte array and fold lines at the standard 76th character unless
++    * ignore line breaks property is set.
+     *
+     * @param binaryData <code>byte[]<code> to be base64 encoded
+     * @return the <code>String<code> with encoded data
+     */
+-   public static String encode(byte[] binaryData) {
+-        return encode(binaryData,BASE64DEFAULTLENGTH);
++   public static final String encode(byte[] binaryData) {
++      return XMLUtils.ignoreLineBreaks()
++         ? encode(binaryData, Integer.MAX_VALUE)
++         : encode(binaryData, BASE64DEFAULTLENGTH);
+    }
+ 
+    /**
+@@ -302,7 +291,7 @@
+     * @throws IOException
+     * @throws Base64DecodingException
+     */
+-   public static byte[] decode(BufferedReader reader)
++   public final static byte[] decode(BufferedReader reader)
+            throws IOException, Base64DecodingException {
+ 
+       UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
+@@ -317,28 +306,6 @@
+       return baos.toByteArray();
+    }
+ 
+-   /**
+-    * Method main
+-    *
+-    *
+-    * @param args
+-    *
+-    * @throws Exception
+-    */
+-   public static void main(String[] args) throws Exception {
+-
+-      DocumentBuilderFactory docBuilderFactory =
+-         DocumentBuilderFactory.newInstance();
+-      DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+-      String testString1 =
+-         "<container><base64 value=\"Should be 'Hallo'\">SGFsbG8=</base64></container>";
+-      InputSource inputSource = new InputSource(new StringReader(testString1));
+-      Document doc = docBuilder.parse(inputSource);
+-      Element base64Elem =
+-         (Element) doc.getDocumentElement().getChildNodes().item(0);
+-
+-      System.out.println(new String(decode(base64Elem)));
+-   }
+    static private final int  BASELENGTH         = 255;
+    static private final int  LOOKUPLENGTH       = 64;
+    static private final int  TWENTYFOURBITGROUP = 24;
+@@ -347,7 +314,6 @@
+    static private final int  FOURBYTE           = 4;
+    static private final int  SIGN               = -128;
+    static private final char PAD                = '=';
+-   static private final boolean fDebug          = false;
+    static final private byte [] base64Alphabet        = new byte[BASELENGTH];
+    static final private char [] lookUpBase64Alphabet  = new char[LOOKUPLENGTH];
+ 
+@@ -406,7 +372,7 @@
+     * @param length <code>int<code> length of wrapped lines; No wrapping if less than 4.
+     * @return a <code>String</code> with encoded data
+     */
+-    public static String encode(byte[] binaryData,int length) {
++    public static final String  encode(byte[] binaryData,int length) {
+ 
+         if (length<4) {
+                 length=Integer.MAX_VALUE;
+@@ -434,9 +400,7 @@
+        int encodedIndex = 0;
+        int dataIndex   = 0;
+        int i           = 0;
+-       if (fDebug) {
+-           System.out.println("number of triplets = " + numberTriplets );
+-       }
++
+ 
+        for (int line = 0; line < numberLines; line++) {
+            for (int quartet = 0; quartet < 19; quartet++) {
+@@ -444,9 +408,6 @@
+                b2 = binaryData[dataIndex++];
+                b3 = binaryData[dataIndex++];
+ 
+-               if (fDebug) {
+-                   System.out.println( "b1= " + b1 +", b2= " + b2 + ", b3= " + b3 );
+-               }
+ 
+                l  = (byte)(b2 & 0x0f);
+                k  = (byte)(b1 & 0x03);
+@@ -456,11 +417,6 @@
+                byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);
+                byte val3 = ((b3 & SIGN)==0)?(byte)(b3>>6):(byte)((b3)>>6^0xfc);
+ 
+-               if (fDebug) {
+-                   System.out.println( "val2 = " + val2 );
+-                   System.out.println( "k4   = " + (k<<4));
+-                   System.out.println( "vak  = " + (val2 | (k<<4)));
+-               }
+ 
+                encodedData[encodedIndex++] = lookUpBase64Alphabet[ val1 ];
+                encodedData[encodedIndex++] = lookUpBase64Alphabet[ val2 | ( k<<4 )];
+@@ -477,9 +433,6 @@
+            b2 = binaryData[dataIndex++];
+            b3 = binaryData[dataIndex++];
+ 
+-           if (fDebug) {
+-               System.out.println( "b1= " + b1 +", b2= " + b2 + ", b3= " + b3 );
+-           }
+ 
+            l  = (byte)(b2 & 0x0f);
+            k  = (byte)(b1 & 0x03);
+@@ -489,11 +442,6 @@
+            byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);
+            byte val3 = ((b3 & SIGN)==0)?(byte)(b3>>6):(byte)((b3)>>6^0xfc);
+ 
+-           if (fDebug) {
+-               System.out.println( "val2 = " + val2 );
+-               System.out.println( "k4   = " + (k<<4));
+-               System.out.println( "vak  = " + (val2 | (k<<4)));
+-           }
+ 
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[ val1 ];
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[ val2 | ( k<<4 )];
+@@ -505,11 +453,7 @@
+        if (fewerThan24bits == EIGHTBIT) {
+            b1 = binaryData[dataIndex];
+            k = (byte) ( b1 &0x03 );
+-           if (fDebug) {
+-               System.out.println("b1=" + b1);
+-               System.out.println("b1<<2 = " + (b1>>2) );
+-           }
+-           byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);
++          byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[ val1 ];
+            encodedData[encodedIndex++] = lookUpBase64Alphabet[ k<<4 ];
+            encodedData[encodedIndex++] = PAD;
+@@ -534,23 +478,38 @@
+        return new String(encodedData);
+    }
+ 
+-   /**
+-    * Decodes Base64 data into octects
+-    *
+-    * @param encoded Byte array containing Base64 data
+-    * @return Array containind decoded data.
+-    * @throws Base64DecodingException
+-    */
+-   public final static byte[] decode(String encoded) throws Base64DecodingException {
++    /**
++     * Decodes Base64 data into octects
++     *
++     * @param encoded String containing base64 encoded data
++     * @return byte array containing the decoded data
++     * @throws Base64DecodingException if there is a problem decoding the data
++     */
++    public final static byte[] decode(String encoded) throws Base64DecodingException {
+ 
+-       if (encoded == null)
+-           return null;
++        if (encoded == null)
++                return null;
++        byte []bytes=new byte[encoded.length()];
++        int len=getBytesInternal(encoded, bytes);
++        return decodeInternal(bytes, len);
++        }
+ 
+-       return decodeInternal(encoded.getBytes());
+-   }
+-   protected final static byte[] decodeInternal(byte[] base64Data) throws Base64DecodingException {
++    protected static final int getBytesInternal(String s,byte[] result) {
++        int length=s.length();
++
++        int newSize=0;
++        for (int i = 0; i < length; i++) {
++            byte dataS=(byte)s.charAt(i);
++            if (!isWhiteSpace(dataS))
++                result[newSize++] = dataS;
++        }
++        return newSize;
++
++    }
++   protected final static byte[] decodeInternal(byte[] base64Data, int len) throws Base64DecodingException {
+        // remove white spaces
+-       int len = removeWhiteSpace(base64Data);
++           if (len==-1)
++          len = removeWhiteSpace(base64Data);
+ 
+        if (len%FOURBYTE != 0) {
+            throw new Base64DecodingException("decoding.divisible.four");
+@@ -629,7 +588,20 @@
+        }
+        return decodedData;
+    }
+-
++   /**
++    * Decodes Base64 data into  outputstream
++    *
++    * @param base64Data String containing Base64 data
++    * @param os the outputstream
++    * @throws IOException
++    * @throws Base64DecodingException
++    */
++   public final static void decode(String base64Data,
++        OutputStream os) throws Base64DecodingException, IOException {
++           byte[] bytes=new byte[base64Data.length()];
++           int len=getBytesInternal(base64Data, bytes);
++           decode(bytes,os,len);
++   }
+    /**
+     * Decodes Base64 data into  outputstream
+     *
+@@ -640,8 +612,14 @@
+     */
+    public final static void decode(byte[] base64Data,
+         OutputStream os) throws Base64DecodingException, IOException {
+-    // remove white spaces
+-    int len = removeWhiteSpace(base64Data);
++            decode(base64Data,os,-1);
++   }
++   protected final static void decode(byte[] base64Data,
++                        OutputStream os,int len) throws Base64DecodingException, IOException {
++
++        // remove white spaces
++    if (len==-1)
++       len = removeWhiteSpace(base64Data);
+ 
+     if (len%FOURBYTE != 0) {
+         throw new Base64DecodingException("decoding.divisible.four");
+@@ -798,7 +776,7 @@
+     * @param data  the byte array of base64 data (with WS)
+     * @return      the new length
+     */
+-   protected static int removeWhiteSpace(byte[] data) {
++   protected static final int removeWhiteSpace(byte[] data) {
+        if (data == null)
+            return 0;
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathAPIHolder.java
+@@ -23,35 +23,33 @@
+ import com.sun.org.apache.xpath.internal.CachedXPathAPI;
+ import org.w3c.dom.Document;
+ 
+-
+ /**
+  * @author Raul Benito
+  */
+ public class CachedXPathAPIHolder {
+-         static java.util.logging.Logger log =
+-                java.util.logging.Logger.getLogger(CachedXPathAPIHolder.class.getName());
+ 
+     static ThreadLocal  local=new ThreadLocal();
+     static ThreadLocal localDoc=new ThreadLocal();
+ 
+-        /**
+-         * Sets the doc for the xpath transformation. Resets the cache if needed
+-         * @param doc
+-         */
+-        public static void setDoc(Document doc) {
+-       if (localDoc.get()!=doc) {
++    /**
++     * Sets the doc for the xpath transformation. Resets the cache if needed
++     * @param doc
++     */
++    public static void setDoc(Document doc) {
++        if (localDoc.get()!=doc) {
+             CachedXPathAPI cx=(CachedXPathAPI)local.get();
+             if (cx==null) {
+-               cx=new CachedXPathAPI();
+-               local.set(cx);
+-               localDoc.set(doc);
+-               return;
++                cx=new CachedXPathAPI();
++                local.set(cx);
++                localDoc.set(doc);
++                return;
+             }
+             //Different docs reset.
+             cx.getXPathContext().reset();
+             localDoc.set(doc);
+         }
+-        }
++    }
++
+     /**
+      * @return the cachexpathapi for this thread
+      */
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/CachedXPathFuncHereAPI.java
+@@ -45,7 +45,7 @@
+ 
+ /**
+  *
+- * @author $Author: dims $
++ * @author $Author: mullan $
+  */
+ public class CachedXPathFuncHereAPI {
+ 
+@@ -291,6 +291,7 @@
+                                       .getDocumentElement()
+                                    : namespaceNode);
+ 
++      // only check if string points to different object (for performance)
+       if (str!=xpathStr) {
+         if (str.indexOf("here()")>0) {
+             _context.reset();
+@@ -340,6 +341,7 @@
+       //    XPathContext should be done away with.)
+       // Create the XPath object.
+       //String str = CachedXPathFuncHereAPI.getStrFromNode(xpathnode);
++    // only check if string points to different object (for performance)
+     if (str!=xpathStr) {
+         if (str.indexOf("here()")>0) {
+             _context.reset();
+@@ -421,7 +423,7 @@
+ 
+     private static void fixupFunctionTable() {
+         boolean installed = false;
+-        if (log.isLoggable(java.util.logging.Level.INFO))                                  log.log(java.util.logging.Level.INFO, "Registering Here function");
++        log.log(java.util.logging.Level.INFO, "Registering Here function");
+         /**
+          * Try to register our here() implementation as internal function.
+          */
+@@ -434,7 +436,7 @@
+                 installed = true;
+             }
+         } catch (Throwable t) {
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Error installing function using the static installFunction method", t);
++            log.log(java.util.logging.Level.FINE, "Error installing function using the static installFunction method", t);
+         }
+         if(!installed) {
+             try {
+@@ -445,15 +447,15 @@
+                 installFunction.invoke(_funcTable, params);
+                 installed = true;
+             } catch (Throwable t) {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Error installing function using the static installFunction method", t);
++                log.log(java.util.logging.Level.FINE, "Error installing function using the static installFunction method", t);
+             }
+         }
+-        if (true) {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
+             if (installed) {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Registered class " + FuncHere.class.getName()
++                log.log(java.util.logging.Level.FINE, "Registered class " + FuncHere.class.getName()
+                         + " for XPath function 'here()' function in internal table");
+             } else {
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Unable to register class " + FuncHere.class.getName()
++                log.log(java.util.logging.Level.FINE, "Unable to register class " + FuncHere.class.getName()
+                         + " for XPath function 'here()' function in internal table");
+             }
+         }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ClassLoaderUtils.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ClassLoaderUtils.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ClassLoaderUtils.java
+@@ -0,0 +1,277 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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.
++ */
++
++package com.sun.org.apache.xml.internal.security.utils;
++
++import java.io.IOException;
++import java.io.InputStream;
++import java.net.URL;
++import java.util.ArrayList;
++import java.util.Enumeration;
++import java.util.List;
++
++/**
++ * This class is extremely useful for loading resources and classes in a fault
++ * tolerant manner that works across different applications servers. Do not
++ * touch this unless you're a grizzled classloading guru veteran who is going to
++ * verify any change on 6 different application servers.
++ */
++public final class ClassLoaderUtils {
++
++    /** {@link org.apache.commons.logging} logging facility */
++    private static final java.util.logging.Logger log =
++        java.util.logging.Logger.getLogger(ClassLoaderUtils.class.getName());
++
++    private ClassLoaderUtils() {
++    }
++
++    /**
++     * Load a given resource. <p/> This method will try to load the resource
++     * using the following methods (in order):
++     * <ul>
++     * <li>From Thread.currentThread().getContextClassLoader()
++     * <li>From ClassLoaderUtil.class.getClassLoader()
++     * <li>callingClass.getClassLoader()
++     * </ul>
++     *
++     * @param resourceName The name of the resource to load
++     * @param callingClass The Class object of the calling object
++     */
++    public static URL getResource(String resourceName, Class<?> callingClass) {
++        URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
++        if (url == null && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            url =
++                Thread.currentThread().getContextClassLoader().getResource(
++                    resourceName.substring(1)
++                );
++        }
++
++        ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
++        if (cluClassloader == null) {
++            cluClassloader = ClassLoader.getSystemClassLoader();
++        }
++        if (url == null) {
++            url = cluClassloader.getResource(resourceName);
++        }
++        if (url == null && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            url = cluClassloader.getResource(resourceName.substring(1));
++        }
++
++        if (url == null) {
++            ClassLoader cl = callingClass.getClassLoader();
++
++            if (cl != null) {
++                url = cl.getResource(resourceName);
++            }
++        }
++
++        if (url == null) {
++            url = callingClass.getResource(resourceName);
++        }
++
++        if ((url == null) && (resourceName != null) && (resourceName.charAt(0) != '/')) {
++            return getResource('/' + resourceName, callingClass);
++        }
++
++        return url;
++    }
++
++    /**
++     * Load a given resources. <p/> This method will try to load the resources
++     * using the following methods (in order):
++     * <ul>
++     * <li>From Thread.currentThread().getContextClassLoader()
++     * <li>From ClassLoaderUtil.class.getClassLoader()
++     * <li>callingClass.getClassLoader()
++     * </ul>
++     *
++     * @param resourceName The name of the resource to load
++     * @param callingClass The Class object of the calling object
++     */
++    public static List<URL> getResources(String resourceName, Class<?> callingClass) {
++        List<URL> ret = new ArrayList<URL>();
++        Enumeration<URL> urls = new Enumeration<URL>() {
++            public boolean hasMoreElements() {
++                return false;
++            }
++            public URL nextElement() {
++                return null;
++            }
++
++        };
++        try {
++            urls = Thread.currentThread().getContextClassLoader().getResources(resourceName);
++        } catch (IOException e) {
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++            }
++            //ignore
++        }
++        if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            try {
++                urls =
++                    Thread.currentThread().getContextClassLoader().getResources(
++                        resourceName.substring(1)
++                    );
++            } catch (IOException e) {
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                }
++                // ignore
++            }
++        }
++
++        ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
++        if (cluClassloader == null) {
++            cluClassloader = ClassLoader.getSystemClassLoader();
++        }
++        if (!urls.hasMoreElements()) {
++            try {
++                urls = cluClassloader.getResources(resourceName);
++            } catch (IOException e) {
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                }
++                // ignore
++            }
++        }
++        if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            try {
++                urls = cluClassloader.getResources(resourceName.substring(1));
++            } catch (IOException e) {
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                }
++                // ignore
++            }
++        }
++
++        if (!urls.hasMoreElements()) {
++            ClassLoader cl = callingClass.getClassLoader();
++
++            if (cl != null) {
++                try {
++                    urls = cl.getResources(resourceName);
++                } catch (IOException e) {
++                    if (log.isLoggable(java.util.logging.Level.FINE)) {
++                        log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                    }
++                    // ignore
++                }
++            }
++        }
++
++        if (!urls.hasMoreElements()) {
++            URL url = callingClass.getResource(resourceName);
++            if (url != null) {
++                ret.add(url);
++            }
++        }
++        while (urls.hasMoreElements()) {
++            ret.add(urls.nextElement());
++        }
++
++
++        if (ret.isEmpty() && (resourceName != null) && (resourceName.charAt(0) != '/')) {
++            return getResources('/' + resourceName, callingClass);
++        }
++        return ret;
++    }
++
++
++    /**
++     * This is a convenience method to load a resource as a stream. <p/> The
++     * algorithm used to find the resource is given in getResource()
++     *
++     * @param resourceName The name of the resource to load
++     * @param callingClass The Class object of the calling object
++     */
++    public static InputStream getResourceAsStream(String resourceName, Class<?> callingClass) {
++        URL url = getResource(resourceName, callingClass);
++
++        try {
++            return (url != null) ? url.openStream() : null;
++        } catch (IOException e) {
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++            }
++            return null;
++        }
++    }
++
++    /**
++     * Load a class with a given name. <p/> It will try to load the class in the
++     * following order:
++     * <ul>
++     * <li>From Thread.currentThread().getContextClassLoader()
++     * <li>Using the basic Class.forName()
++     * <li>From ClassLoaderUtil.class.getClassLoader()
++     * <li>From the callingClass.getClassLoader()
++     * </ul>
++     *
++     * @param className The name of the class to load
++     * @param callingClass The Class object of the calling object
++     * @throws ClassNotFoundException If the class cannot be found anywhere.
++     */
++    public static Class<?> loadClass(String className, Class<?> callingClass)
++        throws ClassNotFoundException {
++        try {
++            ClassLoader cl = Thread.currentThread().getContextClassLoader();
++
++            if (cl != null) {
++                return cl.loadClass(className);
++            }
++        } catch (ClassNotFoundException e) {
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++            }
++            //ignore
++        }
++        return loadClass2(className, callingClass);
++    }
++
++    private static Class<?> loadClass2(String className, Class<?> callingClass)
++        throws ClassNotFoundException {
++        try {
++            return Class.forName(className);
++        } catch (ClassNotFoundException ex) {
++            try {
++                if (ClassLoaderUtils.class.getClassLoader() != null) {
++                    return ClassLoaderUtils.class.getClassLoader().loadClass(className);
++                }
++            } catch (ClassNotFoundException exc) {
++                if (callingClass != null && callingClass.getClassLoader() != null) {
++                    return callingClass.getClassLoader().loadClass(className);
++                }
++            }
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, ex.getMessage(), ex);
++            }
++            throw ex;
++        }
++    }
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Constants.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Constants.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Constants.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/Constants.java
+@@ -20,11 +20,8 @@
+  */
+ package com.sun.org.apache.xml.internal.security.utils;
+ 
+-
+-
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ 
+-
+ /**
+  * Provides all constants and some translation functions for i18n.
+  *
+@@ -32,14 +29,10 @@
+  * <A HREF="http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg">XML
+  * Signature specification</A>.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class Constants {
+ 
+-   /** {@link java.util.logging} logging facility */
+-   static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(Constants.class.getName());
+-
+    /** Field configurationFile */
+    public static final String configurationFile = "data/websig.conf";
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/DigesterOutputStream.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/DigesterOutputStream.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/DigesterOutputStream.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/DigesterOutputStream.java
+@@ -3,7 +3,7 @@
+  * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * Copyright  1999-2004 The Apache Software Foundation.
++ * Copyright 1999-2008 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.
+@@ -29,34 +29,40 @@
+  *
+  */
+ public class DigesterOutputStream extends ByteArrayOutputStream {
+-    final static byte none[]="error".getBytes();
+     final MessageDigestAlgorithm mda;
+-        /**
+-         * @param mda
+-         */
+-        public DigesterOutputStream(MessageDigestAlgorithm mda) {
++    static java.util.logging.Logger log =
++        java.util.logging.Logger.getLogger
++        (DigesterOutputStream.class.getName());
++
++    /**
++     * @param mda
++     */
++    public DigesterOutputStream(MessageDigestAlgorithm mda) {
+         this.mda=mda;
+-        }
++    }
+ 
+     /** @inheritDoc */
+-        public byte[] toByteArray() {
+-                return none;
+-        }
+-
+-        /** @inheritDoc */
+-        public void write(byte[] arg0) {
+-                mda.update(arg0);
+-        }
++    public void write(byte[] arg0) {
++        write(arg0, 0, arg0.length);
++    }
+ 
+     /** @inheritDoc */
+-        public void write(int arg0) {
+-                mda.update((byte)arg0);
+-        }
++    public void write(int arg0) {
++        mda.update((byte)arg0);
++    }
+ 
+     /** @inheritDoc */
+-        public void write(byte[] arg0, int arg1, int arg2) {
+-                mda.update(arg0, arg1, arg2);
++    public void write(byte[] arg0, int arg1, int arg2) {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Pre-digested input:");
++            StringBuffer sb = new StringBuffer(arg2);
++            for (int i=arg1; i<(arg1+arg2); i++) {
++                sb.append((char) arg0[i]);
++            }
++            log.log(java.util.logging.Level.FINE, sb.toString());
+         }
++        mda.update(arg0, arg1, arg2);
++    }
+ 
+     /**
+      * @return the digest value
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementChecker.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementChecker.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementChecker.java
+@@ -0,0 +1,17 @@
++package com.sun.org.apache.xml.internal.security.utils;
++
++import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
++import org.w3c.dom.Element;
++import org.w3c.dom.Node;
++
++public interface ElementChecker {
++         /**
++          * Check that the elemnt is the one expect
++          *
++          * @throws XMLSecurityException
++          */
++           public void guaranteeThatElementInCorrectSpace(ElementProxy expected, Element actual)
++                   throws XMLSecurityException;
++
++           public boolean isNamespaceElement(Node el, String type, String ns);
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementCheckerImpl.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementCheckerImpl.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementCheckerImpl.java
+@@ -0,0 +1,60 @@
++package com.sun.org.apache.xml.internal.security.utils;
++
++import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
++import org.w3c.dom.Element;
++import org.w3c.dom.Node;
++
++public abstract class ElementCheckerImpl implements ElementChecker {
++        public boolean isNamespaceElement(Node el, String type, String ns) {
++                if ((el == null) ||
++                   ns!=el.getNamespaceURI() || !el.getLocalName().equals(type)){
++                   return false;
++                }
++
++                return true;
++        }
++        /** A checker for DOM that interns NS */
++        public static class InternedNsChecker extends ElementCheckerImpl{
++                public void guaranteeThatElementInCorrectSpace(ElementProxy expected,
++                                Element actual) throws XMLSecurityException {
++
++                      String localnameSHOULDBE = expected.getBaseLocalName();
++                      String namespaceSHOULDBE = expected.getBaseNamespace();
++
++                      String localnameIS = actual.getLocalName();
++                      String namespaceIS = actual.getNamespaceURI();
++                      if ((namespaceSHOULDBE!=namespaceIS) ||
++                       !localnameSHOULDBE.equals(localnameIS) ) {
++                         Object exArgs[] = { namespaceIS +":"+ localnameIS,
++                           namespaceSHOULDBE +":"+ localnameSHOULDBE};
++                         throw new XMLSecurityException("xml.WrongElement", exArgs);
++                      }
++                }
++        }
++
++        /** A checker for DOM that interns NS */
++        public static class FullChecker extends ElementCheckerImpl {
++                public void guaranteeThatElementInCorrectSpace(ElementProxy expected,
++                                Element actual) throws XMLSecurityException {
++
++                      String localnameSHOULDBE = expected.getBaseLocalName();
++                      String namespaceSHOULDBE = expected.getBaseNamespace();
++
++                      String localnameIS = actual.getLocalName();
++                      String namespaceIS = actual.getNamespaceURI();
++                      if ((!namespaceSHOULDBE.equals(namespaceIS)) ||
++                       !localnameSHOULDBE.equals(localnameIS) ) {
++                         Object exArgs[] = { namespaceIS +":"+ localnameIS,
++                           namespaceSHOULDBE +":"+ localnameSHOULDBE};
++                         throw new XMLSecurityException("xml.WrongElement", exArgs);
++                      }
++                }
++        }
++
++        /** An empty checker if schema checking is used */
++        public static class EmptyChecker extends ElementCheckerImpl {
++                public void guaranteeThatElementInCorrectSpace(ElementProxy expected,
++                                Element actual) throws XMLSecurityException {
++                }
++        }
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java
+@@ -3,7 +3,7 @@
+  * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * Copyright  1999-2004 The Apache Software Foundation.
++ * Copyright 1999-2008 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.
+@@ -46,26 +46,6 @@
+    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(ElementProxy.class.getName());
+-   //J-
+-    /** The element has been created by the code **/
+-   public static final int MODE_CREATE  = 0;
+-   /** The element has been readed from a DOM tree by the code **/
+-   public static final int MODE_PROCESS = 1;
+-   /** The element isn't known if it is readen or created **/
+-   public static final int MODE_UNKNOWN = 2;
+-
+-   /** The element is going to be signed **/
+-   public static final int MODE_SIGN    = MODE_CREATE;
+-   /** The element is going to be verified **/
+-   public static final int MODE_VERIFY  = MODE_PROCESS;
+-
+-   /** The element is going to be encrypted **/
+-   public static final int MODE_ENCRYPT = MODE_CREATE;
+-   /** The element is going to be decrypted **/
+-   public static final int MODE_DECRYPT = MODE_PROCESS;
+-
+-   protected int _state = MODE_UNKNOWN;
+-   //J+
+ 
+    /**
+     * Returns the namespace of the Elements of the sub-class.
+@@ -95,11 +75,6 @@
+     *
+     */
+    public ElementProxy() {
+-
+-      this._doc = null;
+-      this._state = ElementProxy.MODE_UNKNOWN;
+-      this._baseURI = null;
+-      this._constructionElement = null;
+    }
+ 
+    /**
+@@ -108,18 +83,43 @@
+     * @param doc
+     */
+    public ElementProxy(Document doc) {
+-
+-      this();
+-
+       if (doc == null) {
+          throw new RuntimeException("Document is null");
+       }
+ 
+       this._doc = doc;
+-      this._state = ElementProxy.MODE_CREATE;
+-      this._constructionElement = ElementProxy.createElementForFamily(this._doc,
+-              this.getBaseNamespace(), this.getBaseLocalName());
++      this._constructionElement = createElementForFamilyLocal(this._doc,
++                  this.getBaseNamespace(), this.getBaseLocalName());
+    }
++   protected Element createElementForFamilyLocal(Document doc, String namespace,
++           String localName) {
++                  Element result = null;
++              if (namespace == null) {
++                 result = doc.createElementNS(null, localName);
++              } else {
++                  String baseName=this.getBaseNamespace();
++                  String prefix=ElementProxy.getDefaultPrefix(baseName);
++                 if ((prefix == null) || (prefix.length() == 0)) {
++                    result = doc.createElementNS(namespace, localName);
++
++                    result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns",
++                                          namespace);
++                 } else {
++                         String tagName=null;
++                         String defaultPrefixNaming=ElementProxy.getDefaultPrefixBindings(baseName);
++                         StringBuffer sb=new StringBuffer(prefix);
++                         sb.append(':');
++                         sb.append(localName);
++                         tagName=sb.toString();
++                    result = doc.createElementNS(namespace, tagName );
++
++                    result.setAttributeNS(Constants.NamespaceSpecNS,  defaultPrefixNaming,
++                                          namespace);
++                 }
++              }
++              return result;
++}
++
+ 
+    /**
+     * This method creates an Element in a given namespace with a given localname.
+@@ -150,7 +150,7 @@
+          } else {
+             result = doc.createElementNS(namespace, prefix + ":" + localName);
+ 
+-            result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix,
++            result.setAttributeNS(Constants.NamespaceSpecNS,  ElementProxy.getDefaultPrefixBindings(namespace),
+                                   namespace);
+          }
+       }
+@@ -171,15 +171,12 @@
+       if (element == null) {
+          throw new XMLSecurityException("ElementProxy.nullElement");
+       }
+-      if (true) {
+-      }
+ 
+-      if (true) {
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "setElement(" + element.getTagName() + ", \"" + BaseURI + "\"");
++      if (log.isLoggable(java.util.logging.Level.FINE)) {
++        log.log(java.util.logging.Level.FINE, "setElement(" + element.getTagName() + ", \"" + BaseURI + "\"");
+       }
+ 
+       this._doc = element.getOwnerDocument();
+-      this._state = ElementProxy.MODE_PROCESS;
+       this._constructionElement = element;
+       this._baseURI = BaseURI;
+    }
+@@ -193,20 +190,16 @@
+     */
+    public ElementProxy(Element element, String BaseURI)
+            throws XMLSecurityException {
+-
+-      this();
+-
+       if (element == null) {
+          throw new XMLSecurityException("ElementProxy.nullElement");
+       }
+ 
+-      if (true) {
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "setElement(\"" + element.getTagName() + "\", \"" + BaseURI
++      if (log.isLoggable(java.util.logging.Level.FINE)) {
++        log.log(java.util.logging.Level.FINE, "setElement(\"" + element.getTagName() + "\", \"" + BaseURI
+                 + "\")");
+       }
+ 
+       this._doc = element.getOwnerDocument();
+-      this._state = ElementProxy.MODE_PROCESS;
+       this._constructionElement = element;
+       this._baseURI = BaseURI;
+ 
+@@ -256,25 +249,18 @@
+       return this._baseURI;
+    }
+ 
++   static ElementChecker checker = new ElementCheckerImpl.InternedNsChecker();
++
+    /**
+     * Method guaranteeThatElementInCorrectSpace
+     *
+     * @throws XMLSecurityException
+     */
+-   public void guaranteeThatElementInCorrectSpace()
++   void guaranteeThatElementInCorrectSpace()
+            throws XMLSecurityException {
+ 
+-      String localnameSHOULDBE = this.getBaseLocalName();
+-      String namespaceSHOULDBE = this.getBaseNamespace();
++          checker.guaranteeThatElementInCorrectSpace(this,this._constructionElement);
+ 
+-      String localnameIS = this._constructionElement.getLocalName();
+-      String namespaceIS = this._constructionElement.getNamespaceURI();
+-      if ( !localnameSHOULDBE.equals(localnameIS) ||
+-        !namespaceSHOULDBE.equals(namespaceIS)) {
+-         Object exArgs[] = { namespaceIS +":"+ localnameIS,
+-           namespaceSHOULDBE +":"+ localnameSHOULDBE};
+-         throw new XMLSecurityException("xml.WrongElement", exArgs);
+-      }
+    }
+ 
+    /**
+@@ -308,7 +294,9 @@
+          Element e = Base64.encodeToElement(this._doc, localname, bytes);
+ 
+          this._constructionElement.appendChild(e);
+-         this._constructionElement.appendChild(this._doc.createTextNode("\n"));
++         if (!XMLUtils.ignoreLineBreaks()) {
++            this._constructionElement.appendChild(this._doc.createTextNode("\n"));
++         }
+       }
+    }
+ 
+@@ -336,8 +324,9 @@
+    public void addBase64Text(byte[] bytes) {
+ 
+       if (bytes != null) {
+-         Text t = this._doc.createTextNode("\n" + Base64.encode(bytes) + "\n");
+-
++         Text t = XMLUtils.ignoreLineBreaks()
++             ? this._doc.createTextNode(Base64.encode(bytes))
++             : this._doc.createTextNode("\n" + Base64.encode(bytes) + "\n");
+          this._constructionElement.appendChild(t);
+       }
+    }
+@@ -375,7 +364,7 @@
+ 
+    /**
+     * Method getBytesFromChildElement
+-    *
++    * @deprecated
+     * @param localname
+     * @param namespace
+     * @return the bytes
+@@ -416,28 +405,24 @@
+    /**
+     * Method getBytesFromTextChild
+     *
+-    * @return The base64 bytes from the first text child of this element
++    * @return The base64 bytes from the text children of this element
+     * @throws XMLSecurityException
+     */
+    public byte[] getBytesFromTextChild() throws XMLSecurityException {
+-
+-         Text t = (Text)this._constructionElement.getFirstChild();
+-
+-
+-         return Base64.decode(t.getData());
++      return Base64.decode
++         (XMLUtils.getFullTextChildrenFromElement(this._constructionElement));
+    }
+ 
+    /**
+     * Method getTextFromTextChild
+     *
+-    * @return the Text obtained concatening all the the text nodes of this element
++    * @return the Text obtained by concatenating all the text nodes of this
++    *    element
+     */
+    public String getTextFromTextChild() {
+       return XMLUtils.getFullTextChildrenFromElement(this._constructionElement);
+    }
+ 
+-
+-
+    /**
+     * Method length
+     *
+@@ -451,7 +436,7 @@
+             while (sibling!=null) {
+                 if (localname.equals(sibling.getLocalName())
+                                 &&
+-                                        namespace.equals(sibling.getNamespaceURI())) {
++                                        namespace==sibling.getNamespaceURI() ) {
+                         number++;
+                 }
+                 sibling=sibling.getNextSibling();
+@@ -509,39 +494,49 @@
+ 
+    /** Field _prefixMappings */
+    static HashMap _prefixMappings = new HashMap();
++   static HashMap _prefixMappingsBindings = new HashMap();
+ 
+-   /**
+-    * Method setDefaultPrefix
+-    *
+-    * @param namespace
+-    * @param prefix
+-    * @throws XMLSecurityException
+-    */
+-   public static void setDefaultPrefix(String namespace, String prefix)
+-           throws XMLSecurityException {
++    /**
++     * Method setDefaultPrefix
++     *
++     * @param namespace
++     * @param prefix
++     * @throws XMLSecurityException
++     */
++    public static void setDefaultPrefix(String namespace, String prefix)
++        throws XMLSecurityException {
+ 
+         if (ElementProxy._prefixMappings.containsValue(prefix)) {
+ 
+-                Object storedNamespace=ElementProxy._prefixMappings.get(namespace);
+-         if (!storedNamespace.equals(prefix)) {
++            Object storedNamespace=ElementProxy._prefixMappings.get(namespace);
++            if (!storedNamespace.equals(prefix)) {
+                 Object exArgs[] = { prefix, namespace, storedNamespace };
+ 
+                 throw new XMLSecurityException("prefix.AlreadyAssigned", exArgs);
+-         }
+-    }
+-      ElementProxy._prefixMappings.put(namespace, prefix);
++            }
++        }
++        if (Constants.SignatureSpecNS.equals(namespace)) {
++            XMLUtils.dsPrefix=prefix;
++        }
++        ElementProxy._prefixMappings.put(namespace, prefix.intern());
++        if (prefix.length() == 0) {
++            ElementProxy._prefixMappingsBindings.put(namespace, "xmlns");
++        } else {
++            ElementProxy._prefixMappingsBindings.put(namespace, ("xmlns:"+prefix).intern());
++        }
+    }
+ 
+-   /**
+-    * Method getDefaultPrefix
+-    *
+-    * @param namespace
+-    * @return the default prefix bind to this element.
+-    */
+-   public static String getDefaultPrefix(String namespace) {
++    /**
++     * Method getDefaultPrefix
++     *
++     * @param namespace
++     * @return the default prefix bind to this element.
++     */
++    public static String getDefaultPrefix(String namespace) {
++        return (String) ElementProxy._prefixMappings.get(namespace);
++    }
+ 
+-      String prefix = (String) ElementProxy._prefixMappings.get(namespace);
+-
+-      return prefix;
+-   }
++    public static String getDefaultPrefixBindings(String namespace) {
++        return (String) ElementProxy._prefixMappingsBindings.get(namespace);
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/EncryptionConstants.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/EncryptionConstants.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/EncryptionConstants.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/EncryptionConstants.java
+@@ -27,7 +27,7 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class EncryptionConstants {
+    //J-
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/EncryptionElementProxy.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/EncryptionElementProxy.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/EncryptionElementProxy.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/EncryptionElementProxy.java
+@@ -31,7 +31,7 @@
+  * This is the base object for all objects which map directly to an Element from
+  * the xenc spec.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public abstract class EncryptionElementProxy extends ElementProxy {
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/HelperNodeList.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -21,30 +20,21 @@
+  */
+ package com.sun.org.apache.xml.internal.security.utils;
+ 
+-
+-
+ import java.util.ArrayList;
+ 
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Node;
+ import org.w3c.dom.NodeList;
+ 
+-
+ /**
+  *
+- *
+  * @author Christian Geuer-Pollmann
+  *
+  */
+ public class HelperNodeList implements NodeList {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-    java.util.logging.Logger.getLogger(HelperNodeList.class.getName());
+-
+    /** Field nodes */
+    ArrayList nodes = new ArrayList(20);
+-
+    boolean _allNodesMustHaveSameParent = false;
+ 
+    /**
+@@ -70,7 +60,7 @@
+     */
+    public Node item(int index) {
+ 
+-      // if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "item(" + index + ") of " + this.getLength() + " nodes");
++      // log.log(java.util.logging.Level.FINE, "item(" + index + ") of " + this.getLength() + " nodes");
+ 
+       return (Node) nodes.get(index);
+    }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/I18n.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/I18n.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/I18n.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/I18n.java
+@@ -20,18 +20,13 @@
+  */
+ package com.sun.org.apache.xml.internal.security.utils;
+ 
+-
+-
+ import java.text.MessageFormat;
+ import java.util.Locale;
+ import java.util.ResourceBundle;
+ 
+-
+ /**
+  * The Internationalization (I18N) pack.
+  *
+- *
+- *
+  * @author Christian Geuer-Pollmann
+  */
+ public class I18n {
+@@ -50,8 +45,8 @@
+ 
+    /** Field resourceBundle */
+    private static ResourceBundle resourceBundle =
+-      ResourceBundle.getBundle
+-        (Constants.exceptionMessagesResourceBundleBase, Locale.US);
++       ResourceBundle.getBundle
++         (Constants.exceptionMessagesResourceBundleBase, Locale.US);
+ 
+    /** Field alreadyInitialized */
+    private static boolean alreadyInitialized = false;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/IdResolver.java
+@@ -20,18 +20,16 @@
+  */
+ package com.sun.org.apache.xml.internal.security.utils;
+ 
+-
+-
++import java.lang.ref.WeakReference;
++import java.util.Arrays;
++import java.util.WeakHashMap;
+ 
+ import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
++import org.w3c.dom.NamedNodeMap;
+ import org.w3c.dom.Node;
+ 
+-import java.util.Arrays;
+-import java.util.WeakHashMap;
+-import java.lang.ref.WeakReference;
+-
+ 
+ /**
+  * Purpose of this class is to enable the XML Parser to keep track of ID
+@@ -45,193 +43,242 @@
+  * ID: We know that all <CODE>@Id</CODE> attributes in an Element from the XML
+  * Signature namespace are of type <CODE>ID</CODE>.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  * @see <A HREF="http://www.xml.com/lpt/a/2001/11/07/id.html">"Identity Crisis" on xml.com</A>
+  */
+ public class IdResolver {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
++    /** {@link java.util.logging} logging facility */
++    private static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(IdResolver.class.getName());
+ 
+-   static WeakHashMap docMap = new WeakHashMap();
++    private static WeakHashMap docMap = new WeakHashMap();
+ 
+-   /**
+-    * Constructor IdResolver
+-    *
+-    */
+-   private IdResolver() {
++    /**
++     * Constructor IdResolver
++     *
++     */
++    private IdResolver() {
++       // we don't allow instantiation
++    }
+ 
+-      // we don't allow instantiation
+-   }
++    /**
++     * Method registerElementById
++     *
++     * @param element the element to register
++     * @param idValue the value of the ID attribute
++     */
++    public static void registerElementById(Element element, String idValue) {
++        Document doc = element.getOwnerDocument();
++        WeakHashMap elementMap = (WeakHashMap) docMap.get(doc);
++        if(elementMap == null) {
++            elementMap = new WeakHashMap();
++            docMap.put(doc, elementMap);
++        }
++        elementMap.put(idValue, new WeakReference(element));
++    }
+ 
+-   /**
+-    * Method registerElementById
+-    *
+-    * @param element
+-    * @param idValue
+-    */
+-   public static void registerElementById(Element element, String idValue) {
+-      Document doc = element.getOwnerDocument();
+-      WeakHashMap elementMap = (WeakHashMap) docMap.get(doc);
+-      if(elementMap == null) {
+-          elementMap = new WeakHashMap();
+-          docMap.put(doc, elementMap);
+-      }
+-      elementMap.put(idValue, new WeakReference(element));
+-   }
++    /**
++     * Method registerElementById
++     *
++     * @param element the element to register
++     * @param id the ID attribute
++     */
++    public static void registerElementById(Element element, Attr id) {
++        IdResolver.registerElementById(element, id.getNodeValue());
++    }
+ 
+-   /**
+-    * Method registerElementById
+-    *
+-    * @param element
+-    * @param id
+-    */
+-   public static void registerElementById(Element element, Attr id) {
+-      IdResolver.registerElementById(element, id.getNodeValue());
+-   }
++    /**
++     * Method getElementById
++     *
++     * @param doc the document
++     * @param id the value of the ID
++     * @return the element obtained by the id, or null if it is not found.
++     */
++    public static Element getElementById(Document doc, String id) {
+ 
+-   /**
+-    * Method getElementById
+-    *
+-    * @param doc
+-    * @param id
+-    * @return the element obtained by the Id, or null if it is not found.
+-    */
+-   public static Element getElementById(Document doc, String id) {
++        Element result = IdResolver.getElementByIdType(doc, id);
+ 
+-      Element result = null;
+-
+-      result = IdResolver.getElementByIdType(doc, id);
+-
+-      if (result != null) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE,
++        if (result != null) {
++            log.log(java.util.logging.Level.FINE,
+             "I could find an Element using the simple getElementByIdType method: "
+             + result.getTagName());
+ 
+-         return result;
+-      }
++            return result;
++        }
+ 
+-       result = IdResolver.getElementByIdUsingDOM(doc, id);
++        result = IdResolver.getElementByIdUsingDOM(doc, id);
+ 
+-       if (result != null) {
+-          if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE,
++        if (result != null) {
++            log.log(java.util.logging.Level.FINE,
+              "I could find an Element using the simple getElementByIdUsingDOM method: "
+             + result.getTagName());
+ 
+-         return result;
+-      }
+-       // this must be done so that Xalan can catch ALL namespaces
+-       //XMLUtils.circumventBug2650(doc);
+-      result = IdResolver.getElementBySearching(doc, id);
++            return result;
++        }
++        // this must be done so that Xalan can catch ALL namespaces
++        //XMLUtils.circumventBug2650(doc);
++        result = IdResolver.getElementBySearching(doc, id);
+ 
+-      if (result != null) {
+-                  IdResolver.registerElementById(result, id);
++        if (result != null) {
++            IdResolver.registerElementById(result, id);
+ 
+-         return result;
+-      }
++            return result;
++        }
+ 
+-      return null;
+-   }
++        return null;
++    }
+ 
+ 
+     /**
+      * Method getElementByIdUsingDOM
+      *
+-     * @param doc
+-     * @param id
+-     * @return the element obtained by the Id, or null if it is not found.
++     * @param doc the document
++     * @param id the value of the ID
++     * @return the element obtained by the id, or null if it is not found.
+      */
+     private static Element getElementByIdUsingDOM(Document doc, String id) {
+-        if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "getElementByIdUsingDOM() Search for ID " + id);
++        if (log.isLoggable(java.util.logging.Level.FINE))
++            log.log(java.util.logging.Level.FINE, "getElementByIdUsingDOM() Search for ID " + id);
+         return doc.getElementById(id);
+     }
+ 
+-   /**
+-    * Method getElementByIdType
+-    *
+-    * @param doc
+-    * @param id
+-    * @return the element obtained by the Id, or null if it is not found.
+-    */
+-   private static Element getElementByIdType(Document doc, String id) {
+-          if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "getElementByIdType() Search for ID " + id);
+-       WeakHashMap elementMap = (WeakHashMap) docMap.get(doc);
+-       if (elementMap != null) {
+-           WeakReference weakReference = (WeakReference) elementMap.get(id);
+-           if (weakReference != null)
+-           {
++    /**
++     * Method getElementByIdType
++     *
++     * @param doc the document
++     * @param id the value of the ID
++     * @return the element obtained by the id, or null if it is not found.
++     */
++    private static Element getElementByIdType(Document doc, String id) {
++        if (log.isLoggable(java.util.logging.Level.FINE))
++            log.log(java.util.logging.Level.FINE, "getElementByIdType() Search for ID " + id);
++        WeakHashMap elementMap = (WeakHashMap) docMap.get(doc);
++        if (elementMap != null) {
++            WeakReference weakReference = (WeakReference) elementMap.get(id);
++            if (weakReference != null) {
+                 return (Element) weakReference.get();
+-           }
+-       }
+-       return null;
+-   }
++            }
++        }
++        return null;
++    }
+ 
++    private static java.util.List names;
++    private static int namesLength;
++    static {
++        String namespaces[]={
++            Constants.SignatureSpecNS,
++            EncryptionConstants.EncryptionSpecNS,
++            "http://schemas.xmlsoap.org/soap/security/2000-12",
++            "http://www.w3.org/2002/03/xkms#",
++            "urn:oasis:names:tc:SAML:1.0:assertion",
++            "urn:oasis:names:tc:SAML:1.0:protocol"
++        };
++        names = Arrays.asList(namespaces);
++        namesLength = names.size();
++    }
+ 
+-   static java.util.List names;
+-   static {
+-           String namespaces[]={ Constants.SignatureSpecNS,
+-                           EncryptionConstants.EncryptionSpecNS,
+-                           "http://schemas.xmlsoap.org/soap/security/2000-12",
+-                           "http://www.w3.org/2002/03/xkms#"
+-                   };
+-           names=Arrays.asList(namespaces);
+-   }
+ 
++    private static Element getElementBySearching(Node root,String id) {
++        Element []els=new Element[namesLength + 1];
++        getEl(root,id,els);
++        for (int i=0;i<els.length;i++) {
++            if (els[i]!=null) {
++                return els[i];
++            }
++        }
++        return null;
++    }
+ 
+-   private static Element getElementBySearching(Node root,String id) {
+-           Element []els=new Element[5];
+-           getElementBySearching(root,id,els);
+-           for (int i=0;i<els.length;i++) {
+-                   if (els[i]!=null) {
+-                           return els[i];
+-                   }
+-           }
+-           return null;
++    private static int getEl(Node currentNode,String id,Element []els) {
++        Node sibling=null;
++        Node parentNode=null;
++        do {
++                switch (currentNode.getNodeType()) {
++                case Node.DOCUMENT_FRAGMENT_NODE :
++                case Node.DOCUMENT_NODE :
++                        sibling= currentNode.getFirstChild();
++                        break;
+ 
+-   }
+-   private static int getElementBySearching(Node root,String id,Element []els) {
+-           switch (root.getNodeType()) {
+-           case Node.ELEMENT_NODE:
+-                   Element el=(Element)root;
+-                   if (el.hasAttributes()) {
+-                           int index=names.indexOf(el.getNamespaceURI());
+-                           if (index<0) {
+-                                   index=4;
+-                           }
+-                           if (el.getAttribute("Id").equals(id)) {
+-                                   els[index]=el;
+-                                   if (index==0) {
+-                                           return 1;
+-                                   }
+-                           } else if ( el.getAttribute("id").equals(id) ) {
+-                                   if (index!=2) {
+-                                           index=4;
+-                                   }
+-                                   els[index]=el;
+-                           } else if ( el.getAttribute("ID").equals(id) ) {
+-                                   if (index!=3) {
+-                                           index=4;
+-                                   }
+-                                   els[index]=el;
+-                           } else if ((index==3)&&(
+-                                   el.getAttribute("OriginalRequestID").equals(id) ||
+-                                   el.getAttribute("RequestID").equals(id) ||
+-                                   el.getAttribute("ResponseID" ).equals(id))) {
+-                                   els[3]=el;
+-                           }
+-                   }
+-                case Node.DOCUMENT_NODE:
+-                        Node sibling=root.getFirstChild();
+-                        while (sibling!=null) {
+-                                if (getElementBySearching(sibling,id,els)==1)
++
++                case Node.ELEMENT_NODE :
++                        Element currentElement = (Element) currentNode;
++                        if (isElement(currentElement, id, els)==1)
++                                return 1;
++                        sibling= currentNode.getFirstChild();
++                        if (sibling==null) {
++                            if (parentNode != null) {
++                                        sibling= currentNode.getNextSibling();
++                                    }
++                        } else {
++                                parentNode=currentElement;
++                        }
++                        break;
++        } while (sibling==null  && parentNode!=null) {
++                        sibling=parentNode.getNextSibling();
++                        parentNode=parentNode.getParentNode();
++                        if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
++                                parentNode=null;
++                        }
++                }
++                if (sibling==null)
++                        return 1;
++                currentNode=sibling;
++                sibling=currentNode.getNextSibling();
++        } while(true);
++
++    }
++    public static int isElement(Element el, String id,Element[] els) {
++        if (!el.hasAttributes()) {
++                return 0;
++        }
++        NamedNodeMap ns=el.getAttributes();
++        int elementIndex=names.indexOf(el.getNamespaceURI());
++            elementIndex=(elementIndex<0) ? namesLength : elementIndex;
++        for (int length=ns.getLength(), i=0; i<length; i++) {
++                Attr n=(Attr)ns.item(i);
++                String s=n.getNamespaceURI();
++
++                    int index=s==null ? elementIndex : names.indexOf(n.getNamespaceURI());
++                    index=(index<0) ? namesLength : index;
++                    String name=n.getLocalName();
++                    if (name.length()>2)
++                        continue;
++                    String value=n.getNodeValue();
++                    if (name.charAt(0)=='I') {
++                        char ch=name.charAt(1);
++                        if (ch=='d' && value.equals(id)) {
++                                els[index]=el;
++                                if (index==0) {
+                                         return 1;
+-                                sibling=sibling.getNextSibling();
++                                }
++                        } else if (ch=='D' &&value.endsWith(id)) {
++                                if (index!=3) {
++                                    index=namesLength;
++                                }
++                                els[index]=el;
+                         }
+-           }
+-           return 0;
+-   }
+-
++                    } else if ( "id".equals(name) && value.equals(id) ) {
++                        if (index!=2) {
++                                index=namesLength;
++                        }
++                        els[index]=el;
++                    }
++        }
++        //For an element namespace search for importants
++        if ((elementIndex==3)&&(
++                    el.getAttribute("OriginalRequestID").equals(id) ||
++                    el.getAttribute("RequestID").equals(id) ||
++                    el.getAttribute("ResponseID").equals(id))) {
++                    els[3]=el;
++        } else if ((elementIndex==4)&&(
++                    el.getAttribute("AssertionID").equals(id))) {
++                    els[4]=el;
++        } else if ((elementIndex==5)&&(
++                    el.getAttribute("RequestID").equals(id) ||
++                    el.getAttribute("ResponseID").equals(id))) {
++                    els[5]=el;
++                 }
++        return 0;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/JavaUtils.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.utils;
+ 
+-
+-
+ import java.io.File;
+ import java.io.FileInputStream;
+ import java.io.FileNotFoundException;
+@@ -29,99 +27,105 @@
+ import java.io.IOException;
+ import java.io.InputStream;
+ 
+-
+ /**
+  * A collection of different, general-purpose methods for JAVA-specific things
+  * @author Christian Geuer-Pollmann
+- *
+  */
+ public class JavaUtils {
+ 
+-   /** {@link java.util.logging} logging facility */
++    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(JavaUtils.class.getName());
+ 
+-   private JavaUtils() {
+-     // we don't allow instantiation
+-   }
+-   /**
+-    * Method getBytesFromFile
+-    *
+-    * @param fileName
+-    * @return the bytes readed from the file
+-    *
+-    * @throws FileNotFoundException
+-    * @throws IOException
+-    */
+-   public static byte[] getBytesFromFile(String fileName)
+-           throws FileNotFoundException, IOException {
++    private JavaUtils() {
++        // we don't allow instantiation
++    }
+ 
+-      byte refBytes[] = null;
++    /**
++     * Method getBytesFromFile
++     *
++     * @param fileName
++     * @return the bytes readed from the file
++     *
++     * @throws FileNotFoundException
++     * @throws IOException
++     */
++    public static byte[] getBytesFromFile(String fileName)
++        throws FileNotFoundException, IOException {
+ 
+-      {
+-         FileInputStream fisRef = new FileInputStream(fileName);
+-         UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
+-         byte buf[] = new byte[1024];
+-         int len;
++        byte refBytes[] = null;
+ 
+-         while ((len = fisRef.read(buf)) > 0) {
++        FileInputStream fisRef = new FileInputStream(fileName);
++        try {
++            UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
++            byte buf[] = new byte[1024];
++            int len;
++
++            while ((len = fisRef.read(buf)) > 0) {
++                baos.write(buf, 0, len);
++            }
++
++            refBytes = baos.toByteArray();
++        } finally {
++            fisRef.close();
++        }
++
++        return refBytes;
++    }
++
++    /**
++     * Method writeBytesToFilename
++     *
++     * @param filename
++     * @param bytes
++     */
++    public static void writeBytesToFilename(String filename, byte[] bytes) {
++
++        FileOutputStream fos = null;
++        try {
++            if (filename != null && bytes != null) {
++                File f = new File(filename);
++
++                fos = new FileOutputStream(f);
++
++                fos.write(bytes);
++                fos.close();
++            } else {
++                log.log(java.util.logging.Level.FINE, "writeBytesToFilename got null byte[] pointed");
++            }
++        } catch (IOException ex) {
++            if (fos != null) {
++                try {
++                    fos.close();
++                } catch (IOException ioe) {}
++            }
++        }
++    }
++
++    /**
++     * This method reads all bytes from the given InputStream till EOF and
++     * returns them as a byte array.
++     *
++     * @param inputStream
++     * @return the bytes readed from the stream
++     *
++     * @throws FileNotFoundException
++     * @throws IOException
++     */
++    public static byte[] getBytesFromStream(InputStream inputStream)
++        throws IOException {
++
++        byte refBytes[] = null;
++
++        UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
++        byte buf[] = new byte[1024];
++        int len;
++
++        while ((len = inputStream.read(buf)) > 0) {
+             baos.write(buf, 0, len);
+-         }
++        }
+ 
+-         refBytes = baos.toByteArray();
+-      }
+-
+-      return refBytes;
+-   }
+-
+-   /**
+-    * Method writeBytesToFilename
+-    *
+-    * @param filename
+-    * @param bytes
+-    */
+-   public static void writeBytesToFilename(String filename, byte[] bytes) {
+-
+-      try {
+-         if (filename != null && bytes != null) {
+-            File f = new File(filename);
+-
+-            FileOutputStream fos = new FileOutputStream(f);
+-
+-            fos.write(bytes);
+-            fos.close();
+-         } else {
+-            if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "writeBytesToFilename got null byte[] pointed");
+-         }
+-      } catch (Exception ex) {}
+-   }
+-
+-   /**
+-    * This method reads all bytes from the given InputStream till EOF and returns
+-    * them as a byte array.
+-    *
+-    * @param inputStream
+-    * @return the bytes readed from the stream
+-    *
+-    * @throws FileNotFoundException
+-    * @throws IOException
+-    */
+-   public static byte[] getBytesFromStream(InputStream inputStream) throws IOException {
+-
+-      byte refBytes[] = null;
+-
+-      {
+-         UnsyncByteArrayOutputStream baos = new UnsyncByteArrayOutputStream();
+-         byte buf[] = new byte[1024];
+-         int len;
+-
+-         while ((len = inputStream.read(buf)) > 0) {
+-            baos.write(buf, 0, len);
+-         }
+-
+-         refBytes = baos.toByteArray();
+-      }
+-
+-      return refBytes;
+-   }
++        refBytes = baos.toByteArray();
++        return refBytes;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/RFC2253Parser.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/RFC2253Parser.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/RFC2253Parser.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/RFC2253Parser.java
+@@ -28,7 +28,7 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class RFC2253Parser {
+ 
+@@ -158,7 +158,13 @@
+          return str;
+       }
+       String attrType = normalizeAT(str.substring(0, i));
+-      String attrValue = normalizeV(str.substring(i + 1));
++      // only normalize if value is a String
++      String attrValue = null;
++      if (attrType.charAt(0) >= '0' && attrType.charAt(0) <= '9') {
++          attrValue = str.substring(i + 1);
++      } else {
++          attrValue = normalizeV(str.substring(i + 1));
++      }
+ 
+       return attrType + "=" + attrValue;
+ 
+@@ -474,7 +480,7 @@
+    static String trim(String str) {
+ 
+       String trimed = str.trim();
+-      int i = str.indexOf(trimed.substring(0)) + trimed.length();
++      int i = str.indexOf(trimed) + trimed.length();
+ 
+       if ((str.length() > i) && trimed.endsWith("\\")
+               &&!trimed.endsWith("\\\\")) {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/SignatureElementProxy.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/SignatureElementProxy.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/SignatureElementProxy.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/SignatureElementProxy.java
+@@ -30,19 +30,25 @@
+ /**
+  * Class SignatureElementProxy
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
++ * @version $Revision: 1.5 $
+  */
+ public abstract class SignatureElementProxy extends ElementProxy {
+-
++        protected SignatureElementProxy() {
++        };
+    /**
+     * Constructor SignatureElementProxy
+     *
+     * @param doc
+     */
+    public SignatureElementProxy(Document doc) {
+-      super(doc);
+-      //this._constructionElement.setAttributeNS(Constants.NamespaceSpecNS,"xmlns:ds",
+-        //          Constants.SignatureSpecNS);
++              if (doc == null) {
++                 throw new RuntimeException("Document is null");
++              }
++
++              this._doc = doc;
++              this._constructionElement =  XMLUtils.createElementInSignatureSpace(this._doc,
++                           this.getBaseLocalName());
+    }
+ 
+    /**
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/SignerOutputStream.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/SignerOutputStream.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/SignerOutputStream.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/SignerOutputStream.java
+@@ -3,7 +3,7 @@
+  * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * Copyright  1999-2004 The Apache Software Foundation.
++ * Copyright 1999-2008 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.
+@@ -30,8 +30,11 @@
+  *
+  */
+ public class SignerOutputStream extends ByteArrayOutputStream {
+-    final static byte none[]="error".getBytes();
+     final SignatureAlgorithm sa;
++    static java.util.logging.Logger log =
++        java.util.logging.Logger.getLogger
++        (SignerOutputStream.class.getName());
++
+     /**
+      * @param sa
+      */
+@@ -40,21 +43,18 @@
+     }
+ 
+     /** @inheritDoc */
+-    public byte[] toByteArray() {
+-        return none;
+-    }
+-
+-    /** @inheritDoc */
+     public void write(byte[] arg0)  {
++        super.write(arg0, 0, arg0.length);
+         try {
+-                        sa.update(arg0);
+-                } catch (XMLSignatureException e) {
++            sa.update(arg0);
++        } catch (XMLSignatureException e) {
+             throw new RuntimeException(""+e);
+-                }
++        }
+     }
+ 
+     /** @inheritDoc */
+     public void write(int arg0) {
++        super.write(arg0);
+         try {
+             sa.update((byte)arg0);
+         } catch (XMLSignatureException e) {
+@@ -64,12 +64,19 @@
+ 
+     /** @inheritDoc */
+     public void write(byte[] arg0, int arg1, int arg2) {
++        super.write(arg0, arg1, arg2);
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Canonicalized SignedInfo:");
++            StringBuffer sb = new StringBuffer(arg2);
++            for (int i=arg1; i<(arg1+arg2); i++) {
++                sb.append((char) arg0[i]);
++            }
++            log.log(java.util.logging.Level.FINE, sb.toString());
++        }
+         try {
+             sa.update(arg0,arg1,arg2);
+         } catch (XMLSignatureException e) {
+             throw new RuntimeException(""+e);
+         }
+     }
+-
+-
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java
+@@ -30,14 +30,21 @@
+  */
+ public class UnsyncBufferedOutputStream extends OutputStream {
+         final OutputStream out;
++
++        final byte[] buf;
+         static final int size=8*1024;
+-        final byte[] buf=new byte[size];
++        private static ThreadLocal bufCahce = new ThreadLocal() {
++        protected synchronized Object initialValue() {
++            return new byte[size];
++        }
++    };
+         int pointer=0;
+         /**
+          * Creates a buffered output stream without synchronization
+          * @param out the outputstream to buffer
+          */
+         public UnsyncBufferedOutputStream(OutputStream out) {
++                buf=(byte[])bufCahce.get();
+                 this.out=out;
+         }
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncByteArrayOutputStream.java
+@@ -20,17 +20,25 @@
+  */
+ package com.sun.org.apache.xml.internal.security.utils;
+ 
+-import java.io.ByteArrayOutputStream;
++import java.io.OutputStream;
+ 
+ /**
+  * A simple Unsynced ByteArryOutputStream
+  * @author raul
+  *
+  */
+-public class UnsyncByteArrayOutputStream extends ByteArrayOutputStream {
+-        int size=4*1024;
+-        byte []buf=new byte[size];
+-        int pos;
++public class UnsyncByteArrayOutputStream extends OutputStream  {
++        private static ThreadLocal bufCahce = new ThreadLocal() {
++        protected synchronized Object initialValue() {
++            return new byte[8*1024];
++        }
++    };
++    byte[] buf;
++        int size=8*1024;//buf.length;
++        int pos=0;
++        public UnsyncByteArrayOutputStream() {
++                buf=(byte[])bufCahce.get();
++        }
+         /** @inheritDoc */
+         public void write(byte[] arg0) {
+                 int newPos=pos+arg0.length;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -25,8 +24,12 @@
+ 
+ import java.io.IOException;
+ import java.io.OutputStream;
++import java.security.AccessController;
++import java.security.PrivilegedAction;
++import java.util.HashMap;
+ import java.util.HashSet;
+ import java.util.Iterator;
++import java.util.Map;
+ import java.util.Set;
+ 
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+@@ -49,6 +52,14 @@
+  */
+ public class XMLUtils {
+ 
++   private static boolean ignoreLineBreaks =
++      AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
++         public Boolean run() {
++            return Boolean.getBoolean
++               ("com.sun.org.apache.xml.internal.security.ignoreLineBreaks");
++         }
++      });
++
+    /**
+     * Constructor XMLUtils
+     *
+@@ -57,7 +68,13 @@
+ 
+       // we don't allow instantiation
+    }
++   public static Element getNextElement(Node el) {
++           while ((el!=null) && (el.getNodeType()!=Node.ELEMENT_NODE)) {
++                   el=el.getNextSibling();
++           }
++           return (Element)el;
+ 
++   }
+ 
+    /**
+     * @param rootNode
+@@ -212,6 +229,8 @@
+    }
+ 
+ 
++   static  String dsPrefix=null;
++   static Map namePrefixes=new HashMap();
+    /**
+     * Creates an Element in the XML Signature specification namespace.
+     *
+@@ -226,28 +245,20 @@
+          throw new RuntimeException("Document is null");
+       }
+ 
+-      String ds = Constants.getSignatureSpecNSprefix();
+-
+-      if ((ds == null) || (ds.length() == 0)) {
+-         Element element = doc.createElementNS(Constants.SignatureSpecNS,
+-                                               elementName);
+-
+-         element.setAttributeNS(Constants.NamespaceSpecNS, "xmlns",
+-                                Constants.SignatureSpecNS);
+-
+-         return element;
++      if ((dsPrefix == null) || (dsPrefix.length() == 0)) {
++         return doc.createElementNS(Constants.SignatureSpecNS, elementName);
+       }
+-         Element element = doc.createElementNS(Constants.SignatureSpecNS,
+-                                               ds + ":" + elementName);
+-
+-         element.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + ds,
+-                                Constants.SignatureSpecNS);
+-
+-         return element;
+-
++      String namePrefix=(String) namePrefixes.get(elementName);
++      if (namePrefix==null) {
++          StringBuffer tag=new StringBuffer(dsPrefix);
++          tag.append(':');
++          tag.append(elementName);
++          namePrefix=tag.toString();
++          namePrefixes.put(elementName,namePrefix);
++      }
++      return doc.createElementNS(Constants.SignatureSpecNS, namePrefix);
+    }
+ 
+-
+    /**
+     * Returns true if the element is in XML Signature namespace and the local
+     * name equals the supplied one.
+@@ -258,17 +269,7 @@
+     */
+    public static boolean elementIsInSignatureSpace(Element element,
+            String localName) {
+-
+-      if ((element == null) ||
+-          !Constants.SignatureSpecNS.equals(element.getNamespaceURI()) ){
+-         return false;
+-      }
+-
+-      if (!element.getLocalName().equals(localName)) {
+-         return false;
+-      }
+-
+-      return true;
++      return ElementProxy.checker.isNamespaceElement(element, localName, Constants.SignatureSpecNS);
+    }
+ 
+    /**
+@@ -281,18 +282,7 @@
+     */
+    public static boolean elementIsInEncryptionSpace(Element element,
+            String localName) {
+-
+-      if ((element == null) ||
+-            !EncryptionConstants.EncryptionSpecNS.equals(element.getNamespaceURI())
+-          ){
+-         return false;
+-      }
+-
+-      if (!element.getLocalName().equals(localName)) {
+-         return false;
+-      }
+-
+-      return true;
++           return ElementProxy.checker.isNamespaceElement(element, localName, EncryptionConstants.EncryptionSpecNS);
+    }
+ 
+    /**
+@@ -352,32 +342,28 @@
+                                        + (npe == null ? "" : npe.getMessage()) + "\"");
+     }
+ 
++    /**
++     * Method createDSctx
++     *
++     * @param doc
++     * @param prefix
++     * @param namespace
++     * @return the element.
++     */
++    public static Element createDSctx(Document doc, String prefix,
++                                      String namespace) {
+ 
++       if ((prefix == null) || (prefix.trim().length() == 0)) {
++          throw new IllegalArgumentException("You must supply a prefix");
++       }
+ 
+-   /**
+-    * Method createDSctx
+-    *
+-    * @param doc
+-    * @param prefix
+-    * @param namespace
+-    * @return the element.
+-    */
+-   public static Element createDSctx(Document doc, String prefix,
+-                                     String namespace) {
++       Element ctx = doc.createElementNS(null, "namespaceContext");
+ 
+-      if ((prefix == null) || (prefix.trim().length() == 0)) {
+-         throw new IllegalArgumentException("You must supply a prefix");
+-      }
++       ctx.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix.trim(),
++                          namespace);
+ 
+-      Element ctx = doc.createElementNS(null, "namespaceContext");
+-
+-      ctx.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix.trim(),
+-                         namespace);
+-
+-      return ctx;
+-   }
+-
+-
++       return ctx;
++    }
+ 
+    /**
+     * Method addReturnToElement
+@@ -386,9 +372,23 @@
+     */
+    public static void addReturnToElement(Element e) {
+ 
+-      Document doc = e.getOwnerDocument();
++      if (!ignoreLineBreaks) {
++         Document doc = e.getOwnerDocument();
++         e.appendChild(doc.createTextNode("\n"));
++      }
++   }
+ 
+-      e.appendChild(doc.createTextNode("\n"));
++   public static void addReturnToElement(Document doc, HelperNodeList nl) {
++      if (!ignoreLineBreaks) {
++         nl.appendChild(doc.createTextNode("\n"));
++      }
++   }
++
++   public static void addReturnBeforeChild(Element e, Node child) {
++      if (!ignoreLineBreaks) {
++         Document doc = e.getOwnerDocument();
++         e.insertBefore(doc.createTextNode("\n"), child);
++      }
+    }
+ 
+    /**
+@@ -470,7 +470,7 @@
+ 
+                 for (int i = 0; i < attributesLength; i++) {
+                         Attr currentAttr = (Attr) attributes.item(i);
+-                        if (!namespaceNs.equals(currentAttr.getNamespaceURI()))
++                        if (namespaceNs!=currentAttr.getNamespaceURI())
+                                 continue;
+                         if (childElement.hasAttributeNS(namespaceNs,
+                                                         currentAttr.getLocalName())) {
+@@ -511,8 +511,7 @@
+     */
+    public static Element selectDsNode(Node sibling, String nodeName, int number) {
+         while (sibling!=null) {
+-                if (nodeName.equals(sibling.getLocalName())
+-                                && Constants.SignatureSpecNS.equals(sibling.getNamespaceURI())) {
++                if (ElementProxy.checker.isNamespaceElement(sibling, nodeName, Constants.SignatureSpecNS )) {
+                         if (number==0){
+                                 return (Element)sibling;
+                         }
+@@ -532,8 +531,7 @@
+ 
+    public static Element selectXencNode(Node sibling, String nodeName, int number) {
+         while (sibling!=null) {
+-                if (nodeName.equals(sibling.getLocalName())
+-                                && EncryptionConstants.EncryptionSpecNS.equals(sibling.getNamespaceURI())) {
++                if (ElementProxy.checker.isNamespaceElement(sibling, nodeName, EncryptionConstants.EncryptionSpecNS )) {
+                         if (number==0){
+                                 return (Element)sibling;
+                         }
+@@ -591,8 +589,7 @@
+     */
+    public static Element selectNode(Node sibling, String uri,String nodeName, int number) {
+         while (sibling!=null) {
+-                if (nodeName.equals(sibling.getLocalName())
+-                                && uri.equals(sibling.getNamespaceURI())) {
++                if (ElementProxy.checker.isNamespaceElement(sibling, nodeName, uri)) {
+                         if (number==0){
+                                 return (Element)sibling;
+                         }
+@@ -611,7 +608,6 @@
+    public static Element[] selectDsNodes(Node sibling,String nodeName) {
+      return selectNodes(sibling,Constants.SignatureSpecNS,nodeName);
+    }
+-
+    /**
+     * @param sibling
+     * @param uri
+@@ -624,8 +620,7 @@
+         int curr=0;
+         //List list=new ArrayList();
+         while (sibling!=null) {
+-                if (nodeName.equals(sibling.getLocalName())
+-                                && uri.equals(sibling.getNamespaceURI())) {
++                if (ElementProxy.checker.isNamespaceElement(sibling, nodeName, uri)) {
+                         a[curr++]=(Element)sibling;
+                         if (size<=curr) {
+                                 int cursize= size<<2;
+@@ -694,4 +689,8 @@
+          }
+       }
+    }
++
++    public static boolean ignoreLineBreaks() {
++        return ignoreLineBreaks;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XPathFuncHereAPI.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XPathFuncHereAPI.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XPathFuncHereAPI.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XPathFuncHereAPI.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -53,7 +52,7 @@
+  * XPaths using the low-level API, and then just use the XPaths
+  * over and over.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  * @see <a href="http://www.w3.org/TR/xpath">XPath Specification</a>
+  */
+ public class XPathFuncHereAPI {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -21,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.utils.resolver;
+ 
+-
+-
+ import java.util.ArrayList;
+ import java.util.List;
+ import java.util.Map;
+@@ -30,7 +27,6 @@
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+ import org.w3c.dom.Attr;
+ 
+-
+ /**
+  * During reference validation, we have to retrieve resources from somewhere.
+  * This is done by retrieving a Resolver. The resolver needs two arguments: The
+@@ -48,7 +44,7 @@
+  * <LI> Die erste Implementierung, die die Aufgabe erf??llt, f??hrt die Aufl??sung durch.
+  * </UL>
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class ResourceResolver {
+ 
+@@ -62,8 +58,7 @@
+    /** these are the system-wide resolvers */
+    static List _resolverVector = null;
+ 
+-   /** Field _individualResolverVector */
+-   List _individualResolverVector = null;
++   static boolean allThreadSafeInList=true;
+ 
+    /** Field transformSpi */
+    protected ResourceResolverSpi _resolverSpi = null;
+@@ -92,6 +87,7 @@
+       this._resolverSpi = resourceResolver;
+    }
+ 
++
+    /**
+     * Method getInstance
+     *
+@@ -107,13 +103,32 @@
+       for (int i = 0; i < length; i++) {
+                   ResourceResolver resolver =
+             (ResourceResolver) ResourceResolver._resolverVector.get(i);
++                  ResourceResolver resolverTmp=null;
++                  try {
++                        resolverTmp =  allThreadSafeInList || resolver._resolverSpi.engineIsThreadSafe() ? resolver :
++                                        new ResourceResolver((ResourceResolverSpi)resolver._resolverSpi.getClass().newInstance());
++                  } catch (InstantiationException e) {
++                          throw new ResourceResolverException("",e,uri,BaseURI);
++                  } catch (IllegalAccessException e) {
++                          throw new ResourceResolverException("",e,uri,BaseURI);
++                  }
+ 
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver._resolverSpi.getClass().getName());
+ 
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass().getName());
++         if ((resolver != null) && resolverTmp.canResolve(uri, BaseURI)) {
++                 if (i!=0) {
++                 //update resolver.
++                         //System.out.println("Swaping");
++                         List resolverVector=(List)((ArrayList)_resolverVector).clone();
++                         resolverVector.remove(i);
++                         resolverVector.add(0,resolver);
++                         _resolverVector=resolverVector;
++                 } else {
++                         //System.out.println("hitting");
++                 }
+ 
+-         if ((resolver != null) && resolver.canResolve(uri, BaseURI)) {
+-            return resolver;
++            return resolverTmp;
+          }
+       }
+ 
+@@ -137,9 +152,10 @@
+    public static final ResourceResolver getInstance(
+            Attr uri, String BaseURI, List individualResolvers)
+               throws ResourceResolverException {
+-      if (true) {
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I was asked to create a ResourceResolver and got " + individualResolvers.size());
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, " extra resolvers to my existing " + ResourceResolver._resolverVector.size() + " system-wide resolvers");
++      if (log.isLoggable(java.util.logging.Level.FINE)) {
++
++        log.log(java.util.logging.Level.FINE, "I was asked to create a ResourceResolver and got " + (individualResolvers==null? 0 : individualResolvers.size()) );
++        log.log(java.util.logging.Level.FINE, " extra resolvers to my existing " + ResourceResolver._resolverVector.size() + " system-wide resolvers");
+       }
+ 
+       // first check the individual Resolvers
+@@ -151,8 +167,8 @@
+ 
+             if (resolver != null) {
+                String currentClass = resolver._resolverSpi.getClass().getName();
+-               if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "check resolvability by class " + currentClass);
++               if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "check resolvability by class " + currentClass);
+ 
+                if (resolver.canResolve(uri, BaseURI)) {
+                   return resolver;
+@@ -175,39 +191,46 @@
+       }
+    }
+ 
+-   /**
+-    * Method register
+-    *
+-    * @param className
+-    */
+-   public static void register(String className) {
+-            ResourceResolver resolver = null;
++    /**
++     * Registers a ResourceResolverSpi class. This method logs a warning if
++     * the class cannot be registered.
++     *
++     * @param className the name of the ResourceResolverSpi class to be
++     *    registered
++     */
++    public static void register(String className) {
++        register(className, false);
++    }
+ 
++    /**
++     * Registers a ResourceResolverSpi class at the beginning of the provider
++     * list. This method logs a warning if the class cannot be registered.
++     *
++     * @param className the name of the ResourceResolverSpi class to be
++     *    registered
++     */
++    public static void registerAtStart(String className) {
++        register(className, true);
++    }
++
++    private static void register(String className, boolean start) {
+         try {
+-           resolver = new ResourceResolver(className);
+-                   ResourceResolver._resolverVector.add(resolver);
++            ResourceResolver resolver = new ResourceResolver(className);
++            if (start) {
++                ResourceResolver._resolverVector.add(0, resolver);
++                log.log(java.util.logging.Level.FINE, "registered resolver");
++            } else {
++                ResourceResolver._resolverVector.add(resolver);
++            }
++            if (!resolver._resolverSpi.engineIsThreadSafe()) {
++                allThreadSafeInList=false;
++        }
+         } catch (Exception e) {
+-//                      Object exArgs[] = { ((uri != null)
+-//                    ? uri.getNodeValue()
+-//                    : "null"), BaseURI };
+-//
+-//                      throw new ResourceResolverException("utils.resolver.noClass",
+-//                                   exArgs, e, uri, BaseURI);
+-                        log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className +" disabling it");
++            log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className +" disabling it");
+         } catch (NoClassDefFoundError e) {
+-                        log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className +" disabling it");
++            log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className +" disabling it");
+         }
+-
+-   }
+-
+-   /**
+-    * Method registerAtStart
+-    *
+-    * @param className
+-    */
+-   public static void registerAtStart(String className) {
+-      ResourceResolver._resolverVector.add(0, className);
+-   }
++    }
+ 
+    /**
+     * Method resolve
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverException.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverException.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverException.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverException.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -31,7 +30,7 @@
+  * This Exception is thrown if something related to the
+  * {@link com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver} goes wrong.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class ResourceResolverException extends XMLSecurityException {
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -22,6 +21,7 @@
+ package com.sun.org.apache.xml.internal.security.utils.resolver;
+ 
+ 
++import java.util.HashMap;
+ import java.util.Map;
+ 
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+@@ -31,7 +31,7 @@
+ /**
+  * During reference validation, we have to retrieve resources from somewhere.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public abstract class ResourceResolverSpi {
+ 
+@@ -41,7 +41,7 @@
+                     ResourceResolverSpi.class.getName());
+ 
+    /** Field _properties */
+-   protected java.util.Map _properties = new java.util.HashMap(10);
++   protected java.util.Map _properties = null;
+ 
+    /**
+     * This is the workhorse method used to resolve resources.
+@@ -62,19 +62,9 @@
+     * @param value
+     */
+    public void engineSetProperty(String key, String value) {
+-
+-      java.util.Iterator i = this._properties.keySet().iterator();
+-
+-      while (i.hasNext()) {
+-         String c = (String) i.next();
+-
+-         if (c.equals(key)) {
+-            key = c;
+-
+-            break;
+-         }
+-      }
+-
++          if (_properties==null) {
++                  _properties=new HashMap();
++          }
+       this._properties.put(key, value);
+    }
+ 
+@@ -85,19 +75,9 @@
+     * @return the value of the property
+     */
+    public String engineGetProperty(String key) {
+-
+-      java.util.Iterator i = this._properties.keySet().iterator();
+-
+-      while (i.hasNext()) {
+-         String c = (String) i.next();
+-
+-         if (c.equals(key)) {
+-            key = c;
+-
+-            break;
+-         }
+-      }
+-
++          if (_properties==null) {
++                        return null;
++          }
+       return (String) this._properties.get(key);
+    }
+ 
+@@ -106,9 +86,22 @@
+     * @param properties
+     */
+    public void engineAddProperies(Map properties) {
+-      this._properties.putAll(properties);
++          if (properties!=null) {
++                  if (_properties==null) {
++                          _properties=new HashMap();
++                  }
++                  this._properties.putAll(properties);
++          }
+    }
+-
++   /**
++    * Tells if the implementation does can be reused by several threads safely.
++    * It normally means that the implemantation does not have any member, or there is
++    * member change betwen engineCanResolve & engineResolve invocations. Or it mantians all
++    * member info in ThreadLocal methods.
++    */
++   public boolean engineIsThreadSafe() {
++           return false;
++   }
+    /**
+     * This method helps the {@link ResourceResolver} to decide whether a
+     * {@link ResourceResolverSpi} is able to perform the requested action.
+@@ -174,8 +167,8 @@
+                                   && (ch3 != '/'));
+ 
+          if (isDosFilename) {
+-            if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Found DOS filename: " + str);
++            if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Found DOS filename: " + str);
+          }
+       }
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverAnonymous.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverAnonymous.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverAnonymous.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverAnonymous.java
+@@ -32,14 +32,10 @@
+ 
+ /**
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ 
+ public class ResolverAnonymous extends ResourceResolverSpi {
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(
+-                        ResolverAnonymous.class.getName());
+ 
+    private XMLSignatureInput _input = null;
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverDirectHTTP.java
+@@ -2,7 +2,6 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-
+ /*
+  * Copyright  1999-2004 The Apache Software Foundation.
+  *
+@@ -67,11 +66,12 @@
+                             ResolverDirectHTTP.class.getName());
+ 
+    /** Field properties[] */
+-   static final String properties[] = { "http.proxy.host", "http.proxy.port",
+-                                        "http.proxy.username",
+-                                        "http.proxy.password",
+-                                        "http.basic.username",
+-                                        "http.basic.password" };
++   private static final String properties[] =
++        { "http.proxy.host", "http.proxy.port",
++          "http.proxy.username",
++          "http.proxy.password",
++          "http.basic.username",
++          "http.basic.password" };
+ 
+    /** Field HttpProxyHost */
+    private static final int HttpProxyHost = 0;
+@@ -91,6 +91,9 @@
+    /** Field HttpProxyPass */
+    private static final int HttpBasicPass = 5;
+ 
++   public boolean engineIsThreadSafe() {
++           return true;
++   }
+    /**
+     * Method resolve
+     *
+@@ -117,15 +120,14 @@
+             useProxy = true;
+          }
+ 
+-         // switch on proxy usage
+          String oldProxySet = null;
+          String oldProxyHost = null;
+          String oldProxyPort = null;
++         // switch on proxy usage
+          if (useProxy) {
+             if (log.isLoggable(java.util.logging.Level.FINE)) {
+-               log.log(java.util.logging.Level.FINE,
+-                  "Use of HTTP proxy enabled: " + proxyHost + ":"
+-                  + proxyPort);
++                log.log(java.util.logging.Level.FINE, "Use of HTTP proxy enabled: " + proxyHost + ":"
++                      + proxyPort);
+             }
+             oldProxySet = System.getProperty("http.proxySet");
+             oldProxyHost = System.getProperty("http.proxyHost");
+@@ -215,11 +217,8 @@
+             summarized += read;
+          }
+ 
+-         if (log.isLoggable(java.util.logging.Level.FINE)) {
+-            log.log(java.util.logging.Level.FINE,
+-               "Fetched " + summarized + " bytes from URI "
+-               + uriNew.toString());
+-         }
++         log.log(java.util.logging.Level.FINE, "Fetched " + summarized + " bytes from URI "
++                   + uriNew.toString());
+ 
+          XMLSignatureInput result = new XMLSignatureInput(baos.toByteArray());
+ 
+@@ -253,39 +252,36 @@
+     */
+    public boolean engineCanResolve(Attr uri, String BaseURI) {
+       if (uri == null) {
+-         if (log.isLoggable(java.util.logging.Level.FINE)) {
+-            log.log(java.util.logging.Level.FINE, "quick fail, uri == null");
+-         }
++         log.log(java.util.logging.Level.FINE, "quick fail, uri == null");
++
+          return false;
+       }
+ 
+       String uriNodeValue = uri.getNodeValue();
+ 
+       if (uriNodeValue.equals("") || (uriNodeValue.charAt(0)=='#')) {
+-         if (log.isLoggable(java.util.logging.Level.FINE)) {
+-            log.log(java.util.logging.Level.FINE,
+-               "quick fail for empty URIs and local ones");
+-         }
++         log.log(java.util.logging.Level.FINE, "quick fail for empty URIs and local ones");
++
+          return false;
+       }
+ 
+       if (log.isLoggable(java.util.logging.Level.FINE)) {
+-         log.log(java.util.logging.Level.FINE,
+-               "I was asked whether I can resolve " + uriNodeValue);
++         log.log(java.util.logging.Level.FINE, "I was asked whether I can resolve " + uriNodeValue);
+       }
++
+       if ( uriNodeValue.startsWith("http:") ||
+-                                 BaseURI.startsWith("http:")) {
++                                (BaseURI!=null && BaseURI.startsWith("http:") )) {
+          if (log.isLoggable(java.util.logging.Level.FINE)) {
+-            log.log(java.util.logging.Level.FINE,
+-                  "I state that I can resolve " + uriNodeValue);
++            log.log(java.util.logging.Level.FINE, "I state that I can resolve " + uriNodeValue);
+          }
++
+          return true;
+       }
+ 
+       if (log.isLoggable(java.util.logging.Level.FINE)) {
+-         log.log(java.util.logging.Level.FINE,
+-            "I state that I can't resolve " + uriNodeValue);
++         log.log(java.util.logging.Level.FINE, "I state that I can't resolve " + uriNodeValue);
+       }
++
+       return false;
+    }
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java
+@@ -34,7 +34,7 @@
+ /**
+  * This resolver is used for resolving same-document URIs like URI="" of URI="#id".
+  *
+- * @author $Author: dims $
++ * @author $Author: mullan $
+  * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#sec-ReferenceProcessingModel">The Reference processing model in the XML Signature spec</A>
+  * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#sec-Same-Document">Same-Document URI-References in the XML Signature spec</A>
+  * @see <A HREF="http://www.ietf.org/rfc/rfc2396.txt">Section 4.2 of RFC 2396</A>
+@@ -45,7 +45,9 @@
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(
+                             ResolverFragment.class.getName());
+-
++   public boolean engineIsThreadSafe() {
++           return true;
++   }
+    /**
+     * Method engineResolve
+     *
+@@ -72,7 +74,7 @@
+           * resource containing the signature
+           */
+ 
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "ResolverFragment with empty URI (means complete document)");
++         log.log(java.util.logging.Level.FINE, "ResolverFragment with empty URI (means complete document)");
+          selectedElem = doc;
+       } else {
+ 
+@@ -93,14 +95,14 @@
+             throw new ResourceResolverException(
+                "signature.Verification.MissingID", exArgs, uri, BaseURI);
+          }
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Try to catch an Element with ID " + id + " and Element was " + selectedElem);
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Try to catch an Element with ID " + id + " and Element was " + selectedElem);
+       }
+ 
+       XMLSignatureInput result = new XMLSignatureInput(selectedElem);
+       result.setExcludeComments(true);
+ 
+-      //if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "We return a nodeset with " + resultSet.size() + " nodes");
++      //log.log(java.util.logging.Level.FINE, "We return a nodeset with " + resultSet.size() + " nodes");
+       result.setMIMEType("text/xml");
+           result.setSourceURI((BaseURI != null) ? BaseURI.concat(uri.getNodeValue()) :
+                   uri.getNodeValue());
+@@ -117,21 +119,24 @@
+    public boolean engineCanResolve(Attr uri, String BaseURI) {
+ 
+       if (uri == null) {
+-         if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Quick fail for null uri");
++         log.log(java.util.logging.Level.FINE, "Quick fail for null uri");
+          return false;
+       }
+ 
+       String uriNodeValue = uri.getNodeValue();
+ 
+-      if (uriNodeValue.equals("")
+-              || ((uriNodeValue.charAt(0)=='#')
+-                  &&!uriNodeValue.startsWith("#xpointer("))) {
+-         if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "State I can resolve reference: \"" + uriNodeValue + "\"");
++      if  (uriNodeValue.equals("") ||
++             (
++            (uriNodeValue.charAt(0)=='#')
++              && !((uriNodeValue.charAt(1)=='x') && uriNodeValue.startsWith("#xpointer("))
++              )
++           ){
++         if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "State I can resolve reference: \"" + uriNodeValue + "\"");
+          return true;
+       }
+-      if (true)
+-        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Do not seem to be able to resolve reference: \"" + uriNodeValue + "\"");
++      if (log.isLoggable(java.util.logging.Level.FINE))
++        log.log(java.util.logging.Level.FINE, "Do not seem to be able to resolve reference: \"" + uriNodeValue + "\"");
+       return false;
+    }
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverLocalFilesystem.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverLocalFilesystem.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverLocalFilesystem.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverLocalFilesystem.java
+@@ -20,8 +20,6 @@
+  */
+ package com.sun.org.apache.xml.internal.security.utils.resolver.implementations;
+ 
+-
+-
+ import java.io.FileInputStream;
+ 
+ import com.sun.org.apache.xml.internal.utils.URI;
+@@ -30,11 +28,10 @@
+ import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverSpi;
+ import org.w3c.dom.Attr;
+ 
+-
+ /**
+  * A simple ResourceResolver for requests into the local filesystem.
+  *
+- * @author $Author: raul $
++ * @author $Author: mullan $
+  */
+ public class ResolverLocalFilesystem extends ResourceResolverSpi {
+ 
+@@ -43,6 +40,9 @@
+         java.util.logging.Logger.getLogger(
+                     ResolverLocalFilesystem.class.getName());
+ 
++    public boolean engineIsThreadSafe() {
++           return true;
++   }
+    /**
+     * @inheritDoc
+     */
+@@ -50,7 +50,7 @@
+            throws ResourceResolverException {
+ 
+      try {
+-        URI uriNew = new URI(new URI(BaseURI), uri.getNodeValue());
++        URI uriNew = getNewURI(uri.getNodeValue(), BaseURI);
+ 
+         // if the URI contains a fragment, ignore it
+         URI uriNewNoFrag = new URI(uriNew);
+@@ -72,6 +72,7 @@
+       }
+    }
+ 
++   private static int FILE_URI_LENGTH="file:/".length();
+    /**
+     * Method translateUriToFilename
+     *
+@@ -80,7 +81,7 @@
+     */
+    private static String translateUriToFilename(String uri) {
+ 
+-      String subStr = uri.substring("file:/".length());
++      String subStr = uri.substring(FILE_URI_LENGTH);
+ 
+       if (subStr.indexOf("%20") > -1)
+       {
+@@ -121,26 +122,36 @@
+ 
+       String uriNodeValue = uri.getNodeValue();
+ 
+-      if (uriNodeValue.equals("") || (uriNodeValue.charAt(0)=='#')) {
++      if (uriNodeValue.equals("") || (uriNodeValue.charAt(0)=='#') ||
++          uriNodeValue.startsWith("http:")) {
+          return false;
+       }
+ 
+       try {
+                  //URI uriNew = new URI(new URI(BaseURI), uri.getNodeValue());
+-                 if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I was asked whether I can resolve " + uriNodeValue/*uriNew.toString()*/);
++                 if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "I was asked whether I can resolve " + uriNodeValue/*uriNew.toString()*/);
+ 
+                  if ( uriNodeValue.startsWith("file:") ||
+                                          BaseURI.startsWith("file:")/*uriNew.getScheme().equals("file")*/) {
+-                    if (true)
+-                        if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "I state that I can resolve " + uriNodeValue/*uriNew.toString()*/);
++                    if (log.isLoggable(java.util.logging.Level.FINE))
++                        log.log(java.util.logging.Level.FINE, "I state that I can resolve " + uriNodeValue/*uriNew.toString()*/);
+ 
+                     return true;
+                  }
+       } catch (Exception e) {}
+ 
+-      if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "But I can't");
++      log.log(java.util.logging.Level.FINE, "But I can't");
+ 
+       return false;
+    }
++
++   private static URI getNewURI(String uri, String BaseURI)
++           throws URI.MalformedURIException {
++
++      if ((BaseURI == null) || "".equals(BaseURI)) {
++         return new URI(uri);
++      }
++      return new URI(new URI(BaseURI), uri);
++   }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java
+@@ -44,7 +44,7 @@
+  * nodes of the parse tree (all descendants, plus all attributes,
+  * plus all namespaces nodes).
+  *
+- * @author $Author: dims $
++ * @author $Author: mullan $
+  */
+ public class ResolverXPointer extends ResourceResolverSpi {
+ 
+@@ -53,6 +53,9 @@
+         java.util.logging.Logger.getLogger(
+                             ResolverXPointer.class.getName());
+ 
++    public boolean engineIsThreadSafe() {
++           return true;
++   }
+    /**
+     * @inheritDoc
+     */
+@@ -70,7 +73,7 @@
+             String id = getXPointerId(uriStr);
+             resultNode =IdResolver.getElementById(doc, id);
+ 
+-            // if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Use #xpointer(id('" + id + "')) on element " + selectedElem);
++            // log.log(java.util.logging.Level.FINE, "Use #xpointer(id('" + id + "')) on element " + selectedElem);
+ 
+             if (resultNode == null) {
+                Object exArgs[] = { id };
+@@ -148,14 +151,14 @@
+                                                      uri.length()
+                                                      - 2);
+ 
+-         // if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "idPlusDelim=" + idPlusDelim);
++         // log.log(java.util.logging.Level.FINE, "idPlusDelim=" + idPlusDelim);
+                  int idLen=idPlusDelim.length() -1;
+          if (((idPlusDelim.charAt(0) == '"') && (idPlusDelim
+                  .charAt(idLen) == '"')) || ((idPlusDelim
+                  .charAt(0) == '\'') && (idPlusDelim
+                  .charAt(idLen) == '\''))) {
+-            if (true)
+-                if (log.isLoggable(java.util.logging.Level.FINE))                                     log.log(java.util.logging.Level.FINE, "Id="
++            if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Id="
+                       + idPlusDelim.substring(1, idLen));
+ 
+             return true;
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/DigesterOutputStream.java b/src/share/classes/org/jcp/xml/dsig/internal/DigesterOutputStream.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/DigesterOutputStream.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/DigesterOutputStream.java
+@@ -19,7 +19,10 @@
+  *
+  */
+ /*
+- * $Id: DigesterOutputStream.java,v 1.1.2.2 2005/08/12 18:15:35 mullan Exp $
++ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
++ */
++/*
++ * $Id: DigesterOutputStream.java,v 1.2 2008/07/24 15:20:31 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal;
+ 
+@@ -35,10 +38,11 @@
+ /**
+  * This class has been modified slightly to use java.security.MessageDigest
+  * objects as input, rather than
+- * org.apache.xml.security.algorithms.MessageDigestAlgorithm objects.
++ * com.sun.org.apache.xml.internal.security.algorithms.MessageDigestAlgorithm objects.
+  * It also optionally caches the input bytes.
+  *
+  * @author raul
++ * @author Sean Mullan
+  */
+ public class DigesterOutputStream extends OutputStream {
+     private boolean buffer = false;
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/MacOutputStream.java b/src/share/classes/org/jcp/xml/dsig/internal/MacOutputStream.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/MacOutputStream.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/MacOutputStream.java
+@@ -24,15 +24,14 @@
+ import javax.crypto.Mac;
+ 
+ /**
+- * Derived from Apache sources and changed to use Mac objects
+- * objects instead of org.apache.xml.security.algorithms.SignatureAlgorithm
+- * objects.
++ * Derived from Apache sources and changed to use Mac objects instead of
++ * com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm objects.
+  *
+  * @author raul
++ * @author Sean Mullan
+  *
+  */
+ public class MacOutputStream extends ByteArrayOutputStream {
+-    private final static byte none[]="error".getBytes();
+     private final Mac mac;
+ 
+     public MacOutputStream(Mac mac) {
+@@ -40,22 +39,20 @@
+     }
+ 
+     /** @inheritDoc */
+-    public byte[] toByteArray() {
+-        return none;
+-    }
+-
+-    /** @inheritDoc */
+     public void write(byte[] arg0)  {
++        super.write(arg0, 0, arg0.length);
+         mac.update(arg0);
+     }
+ 
+     /** @inheritDoc */
+     public void write(int arg0) {
+-        mac.update((byte)arg0);
++        super.write(arg0);
++        mac.update((byte) arg0);
+     }
+ 
+     /** @inheritDoc */
+     public void write(byte[] arg0, int arg1, int arg2) {
+-        mac.update(arg0,arg1,arg2);
++        super.write(arg0, arg1, arg2);
++        mac.update(arg0, arg1, arg2);
+     }
+ }
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/SignerOutputStream.java b/src/share/classes/org/jcp/xml/dsig/internal/SignerOutputStream.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/SignerOutputStream.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/SignerOutputStream.java
+@@ -19,7 +19,10 @@
+  *
+  */
+ /*
+- * $Id: SignerOutputStream.java,v 1.1.2.2 2005/08/12 18:01:58 mullan Exp $
++ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
++ */
++/*
++ * $Id: SignerOutputStream.java,v 1.2 2008/07/24 15:20:31 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal;
+ 
+@@ -29,10 +32,11 @@
+ 
+ /**
+  * Derived from Apache sources and changed to use java.security.Signature
+- * objects as input instead of org.apache.xml.security.algorithms.SignatureAlgorithm
++ * objects as input instead of com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm
+  * objects.
+  *
+  * @author raul
++ * @author Sean Mullan
+  */
+ public class SignerOutputStream extends ByteArrayOutputStream {
+     private final Signature sig;
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: ApacheCanonicalizer.java,v 1.17 2005/09/19 18:20:04 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: ApacheCanonicalizer.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -53,6 +52,10 @@
+ 
+ public abstract class ApacheCanonicalizer extends TransformService {
+ 
++    static {
++        com.sun.org.apache.xml.internal.security.Init.init();
++    }
++
+     private static Logger log = Logger.getLogger("org.jcp.xml.dsig.internal.dom");
+     protected Canonicalizer apacheCanonicalizer;
+     private Transform apacheTransform;
+@@ -235,13 +238,9 @@
+         }
+ 
+         try {
+-            if (os != null) {
+-                in = apacheTransform.performTransform(in, os);
+-                if (!in.isNodeSet() && !in.isElement()) {
+-                    return null;
+-                }
+-            } else {
+-                in = apacheTransform.performTransform(in);
++            in = apacheTransform.performTransform(in, os);
++            if (!in.isNodeSet() && !in.isElement()) {
++                return null;
+             }
+             if (in.isOctetStream()) {
+                 return new ApacheOctetStreamData(in);
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheData.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheData.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheData.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheData.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: ApacheData.java,v 1.4 2005/05/10 18:15:31 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: ApacheData.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheNodeSetData.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: ApacheNodeSetData.java,v 1.4 2005/05/10 18:15:31 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: ApacheNodeSetData.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -83,7 +82,7 @@
+             boolean skipNode = false;
+             while (it.hasNext() && !skipNode) {
+                 NodeFilter nf = (NodeFilter) it.next();
+-                if (!nf.isNodeInclude(currentNode)) {
++                if (nf.isNodeInclude(currentNode)!=1) {
+                     skipNode = true;
+                 }
+             }
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheOctetStreamData.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: ApacheOctetStreamData.java,v 1.4 2005/05/10 18:15:31 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: ApacheOctetStreamData.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: ApacheTransform.java,v 1.23 2005/09/15 14:29:03 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: ApacheTransform.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -54,6 +53,10 @@
+  */
+ public abstract class ApacheTransform extends TransformService {
+ 
++    static {
++        com.sun.org.apache.xml.internal.security.Init.init();
++    }
++
+     private static Logger log = Logger.getLogger("org.jcp.xml.dsig.internal.dom");
+     private Transform apacheTransform;
+     protected Document ownerDoc;
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMBase64Transform.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMBase64Transform.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMBase64Transform.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMBase64Transform.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMBase64Transform.java,v 1.14 2005/05/10 18:15:31 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMBase64Transform.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14N11Method.java
+@@ -0,0 +1,79 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2008 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.
++ *
++ */
++/*
++ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
++ */
++/*
++ * $Id: DOMCanonicalXMLC14N11Method.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
++ */
++package org.jcp.xml.dsig.internal.dom;
++
++import javax.xml.crypto.*;
++import javax.xml.crypto.dsig.*;
++import javax.xml.crypto.dsig.spec.TransformParameterSpec;
++
++import java.security.InvalidAlgorithmParameterException;
++
++import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
++import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
++
++/**
++ * DOM-based implementation of CanonicalizationMethod for Canonical XML 1.1
++ * (with or without comments). Uses Apache XML-Sec Canonicalizer.
++ *
++ * @author Sean Mullan
++ */
++public final class DOMCanonicalXMLC14N11Method extends ApacheCanonicalizer {
++
++    public static final String C14N_11 = "http://www.w3.org/2006/12/xml-c14n11";
++    public static final String C14N_11_WITH_COMMENTS
++        = "http://www.w3.org/2006/12/xml-c14n11#WithComments";
++
++    public void init(TransformParameterSpec params)
++        throws InvalidAlgorithmParameterException {
++        if (params != null) {
++            throw new InvalidAlgorithmParameterException("no parameters " +
++                "should be specified for Canonical XML 1.1 algorithm");
++        }
++    }
++
++    public Data transform(Data data, XMLCryptoContext xc)
++        throws TransformException {
++
++        // ignore comments if dereferencing same-document URI that requires
++        // you to omit comments, even if the Transform says otherwise -
++        // this is to be compliant with section 4.3.3.3 of W3C Rec.
++        if (data instanceof DOMSubTreeData) {
++            DOMSubTreeData subTree = (DOMSubTreeData) data;
++            if (subTree.excludeComments()) {
++                try {
++                    apacheCanonicalizer = Canonicalizer.getInstance(C14N_11);
++                } catch (InvalidCanonicalizerException ice) {
++                    throw new TransformException
++                        ("Couldn't find Canonicalizer for: " +
++                         C14N_11 + ": " + ice.getMessage(), ice);
++                }
++            }
++        }
++
++        return canonicalize(data, xc);
++    }
++}
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalXMLC14NMethod.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMCanonicalXMLC14NMethod.java,v 1.24.4.1 2005/08/12 15:27:49 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMCanonicalXMLC14NMethod.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java
+@@ -1,34 +1,34 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMCanonicalizationMethod.java,v 1.25 2005/05/10 18:15:31 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMCanonicalizationMethod.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+ import java.io.OutputStream;
+ import java.security.InvalidAlgorithmParameterException;
++import java.security.Provider;
+ 
+ import org.w3c.dom.Element;
+ 
+@@ -60,9 +60,9 @@
+      *
+      * @param cmElem a CanonicalizationMethod element
+      */
+-    public DOMCanonicalizationMethod(Element cmElem, XMLCryptoContext context)
+-        throws MarshalException{
+-        super(cmElem, context);
++    public DOMCanonicalizationMethod(Element cmElem, XMLCryptoContext context,
++        Provider provider) throws MarshalException {
++        super(cmElem, context, provider);
+     }
+ 
+     /**
+@@ -75,7 +75,7 @@
+      *     additional context (may be <code>null</code> if not applicable)
+      * @return the canonicalized data
+      * @throws NullPointerException if <code>data</code> is <code>null</code>
+-     * @throws XMLSignatureException if an unexpected error occurs while
++     * @throws TransformException if an unexpected error occurs while
+      *    canonicalizing the data
+      */
+     public Data canonicalize(Data data, XMLCryptoContext xc)
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCryptoBinary.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMCryptoBinary.java,v 1.14 2005/05/12 19:28:29 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMCryptoBinary.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMDigestMethod.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMDigestMethod.java,v 1.17 2005/05/10 18:15:32 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMDigestMethod.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -127,7 +126,7 @@
+ 
+     /**
+      * Unmarshals <code>DigestMethodParameterSpec</code> from the specified
+-     * <code>Element</code>. By default, this method throws an exception since
++     * <code>Element</code>.  By default, this method throws an exception since
+      * most DigestMethod algorithms do not have parameters. Subclasses should
+      * override it if they have parameters.
+      *
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMEnvelopedTransform.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMEnvelopedTransform.java,v 1.16 2005/05/10 18:15:32 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMEnvelopedTransform.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMExcC14NMethod.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMExcC14NMethod.java,v 1.28 2005/09/23 20:20:41 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMExcC14NMethod.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -104,7 +103,7 @@
+         Element excElem = DOMUtils.createElement
+             (ownerDoc, "InclusiveNamespaces",
+              CanonicalizationMethod.EXCLUSIVE, prefix);
+-        if (prefix == null) {
++        if (prefix == null || prefix.length() == 0) {
+             excElem.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
+                 CanonicalizationMethod.EXCLUSIVE);
+         } else {
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMHMACSignatureMethod.java
+@@ -1,29 +1,28 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2005 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.
++ *
++ */
+ /*
+  * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+  */
+ /*
+- * $Id: DOMHMACSignatureMethod.java,v 1.17 2005/09/15 14:29:04 mullan Exp $
++ * $Id: DOMHMACSignatureMethod.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMKeyInfo.java,v 1.19 2005/05/12 19:28:30 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMKeyInfo.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -33,6 +32,7 @@
+ import javax.xml.crypto.dsig.keyinfo.KeyInfo;
+ import javax.xml.crypto.dom.*;
+ 
++import java.security.Provider;
+ import java.util.*;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+@@ -82,10 +82,10 @@
+     /**
+      * Creates a <code>DOMKeyInfo</code> from XML.
+      *
+-     * @param input XML input
++     * @param kiElem KeyInfo element
+      */
+-    public DOMKeyInfo(Element kiElem, XMLCryptoContext context)
+-        throws MarshalException {
++    public DOMKeyInfo(Element kiElem, XMLCryptoContext context,
++        Provider provider) throws MarshalException {
+         // get Id attribute, if specified
+         id = DOMUtils.getAttributeValue(kiElem, "Id");
+ 
+@@ -112,7 +112,10 @@
+             } else if (localName.equals("KeyValue")) {
+                 content.add(new DOMKeyValue(childElem));
+             } else if (localName.equals("RetrievalMethod")) {
+-                content.add(new DOMRetrievalMethod(childElem, context));
++                content.add
++                    (new DOMRetrievalMethod(childElem, context, provider));
++            } else if (localName.equals("PGPData")) {
++                content.add(new DOMPGPData(childElem));
+             } else { //may be MgmtData, SPKIData or element from other namespace
+                 content.add(new javax.xml.crypto.dom.DOMStructure((childElem)));
+             }
+@@ -139,7 +142,7 @@
+         Element kiElem = DOMUtils.createElement
+             (DOMUtils.getOwnerDocument(pNode), "KeyInfo",
+              XMLSignature.XMLNS, dsPrefix);
+-        if (dsPrefix == null) {
++        if (dsPrefix == null || dsPrefix.length() == 0) {
+             kiElem.setAttributeNS
+                 ("http://www.w3.org/2000/xmlns/", "xmlns", XMLSignature.XMLNS);
+         } else {
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfoFactory.java
+@@ -1,34 +1,34 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMKeyInfoFactory.java,v 1.24 2005/09/23 20:18:50 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMKeyInfoFactory.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+ import java.math.BigInteger;
+-import java.security.*;
++import java.security.KeyException;
++import java.security.PublicKey;
+ import java.util.List;
+ import javax.xml.crypto.*;
+ import javax.xml.crypto.dsig.*;
+@@ -45,7 +45,6 @@
+  */
+ public final class DOMKeyInfoFactory extends KeyInfoFactory {
+ 
+-
+     public DOMKeyInfoFactory() { }
+ 
+     public KeyInfo newKeyInfo(List content) {
+@@ -135,7 +134,7 @@
+                 "support DOM Level 2 and be namespace aware");
+         }
+         if (tag.equals("KeyInfo")) {
+-            return new DOMKeyInfo(element, null);
++            return new DOMKeyInfo(element, null, getProvider());
+         } else {
+             throw new MarshalException("invalid KeyInfo tag: " + tag);
+         }
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyName.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMKeyName.java,v 1.12 2005/05/10 18:15:32 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMKeyName.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyValue.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMKeyValue.java,v 1.18 2005/05/10 18:15:33 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMKeyValue.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMManifest.java,v 1.16 2005/05/12 19:28:31 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMManifest.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -31,6 +30,7 @@
+ import javax.xml.crypto.dom.DOMCryptoContext;
+ import javax.xml.crypto.dsig.*;
+ 
++import java.security.Provider;
+ import java.util.*;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+@@ -83,13 +83,13 @@
+      *
+      * @param manElem a Manifest element
+      */
+-    public DOMManifest(Element manElem, XMLCryptoContext context)
+-        throws MarshalException {
++    public DOMManifest(Element manElem, XMLCryptoContext context,
++        Provider provider) throws MarshalException {
+         this.id = DOMUtils.getAttributeValue(manElem, "Id");
+         Element refElem = DOMUtils.getFirstChildElement(manElem);
+         List refs = new ArrayList();
+         while (refElem != null) {
+-            refs.add(new DOMReference(refElem, context));
++            refs.add(new DOMReference(refElem, context, provider));
+             refElem = DOMUtils.getNextSiblingElement(refElem);
+         }
+         this.references = Collections.unmodifiableList(refs);
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMPGPData.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMPGPData.java,v 1.18 2005/05/12 19:28:31 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMPGPData.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java
+@@ -1,28 +1,26 @@
+ /*
+- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2005 The Apache Software Foundation.
+  *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
++ *  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
+  *
+- * 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).
++ *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+- * 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.
++ *  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.
+  *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+  */
+-
++/*
++ * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
++ */
+ /*
+  * ===========================================================================
+  *
+@@ -31,7 +29,7 @@
+  * ===========================================================================
+  */
+ /*
+- * $Id: DOMReference.java,v 1.40 2005/09/19 18:27:04 mullan Exp $
++ * $Id: DOMReference.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -67,13 +65,27 @@
+ public final class DOMReference extends DOMStructure
+     implements Reference, DOMURIReference {
+ 
++   /**
++    * Look up useC14N11 system property. If true, an explicit C14N11 transform
++    * will be added if necessary when generating the signature. See section
++    * 3.1.1 of http://www.w3.org/2007/xmlsec/Drafts/xmldsig-core/ for more info.
++    *
++    * If true, overrides the same property if set in the XMLSignContext.
++    */
++    private static boolean useC14N11 =
++        AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
++            public Boolean run() {
++                return Boolean.getBoolean
++                    ("com.sun.org.apache.xml.internal.security.useC14N11");
++            }
++        });
++
+     private static Logger log = Logger.getLogger("org.jcp.xml.dsig.internal.dom");
+ 
+     private final DigestMethod digestMethod;
+     private final String id;
+-    private final List appliedTransforms;
+     private final List transforms;
+-    private final List allTransforms;
++    private List allTransforms;
+     private final Data appliedTransformData;
+     private Attr here;
+     private final String uri;
+@@ -87,6 +99,7 @@
+     private Data derefData;
+     private InputStream dis;
+     private MessageDigest md;
++    private Provider provider;
+ 
+     /**
+      * Creates a <code>Reference</code> from the specified parameters.
+@@ -104,24 +117,25 @@
+      *    not of type <code>Transform</code>
+      */
+     public DOMReference(String uri, String type, DigestMethod dm,
+-        List transforms, String id) {
+-        this(uri, type, dm, null, null, transforms, id, null);
+-    }
+-
+-    public DOMReference(String uri, String type, DigestMethod dm,
+-        List appliedTransforms, Data result, List transforms, String id) {
+-        this(uri, type, dm, appliedTransforms, result, transforms, id, null);
++        List transforms, String id, Provider provider) {
++        this(uri, type, dm, null, null, transforms, id, null, provider);
+     }
+ 
+     public DOMReference(String uri, String type, DigestMethod dm,
+         List appliedTransforms, Data result, List transforms, String id,
+-        byte[] digestValue){
++        Provider provider) {
++        this(uri, type, dm, appliedTransforms,
++             result, transforms, id, null, provider);
++    }
++
++    public DOMReference(String uri, String type, DigestMethod dm,
++        List appliedTransforms, Data result, List transforms, String id,
++        byte[] digestValue, Provider provider) {
+         if (dm == null) {
+             throw new NullPointerException("DigestMethod must be non-null");
+         }
+-        if (appliedTransforms == null || appliedTransforms.isEmpty()) {
+-            this.appliedTransforms = Collections.EMPTY_LIST;
+-        } else {
++        this.allTransforms = new ArrayList();
++        if (appliedTransforms != null) {
+             List transformsCopy = new ArrayList(appliedTransforms);
+             for (int i = 0, size = transformsCopy.size(); i < size; i++) {
+                 if (!(transformsCopy.get(i) instanceof Transform)) {
+@@ -129,10 +143,9 @@
+                         ("appliedTransforms["+i+"] is not a valid type");
+                 }
+             }
+-            this.appliedTransforms =
+-                Collections.unmodifiableList(transformsCopy);
++            this.allTransforms = transformsCopy;
+         }
+-        if (transforms == null || transforms.isEmpty()) {
++        if (transforms == null) {
+             this.transforms = Collections.EMPTY_LIST;
+         } else {
+             List transformsCopy = new ArrayList(transforms);
+@@ -142,11 +155,9 @@
+                         ("transforms["+i+"] is not a valid type");
+                 }
+             }
+-            this.transforms = Collections.unmodifiableList(transformsCopy);
++            this.transforms = transformsCopy;
++            this.allTransforms.addAll(transformsCopy);
+         }
+-        List all = new ArrayList(this.appliedTransforms);
+-        all.addAll(this.transforms);
+-        this.allTransforms = Collections.unmodifiableList(all);
+         this.digestMethod = dm;
+         this.uri = uri;
+         if ((uri != null) && (!uri.equals(""))) {
+@@ -163,6 +174,7 @@
+             this.digested = true;
+         }
+         this.appliedTransformData = result;
++        this.provider = provider;
+     }
+ 
+     /**
+@@ -170,15 +182,16 @@
+      *
+      * @param refElem a Reference element
+      */
+-    public DOMReference(Element refElem, XMLCryptoContext context)
+-        throws MarshalException {
++    public DOMReference(Element refElem, XMLCryptoContext context,
++        Provider provider) throws MarshalException {
+         // unmarshal Transforms, if specified
+         Element nextSibling = DOMUtils.getFirstChildElement(refElem);
+         List transforms = new ArrayList(5);
+         if (nextSibling.getLocalName().equals("Transforms")) {
+             Element transformElem = DOMUtils.getFirstChildElement(nextSibling);
+             while (transformElem != null) {
+-                transforms.add(new DOMTransform(transformElem, context));
++                transforms.add
++                    (new DOMTransform(transformElem, context, provider));
+                 transformElem = DOMUtils.getNextSiblingElement(transformElem);
+             }
+             nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
+@@ -203,15 +216,10 @@
+         this.type = DOMUtils.getAttributeValue(refElem, "Type");
+         this.here = refElem.getAttributeNodeNS(null, "URI");
+         this.refElem = refElem;
+-
+-        if (transforms.isEmpty()) {
+-            this.transforms = Collections.EMPTY_LIST;
+-        } else {
+-            this.transforms = Collections.unmodifiableList(transforms);
+-        }
+-        this.appliedTransforms = Collections.EMPTY_LIST;
++        this.transforms = transforms;
+         this.allTransforms = transforms;
+         this.appliedTransformData = null;
++        this.provider = provider;
+     }
+ 
+     public DigestMethod getDigestMethod() {
+@@ -231,7 +239,7 @@
+     }
+ 
+     public List getTransforms() {
+-        return allTransforms;
++        return Collections.unmodifiableList(allTransforms);
+     }
+ 
+     public byte[] getDigestValue() {
+@@ -259,17 +267,13 @@
+         DOMUtils.setAttribute(refElem, "Type", type);
+ 
+         // create and append Transforms element
+-        if (!transforms.isEmpty() || !appliedTransforms.isEmpty()) {
++        if (!allTransforms.isEmpty()) {
+             Element transformsElem = DOMUtils.createElement
+                 (ownerDoc, "Transforms", XMLSignature.XMLNS, dsPrefix);
+             refElem.appendChild(transformsElem);
+-            for (int i = 0, size = appliedTransforms.size(); i < size; i++) {
++            for (int i = 0, size = allTransforms.size(); i < size; i++) {
+                 DOMStructure transform =
+-                    (DOMStructure) appliedTransforms.get(i);
+-                transform.marshal(transformsElem, dsPrefix, context);
+-            }
+-            for (int i = 0, size = transforms.size(); i < size; i++) {
+-                DOMStructure transform = (DOMStructure) transforms.get(i);
++                    (DOMStructure) allTransforms.get(i);
+                 transform.marshal(transformsElem, dsPrefix, context);
+             }
+         }
+@@ -416,21 +420,62 @@
+         try {
+             if (data != null) {
+                 XMLSignatureInput xi;
++                // explicitly use C14N 1.1 when generating signature
++                // first check system property, then context property
++                boolean c14n11 = useC14N11;
++                String c14nalg = CanonicalizationMethod.INCLUSIVE;
++                if (context instanceof XMLSignContext) {
++                    if (!c14n11) {
++                        Boolean prop = (Boolean) context.getProperty
++                            ("com.sun.org.apache.xml.internal.security.useC14N11");
++                        c14n11 = (prop != null && prop.booleanValue() == true);
++                        if (c14n11) {
++                            c14nalg = "http://www.w3.org/2006/12/xml-c14n11";
++                        }
++                    } else {
++                        c14nalg = "http://www.w3.org/2006/12/xml-c14n11";
++                    }
++                }
+                 if (data instanceof ApacheData) {
+                     xi = ((ApacheData) data).getXMLSignatureInput();
+                 } else if (data instanceof OctetStreamData) {
+                     xi = new XMLSignatureInput
+                         (((OctetStreamData)data).getOctetStream());
+                 } else if (data instanceof NodeSetData) {
+-                    TransformService spi = TransformService.getInstance
+-                        (CanonicalizationMethod.INCLUSIVE, "DOM");
++                    TransformService spi = null;
++                    try {
++                        spi = TransformService.getInstance(c14nalg, "DOM");
++                    } catch (NoSuchAlgorithmException nsae) {
++                        spi = TransformService.getInstance
++                            (c14nalg, "DOM", provider);
++                    }
+                     data = spi.transform(data, context);
+                     xi = new XMLSignatureInput
+                         (((OctetStreamData)data).getOctetStream());
+                 } else {
+                     throw new XMLSignatureException("unrecognized Data type");
+                 }
+-                xi.updateOutputStream(os);
++                if (context instanceof XMLSignContext && c14n11
++                    && !xi.isOctetStream() && !xi.isOutputStreamSet()) {
++                    DOMTransform t = new DOMTransform
++                        (TransformService.getInstance(c14nalg, "DOM"));
++                    Element transformsElem = null;
++                    String dsPrefix = DOMUtils.getSignaturePrefix(context);
++                    if (allTransforms.isEmpty()) {
++                        transformsElem = DOMUtils.createElement(
++                            refElem.getOwnerDocument(),
++                            "Transforms", XMLSignature.XMLNS, dsPrefix);
++                        refElem.insertBefore(transformsElem,
++                            DOMUtils.getFirstChildElement(refElem));
++                    } else {
++                        transformsElem = DOMUtils.getFirstChildElement(refElem);
++                    }
++                    t.marshal(transformsElem, dsPrefix, (DOMCryptoContext) context);
++                    allTransforms.add(t);
++                    xi.updateOutputStream(os, true);
++                } else {
++                    xi.updateOutputStream(os);
++                }
+             }
+             os.flush();
+             if (cache != null && cache.booleanValue() == true) {
+@@ -466,7 +511,7 @@
+             Arrays.equals(digestValue, oref.getDigestValue());
+ 
+         return (digestMethod.equals(oref.getDigestMethod()) && idsEqual &&
+-            urisEqual && typesEqual && transforms.equals(oref.getTransforms()));
++            urisEqual && typesEqual && allTransforms.equals(oref.getTransforms()));
+     }
+ 
+     boolean isDigested() {
+@@ -486,7 +531,7 @@
+                     };
+                 } catch (Exception e) {
+                     // log a warning
+-                    log.log(Level.WARNING,
++                            log.log(Level.WARNING,
+                         "cannot cache dereferenced data: " + e);
+                     return null;
+                 }
+@@ -499,7 +544,7 @@
+                   (xsi.getOctetStream(), xsi.getSourceURI(), xsi.getMIMEType());
+                 } catch (IOException ioe) {
+                     // log a warning
+-                    log.log(Level.WARNING,
++                            log.log(Level.WARNING,
+                         "cannot cache dereferenced data: " + ioe);
+                     return null;
+                 }
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
+@@ -1,28 +1,26 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2005 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.
++ *
++ */
+ /*
+  * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+  */
+-
+ /*
+  * ===========================================================================
+  *
+@@ -31,13 +29,14 @@
+  * ===========================================================================
+  */
+ /*
+- * $Id: DOMRetrievalMethod.java,v 1.24 2005/05/12 19:28:32 mullan Exp $
++ * $Id: DOMRetrievalMethod.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+ import java.io.ByteArrayInputStream;
+ import java.net.URI;
+ import java.net.URISyntaxException;
++import java.security.Provider;
+ import java.util.*;
+ import javax.xml.crypto.*;
+ import javax.xml.crypto.dsig.*;
+@@ -116,8 +115,8 @@
+      *
+      * @param rmElem a RetrievalMethod element
+      */
+-    public DOMRetrievalMethod(Element rmElem, XMLCryptoContext context)
+-        throws MarshalException {
++    public DOMRetrievalMethod(Element rmElem, XMLCryptoContext context,
++        Provider provider) throws MarshalException {
+         // get URI and Type attributes
+         uri = DOMUtils.getAttributeValue(rmElem, "URI");
+         type = DOMUtils.getAttributeValue(rmElem, "Type");
+@@ -132,7 +131,8 @@
+             Element transformElem =
+                 DOMUtils.getFirstChildElement(transformsElem);
+             while (transformElem != null) {
+-                transforms.add(new DOMTransform(transformElem, context));
++                transforms.add
++                    (new DOMTransform(transformElem, context, provider));
+                 transformElem = DOMUtils.getNextSiblingElement(transformElem);
+             }
+         }
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
+@@ -1,32 +1,28 @@
+ /*
+- * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * Copyright  1999-2004 The Apache Software Foundation.
++ * Copyright 2005 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: DOMSignatureMethod.java,v 1.20.4.1 2005/08/12 14:23:49 mullan Exp $
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMSignatureMethod.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -226,7 +222,11 @@
+         }
+         if (signature == null) {
+             try {
+-                signature = Signature.getInstance(getSignatureAlgorithm());
++                Provider p = (Provider) context.getProperty
++                    ("org.jcp.xml.dsig.internal.dom.SignatureProvider");
++                signature = (p == null)
++                    ? Signature.getInstance(getSignatureAlgorithm())
++                    : Signature.getInstance(getSignatureAlgorithm(), p);
+             } catch (NoSuchAlgorithmException nsae) {
+                 throw new XMLSignatureException(nsae);
+             }
+@@ -274,7 +274,11 @@
+         }
+         if (signature == null) {
+             try {
+-                signature = Signature.getInstance(getSignatureAlgorithm());
++                Provider p = (Provider) context.getProperty
++                    ("org.jcp.xml.dsig.internal.dom.SignatureProvider");
++                signature = (p == null)
++                    ? Signature.getInstance(getSignatureAlgorithm())
++                    : Signature.getInstance(getSignatureAlgorithm(), p);
+             } catch (NoSuchAlgorithmException nsae) {
+                 throw new XMLSignatureException(nsae);
+             }
+@@ -302,7 +306,7 @@
+ 
+     /**
+      * Marshals the algorithm-specific parameters to an Element and
+-     * appends it to the specified parent element.  By default, this method
++     * appends it to the specified parent element. By default, this method
+      * throws an exception since most SignatureMethod algorithms do not have
+      * parameters. Subclasses should override it if they have parameters.
+      *
+@@ -360,7 +364,6 @@
+     private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[])
+         throws IOException {
+ 
+-        // THIS CODE IS COPIED FROM APACHE (see copyright at top of file)
+         byte rLength = asn1Bytes[3];
+         int i;
+ 
+@@ -401,7 +404,6 @@
+     private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[])
+         throws IOException {
+ 
+-        // THIS CODE IS COPIED FROM APACHE (see copyright at top of file)
+         if (xmldsigBytes.length != 40) {
+             throw new IOException("Invalid XMLDSIG format of DSA signature");
+         }
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMSignatureProperties.java,v 1.12 2005/05/12 19:28:32 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMSignatureProperties.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMSignatureProperty.java,v 1.14 2005/05/12 19:28:32 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMSignatureProperty.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMSignedInfo.java,v 1.30 2005/09/23 20:14:07 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMSignedInfo.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -37,6 +36,7 @@
+ import java.io.IOException;
+ import java.io.InputStreamReader;
+ import java.io.OutputStream;
++import java.security.Provider;
+ import java.util.*;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
+@@ -126,8 +126,8 @@
+      *
+      * @param siElem a SignedInfo element
+      */
+-    public DOMSignedInfo(Element siElem, XMLCryptoContext context)
+-        throws MarshalException {
++    public DOMSignedInfo(Element siElem, XMLCryptoContext context,
++        Provider provider) throws MarshalException {
+         localSiElem = siElem;
+         ownerDoc = siElem.getOwnerDocument();
+ 
+@@ -136,7 +136,8 @@
+ 
+         // unmarshal CanonicalizationMethod
+         Element cmElem = DOMUtils.getFirstChildElement(siElem);
+-        canonicalizationMethod = new DOMCanonicalizationMethod(cmElem, context);
++        canonicalizationMethod = new DOMCanonicalizationMethod
++            (cmElem, context, provider);
+ 
+         // unmarshal SignatureMethod
+         Element smElem = DOMUtils.getNextSiblingElement(cmElem);
+@@ -146,7 +147,7 @@
+         ArrayList refList = new ArrayList(5);
+         Element refElem = DOMUtils.getNextSiblingElement(smElem);
+         while (refElem != null) {
+-            refList.add(new DOMReference(refElem, context));
++            refList.add(new DOMReference(refElem, context, provider));
+             refElem = DOMUtils.getNextSiblingElement(refElem);
+         }
+         references = Collections.unmodifiableList(refList);
+@@ -188,9 +189,8 @@
+ 
+         DOMSubTreeData subTree = new DOMSubTreeData(localSiElem, true);
+ 
+-        OctetStreamData data = null;
+         try {
+-            data = (OctetStreamData) ((DOMCanonicalizationMethod)
++            Data data = ((DOMCanonicalizationMethod)
+                 canonicalizationMethod).canonicalize(subTree, context, os);
+         } catch (TransformException te) {
+             throw new XMLSignatureException(te);
+@@ -205,9 +205,11 @@
+             char[] siBytes = new char[signedInfoBytes.length];
+             try {
+                 isr.read(siBytes);
+-            } catch (IOException ioex) {} //ignore since this is logging code
+-            log.log(Level.FINE, "Canonicalized SignedInfo:\n"
+-                + new String(siBytes));
++                log.log(Level.FINE, "Canonicalized SignedInfo:\n"
++                    + new String(siBytes));
++            } catch (IOException ioex) {
++                log.log(Level.FINE, "IOException reading SignedInfo bytes");
++            }
+             log.log(Level.FINE, "Data to be signed/verified:"
+                 + Base64.encode(signedInfoBytes));
+         }
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMStructure.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMStructure.java,v 1.11 2005/05/10 18:15:34 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMStructure.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSubTreeData.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMSubTreeData.java,v 1.2 2005/09/15 14:29:04 mullan Exp $
++ * Copyright 2006 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMSubTreeData.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMTransform.java
+@@ -1,35 +1,35 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMTransform.java,v 1.25 2005/05/10 18:15:34 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMTransform.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+ import java.io.OutputStream;
+ import java.security.InvalidAlgorithmParameterException;
+ import java.security.NoSuchAlgorithmException;
++import java.security.Provider;
+ import java.security.spec.AlgorithmParameterSpec;
+ 
+ import org.w3c.dom.Document;
+@@ -68,14 +68,17 @@
+      *
+      * @param transElem a Transform element
+      */
+-    public DOMTransform(Element transElem, XMLCryptoContext context)
+-        throws MarshalException {
+-        Document ownerDoc = transElem.getOwnerDocument();
++    public DOMTransform(Element transElem, XMLCryptoContext context,
++        Provider provider) throws MarshalException {
+         String algorithm = DOMUtils.getAttributeValue(transElem, "Algorithm");
+         try {
+             spi = TransformService.getInstance(algorithm, "DOM");
+-        } catch (NoSuchAlgorithmException e) {
+-            throw new MarshalException(e);
++        } catch (NoSuchAlgorithmException e1) {
++            try {
++                spi = TransformService.getInstance(algorithm, "DOM", provider);
++            } catch (NoSuchAlgorithmException e2) {
++                throw new MarshalException(e2);
++            }
+         }
+         try {
+             spi.init(new javax.xml.crypto.dom.DOMStructure(transElem), context);
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMURIDereferencer.java,v 1.19 2005/09/23 20:09:34 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMURIDereferencer.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -83,11 +82,9 @@
+             // this is a bit of a hack to check for registered
+             // IDRefs and manually register them with Apache's IdResolver
+             // map which includes builtin schema knowledge of DSig/Enc IDs
+-            if (context instanceof XMLSignContext) {
+-                Node referencedElem = dcc.getElementById(id);
+-                if (referencedElem != null) {
+-                    IdResolver.registerElementById((Element) referencedElem, id);
+-                }
++            Node referencedElem = dcc.getElementById(id);
++            if (referencedElem != null) {
++                IdResolver.registerElementById((Element) referencedElem, id);
+             }
+         }
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMUtils.java,v 1.18 2005/05/12 19:28:34 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMUtils.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -77,7 +76,8 @@
+      */
+     public static Element createElement(Document doc, String tag, String nsURI,
+         String prefix) {
+-        String qName = prefix == null ? tag : prefix + ":" + tag;
++        String qName = (prefix == null || prefix.length() == 0)
++                       ? tag : prefix + ":" + tag;
+         return doc.createElementNS(nsURI, qName);
+     }
+ 
+@@ -327,6 +327,7 @@
+             XPathType type = (XPathType) types.get(i);
+             XPathType otype = (XPathType) otypes.get(i);
+             if (!type.getExpression().equals(otype.getExpression()) ||
++                !type.getNamespaceMap().equals(otype.getNamespaceMap()) ||
+                 type.getFilter() != otype.getFilter()) {
+                 return false;
+             }
+@@ -341,8 +342,8 @@
+ 
+     private static boolean paramsEqual(XPathFilterParameterSpec spec1,
+         XPathFilterParameterSpec spec2) {
+-
+-        return spec1.getXPath().equals(spec2.getXPath());
++        return (spec1.getXPath().equals(spec2.getXPath()) &&
++            spec1.getNamespaceMap().equals(spec2.getNamespaceMap()));
+     }
+ 
+     private static boolean paramsEqual(XSLTTransformParameterSpec spec1,
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509Data.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMX509Data.java,v 1.20 2005/05/12 19:28:34 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMX509Data.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -53,7 +52,7 @@
+ public final class DOMX509Data extends DOMStructure implements X509Data {
+ 
+     private final List content;
+-    private CertificateFactory cf; //FIX - make this static?
++    private CertificateFactory cf;
+ 
+     /**
+      * Creates a DOMX509Data.
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMX509IssuerSerial.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMX509IssuerSerial.java,v 1.13 2005/05/10 18:15:35 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMX509IssuerSerial.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMXMLObject.java,v 1.16 2005/05/12 19:28:35 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMXMLObject.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -31,6 +30,7 @@
+ import javax.xml.crypto.dom.DOMCryptoContext;
+ import javax.xml.crypto.dsig.*;
+ 
++import java.security.Provider;
+ import java.util.*;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+@@ -87,8 +87,8 @@
+      * @param objElem an Object element
+      * @throws MarshalException if there is an error when unmarshalling
+      */
+-    public DOMXMLObject(Element objElem, XMLCryptoContext context)
+-        throws MarshalException {
++    public DOMXMLObject(Element objElem, XMLCryptoContext context,
++        Provider provider) throws MarshalException {
+         // unmarshal attributes
+         this.encoding = DOMUtils.getAttributeValue(objElem, "Encoding");
+         this.id = DOMUtils.getAttributeValue(objElem, "Id");
+@@ -103,7 +103,7 @@
+                 Element childElem = (Element) child;
+                 String tag = childElem.getLocalName();
+                 if (tag.equals("Manifest")) {
+-                    content.add(new DOMManifest(childElem, context));
++                    content.add(new DOMManifest(childElem, context, provider));
+                     continue;
+                 } else if (tag.equals("SignatureProperties")) {
+                     content.add(new DOMSignatureProperties(childElem));
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
+@@ -1,28 +1,26 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2005 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.
++ *
++ */
+ /*
+  * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+  */
+-
+ /*
+  * ===========================================================================
+  *
+@@ -31,7 +29,7 @@
+  * ===========================================================================
+  */
+ /*
+- * $Id: DOMXMLSignature.java,v 1.42 2005/09/23 20:29:04 mullan Exp $
++ * $Id: DOMXMLSignature.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -45,6 +43,7 @@
+ import java.io.*;
+ import java.security.InvalidKeyException;
+ import java.security.Key;
++import java.security.Provider;
+ import java.util.Collections;
+ import java.util.ArrayList;
+ import java.util.HashMap;
+@@ -128,8 +127,8 @@
+      * @param sigElem Signature element
+      * @throws MarshalException if XMLSignature cannot be unmarshalled
+      */
+-    public DOMXMLSignature(Element sigElem, XMLCryptoContext context)
+-        throws MarshalException {
++    public DOMXMLSignature(Element sigElem, XMLCryptoContext context,
++        Provider provider) throws MarshalException {
+         localSigElem = sigElem;
+         ownerDoc = localSigElem.getOwnerDocument();
+ 
+@@ -138,7 +137,7 @@
+ 
+         // unmarshal SignedInfo
+         Element siElem = DOMUtils.getFirstChildElement(localSigElem);
+-        si = new DOMSignedInfo(siElem, context);
++        si = new DOMSignedInfo(siElem, context, provider);
+ 
+         // unmarshal SignatureValue
+         Element sigValElem = DOMUtils.getNextSiblingElement(siElem);
+@@ -147,7 +146,7 @@
+         // unmarshal KeyInfo, if specified
+         Element nextSibling = DOMUtils.getNextSiblingElement(sigValElem);
+         if (nextSibling != null && nextSibling.getLocalName().equals("KeyInfo")) {
+-            ki = new DOMKeyInfo(nextSibling, context);
++            ki = new DOMKeyInfo(nextSibling, context, provider);
+             nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
+         }
+ 
+@@ -157,7 +156,8 @@
+         } else {
+             List tempObjects = new ArrayList();
+             while (nextSibling != null) {
+-                tempObjects.add(new DOMXMLObject(nextSibling, context));
++                tempObjects.add
++                    (new DOMXMLObject(nextSibling, context, provider));
+                 nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
+             }
+             objects = Collections.unmodifiableList(tempObjects);
+@@ -201,9 +201,7 @@
+             (ownerDoc, "Signature", XMLSignature.XMLNS, dsPrefix);
+ 
+         // append xmlns attribute
+-        //XXX I think this is supposed to be automatically inserted when
+-        //XXX serializing a DOM2 tree, but doesn't seem to work with JAXP/Xalan
+-        if (dsPrefix == null) {
++        if (dsPrefix == null || dsPrefix.length() == 0) {
+             sigElem.setAttributeNS
+                 ("http://www.w3.org/2000/xmlns/", "xmlns", XMLSignature.XMLNS);
+         } else {
+@@ -301,7 +299,7 @@
+                             Reference ref = (Reference) manRefs.get(k);
+                             boolean refValid = ref.validate(vc);
+                             if (log.isLoggable(Level.FINE)) {
+-                               log.log(Level.FINE, "Manifest ref["
++                                log.log(Level.FINE, "Manifest ref["
+                                     + ref.getURI() + "] is valid: " + refValid);
+                             }
+                             validateMans &= refValid;
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignatureFactory.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMXMLSignatureFactory.java,v 1.21 2005/09/23 19:59:11 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMXMLSignatureFactory.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -33,7 +32,8 @@
+ import javax.xml.crypto.dsig.keyinfo.*;
+ import javax.xml.crypto.dsig.spec.*;
+ 
+-import java.security.*;
++import java.security.InvalidAlgorithmParameterException;
++import java.security.NoSuchAlgorithmException;
+ import java.security.spec.AlgorithmParameterSpec;
+ import java.util.List;
+ import org.w3c.dom.Document;
+@@ -67,7 +67,7 @@
+ 
+     public Reference newReference(String uri, DigestMethod dm, List transforms,
+         String type, String id) {
+-        return new DOMReference(uri, type, dm, transforms, id);
++        return new DOMReference(uri, type, dm, transforms, id, getProvider());
+     }
+ 
+     public Reference newReference(String uri, DigestMethod dm,
+@@ -83,7 +83,7 @@
+             throw new NullPointerException("result cannot be null");
+         }
+         return new DOMReference
+-            (uri, type, dm, appliedTransforms, result, transforms, id);
++            (uri, type, dm, appliedTransforms, result, transforms, id, getProvider());
+     }
+ 
+     public Reference newReference(String uri, DigestMethod dm, List transforms,
+@@ -92,7 +92,7 @@
+             throw new NullPointerException("digestValue cannot be null");
+         }
+         return new DOMReference
+-            (uri, type, dm, null, null, transforms, id, digestValue);
++            (uri, type, dm, null, null, transforms, id, digestValue, getProvider());
+     }
+ 
+     public SignedInfo newSignedInfo(CanonicalizationMethod cm,
+@@ -170,7 +170,7 @@
+                 "support DOM Level 2 and be namespace aware");
+         }
+         if (tag.equals("Signature")) {
+-            return new DOMXMLSignature(element, context);
++            return new DOMXMLSignature(element, context, getProvider());
+         } else {
+             throw new MarshalException("invalid Signature tag: " + tag);
+         }
+@@ -235,7 +235,12 @@
+     public Transform newTransform(String algorithm,
+         TransformParameterSpec params) throws NoSuchAlgorithmException,
+         InvalidAlgorithmParameterException {
+-        TransformService spi = TransformService.getInstance(algorithm, "DOM");
++        TransformService spi;
++        try {
++            spi = TransformService.getInstance(algorithm, "DOM");
++        } catch (NoSuchAlgorithmException nsae) {
++            spi = TransformService.getInstance(algorithm, "DOM", getProvider());
++        }
+         spi.init(params);
+         return new DOMTransform(spi);
+     }
+@@ -243,7 +248,12 @@
+     public Transform newTransform(String algorithm,
+         XMLStructure params) throws NoSuchAlgorithmException,
+         InvalidAlgorithmParameterException {
+-        TransformService spi = TransformService.getInstance(algorithm, "DOM");
++        TransformService spi;
++        try {
++            spi = TransformService.getInstance(algorithm, "DOM");
++        } catch (NoSuchAlgorithmException nsae) {
++            spi = TransformService.getInstance(algorithm, "DOM", getProvider());
++        }
+         if (params == null) {
+             spi.init(null);
+         } else {
+@@ -255,7 +265,12 @@
+     public CanonicalizationMethod newCanonicalizationMethod(String algorithm,
+         C14NMethodParameterSpec params) throws NoSuchAlgorithmException,
+         InvalidAlgorithmParameterException {
+-        TransformService spi = TransformService.getInstance(algorithm, "DOM");
++        TransformService spi;
++        try {
++            spi = TransformService.getInstance(algorithm, "DOM");
++        } catch (NoSuchAlgorithmException nsae) {
++            spi = TransformService.getInstance(algorithm, "DOM", getProvider());
++        }
+         spi.init(params);
+         return new DOMCanonicalizationMethod(spi);
+     }
+@@ -263,7 +278,12 @@
+     public CanonicalizationMethod newCanonicalizationMethod(String algorithm,
+         XMLStructure params) throws NoSuchAlgorithmException,
+         InvalidAlgorithmParameterException {
+-        TransformService spi = TransformService.getInstance(algorithm, "DOM");
++        TransformService spi;
++        try {
++            spi = TransformService.getInstance(algorithm, "DOM");
++        } catch (NoSuchAlgorithmException nsae) {
++            spi = TransformService.getInstance(algorithm, "DOM", getProvider());
++        }
+         if (params == null) {
+             spi.init(null);
+         } else {
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathFilter2Transform.java
+@@ -1,28 +1,23 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2005 The Apache Software Foundation.
+  *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
++ *  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
+  *
+- * 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).
++ *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+- * 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.
++ *  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.
+  *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+  */
+-
+ /*
+  * ===========================================================================
+  *
+@@ -31,7 +26,10 @@
+  * ===========================================================================
+  */
+ /*
+- * $Id: DOMXPathFilter2Transform.java,v 1.18 2005/09/19 18:30:30 mullan Exp $
++ * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMXPathFilter2Transform.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -129,7 +127,8 @@
+         XPathFilter2ParameterSpec xp =
+             (XPathFilter2ParameterSpec) getParameterSpec();
+         String prefix = DOMUtils.getNSPrefix(context, Transform.XPATH2);
+-        String qname = (prefix == null) ? "xmlns" : "xmlns:" + prefix;
++        String qname = (prefix == null || prefix.length() == 0)
++                       ? "xmlns" : "xmlns:" + prefix;
+         List list = xp.getXPathList();
+         for (int i = 0, size = list.size(); i < size; i++) {
+             XPathType xpathType = (XPathType) list.get(i);
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXPathTransform.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMXPathTransform.java,v 1.16 2005/05/12 19:28:35 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMXPathTransform.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXSLTTransform.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: DOMXSLTTransform.java,v 1.15 2005/05/10 18:15:36 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: DOMXSLTTransform.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java
+@@ -1,29 +1,28 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
+  */
+ /*
+- * $Id: Utils.java,v 1.14 2005/09/23 19:49:20 mullan Exp $
++ * Copyright 2005 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.
++ *
++ */
++/*
++ * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: Utils.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/XMLDSigRI.java
+@@ -1,28 +1,23 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/*
++ * Copyright 2005 The Apache Software Foundation.
+  *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
++ *  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
+  *
+- * 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).
++ *      http://www.apache.org/licenses/LICENSE-2.0
+  *
+- * 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.
++ *  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.
+  *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+  */
+-
+ /*
+  * ===========================================================================
+  *
+@@ -31,7 +26,10 @@
+  * ===========================================================================
+  */
+ /*
+- * $Id: XMLDSigRI.java,v 1.7 2005/05/12 19:28:36 mullan Exp $
++ * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
++ */
++/*
++ * $Id: XMLDSigRI.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
+  */
+ package org.jcp.xml.dsig.internal.dom;
+ 
+@@ -86,6 +84,22 @@
+                 CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS +
+                 " MechanismType", "DOM");
+ 
++        // Inclusive C14N 1.1
++        map.put((String)"TransformService." +
++                "http://www.w3.org/2006/12/xml-c14n11",
++                "org.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14N11Method");
++        map.put((String)"TransformService." +
++                "http://www.w3.org/2006/12/xml-c14n11" +
++                " MechanismType", "DOM");
++
++        // InclusiveWithComments C14N 1.1
++        map.put((String)"TransformService." +
++                "http://www.w3.org/2006/12/xml-c14n11#WithComments",
++                "org.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14N11Method");
++        map.put((String)"TransformService." +
++                "http://www.w3.org/2006/12/xml-c14n11#WithComments" +
++                " MechanismType", "DOM");
++
+         // Exclusive C14N
+         map.put((String) "TransformService." + CanonicalizationMethod.EXCLUSIVE,
+                 "org.jcp.xml.dsig.internal.dom.DOMExcC14NMethod");
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/package.html b/src/share/classes/org/jcp/xml/dsig/internal/package.html
+deleted file mode 100644
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/package.html
++++ /dev/null
+@@ -1,5 +0,0 @@
+-<html>
+-<body>
+-Contains the classes of the Reference Implementation of JSR 105.
+-</body>
+-</html>
+diff --git a/test/javax/xml/crypto/dsig/GenerationTests.java b/test/javax/xml/crypto/dsig/GenerationTests.java
+--- openjdk/jdk/test/javax/xml/crypto/dsig/GenerationTests.java
++++ openjdk/jdk/test/javax/xml/crypto/dsig/GenerationTests.java
+@@ -90,6 +90,7 @@
+     private static Certificate signingCert;
+     private static KeyStore ks;
+     private final static String DIR = System.getProperty("test.src", ".");
++//    private final static String DIR = ".";
+     private final static String DATA_DIR =
+         DIR + System.getProperty("file.separator") + "data";
+     private final static String KEYSTORE =
+@@ -200,6 +201,9 @@
+         DOMSignContext dsc = new DOMSignContext(signingKey, envelope);
+ 
+         sig.sign(dsc);
++//      StringWriter sw = new StringWriter();
++//      dumpDocument(doc, sw);
++//      System.out.println(sw.toString());
+ 
+         DOMValidateContext dvc = new DOMValidateContext
+             (kvks, envelope.getFirstChild());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6656651-windows_lcd_glyphs.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,938 @@
+diff -Nru openjdk.orig/jdk/make/sun/font/FILES_c.gmk openjdk/jdk/make/sun/font/FILES_c.gmk
+--- openjdk.orig/jdk/make/sun/font/FILES_c.gmk	2013-06-21 19:10:28.473006180 -0500
++++ openjdk/jdk/make/sun/font/FILES_c.gmk	2013-06-21 19:11:27.994043654 -0500
+@@ -114,7 +114,9 @@
+ 
+ 
+ ifeq ($(PLATFORM),windows)
+-FILES_c_platform = fontpath.c
++FILES_c_platform = fontpath.c \
++                   lcdglyph.c
++
+ FILES_cpp_platform =
+ else
+ FILES_c_platform = X11FontScaler.c \
+diff -Nru openjdk.orig/jdk/make/sun/font/Makefile openjdk/jdk/make/sun/font/Makefile
+--- openjdk.orig/jdk/make/sun/font/Makefile	2013-06-21 19:10:28.473006180 -0500
++++ openjdk/jdk/make/sun/font/Makefile	2013-06-21 19:11:05.272031592 -0500
+@@ -63,6 +63,7 @@
+     java/awt/Font.java \
+     java/text/Bidi.java \
+     sun/font/FileFont.java \
++    sun/font/FileFontStrike.java \
+     sun/font/FontManager.java \
+     sun/font/GlyphList.java \
+     sun/font/NativeFont.java \
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/font/FileFontStrike.java openjdk/jdk/src/share/classes/sun/font/FileFontStrike.java
+--- openjdk.orig/jdk/src/share/classes/sun/font/FileFontStrike.java	2011-11-14 16:11:59.000000000 -0600
++++ openjdk/jdk/src/share/classes/sun/font/FileFontStrike.java	2013-06-21 19:11:05.273031593 -0500
+@@ -27,6 +27,7 @@
+ 
+ import java.lang.ref.SoftReference;
+ import java.awt.Font;
++import java.awt.GraphicsEnvironment;
+ import java.awt.Rectangle;
+ import java.awt.geom.AffineTransform;
+ import java.awt.geom.GeneralPath;
+@@ -105,6 +106,19 @@
+     boolean useNatives;
+     NativeStrike[] nativeStrikes;
+ 
++    /* Used only for communication to native layer */
++    private int intPtSize;
++
++    /* Perform global initialisation needed for Windows native rasterizer */
++    private static native boolean initNative();
++    private static boolean isXPorLater = false;
++    static {
++        if (FontManager.isWindows && !FontManager.useT2K &&
++            !GraphicsEnvironment.isHeadless()) {
++            isXPorLater = initNative();
++        }
++    }
++
+     FileFontStrike(FileFont fileFont, FontStrikeDesc desc) {
+         super(fileFont, desc);
+         this.fileFont = fileFont;
+@@ -165,7 +179,7 @@
+          * should not segment unless there's another reason to do so.
+          */
+         float ptSize = (float)matrix[3]; // interpreted only when meaningful.
+-        int iSize = (int)ptSize;
++        int iSize = intPtSize = (int)ptSize;
+         boolean isSimpleTx = (at.getType() & complexTX) == 0;
+         segmentedCache =
+             (numGlyphs > SEGSIZE << 3) ||
+@@ -189,8 +203,26 @@
+             FontManager.deRegisterBadFont(fileFont);
+             return;
+         }
+-
+-        if (fileFont.checkUseNatives() && desc.aaHint==0 && !algoStyle) {
++        /* First, see if native code should be used to create the glyph.
++         * GDI will return the integer metrics, not fractional metrics, which
++         * may be requested for this strike, so we would require here that :
++         * desc.fmHint != INTVAL_FRACTIONALMETRICS_ON
++         * except that the advance returned by GDI is always overwritten by
++         * the JDK rasteriser supplied one (see getGlyphImageFromWindows()).
++         */
++        if (FontManager.isWindows && isXPorLater &&
++            !FontManager.useT2K &&
++            !GraphicsEnvironment.isHeadless() &&
++            !fileFont.useJavaRasterizer &&
++            (desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HRGB ||
++             desc.aaHint == INTVAL_TEXT_ANTIALIAS_LCD_HBGR) &&
++            (matrix[1] == 0.0 && matrix[2] == 0.0 &&
++             matrix[0] == matrix[3] &&
++             matrix[0] >= 3.0 && matrix[0] <= 100.0) &&
++            !((TrueTypeFont)fileFont).useEmbeddedBitmapsForSize(intPtSize)) {
++            useNatives = true;
++        }
++        else if (fileFont.checkUseNatives() && desc.aaHint==0 && !algoStyle) {
+             /* Check its a simple scale of a pt size in the range
+              * where native bitmaps typically exist (6-36 pts) */
+             if (matrix[1] == 0.0 && matrix[2] == 0.0 &&
+@@ -208,7 +240,16 @@
+                 }
+             }
+         }
+-
++        if (FontManager.logging && FontManager.isWindows) {
++            FontManager.logger.info
++                ("Strike for " + fileFont + " at size = " + intPtSize +
++                 " use natives = " + useNatives +
++                 " useJavaRasteriser = " + fileFont.useJavaRasterizer +
++                 " AAHint = " + desc.aaHint +
++                 " Has Embedded bitmaps = " +
++                 ((TrueTypeFont)fileFont).
++                 useEmbeddedBitmapsForSize(intPtSize));
++        }
+         this.disposer = new FontStrikeDisposer(fileFont, desc, pScalerContext);
+ 
+         /* Always get the image and the advance together for smaller sizes
+@@ -250,8 +291,50 @@
+         return fileFont.getNumGlyphs();
+     }
+ 
+-    /* Try the native strikes first, then try the fileFont strike */
+     long getGlyphImageFromNative(int glyphCode) {
++        if (FontManager.isWindows) {
++            return getGlyphImageFromWindows(glyphCode);
++        } else {
++            return getGlyphImageFromX11(glyphCode);
++        }
++    }
++
++    /* There's no global state conflicts, so this method is not
++     * presently synchronized.
++     */
++    private native long _getGlyphImageFromWindows(String family,
++                                                  int style,
++                                                  int size,
++                                                  int glyphCode,
++                                                  boolean fracMetrics);
++
++    long getGlyphImageFromWindows(int glyphCode) {
++        String family = fileFont.getFamilyName(null);
++        int style = desc.style & Font.BOLD | desc.style & Font.ITALIC
++            | fileFont.getStyle();
++        int size = intPtSize;
++        long ptr = _getGlyphImageFromWindows
++            (family, style, size, glyphCode,
++             desc.fmHint == INTVAL_FRACTIONALMETRICS_ON);
++        if (ptr != 0) {
++            /* Get the advance from the JDK rasterizer. This is mostly
++             * necessary for the fractional metrics case, but there are
++             * also some very small number (<0.25%) of marginal cases where
++             * there is some rounding difference between windows and JDK.
++             * After these are resolved, we can restrict this extra
++             * work to the FM case.
++             */
++            float advance = getGlyphAdvance(glyphCode, false);
++            StrikeCache.unsafe.putFloat(ptr + StrikeCache.xAdvanceOffset,
++                                        advance);
++            return ptr;
++        } else {
++            return fileFont.getGlyphImage(pScalerContext, glyphCode);
++        }
++    }
++
++    /* Try the native strikes first, then try the fileFont strike */
++    long getGlyphImageFromX11(int glyphCode) {
+         long glyphPtr;
+         char charCode = fileFont.glyphToCharMap[glyphCode];
+         for (int i=0;i<nativeStrikes.length;i++) {
+@@ -271,13 +354,19 @@
+         if (glyphCode >= INVISIBLE_GLYPHS) {
+             return StrikeCache.invisibleGlyphPtr;
+         }
+-        long glyphPtr;
++        long glyphPtr = 0L;
+         if ((glyphPtr = getCachedGlyphPtr(glyphCode)) != 0L) {
+             return glyphPtr;
+         } else {
+             if (useNatives) {
+                 glyphPtr = getGlyphImageFromNative(glyphCode);
+-            } else {
++                if (glyphPtr == 0L && FontManager.logging) {
++                    FontManager.logger.info
++                        ("Strike for " + fileFont +
++                         " at size = " + intPtSize +
++                         " couldn't get native glyph for code = " + glyphCode);
++                 }
++            } if (glyphPtr == 0L) {
+                 glyphPtr = fileFont.getGlyphImage(pScalerContext,
+                                                   glyphCode);
+             }
+@@ -295,10 +384,10 @@
+             } else if ((images[i] = getCachedGlyphPtr(glyphCode)) != 0L) {
+                 continue;
+             } else {
+-                long glyphPtr;
++                long glyphPtr = 0L;
+                 if (useNatives) {
+                     glyphPtr = getGlyphImageFromNative(glyphCode);
+-                } else {
++                } if (glyphPtr == 0L) {
+                     glyphPtr = fileFont.getGlyphImage(pScalerContext,
+                                                       glyphCode);
+                 }
+@@ -327,10 +416,11 @@
+             } else if ((images[i] = getCachedGlyphPtr(glyphCode)) != 0L) {
+                 continue;
+             } else {
+-                long glyphPtr;
++                long glyphPtr = 0L;
+                 if (useNatives) {
+                     glyphPtr = getGlyphImageFromNative(glyphCode);
+-                } else {
++                }
++                if (glyphPtr == 0L) {
+                     glyphPtr = fileFont.getGlyphImage(pScalerContext,
+                                                       glyphCode);
+                 }
+@@ -454,11 +544,16 @@
+         }
+     }
+ 
++    float getGlyphAdvance(int glyphCode) {
++        return getGlyphAdvance(glyphCode, true);
++    }
++
+     /* Metrics info is always retrieved. If the GlyphInfo address is non-zero
+      * then metrics info there is valid and can just be copied.
+-     * This is in user space coordinates.
++     * This is in user space coordinates unless getUserAdv == false.
++     * Device space advance should not be propagated out of this class.
+      */
+-    float getGlyphAdvance(int glyphCode) {
++    private float getGlyphAdvance(int glyphCode, boolean getUserAdv) {
+         float advance;
+ 
+         if (glyphCode >= INVISIBLE_GLYPHS) {
+@@ -480,11 +575,11 @@
+             }
+         }
+ 
+-        if (invertDevTx != null) {
++        if (invertDevTx != null || !getUserAdv) {
+             /* If there is a device transform need x & y advance to
+              * transform back into user space.
+              */
+-            advance = getGlyphMetrics(glyphCode).x;
++            advance = getGlyphMetrics(glyphCode, getUserAdv).x;
+         } else {
+             long glyphPtr;
+             if (getImageWithAdvance) {
+@@ -620,6 +715,10 @@
+     }
+ 
+     Point2D.Float getGlyphMetrics(int glyphCode) {
++        return getGlyphMetrics(glyphCode, true);
++    }
++
++    private Point2D.Float getGlyphMetrics(int glyphCode, boolean getUserAdv) {
+         Point2D.Float metrics = new Point2D.Float();
+ 
+         // !!! or do we force sgv user glyphs?
+@@ -627,7 +726,7 @@
+             return metrics;
+         }
+         long glyphPtr;
+-        if (getImageWithAdvance) {
++        if (getImageWithAdvance && getUserAdv) {
+             /* A heuristic optimisation says that for most cases its
+              * worthwhile retrieving the image at the same time as the
+              * metrics. So here we get the image data even if its not
+@@ -644,9 +743,9 @@
+             metrics.y = StrikeCache.unsafe.getFloat
+                 (glyphPtr + StrikeCache.yAdvanceOffset);
+             /* advance is currently in device space, need to convert back
+-             * into user space.
++             * into user space, unless getUserAdv == false.
+              * This must not include the translation component. */
+-            if (invertDevTx != null) {
++            if (invertDevTx != null && getUserAdv) {
+                 invertDevTx.deltaTransform(metrics, metrics);
+             }
+         } else {
+@@ -675,9 +774,9 @@
+             if (value == null) {
+                 fileFont.getGlyphMetrics(pScalerContext, glyphCode, metrics);
+                 /* advance is currently in device space, need to convert back
+-                 * into user space.
++                 * into user space, unless getUserAdv == false.
+                  */
+-                if (invertDevTx != null) {
++                if (invertDevTx != null && getUserAdv) {
+                     invertDevTx.deltaTransform(metrics, metrics);
+                 }
+                 value = new Point2D.Float(metrics.x, metrics.y);
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/font/FontManager.java openjdk/jdk/src/share/classes/sun/font/FontManager.java
+--- openjdk.orig/jdk/src/share/classes/sun/font/FontManager.java	2013-06-21 19:10:08.631992692 -0500
++++ openjdk/jdk/src/share/classes/sun/font/FontManager.java	2013-06-21 19:11:05.273031593 -0500
+@@ -245,9 +245,11 @@
+                osName = System.getProperty("os.name", "unknownOS");
+                isSolaris = osName.startsWith("SunOS");
+ 
+-               if (isSolaris) {
+-                   String t2kStr= System.getProperty("sun.java2d.font.scaler");
++               String t2kStr = System.getProperty("sun.java2d.font.scaler");
++               if (t2kStr != null) {
+                    useT2K = "t2k".equals(t2kStr);
++               }
++               if (isSolaris) {
+                    String version = System.getProperty("os.version", "unk");
+                    isSolaris8 = version.equals("5.8");
+                    isSolaris9 = version.equals("5.9");
+diff -Nru openjdk.orig/jdk/src/share/classes/sun/font/TrueTypeFont.java openjdk/jdk/src/share/classes/sun/font/TrueTypeFont.java
+--- openjdk.orig/jdk/src/share/classes/sun/font/TrueTypeFont.java	2011-11-14 16:11:59.000000000 -0600
++++ openjdk/jdk/src/share/classes/sun/font/TrueTypeFont.java	2013-06-21 19:11:05.274031593 -0500
+@@ -905,6 +905,31 @@
+         return null;
+     }
+ 
++    /* Used to determine if this size has embedded bitmaps, which
++     * for CJK fonts should be used in preference to LCD glyphs.
++     */
++    boolean useEmbeddedBitmapsForSize(int ptSize) {
++        if (!supportsCJK) {
++            return false;
++        }
++        if (getDirectoryEntry(EBLCTag) == null) {
++            return false;
++        }
++        ByteBuffer eblcTable = getTableBuffer(EBLCTag);
++        int numSizes = eblcTable.getInt(4);
++        /* The bitmapSizeTable's start at offset of 8.
++         * Each bitmapSizeTable entry is 48 bytes.
++         * The offset of ppemY in the entry is 45.
++         */
++        for (int i=0;i<numSizes;i++) {
++            int ppemY = eblcTable.get(8+(i*48)+45) &0xff;
++            if (ppemY == ptSize) {
++                return true;
++            }
++        }
++        return false;
++    }
++
+     public String getFullName() {
+         return fullName;
+     }
+diff -Nru openjdk.orig/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java openjdk/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
+--- openjdk.orig/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java	2013-06-21 19:10:28.836006428 -0500
++++ openjdk/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java	2013-06-21 19:11:05.274031593 -0500
+@@ -263,6 +263,7 @@
+         try {
+             while (!found && parser.hasMoreTokens()) {
+                 String newPath = parser.nextToken();
++                boolean ujr = newPath.equals(jreFontDirName);
+                 File theFile = new File(newPath, fontFileName);
+                 if (theFile.canRead()) {
+                     found = true;
+@@ -270,11 +271,11 @@
+                     if (defer) {
+                         FontManager.registerDeferredFont(fontFileName, path,
+                                                          nativeNames,
+-                                                         fontFormat, true,
++                                                         fontFormat, ujr,
+                                                          fontRank);
+                     } else {
+                         FontManager.registerFontFile(path, nativeNames,
+-                                                     fontFormat, true,
++                                                     fontFormat, ujr,
+                                                      fontRank);
+                     }
+                     break;
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/font/lcdglyph.c openjdk/jdk/src/windows/native/sun/font/lcdglyph.c
+--- openjdk.orig/jdk/src/windows/native/sun/font/lcdglyph.c	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/font/lcdglyph.c	2013-06-21 19:11:05.275031593 -0500
+@@ -0,0 +1,481 @@
++/*
++ * Copyright 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.  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.
++ */
++
++/*
++ * The function here is used to get a GDI rasterized LCD glyph and place it
++ * into the JDK glyph cache. The benefit is rendering fidelity for the
++ * most common cases, with no impact on the 2D rendering pipelines.
++ *
++ * Requires that the font and graphics are unrotated, and the scale is
++ * a simple one, and the font is a TT font registered with windows.
++ * Those conditions are established by the calling code.
++ *
++ * This code
++ * - Receives the family name, style, and size of the font
++ * and creates a Font object.
++ * - Create a surface from which we can get a DC : must be 16 bit or more.
++ * Ideally we'd be able to specify the depth of this, but in practice we
++ * have to accept it will be the same as the default screen.
++ * - Selects the GDI font on to the device
++ * - Uses GetGlyphOutline to estimate the bounds.
++ * - Creates a DIB on to which to blit the image.
++ * - Creates a GlyphInfo structure and copies the GDI glyph and offsets
++ * into the glyph which is returned.
++ */
++
++#include <stdio.h>
++#include <malloc.h>
++#include <math.h>
++#include <windows.h>
++#include <winuser.h>
++
++#include <jni.h>
++#include <jni_util.h>
++#include <jlong_md.h>
++#include <sun_font_FileFontStrike.h>
++
++#include "fontscalerdefs.h"
++
++/* Some of these are also defined in awtmsg.h but I don't want a dependency
++ * on that here. They are needed here - and in awtmsg.h - until we
++ * move up our build to define WIN32_WINNT >= 0x501 (ie XP), since MS
++ * headers will not define them otherwise.
++ */
++#ifndef SPI_GETFONTSMOOTHINGTYPE
++#define SPI_GETFONTSMOOTHINGTYPE        0x200A
++#endif //SPI_GETFONTSMOOTHINGTYPE
++
++#ifndef SPI_GETFONTSMOOTHINGCONTRAST
++#define SPI_GETFONTSMOOTHINGCONTRAST    0x200C
++#endif //SPI_GETFONTSMOOTHINGCONTRAST
++
++#ifndef SPI_GETFONTSMOOTHINGORIENTATION
++#define SPI_GETFONTSMOOTHINGORIENTATION    0x2012
++#endif //SPI_GETFONTSMOOTHINGORIENTATION
++
++#ifndef FE_FONTSMOOTHINGORIENTATIONBGR
++#define FE_FONTSMOOTHINGORIENTATIONBGR 0x0000
++#endif //FE_FONTSMOOTHINGORIENTATIONBGR
++
++#ifndef FE_FONTSMOOTHINGORIENTATIONRGB
++#define FE_FONTSMOOTHINGORIENTATIONRGB 0x0001
++#endif //FE_FONTSMOOTHINGORIENTATIONRGB
++
++#define MIN_GAMMA 100
++#define MAX_GAMMA 220
++#define LCDLUTCOUNT (MAX_GAMMA-MIN_GAMMA+1)
++
++static unsigned char* igLUTable[LCDLUTCOUNT];
++
++static unsigned char* getIGTable(int gamma) {
++    int i, index;
++    double ig;
++    char *igTable;
++
++    if (gamma < MIN_GAMMA) {
++        gamma = MIN_GAMMA;
++    } else if (gamma > MAX_GAMMA) {
++        gamma = MAX_GAMMA;
++    }
++
++    index = gamma - MIN_GAMMA;
++
++    if (igLUTable[index] != NULL) {
++        return igLUTable[index];
++    }
++    igTable = (unsigned char*)malloc(256);
++    if (igTable == NULL) {
++      return NULL;
++    }
++    igTable[0] = 0;
++    igTable[255] = 255;
++    ig = ((double)gamma)/100.0;
++
++    for (i=1;i<255;i++) {
++        igTable[i] = (unsigned char)(pow(((double)i)/255.0, ig)*255);
++    }
++    igLUTable[index] = igTable;
++    return igTable;
++}
++
++
++JNIEXPORT jboolean JNICALL
++    Java_sun_font_FileFontStrike_initNative(JNIEnv *env, jclass unused) {
++
++    DWORD osVersion = GetVersion();
++    DWORD majorVersion = (DWORD)(LOBYTE(LOWORD(osVersion)));
++    DWORD minorVersion = (DWORD)(HIBYTE(LOWORD(osVersion)));
++
++    /* Need at least XP which is 5.1 */
++    if (majorVersion < 5 || (majorVersion == 5 && minorVersion < 1)) {
++        return JNI_FALSE;
++    }
++
++    memset(igLUTable, 0,  LCDLUTCOUNT);
++
++    return JNI_TRUE;
++}
++
++#ifndef CLEARTYPE_QUALITY
++#define CLEARTYPE_QUALITY 5
++#endif
++
++#ifndef CLEARTYPE_NATURAL_QUALITY
++#define CLEARTYPE_NATURAL_QUALITY 6
++#endif
++
++#define FREE_AND_RETURN \
++    if (hDesktopDC != 0 && hWnd != 0) { \
++       ReleaseDC(hWnd, hDesktopDC); \
++    }\
++    if (hMemoryDC != 0) { \
++        DeleteObject(hMemoryDC); \
++    } \
++    if (hBitmap != 0) { \
++        DeleteObject(hBitmap); \
++    } \
++    if (dibImage != NULL) { \
++        free(dibImage); \
++    } \
++    if (glyphInfo != NULL) { \
++        free(glyphInfo); \
++    } \
++    return (jlong)0;
++/* end define */
++
++JNIEXPORT jlong JNICALL
++Java_sun_font_FileFontStrike__1getGlyphImageFromWindows
++(JNIEnv *env, jobject unused,
++ jstring fontFamily, jint style, jint size, jint glyphCode, jboolean fm) {
++
++    GLYPHMETRICS glyphMetrics;
++    LOGFONTW lf;
++    BITMAPINFO bmi;
++    TEXTMETRIC textMetric;
++    RECT rect;
++    int bytesWidth, dibBytesWidth, extra, imageSize, dibImageSize;
++    unsigned char* dibImage = NULL, *rowPtr, *pixelPtr, *dibPixPtr, *dibRowPtr;
++    unsigned char r,g,b;
++    unsigned char* igTable;
++    GlyphInfo* glyphInfo = NULL;
++    int nameLen;
++    LPWSTR name;
++    HFONT oldFont, hFont;
++    MAT2 mat2;
++
++    unsigned short width;
++    unsigned short height;
++    short advanceX;
++    short advanceY;
++    int topLeftX;
++    int topLeftY;
++    int err;
++    int bmWidth, bmHeight;
++    int x, y;
++    HBITMAP hBitmap = NULL, hOrigBM;
++    int gamma, orient;
++
++    HWND hWnd = NULL;
++    HDC hDesktopDC = NULL;
++    HDC hMemoryDC = NULL;
++
++    hWnd = GetDesktopWindow();
++    hDesktopDC = GetWindowDC(hWnd);
++    if (hDesktopDC == NULL) {
++        return (jlong)0;
++    }
++    if (GetDeviceCaps(hDesktopDC, BITSPIXEL) < 15) {
++        FREE_AND_RETURN;
++    }
++
++    hMemoryDC = CreateCompatibleDC(hDesktopDC);
++    if (hMemoryDC == NULL || fontFamily == NULL) {
++        FREE_AND_RETURN;
++    }
++    err = SetMapMode(hMemoryDC, MM_TEXT);
++    if (err == 0) {
++        FREE_AND_RETURN;
++    }
++
++    memset(&lf, 0, sizeof(LOGFONTW));
++    lf.lfHeight = -size;
++    lf.lfWeight = (style & 1) ? FW_BOLD : FW_NORMAL;
++    lf.lfItalic = (style & 2) ? 0xff : 0;
++    lf.lfCharSet = DEFAULT_CHARSET;
++    lf.lfQuality = CLEARTYPE_QUALITY;
++    lf.lfOutPrecision = OUT_TT_PRECIS;
++    lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
++    lf.lfPitchAndFamily = DEFAULT_PITCH;
++
++    nameLen = (*env)->GetStringLength(env, fontFamily);
++    name = (LPWSTR)alloca((nameLen+1)*2);
++    if (name == NULL) {
++       FREE_AND_RETURN;
++    }
++    (*env)->GetStringRegion(env, fontFamily, 0, nameLen, name);
++    name[nameLen] = '\0';
++
++    if (nameLen < (sizeof(lf.lfFaceName) / sizeof(lf.lfFaceName[0]))) {
++        wcscpy(lf.lfFaceName, name);
++    } else {
++        FREE_AND_RETURN;
++    }
++
++    hFont = CreateFontIndirectW(&lf);
++    if (hFont == NULL) {
++        FREE_AND_RETURN;
++    }
++    oldFont = SelectObject(hMemoryDC, hFont);
++
++    memset(&textMetric, 0, sizeof(TEXTMETRIC));
++    err = GetTextMetrics(hMemoryDC, &textMetric);
++    if (err == 0) {
++        FREE_AND_RETURN;
++    }
++    memset(&glyphMetrics, 0, sizeof(GLYPHMETRICS));
++    memset(&mat2, 0, sizeof(MAT2));
++    mat2.eM11.value = 1; mat2.eM22.value = 1;
++    err = GetGlyphOutline(hMemoryDC, glyphCode,
++                          GGO_METRICS|GGO_GLYPH_INDEX,
++                          &glyphMetrics,
++                          0, NULL, &mat2);
++    if (err == GDI_ERROR) {
++        /* Probably no such glyph - ie the font wasn't the one we expected. */
++        FREE_AND_RETURN;
++    }
++
++    width  = (unsigned short)glyphMetrics.gmBlackBoxX;
++    height = (unsigned short)glyphMetrics.gmBlackBoxY;
++
++    /* Don't handle "invisible" glyphs in this code */
++    if (width <= 0 || height == 0) {
++       FREE_AND_RETURN;
++    }
++
++    advanceX = glyphMetrics.gmCellIncX;
++    advanceY = glyphMetrics.gmCellIncY;
++    topLeftX = glyphMetrics.gmptGlyphOrigin.x;
++    topLeftY = glyphMetrics.gmptGlyphOrigin.y;
++
++    /* GetGlyphOutline pre-dates cleartype and I'm not sure that it will
++     * account for all pixels touched by the rendering. Need to widen,
++     * and also adjust by one the x position at which it is rendered.
++     * The extra pixels of width are used as follows :
++     * One extra pixel at the left and the right will be needed to absorb
++     * the pixels that will be touched by filtering by GDI to compensate
++     * for colour fringing.
++     * However there seem to be some cases where GDI renders two extra
++     * pixels to the right, so we add one additional pixel to the right,
++     * and in the code that copies this to the image cache we test for
++     * the (rare) cases when this is touched, and if its not reduce the
++     * stated image width for the blitting loops.
++     * For fractional metrics :
++     * One extra pixel at each end to account for sub-pixel positioning used
++     * when fractional metrics is on in LCD mode.
++     * The pixel at the left is needed so the blitting loop can index into
++     * that a byte at a time to more accurately position the glyph.
++     * The pixel at the right is needed so that when such indexing happens,
++     * the blitting still can use the same width.
++     * Consequently the width that is specified for the glyph is one less
++     * than that of the actual image.
++     * Note that in the FM case as a consequence we need to adjust the
++     * position at which GDI renders, and the declared width of the glyph
++     * See the if (fm) {} cases in the code.
++     * For the non-FM case, we not only save 3 bytes per row, but this
++     * prevents apparent glyph overlapping which affects the rendering
++     * performance of accelerated pipelines since it adds additional
++     * read-back requirements.
++     */
++    width+=3;
++    if (fm) {
++        width+=1;
++    }
++    /* DIB scanline must end on a DWORD boundary. We specify 3 bytes per pixel,
++     * so must round up as needed to a multiple of 4 bytes.
++     */
++    dibBytesWidth = bytesWidth = width*3;
++    extra = dibBytesWidth % 4;
++    if (extra != 0) {
++        dibBytesWidth += (4-extra);
++    }
++    /* The glyph cache image must be a multiple of 3 bytes wide. */
++    extra = bytesWidth % 3;
++    if (extra != 0) {
++        bytesWidth += (3-extra);
++    }
++    bmWidth = width;
++    bmHeight = height;
++
++    /* Must use desktop DC to create a bitmap of that depth */
++    hBitmap = CreateCompatibleBitmap(hDesktopDC, bmWidth, bmHeight);
++    if (hBitmap == NULL) {
++        FREE_AND_RETURN;
++    }
++    hOrigBM = (HBITMAP)SelectObject(hMemoryDC, hBitmap);
++
++    /* Fill in black */
++    rect.left = 0;
++    rect.top = 0;
++    rect.right = bmWidth;
++    rect.bottom = bmHeight;
++    FillRect(hMemoryDC, (LPRECT)&rect, GetStockObject(BLACK_BRUSH));
++
++    /* Set text color to white, background to black. */
++    SetBkColor(hMemoryDC, RGB(0,0,0));
++    SetTextColor(hMemoryDC, RGB(255,255,255));
++
++    /* adjust rendering position */
++    x = -topLeftX+1;
++    if (fm) {
++        x += 1;
++    }
++    y = topLeftY - textMetric.tmAscent;
++    err = ExtTextOutW(hMemoryDC, x, y, ETO_GLYPH_INDEX|ETO_OPAQUE,
++                (LPRECT)&rect, (LPCWSTR)&glyphCode, 1, NULL);
++    if (err == 0) {
++        FREE_AND_RETURN;
++    }
++
++    /* Now get the image into a DIB.
++     * MS docs for GetDIBits says the compatible bitmap must not be
++     * selected into a DC, so restore the original first.
++     */
++    SelectObject(hMemoryDC, hOrigBM);
++    SelectObject(hMemoryDC, oldFont);
++    DeleteObject(hFont);
++
++    memset(&bmi, 0, sizeof(BITMAPINFO));
++    bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
++    bmi.bmiHeader.biWidth = width;
++    bmi.bmiHeader.biHeight = -height;
++    bmi.bmiHeader.biPlanes = 1;
++    bmi.bmiHeader.biBitCount = 24;
++    bmi.bmiHeader.biCompression = BI_RGB;
++
++    dibImageSize = dibBytesWidth*height;
++    dibImage = malloc(dibImageSize);
++    if (dibImage == NULL) {
++        FREE_AND_RETURN;
++    }
++    memset(dibImage, 0, dibImageSize);
++
++    err = GetDIBits(hMemoryDC, hBitmap, 0, height, dibImage,
++                    &bmi, DIB_RGB_COLORS);
++
++    if (err == 0) {        /* GetDIBits failed. */
++        FREE_AND_RETURN;
++    }
++
++    err = SystemParametersInfo(SPI_GETFONTSMOOTHINGORIENTATION, 0, &orient, 0);
++    if (err == 0) {
++        FREE_AND_RETURN;
++    }
++    err = SystemParametersInfo(SPI_GETFONTSMOOTHINGCONTRAST, 0, &gamma, 0);
++    if (err == 0) {
++        FREE_AND_RETURN;
++    }
++    igTable = getIGTable(gamma/10);
++    if (igTable == NULL) {
++        FREE_AND_RETURN;
++    }
++
++    /* Now copy glyph image into a GlyphInfo structure and return it.
++     * NB the xadvance calculated here may be overwritten by the caller.
++     * 1 is subtracted from the bitmap width to get the glyph width, since
++     * that extra "1" was added as padding, so the sub-pixel positioning of
++     * fractional metrics could index into it.
++     */
++    imageSize = bytesWidth*height;
++    glyphInfo = (GlyphInfo*)malloc(sizeof(GlyphInfo)+imageSize);
++    if (malloc == NULL) {
++        FREE_AND_RETURN;
++    }
++    glyphInfo->cellInfo = NULL;
++    glyphInfo->rowBytes = bytesWidth;
++    glyphInfo->width = width;
++    if (fm) {
++        glyphInfo->width -= 1; // must subtract 1
++    }
++    glyphInfo->height = height;
++    glyphInfo->advanceX = advanceX;
++    glyphInfo->advanceY = advanceY;
++    glyphInfo->topLeftX = (float)(topLeftX-1);
++    if (fm) {
++        glyphInfo->topLeftX -= 1;
++    }
++    glyphInfo->topLeftY = (float)-topLeftY;
++    glyphInfo->image = (unsigned char*)glyphInfo+sizeof(GlyphInfo);
++    memset(glyphInfo->image, 0, imageSize);
++
++    /* DIB 24bpp data is always stored in BGR order, but we usually
++     * need this in RGB, so we can't just memcpy and need to swap B and R.
++     * Also need to apply inverse gamma adjustment here.
++     * We re-use the variable "extra" to see if the last pixel is touched
++     * at all. If its not we can reduce the glyph image width. This comes
++     * into play in some cases where GDI touches more pixels than accounted
++     * for by increasing width by two pixels over the B&W image. Whilst
++     * the bytes are in the cache, it doesn't affect rendering performance
++     * of the hardware pipelines.
++     */
++    extra = 0;
++    if (fm) {
++        extra = 1; // always need it.
++    }
++    dibRowPtr = dibImage;
++    rowPtr = glyphInfo->image;
++    for (y=0;y<height;y++) {
++        pixelPtr = rowPtr;
++        dibPixPtr = dibRowPtr;
++        for (x=0;x<width;x++) {
++            if (orient == FE_FONTSMOOTHINGORIENTATIONRGB) {
++                b = *dibPixPtr++;
++                g = *dibPixPtr++;
++                r = *dibPixPtr++;
++            } else {
++                r = *dibPixPtr++;
++                g = *dibPixPtr++;
++                b = *dibPixPtr++;
++            }
++            *pixelPtr++ = igTable[r];
++            *pixelPtr++ = igTable[g];
++            *pixelPtr++ = igTable[b];
++            if (!fm && (x==(width-1)) && (r|g|b)) {
++                extra = 1;
++            }
++        }
++        dibRowPtr += dibBytesWidth;
++        rowPtr  += bytesWidth;
++    }
++    if (!extra) {
++        glyphInfo->width -= 1;
++    }
++
++    free(dibImage);
++    ReleaseDC(hWnd, hDesktopDC);
++    DeleteObject(hMemoryDC);
++    DeleteObject(hBitmap);
++
++    return ptr_to_jlong(glyphInfo);
++}
+diff -Nru openjdk.orig/jdk/test/java/awt/Graphics2D/DrawString/ScaledLCDTextMetrics.java openjdk/jdk/test/java/awt/Graphics2D/DrawString/ScaledLCDTextMetrics.java
+--- openjdk.orig/jdk/test/java/awt/Graphics2D/DrawString/ScaledLCDTextMetrics.java	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/test/java/awt/Graphics2D/DrawString/ScaledLCDTextMetrics.java	2013-06-21 19:11:05.275031593 -0500
+@@ -0,0 +1,82 @@
++/*
++ * Copyright 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.
++ */
++
++/**
++ * @test
++ * @bug 6685312
++ * @summary Check advance of LCD text on a scaled graphics.
++ */
++
++import javax.swing.*;
++import java.awt.*;
++import static java.awt.RenderingHints.*;
++
++public class ScaledLCDTextMetrics extends Component {
++
++    public static void main(String[] args) {
++        JFrame f = new JFrame();
++        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
++        f.add("Center", new ScaledLCDTextMetrics());
++        f.pack();
++        f.setVisible(true);
++    }
++
++    public Dimension getPreferredSize() {
++      return new Dimension(200,100);
++    }
++    public void paint(Graphics g) {
++       Graphics2D g2 = (Graphics2D)g;
++
++       Font f = new Font("Tahoma", Font.PLAIN, 11);
++       g.setFont(f);
++       g.setColor(Color.white);
++       g.fillRect(0,0,400,300);
++       g.setColor(Color.black);
++       g2.setRenderingHint(KEY_TEXT_ANTIALIASING,VALUE_TEXT_ANTIALIAS_LCD_HRGB);
++       String text = "ABCDEFGHIJKLI";
++
++       FontMetrics fm1 = g2.getFontMetrics();
++       int adv1 = fm1.stringWidth(text);
++       g.drawString(text, 5, 20);
++
++       g2.scale(2,2);
++
++       FontMetrics fm2 = g2.getFontMetrics();
++       int adv2 = fm2.stringWidth(text);
++       g.drawString(text, 5, 40);
++
++       double frac = Math.abs(adv1/(double)adv2);
++
++       System.out.println("scalex1: " + adv1);
++       System.out.println("scalex2: " + adv2);
++       System.out.println("Fraction : "+ frac);
++
++       // adv1 will not be exactly the same as adv2, but should differ
++       // only by a fraction.
++
++       if (frac < 0.8 || frac > 1.2) {
++           throw new RuntimeException("Metrics differ " +
++           "Adv1="+adv1+" Adv2="+adv2+" Fraction="+frac);
++       }
++    }
++}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6786028-wcag_bold_tags.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,2914 @@
+# HG changeset patch
+# User bpatel
+# Date 1231460819 28800
+# Node ID a50f3556d6954decf0897aa984c8ba43def77b9e
+# Parent  4ab5d66aaf2b9e5c09ab54748f6e2615b7818b12
+6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
+Reviewed-by: jjg
+
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
+@@ -71,7 +71,7 @@
+             member.position().line() != classdoc.position().line()) {
+             writer.printSrcLink(member, member.name());
+         } else {
+-            bold(member.name());
++            strong(member.name());
+         }
+         writeParameters(member);
+         writeExceptions(member);
+@@ -87,10 +87,10 @@
+     protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
+         ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
+         String name = emd.name();
+-        writer.bold();
++        writer.strong();
+         writer.printDocLink(context, cd, (MemberDoc) emd,
+             name, false);
+-        writer.boldEnd();
++        writer.strongEnd();
+         writer.displayLength = name.length();
+         writeParameters(emd, false);
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
+@@ -78,12 +78,12 @@
+     }
+ 
+     /**
+-     * Print the text "Index" in bold format in the navigation bar.
++     * Print the text "Index" in strong format in the navigation bar.
+      */
+     protected void navLinkIndex() {
+         navCellRevStart();
+         fontStyle("NavBarFont1Rev");
+-        boldText("doclet.Index");
++        strongText("doclet.Index");
+         fontEnd();
+         navCellEnd();
+     }
+@@ -98,7 +98,7 @@
+     protected void generateContents(Character unicode, List memberlist) {
+         anchor("_" + unicode + "_");
+         h2();
+-        bold(unicode.toString());
++        strong(unicode.toString());
+         h2End();
+         dl();
+         for (int i = 0; i < memberlist.size(); i++) {
+@@ -195,14 +195,14 @@
+     protected void printComment(ProgramElementDoc element) {
+         Tag[] tags;
+         if (Util.isDeprecated(element)) {
+-            boldText("doclet.Deprecated"); space();
++            strongText("doclet.Deprecated"); space();
+             if ((tags = element.tags("deprecated")).length > 0)
+                 printInlineDeprecatedComment(element, tags[0]);
+         } else {
+             ClassDoc cont = element.containingClass();
+             while (cont != null) {
+                 if (Util.isDeprecated(cont)) {
+-                    boldText("doclet.Deprecated"); space();
++                    strongText("doclet.Deprecated"); space();
+                     break;
+                 }
+                 cont = cont.containingClass();
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+@@ -98,8 +98,8 @@
+         writer.displayLength++;
+     }
+ 
+-    protected void bold(String str) {
+-        writer.bold(str);
++    protected void strong(String str) {
++        writer.strong(str);
+         writer.displayLength += str.length();
+     }
+ 
+@@ -321,7 +321,7 @@
+         if (deprmembers.size() > 0) {
+             writer.tableIndexSummary();
+             writer.tableHeaderStart("#CCCCFF");
+-            writer.boldText(headingKey);
++            writer.strongText(headingKey);
+             writer.tableHeaderEnd();
+             for (int i = 0; i < deprmembers.size(); i++) {
+                 ProgramElementDoc member =(ProgramElementDoc)deprmembers.get(i);
+@@ -363,7 +363,7 @@
+                 if (cd != null && !(pgmdoc instanceof ConstructorDoc)
+                                && !(pgmdoc instanceof ClassDoc)) {
+                     // Add class context
+-                    writer.bold(cd.name() + ".");
++                    writer.strong(cd.name() + ".");
+                 }
+                 writeSummaryLink(
+                     pgmdoc instanceof ClassDoc ?
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
+@@ -137,13 +137,13 @@
+     }
+ 
+     /**
+-     * Highlight "Overview" in the bold format, in the navigation bar as this
++     * Highlight "Overview" in the strong format, in the navigation bar as this
+      * is the overview page.
+      */
+     protected void navLinkContents() {
+         navCellRevStart();
+         fontStyle("NavBarFont1Rev");
+-        boldText("doclet.Overview");
++        strongText("doclet.Overview");
+         fontEnd();
+         navCellEnd();
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
+@@ -173,7 +173,7 @@
+      */
+     protected void printPartialInfo(ClassDoc cd) {
+         li("circle");
+-        printPreQualifiedBoldClassLink(LinkInfoImpl.CONTEXT_TREE, cd);
++        printPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd);
+     }
+ 
+     /**
+@@ -193,7 +193,7 @@
+     protected void navLinkTree() {
+         navCellRevStart();
+         fontStyle("NavBarFont1Rev");
+-        boldText("doclet.Tree");
++        strongText("doclet.Tree");
+         fontEnd();
+         navCellEnd();
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
+@@ -160,7 +160,7 @@
+      */
+     protected void printAllClassesTableHeader() {
+         fontSizeStyle("+1", "FrameHeadingFont");
+-        boldText("doclet.All_Classes");
++        strongText("doclet.All_Classes");
+         fontEnd();
+         br();
+         table();
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+@@ -65,7 +65,7 @@
+     public void writeDefaultValueInfo(MemberDoc member) {
+         writer.dl();
+         writer.dt();
+-        writer.bold(ConfigurationImpl.getInstance().
++        writer.strong(ConfigurationImpl.getInstance().
+             getText("doclet.Default"));
+         writer.dd();
+         writer.print(((AnnotationTypeElementDoc) member).defaultValue());
+@@ -84,7 +84,7 @@
+      * {@inheritDoc}
+      */
+     public void printSummaryLabel(ClassDoc cd) {
+-        writer.boldText("doclet.Annotation_Type_Optional_Member_Summary");
++        writer.strongText("doclet.Annotation_Type_Optional_Member_Summary");
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+@@ -131,7 +131,7 @@
+         if (configuration().linksource) {
+             writer.printSrcLink(member, member.name());
+         } else {
+-            bold(member.name());
++            strong(member.name());
+         }
+         writer.preEnd();
+         writer.dl();
+@@ -183,7 +183,7 @@
+      * {@inheritDoc}
+      */
+     public void printSummaryLabel(ClassDoc cd) {
+-        writer.boldText("doclet.Annotation_Type_Required_Member_Summary");
++        writer.strongText("doclet.Annotation_Type_Required_Member_Summary");
+     }
+ 
+     /**
+@@ -210,9 +210,9 @@
+      * {@inheritDoc}
+      */
+     protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
+-        writer.bold();
++        writer.strong();
+         writer.printDocLink(context, (MemberDoc) member, member.name(), false);
+-        writer.boldEnd();
++        writer.strongEnd();
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
+@@ -84,7 +84,7 @@
+     protected void navLinkClass() {
+         navCellRevStart();
+         fontStyle("NavBarFont1Rev");
+-        boldText("doclet.Class");
++        strongText("doclet.Class");
+         fontEnd();
+         navCellEnd();
+     }
+@@ -176,7 +176,7 @@
+         if (configuration().linksource) {
+             printSrcLink(annotationType, name);
+         } else {
+-            bold(name);
++            strong(name);
+         }
+         dlEnd();
+         preEnd();
+@@ -220,7 +220,7 @@
+         hr();
+         Tag[] deprs = annotationType.tags("deprecated");
+         if (Util.isDeprecated(annotationType)) {
+-            boldText("doclet.Deprecated");
++            strongText("doclet.Deprecated");
+             if (deprs.length > 0) {
+                 Tag[] commentTags = deprs[0].inlineTags();
+                 if (commentTags.length > 0) {
+@@ -330,9 +330,9 @@
+             dl();
+             dt();
+             if (annotationType.isInterface()) {
+-                boldText("doclet.Enclosing_Interface");
++                strongText("doclet.Enclosing_Interface");
+             } else {
+-                boldText("doclet.Enclosing_Class");
++                strongText("doclet.Enclosing_Class");
+             }
+             dd();
+             printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+@@ -394,7 +394,7 @@
+         hr();
+         center();
+         h2();
+-        boldText("doclet.ClassUse_Title", cltype, clname);
++        strongText("doclet.ClassUse_Title", cltype, clname);
+         h2End();
+         centerEnd();
+     }
+@@ -436,7 +436,7 @@
+     protected void navLinkClassUse() {
+         navCellRevStart();
+         fontStyle("NavBarFont1Rev");
+-        boldText("doclet.navClassUse");
++        strongText("doclet.navClassUse");
+         fontEnd();
+         navCellEnd();
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+@@ -91,7 +91,7 @@
+     protected void navLinkClass() {
+         navCellRevStart();
+         fontStyle("NavBarFont1Rev");
+-        boldText("doclet.Class");
++        strongText("doclet.Class");
+         fontEnd();
+         navCellEnd();
+     }
+@@ -185,7 +185,7 @@
+         if (configuration().linksource) {
+             printSrcLink(classDoc, name);
+         } else {
+-            bold(name);
++            strong(name);
+         }
+         if (!isInterface) {
+             Type superclass = Util.getFirstVisibleSuperClass(classDoc,
+@@ -258,7 +258,7 @@
+         hr();
+         Tag[] deprs = classDoc.tags("deprecated");
+         if (Util.isDeprecated(classDoc)) {
+-            boldText("doclet.Deprecated");
++            strongText("doclet.Deprecated");
+             if (deprs.length > 0) {
+                 Tag[] commentTags = deprs[0].inlineTags();
+                 if (commentTags.length > 0) {
+@@ -307,9 +307,9 @@
+                     classDoc, false));
+             if (configuration.shouldExcludeQualifier(
+                     classDoc.containingPackage().name())) {
+-                bold(type.asClassDoc().name() + typeParameters);
++                strong(type.asClassDoc().name() + typeParameters);
+             } else {
+-                bold(type.asClassDoc().qualifiedName() + typeParameters);
++                strong(type.asClassDoc().qualifiedName() + typeParameters);
+             }
+         } else {
+             print(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT,
+@@ -359,7 +359,7 @@
+             if (subclasses.size() > 0) {
+                 dl();
+                 dt();
+-                boldText("doclet.Subclasses");
++                strongText("doclet.Subclasses");
+                 writeClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES,
+                     subclasses);
+             }
+@@ -375,7 +375,7 @@
+             if (subInterfaces.size() > 0) {
+                 dl();
+                 dt();
+-                boldText("doclet.Subinterfaces");
++                strongText("doclet.Subinterfaces");
+                 writeClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES,
+                     subInterfaces);
+             }
+@@ -397,7 +397,7 @@
+         if (implcl.size() > 0) {
+             dl();
+             dt();
+-            boldText("doclet.Implementing_Classes");
++            strongText("doclet.Implementing_Classes");
+             writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES,
+                 implcl);
+         }
+@@ -413,7 +413,7 @@
+         if (classDoc.isClass() && interfaceArray.size() > 0) {
+             dl();
+             dt();
+-            boldText("doclet.All_Implemented_Interfaces");
++            strongText("doclet.All_Implemented_Interfaces");
+             writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES,
+                 interfaceArray);
+         }
+@@ -429,7 +429,7 @@
+         if (classDoc.isInterface() && interfaceArray.size() > 0) {
+             dl();
+             dt();
+-            boldText("doclet.All_Superinterfaces");
++            strongText("doclet.All_Superinterfaces");
+             writeClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES,
+                 interfaceArray);
+         }
+@@ -570,9 +570,9 @@
+             dl();
+             dt();
+             if (outerClass.isInterface()) {
+-                boldText("doclet.Enclosing_Interface");
++                strongText("doclet.Enclosing_Interface");
+             } else {
+-                boldText("doclet.Enclosing_Class");
++                strongText("doclet.Enclosing_Class");
+             }
+             dd();
+             printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
+@@ -92,7 +92,7 @@
+      * {@inheritDoc}
+      */
+     public void writeContentsHeader() {
+-        bold(configuration.getText("doclet.Contents"));
++        strong(configuration.getText("doclet.Contents"));
+         ul();
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+@@ -144,7 +144,7 @@
+         if (configuration().linksource) {
+             writer.printSrcLink(constructor, constructor.name());
+         } else {
+-            bold(constructor.name());
++            strong(constructor.name());
+         }
+         writeParameters(constructor);
+         writeExceptions(constructor);
+@@ -220,7 +220,7 @@
+     }
+ 
+     public void printSummaryLabel(ClassDoc cd) {
+-        writer.boldText("doclet.Constructor_Summary");
++        writer.strongText("doclet.Constructor_Summary");
+     }
+ 
+     public void printSummaryAnchor(ClassDoc cd) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
+@@ -111,7 +111,7 @@
+              throws IOException {
+         writeHeader();
+ 
+-        bold(configuration.getText("doclet.Contents"));
++        strong(configuration.getText("doclet.Contents"));
+         ul();
+         for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
+             writeIndexLink(deprapi, i);
+@@ -156,7 +156,7 @@
+         hr();
+         center();
+         h2();
+-        boldText("doclet.Deprecated_API");
++        strongText("doclet.Deprecated_API");
+         h2End();
+         centerEnd();
+ 
+@@ -180,7 +180,7 @@
+     protected void navLinkDeprecated() {
+         navCellRevStart();
+         fontStyle("NavBarFont1Rev");
+-        boldText("doclet.navDeprecated");
++        strongText("doclet.navDeprecated");
+         fontEnd();
+         navCellEnd();
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+@@ -143,7 +143,7 @@
+         if (configuration().linksource) {
+             writer.printSrcLink(enumConstant, enumConstant.name());
+         } else {
+-            bold(enumConstant.name());
++            strong(enumConstant.name());
+         }
+         writer.preEnd();
+         writer.dl();
+@@ -201,7 +201,7 @@
+     }
+ 
+     public void printSummaryLabel(ClassDoc cd) {
+-        writer.boldText("doclet.Enum_Constant_Summary");
++        writer.strongText("doclet.Enum_Constant_Summary");
+     }
+ 
+     public void printSummaryAnchor(ClassDoc cd) {
+@@ -216,9 +216,9 @@
+     }
+ 
+     protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
+-        writer.bold();
++        writer.strong();
+         writer.printDocLink(context, (MemberDoc) member, member.name(), false);
+-        writer.boldEnd();
++        writer.strongEnd();
+     }
+ 
+     protected void writeInheritedSummaryLink(ClassDoc cd,
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+@@ -153,7 +153,7 @@
+         if (configuration().linksource) {
+             writer.printSrcLink(field, field.name());
+         } else {
+-            bold(field.name());
++            strong(field.name());
+         }
+         writer.preEnd();
+         writer.dl();
+@@ -190,7 +190,7 @@
+                             holder.typeName() : holder.qualifiedTypeName(),
+                         false));
+                 writer.dd();
+-                writer.bold(configuration().getText(holder.isClass()?
++                writer.strong(configuration().getText(holder.isClass()?
+                    "doclet.Description_From_Class" :
+                     "doclet.Description_From_Interface", classlink));
+                 writer.ddEnd();
+@@ -237,7 +237,7 @@
+     }
+ 
+     public void printSummaryLabel(ClassDoc cd) {
+-        writer.boldText("doclet.Field_Summary");
++        writer.strongText("doclet.Field_Summary");
+     }
+ 
+     public void printSummaryAnchor(ClassDoc cd) {
+@@ -251,18 +251,18 @@
+     public void printInheritedSummaryLabel(ClassDoc cd) {
+         String classlink = writer.getPreQualifiedClassLink(
+             LinkInfoImpl.CONTEXT_MEMBER, cd, false);
+-        writer.bold();
++        writer.strong();
+         String key = cd.isClass()?
+             "doclet.Fields_Inherited_From_Class" :
+             "doclet.Fields_Inherited_From_Interface";
+         writer.printText(key, classlink);
+-        writer.boldEnd();
++        writer.strongEnd();
+     }
+ 
+     protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
+-        writer.bold();
++        writer.strong();
+         writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false);
+-        writer.boldEnd();
++        writer.strongEnd();
+     }
+ 
+     protected void writeInheritedSummaryLink(ClassDoc cd,
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
+@@ -223,7 +223,7 @@
+     protected void navLinkHelp() {
+         navCellRevStart();
+         fontStyle("NavBarFont1Rev");
+-        boldText("doclet.Help");
++        strongText("doclet.Help");
+         fontEnd();
+         navCellEnd();
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+@@ -183,21 +183,21 @@
+      * @param where Position in the file
+      * @param target Name of the target frame.
+      * @param label Tag for the link.
+-     * @param bold Whether the label should be bold or not?
++     * @param strong Whether the label should be strong or not?
+      */
+     public void printNoFramesTargetHyperLink(String link, String where,
+                                                String target, String label,
+-                                               boolean bold) {
++                                               boolean strong) {
+         script();
+         println("  <!--");
+         println("  if(window==top) {");
+         println("    document.writeln('"
+-            + getHyperLink(link, where, label, bold, "", "", target) + "');");
++            + getHyperLink(link, where, label, strong, "", "", target) + "');");
+         println("  }");
+         println("  //-->");
+         scriptEnd();
+         noScript();
+-        println("  " + getHyperLink(link, where, label, bold, "", "", target));
++        println("  " + getHyperLink(link, where, label, strong, "", "", target));
+         noScriptEnd();
+         println(DocletConstants.NL);
+     }
+@@ -958,10 +958,10 @@
+      *
+      * @param pkg the package to link to.
+      * @param label the label for the link.
+-     * @param isBold true if the label should be bold.
++     * @param isStrong true if the label should be strong.
+      */
+-    public void printPackageLink(PackageDoc pkg, String label, boolean isBold) {
+-        print(getPackageLink(pkg, label, isBold));
++    public void printPackageLink(PackageDoc pkg, String label, boolean isStrong) {
++        print(getPackageLink(pkg, label, isStrong));
+     }
+ 
+     /**
+@@ -969,12 +969,12 @@
+      *
+      * @param pkg the package to link to.
+      * @param label the label for the link.
+-     * @param isBold true if the label should be bold.
++     * @param isStrong true if the label should be strong.
+      * @param style  the font of the package link label.
+      */
+-    public void printPackageLink(PackageDoc pkg, String label, boolean isBold,
++    public void printPackageLink(PackageDoc pkg, String label, boolean isStrong,
+             String style) {
+-        print(getPackageLink(pkg, label, isBold, style));
++        print(getPackageLink(pkg, label, isStrong, style));
+     }
+ 
+     /**
+@@ -982,12 +982,12 @@
+      *
+      * @param pkg the package to link to.
+      * @param label the label for the link.
+-     * @param isBold true if the label should be bold.
++     * @param isStrong true if the label should be strong.
+      * @return the link to the given package.
+      */
+     public String getPackageLink(PackageDoc pkg, String label,
+-                                 boolean isBold) {
+-        return getPackageLink(pkg, label, isBold, "");
++                                 boolean isStrong) {
++        return getPackageLink(pkg, label, isStrong, "");
+     }
+ 
+     /**
+@@ -995,11 +995,11 @@
+      *
+      * @param pkg the package to link to.
+      * @param label the label for the link.
+-     * @param isBold true if the label should be bold.
++     * @param isStrong true if the label should be strong.
+      * @param style  the font of the package link label.
+      * @return the link to the given package.
+      */
+-    public String getPackageLink(PackageDoc pkg, String label, boolean isBold,
++    public String getPackageLink(PackageDoc pkg, String label, boolean isStrong,
+             String style) {
+         boolean included = pkg != null && pkg.isIncluded();
+         if (! included) {
+@@ -1013,11 +1013,11 @@
+         }
+         if (included || pkg == null) {
+             return getHyperLink(pathString(pkg, "package-summary.html"),
+-                                "", label, isBold, style);
++                                "", label, isStrong, style);
+         } else {
+             String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
+             if (crossPkgLink != null) {
+-                return getHyperLink(crossPkgLink, "", label, isBold, style);
++                return getHyperLink(crossPkgLink, "", label, isStrong, style);
+             } else {
+                 return label;
+             }
+@@ -1087,12 +1087,12 @@
+      * @param refMemName the name of the member being referenced.  This should
+      * be null or empty string if no member is being referenced.
+      * @param label the label for the external link.
+-     * @param bold true if the link should be bold.
++     * @param strong true if the link should be strong.
+      * @param style the style of the link.
+      * @param code true if the label should be code font.
+      */
+     public String getCrossClassLink(String qualifiedClassName, String refMemName,
+-                                    String label, boolean bold, String style,
++                                    String label, boolean strong, String style,
+                                     boolean code) {
+         String className = "",
+             packageName = qualifiedClassName == null ? "" : qualifiedClassName;
+@@ -1113,7 +1113,7 @@
+                                 className + ".html?is-external=true"),
+                     refMemName == null ? "" : refMemName,
+                     label == null || label.length() == 0 ? defaultLabel : label,
+-                    bold, style,
++                    strong, style,
+                     configuration.getText("doclet.Href_Class_Or_Interface_Title", packageName),
+                     "");
+             }
+@@ -1152,26 +1152,26 @@
+      * link label.
+      *
+      * @param cd the class to link to.
+-     * @param isBold true if the link should be bold.
++     * @param isStrong true if the link should be strong.
+      * @return the link with the package portion of the label in plain text.
+      */
+     public String getPreQualifiedClassLink(int context,
+-            ClassDoc cd, boolean isBold) {
++            ClassDoc cd, boolean isStrong) {
+         String classlink = "";
+         PackageDoc pd = cd.containingPackage();
+         if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
+             classlink = getPkgName(cd);
+         }
+-        classlink += getLink(new LinkInfoImpl(context, cd, cd.name(), isBold));
++        classlink += getLink(new LinkInfoImpl(context, cd, cd.name(), isStrong));
+         return classlink;
+     }
+ 
+ 
+     /**
+-     * Print Class link, with only class name as the bold link and prefixing
++     * Print Class link, with only class name as the strong link and prefixing
+      * plain package name.
+      */
+-    public void printPreQualifiedBoldClassLink(int context, ClassDoc cd) {
++    public void printPreQualifiedStrongClassLink(int context, ClassDoc cd) {
+         print(getPreQualifiedClassLink(context, cd, true));
+     }
+ 
+@@ -1187,16 +1187,16 @@
+         print(configuration.getText(key, a1, a2));
+     }
+ 
+-    public void boldText(String key) {
+-        bold(configuration.getText(key));
++    public void strongText(String key) {
++        strong(configuration.getText(key));
+     }
+ 
+-    public void boldText(String key, String a1) {
+-        bold(configuration.getText(key, a1));
++    public void strongText(String key, String a1) {
++        strong(configuration.getText(key, a1));
+     }
+ 
+-    public void boldText(String key, String a1, String a2) {
+-        bold(configuration.getText(key, a1, a2));
++    public void strongText(String key, String a1, String a2) {
++        strong(configuration.getText(key, a1, a2));
+     }
+ 
+     /**
+@@ -1205,11 +1205,11 @@
+      * @param context the id of the context where the link will be printed.
+      * @param doc the member being linked to.
+      * @param label the label for the link.
+-     * @param bold true if the link should be bold.
++     * @param strong true if the link should be strong.
+      */
+     public void printDocLink(int context, MemberDoc doc, String label,
+-            boolean bold) {
+-        print(getDocLink(context, doc, label, bold));
++            boolean strong) {
++        print(getDocLink(context, doc, label, strong));
+     }
+ 
+     /**
+@@ -1221,11 +1221,11 @@
+      *                 inheriting comments.
+      * @param doc the member being linked to.
+      * @param label the label for the link.
+-     * @param bold true if the link should be bold.
++     * @param strong true if the link should be strong.
+      */
+     public void printDocLink(int context, ClassDoc classDoc, MemberDoc doc,
+-            String label, boolean bold) {
+-        print(getDocLink(context, classDoc, doc, label, bold));
++            String label, boolean strong) {
++        print(getDocLink(context, classDoc, doc, label, strong));
+     }
+ 
+     /**
+@@ -1234,12 +1234,12 @@
+      * @param context the id of the context where the link will be printed.
+      * @param doc the member being linked to.
+      * @param label the label for the link.
+-     * @param bold true if the link should be bold.
++     * @param strong true if the link should be strong.
+      * @return the link for the given member.
+      */
+     public String getDocLink(int context, MemberDoc doc, String label,
+-                boolean bold) {
+-        return getDocLink(context, doc.containingClass(), doc, label, bold);
++                boolean strong) {
++        return getDocLink(context, doc.containingClass(), doc, label, strong);
+     }
+ 
+     /**
+@@ -1251,21 +1251,21 @@
+      *                 inheriting comments.
+      * @param doc the member being linked to.
+      * @param label the label for the link.
+-     * @param bold true if the link should be bold.
++     * @param strong true if the link should be strong.
+      * @return the link for the given member.
+      */
+     public String getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
+-        String label, boolean bold) {
++        String label, boolean strong) {
+         if (! (doc.isIncluded() ||
+             Util.isLinkable(classDoc, configuration()))) {
+             return label;
+         } else if (doc instanceof ExecutableMemberDoc) {
+             ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
+             return getLink(new LinkInfoImpl(context, classDoc,
+-                getAnchor(emd), label, bold));
++                getAnchor(emd), label, strong));
+         } else if (doc instanceof MemberDoc) {
+             return getLink(new LinkInfoImpl(context, classDoc,
+-                doc.name(), label, bold));
++                doc.name(), label, strong));
+         } else {
+             return label;
+         }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+@@ -100,7 +100,7 @@
+                 fieldType));
+         }
+         print(fieldDimensions + ' ');
+-        bold(fieldName);
++        strong(fieldName);
+         writer.preEnd();
+         writer.dl();
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
+@@ -81,7 +81,7 @@
+                                 !(linkInfo.classDoc.name() + ".html").equals(m_writer.filename)) {
+                         linkOutput.append(m_writer.getHyperLink(filename,
+                             classLinkInfo.where, label.toString(),
+-                            classLinkInfo.isBold, classLinkInfo.styleName,
++                            classLinkInfo.isStrong, classLinkInfo.styleName,
+                             title, classLinkInfo.target));
+                         if (noLabel && !classLinkInfo.excludeTypeParameterLinks) {
+                             linkOutput.append(getTypeParameterLinks(linkInfo).toString());
+@@ -92,7 +92,7 @@
+         } else {
+             String crossLink = m_writer.getCrossClassLink(
+                 classDoc.qualifiedName(), classLinkInfo.where,
+-                label.toString(), classLinkInfo.isBold, classLinkInfo.styleName,
++                label.toString(), classLinkInfo.isStrong, classLinkInfo.styleName,
+                 true);
+             if (crossLink != null) {
+                 linkOutput.append(crossLink);
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkInfoImpl.java
+@@ -235,15 +235,15 @@
+      * @param classDoc   the class to link to.
+      * @param where      the value of the marker #.
+      * @param label      the label for the link.
+-     * @param isBold       true if the link should be bold.
++     * @param isStrong       true if the link should be strong.
+      * @param styleName  String style of text defined in style sheet.
+      */
+     public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
+-            boolean isBold, String styleName){
++            boolean isStrong, String styleName){
+         this.classDoc = classDoc;
+         this.where = where;
+         this.label = label;
+-        this.isBold = isBold;
++        this.isStrong = isStrong;
+         this.styleName = styleName;
+         setContext(context);
+     }
+@@ -255,14 +255,14 @@
+      * @param classDoc   the class to link to.
+      * @param where      the value of the marker #.
+      * @param label      the label for the link.
+-     * @param isBold       true if the link should be bold.
++     * @param isStrong       true if the link should be strong.
+      */
+     public LinkInfoImpl (int context, ClassDoc classDoc, String where, String label,
+-            boolean isBold){
++            boolean isStrong){
+         this.classDoc = classDoc;
+         this.where = where;
+         this.label = label;
+-        this.isBold = isBold;
++        this.isStrong = isStrong;
+         setContext(context);
+     }
+ 
+@@ -283,12 +283,12 @@
+      *
+      * @param context               the context of the link.
+      * @param executableMemberDoc   the member to link to.
+-     * @param isBold                true if the link should be bold.
++     * @param isStrong                true if the link should be strong.
+      */
+     public LinkInfoImpl (int context, ExecutableMemberDoc executableMemberDoc,
+-            boolean isBold){
++            boolean isStrong){
+         this.executableMemberDoc = executableMemberDoc;
+-        this.isBold = isBold;
++        this.isStrong = isStrong;
+         setContext(context);
+     }
+ 
+@@ -297,11 +297,11 @@
+      *
+      * @param context    the context of the link.
+      * @param classDoc   the class to link to.
+-     * @param isBold       true if the link should be bold.
++     * @param isStrong       true if the link should be strong.
+      */
+-    public LinkInfoImpl (int context, ClassDoc classDoc,  boolean isBold){
++    public LinkInfoImpl (int context, ClassDoc classDoc,  boolean isStrong){
+         this.classDoc = classDoc;
+-        this.isBold = isBold;
++        this.isStrong = isStrong;
+         setContext(context);
+     }
+ 
+@@ -335,13 +335,13 @@
+      * @param context    the context of the link.
+      * @param type       the class to link to.
+      * @param label      the label for the link.
+-     * @param isBold     true if the link should be bold.
++     * @param isStrong     true if the link should be strong.
+      */
+     public LinkInfoImpl (int context, Type type, String label,
+-            boolean isBold){
++            boolean isStrong){
+         this.type = type;
+         this.label = label;
+-        this.isBold = isBold;
++        this.isStrong = isStrong;
+         setContext(context);
+     }
+ 
+@@ -351,13 +351,13 @@
+      * @param context    the context of the link.
+      * @param classDoc   the class to link to.
+      * @param label      the label for the link.
+-     * @param isBold       true if the link should be bold.
++     * @param isStrong       true if the link should be strong.
+      */
+     public LinkInfoImpl (int context, ClassDoc classDoc, String label,
+-            boolean isBold){
++            boolean isStrong){
+         this.classDoc = classDoc;
+         this.label = label;
+-        this.isBold = isBold;
++        this.isStrong = isStrong;
+         setContext(context);
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+@@ -167,7 +167,7 @@
+         if (configuration().linksource) {
+             writer.printSrcLink(method, method.name());
+         } else {
+-            bold(method.name());
++            strong(method.name());
+         }
+         writeParameters(method);
+         writeExceptions(method);
+@@ -210,7 +210,7 @@
+                             holder.typeName() : holder.qualifiedTypeName(),
+                         false));
+                 writer.dd();
+-                writer.boldText(holder.asClassDoc().isClass()?
++                writer.strongText(holder.asClassDoc().isClass()?
+                         "doclet.Description_From_Class":
+                         "doclet.Description_From_Interface",
+                     classlink);
+@@ -259,7 +259,7 @@
+     }
+ 
+     public void printSummaryLabel(ClassDoc cd) {
+-        writer.boldText("doclet.Method_Summary");
++        writer.strongText("doclet.Method_Summary");
+     }
+ 
+     public void printSummaryAnchor(ClassDoc cd) {
+@@ -274,12 +274,12 @@
+     public void printInheritedSummaryLabel(ClassDoc cd) {
+         String classlink = writer.getPreQualifiedClassLink(
+             LinkInfoImpl.CONTEXT_MEMBER, cd, false);
+-        writer.bold();
++        writer.strong();
+         String key = cd.isClass()?
+             "doclet.Methods_Inherited_From_Class" :
+             "doclet.Methods_Inherited_From_Interface";
+         writer.printText(key, classlink);
+-        writer.boldEnd();
++        writer.strongEnd();
+     }
+ 
+     protected void printSummaryType(ProgramElementDoc member) {
+@@ -317,7 +317,7 @@
+                 writer.getLink(new LinkInfoImpl(context, overriddenType)));
+             String name = method.name();
+             writer.dt();
+-            writer.boldText(label);
++            writer.strongText(label);
+             writer.dd();
+             String methLink = writer.codeText(
+                 writer.getLink(
+@@ -363,7 +363,7 @@
+                 writer.getLink(new LinkInfoImpl(
+                     LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac)));
+             writer.dt();
+-            writer.boldText("doclet.Specified_By");
++            writer.strongText("doclet.Specified_By");
+             writer.dd();
+             methlink = writer.codeText(writer.getDocLink(
+                 LinkInfoImpl.CONTEXT_MEMBER, implementedMeth,
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+@@ -149,7 +149,7 @@
+     }
+ 
+     public void printSummaryLabel(ClassDoc cd) {
+-        writer.boldText("doclet.Nested_Class_Summary");
++        writer.strongText("doclet.Nested_Class_Summary");
+     }
+ 
+     public void printSummaryAnchor(ClassDoc cd) {
+@@ -164,18 +164,18 @@
+     public void printInheritedSummaryLabel(ClassDoc cd) {
+         String clslink = writer.getPreQualifiedClassLink(
+             LinkInfoImpl.CONTEXT_MEMBER, cd, false);
+-        writer.bold();
++        writer.strong();
+         writer.printText(cd.isInterface() ?
+             "doclet.Nested_Classes_Interface_Inherited_From_Interface" :
+             "doclet.Nested_Classes_Interfaces_Inherited_From_Class",
+             clslink);
+-        writer.boldEnd();
++        writer.strongEnd();
+     }
+ 
+     protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
+-        writer.bold();
++        writer.strong();
+         writer.printLink(new LinkInfoImpl(context, (ClassDoc)member, false));
+-        writer.boldEnd();
++        writer.strongEnd();
+     }
+ 
+     protected void writeInheritedSummaryLink(ClassDoc cd,
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
+@@ -87,7 +87,7 @@
+     }
+ 
+     /**
+-     * Print the "-packagesheader" string in bold format, at top of the page,
++     * Print the "-packagesheader" string in strong format, at top of the page,
+      * if it is not the empty string.  Otherwise print the "-header" string.
+      * Despite the name, there is actually no navigation bar for this page.
+      */
+@@ -95,9 +95,9 @@
+         printTableHeader(true);
+         fontSizeStyle("+1", "FrameTitleFont");
+         if (configuration.packagesheader.length() > 0) {
+-            bold(replaceDocRootDir(configuration.packagesheader));
++            strong(replaceDocRootDir(configuration.packagesheader));
+         } else {
+-            bold(replaceDocRootDir(configuration.header));
++            strong(replaceDocRootDir(configuration.header));
+         }
+         fontEnd();
+         printTableFooter(true);
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
+@@ -102,9 +102,9 @@
+         if(pkg != null && pkg.name().length() > 0) {
+             trBgcolorStyle("white", "TableRowColor");
+             summaryRow(20);
+-            bold();
++            strong();
+             printPackageLink(pkg, Util.getPackageName(pkg), false);
+-            boldEnd();
++            strongEnd();
+             summaryRowEnd();
+             summaryRow(0);
+             printSummaryComment(pkg);
+@@ -138,7 +138,7 @@
+         if (root.inlineTags().length > 0) {
+             printSummaryComment(root);
+             p();
+-            bold(configuration.getText("doclet.See"));
++            strong(configuration.getText("doclet.See"));
+             br();
+             printNbsps();
+             printHyperLink("", "overview_description",
+@@ -153,7 +153,7 @@
+     protected void printIndexHeader(String text) {
+         tableIndexSummary();
+         tableHeaderStart("#CCCCFF");
+-        bold(text);
++        strong(text);
+         tableHeaderEnd();
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
+@@ -144,7 +144,7 @@
+     protected void printLinkToMainTree() {
+         dl();
+         dt();
+-        boldText("doclet.Package_Hierarchies");
++        strongText("doclet.Package_Hierarchies");
+         dd();
+         navLinkMainTree(configuration.getText("doclet.All_Packages"));
+         dlEnd();
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+@@ -178,9 +178,9 @@
+ 
+         trBgcolorStyle("white", "TableRowColor");
+         summaryRow(0);
+-        bold();
++        strong();
+         printHyperLink(path, packageName, usedClass.name(), true);
+-        boldEnd();
++        strongEnd();
+         println(); br();
+         printNbsps();
+         printIndexComment(usedClass);
+@@ -219,7 +219,7 @@
+         hr();
+         center();
+         h2();
+-        boldText("doclet.ClassUse_Title", packageLabel, name);
++        strongText("doclet.ClassUse_Title", packageLabel, name);
+         h2End();
+         centerEnd();
+     }
+@@ -251,7 +251,7 @@
+     protected void navLinkClassUse() {
+         navCellRevStart();
+         fontStyle("NavBarFont1Rev");
+-        boldText("doclet.navClassUse");
++        strongText("doclet.navClassUse");
+         fontEnd();
+         navCellEnd();
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
+@@ -123,14 +123,14 @@
+                 }
+                 trBgcolorStyle("white", "TableRowColor");
+                 summaryRow(15);
+-                bold();
++                strong();
+                 printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_PACKAGE,
+                     classes[i], false));
+-                boldEnd();
++                strongEnd();
+                 summaryRowEnd();
+                 summaryRow(0);
+                 if (Util.isDeprecated(classes[i])) {
+-                    boldText("doclet.Deprecated");
++                    strongText("doclet.Deprecated");
+                     if (classes[i].tags("deprecated").length > 0) {
+                         space();
+                         printSummaryDeprecatedComment(classes[i],
+@@ -155,7 +155,7 @@
+      */
+     protected void printFirstRow(String label) {
+         tableHeaderStart("#CCCCFF");
+-        bold(label);
++        strong(label);
+         tableHeaderEnd();
+     }
+ 
+@@ -194,7 +194,7 @@
+         if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) {
+             printSummaryComment(packageDoc);
+             p();
+-            bold(configuration.getText("doclet.See"));
++            strong(configuration.getText("doclet.See"));
+             br();
+             printNbsps();
+             printHyperLink("", "package_description",
+@@ -268,7 +268,7 @@
+     protected void navLinkPackage() {
+         navCellRevStart();
+         fontStyle("NavBarFont1Rev");
+-        boldText("doclet.Package");
++        strongText("doclet.Package");
+         fontEnd();
+         navCellEnd();
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
+@@ -73,9 +73,9 @@
+         tableHeader();
+         thAlign("center");
+         font("+2");
+-        boldText("doclet.Package");
++        strongText("doclet.Package");
+         print(' ');
+-        bold(packageName);
++        strong(packageName);
+         tableFooter();
+     }
+ 
+@@ -86,7 +86,7 @@
+      * @param serialUID the serial UID to print.
+      */
+     public void writeSerialUIDInfo(String header, String serialUID) {
+-        bold(header + "&nbsp;");
++        strong(header + "&nbsp;");
+         println(serialUID);
+         p();
+     }
+@@ -131,7 +131,7 @@
+         tableHeader();
+         thAlignColspan("left", 2);
+         font("+2");
+-        bold(className);
++        strong(className);
+         tableFooter();
+         p();
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
+@@ -81,7 +81,7 @@
+     public void printTableHeadingBackground(String str) {
+         tableIndexDetail();
+         tableHeaderStart("#CCCCFF", 1);
+-        bold(str);
++        strong(str);
+         tableHeaderEnd();
+         tableEnd();
+     }
+@@ -117,7 +117,7 @@
+     protected void printIndexComment(Doc member, Tag[] firstSentenceTags) {
+         Tag[] deprs = member.tags("deprecated");
+         if (Util.isDeprecated((ProgramElementDoc) member)) {
+-            boldText("doclet.Deprecated");
++            strongText("doclet.Deprecated");
+             space();
+             if (deprs.length > 0) {
+                 printInlineDeprecatedComment(member, deprs[0]);
+@@ -126,7 +126,7 @@
+         } else {
+             ClassDoc cd = ((ProgramElementDoc)member).containingClass();
+             if (cd != null && Util.isDeprecated(cd)) {
+-                boldText("doclet.Deprecated"); space();
++                strongText("doclet.Deprecated"); space();
+             }
+         }
+         printSummaryComment(member, firstSentenceTags);
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
+@@ -69,9 +69,9 @@
+         Tag[] deprs = doc.tags("deprecated");
+         if (doc instanceof ClassDoc) {
+             if (Util.isDeprecated((ProgramElementDoc) doc)) {
+-                output.append("<B>" +
++                output.append("<STRONG>" +
+                     ConfigurationImpl.getInstance().
+-                        getText("doclet.Deprecated") + "</B>&nbsp;");
++                        getText("doclet.Deprecated") + "</STRONG>&nbsp;");
+                 if (deprs.length > 0) {
+                     Tag[] commentTags = deprs[0].inlineTags();
+                     if (commentTags.length > 0) {
+@@ -86,9 +86,9 @@
+         } else {
+             MemberDoc member = (MemberDoc) doc;
+             if (Util.isDeprecated((ProgramElementDoc) doc)) {
+-                output.append("<DD><B>" +
++                output.append("<DD><STRONG>" +
+                     ConfigurationImpl.getInstance().
+-                            getText("doclet.Deprecated") + "</B>&nbsp;");
++                            getText("doclet.Deprecated") + "</STRONG>&nbsp;");
+                 if (deprs.length > 0) {
+                     output.append("<I>");
+                     output.append(commentTagsToOutput(null, doc,
+@@ -101,9 +101,9 @@
+                 }
+             } else {
+                 if (Util.isDeprecated(member.containingClass())) {
+-                    output.append("<DD><B>" +
++                    output.append("<DD><STRONG>" +
+                     ConfigurationImpl.getInstance().
+-                            getText("doclet.Deprecated") + "</B>&nbsp;");
++                            getText("doclet.Deprecated") + "</STRONG>&nbsp;");
+                 }
+             }
+         }
+@@ -123,7 +123,7 @@
+     public TagletOutput getParamHeader(String header) {
+         StringBuffer result = new StringBuffer();
+         result.append("<DT>");
+-        result.append("<B>" +  header + "</B>");
++        result.append("<STRONG>" +  header + "</STRONG>");
+         return new TagletOutputImpl(result.toString());
+     }
+ 
+@@ -141,8 +141,8 @@
+      */
+     public TagletOutput returnTagOutput(Tag returnTag) {
+         TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "<DT>" +
+-            "<B>" + htmlWriter.configuration.getText("doclet.Returns") +
+-            "</B>" + "<DD>" +
++            "<STRONG>" + htmlWriter.configuration.getText("doclet.Returns") +
++            "</STRONG>" + "<DD>" +
+             htmlWriter.commentTagsToString(returnTag, null, returnTag.inlineTags(),
+             false));
+         return result;
+@@ -189,7 +189,7 @@
+         if (result != null && result.length() > 0) {
+             return result + ", " + DocletConstants.NL;
+         } else {
+-            return "<DT><B>" + htmlWriter.configuration().getText("doclet.See_Also") + "</B><DD>";
++            return "<DT><STRONG>" + htmlWriter.configuration().getText("doclet.See_Also") + "</STRONG><DD>";
+         }
+      }
+ 
+@@ -197,7 +197,7 @@
+      * {@inheritDoc}
+      */
+     public TagletOutput simpleTagOutput(Tag[] simpleTags, String header) {
+-        String result = "<DT><B>" + header + "</B></DT>" + DocletConstants.NL +
++        String result = "<DT><STRONG>" + header + "</STRONG></DT>" + DocletConstants.NL +
+             "  <DD>";
+         for (int i = 0; i < simpleTags.length; i++) {
+             if (i > 0) {
+@@ -212,7 +212,7 @@
+      * {@inheritDoc}
+      */
+     public TagletOutput simpleTagOutput(Tag simpleTag, String header) {
+-        return new TagletOutputImpl("<DT><B>" + header + "</B></DT>" + "  <DD>"
++        return new TagletOutputImpl("<DT><STRONG>" + header + "</STRONG></DT>" + "  <DD>"
+             + htmlWriter.commentTagsToString(simpleTag, null, simpleTag.inlineTags(), false)
+             + "</DD>" + DocletConstants.NL);
+     }
+@@ -221,8 +221,8 @@
+      * {@inheritDoc}
+      */
+     public TagletOutput getThrowsHeader() {
+-        return new TagletOutputImpl(DocletConstants.NL + "<DT>" + "<B>" +
+-            htmlWriter.configuration().getText("doclet.Throws") + "</B>");
++        return new TagletOutputImpl(DocletConstants.NL + "<DT>" + "<STRONG>" +
++            htmlWriter.configuration().getText("doclet.Throws") + "</STRONG>");
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
+@@ -119,7 +119,7 @@
+         if (!classesonly) {
+             dl();
+             dt();
+-            boldText("doclet.Package_Hierarchies");
++            strongText("doclet.Package_Hierarchies");
+             dd();
+             for (int i = 0; i < packages.length; i++) {
+                 if (packages[i].name().length() == 0) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
+@@ -83,11 +83,11 @@
+      * @param where Position of the link in the file. Character '#' is not
+      * needed.
+      * @param label Tag for the link.
+-     * @param bold  Boolean that sets label to bold.
++     * @param strong  Boolean that sets label to strong.
+      */
+     public void printHyperLink(String link, String where,
+-                               String label, boolean bold) {
+-        print(getHyperLink(link, where, label, bold, "", "", ""));
++                               String label, boolean strong) {
++        print(getHyperLink(link, where, label, strong, "", "", ""));
+     }
+ 
+     /**
+@@ -109,13 +109,13 @@
+      * @param where      Position of the link in the file. Character '#' is not
+      * needed.
+      * @param label      Tag for the link.
+-     * @param bold       Boolean that sets label to bold.
++     * @param strong       Boolean that sets label to strong.
+      * @param stylename  String style of text defined in style sheet.
+      */
+     public void printHyperLink(String link, String where,
+-                               String label, boolean bold,
++                               String label, boolean strong,
+                                String stylename) {
+-        print(getHyperLink(link, where, label, bold, stylename, "", ""));
++        print(getHyperLink(link, where, label, strong, stylename, "", ""));
+     }
+ 
+     /**
+@@ -125,12 +125,12 @@
+      * @param where      Position of the link in the file. Character '#' is not
+      * needed.
+      * @param label      Tag for the link.
+-     * @param bold       Boolean that sets label to bold.
++     * @param strong       Boolean that sets label to strong.
+      * @return String    Hyper Link.
+      */
+     public String getHyperLink(String link, String where,
+-                               String label, boolean bold) {
+-        return getHyperLink(link, where, label, bold, "", "", "");
++                               String label, boolean strong) {
++        return getHyperLink(link, where, label, strong, "", "", "");
+     }
+ 
+     /**
+@@ -140,14 +140,14 @@
+      * @param where      Position of the link in the file. Character '#' is not
+      *                   needed.
+      * @param label      Tag for the link.
+-     * @param bold       Boolean that sets label to bold.
++     * @param strong       Boolean that sets label to strong.
+      * @param stylename  String style of text defined in style sheet.
+      * @return String    Hyper Link.
+      */
+     public String getHyperLink(String link, String where,
+-                               String label, boolean bold,
++                               String label, boolean strong,
+                                String stylename) {
+-        return getHyperLink(link, where, label, bold, stylename, "", "");
++        return getHyperLink(link, where, label, strong, stylename, "", "");
+     }
+ 
+     /**
+@@ -157,14 +157,14 @@
+      * @param where      Position of the link in the file. Character '#' is not
+      *                   needed.
+      * @param label      Tag for the link.
+-     * @param bold       Boolean that sets label to bold.
++     * @param strong       Boolean that sets label to strong.
+      * @param stylename  String style of text defined in style sheet.
+      * @param title      String that describes the link's content for accessibility.
+      * @param target     Target frame.
+      * @return String    Hyper Link.
+      */
+     public String getHyperLink(String link, String where,
+-                               String label, boolean bold,
++                               String label, boolean strong,
+                                String stylename, String title, String target) {
+         StringBuffer retlink = new StringBuffer();
+         retlink.append("<A HREF=\"");
+@@ -186,12 +186,12 @@
+             retlink.append(stylename);
+             retlink.append("\">");
+         }
+-        if (bold) {
+-            retlink.append("<B>");
++        if (strong) {
++            retlink.append("<STRONG>");
+         }
+         retlink.append(label);
+-        if (bold) {
+-            retlink.append("</B>");
++        if (strong) {
++            retlink.append("</STRONG>");
+         }
+         if (stylename != null && stylename.length() != 0) {
+             retlink.append("</FONT>");
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+@@ -433,46 +433,46 @@
+     }
+ 
+     /**
+-     * Get the "&lt;B&gt;" string.
++     * Get the "&lt;STRONG&gt;" string.
+      *
+-     * @return String Return String "&lt;B&gt;";
++     * @return String Return String "&lt;STRONG&gt;";
+      */
+-    public String getBold() {
+-        return "<B>";
++    public String getStrong() {
++        return "<STRONG>";
+     }
+ 
+     /**
+-     * Get the "&lt;/B&gt;" string.
++     * Get the "&lt;/STRONG&gt;" string.
+      *
+-     * @return String Return String "&lt;/B&gt;";
++     * @return String Return String "&lt;/STRONG&gt;";
+      */
+-    public String getBoldEnd() {
+-        return "</B>";
++    public String getStrongEnd() {
++        return "</STRONG>";
+     }
+ 
+     /**
+-     * Print &lt;B&gt; tag.
++     * Print &lt;STRONG&gt; tag.
+      */
+-    public void bold() {
+-        print("<B>");
++    public void strong() {
++        print("<STRONG>");
+     }
+ 
+     /**
+-     * Print &lt;/B&gt; tag.
++     * Print &lt;/STRONG&gt; tag.
+      */
+-    public void boldEnd() {
+-        print("</B>");
++    public void strongEnd() {
++        print("</STRONG>");
+     }
+ 
+     /**
+-     * Print text passed, in bold format using &lt;B&gt; and &lt;/B&gt; tags.
++     * Print text passed, in strong format using &lt;STRONG&gt; and &lt;/STRONG&gt; tags.
+      *
+-     * @param text String to be printed in between &lt;B&gt; and &lt;/B&gt; tags.
++     * @param text String to be printed in between &lt;STRONG&gt; and &lt;/STRONG&gt; tags.
+      */
+-    public void bold(String text) {
+-        bold();
++    public void strong(String text) {
++        strong();
+         print(text);
+-        boldEnd();
++        strongEnd();
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/links/LinkInfo.java
+@@ -69,9 +69,9 @@
+     public String label;
+ 
+     /**
+-     * True if the link should be bolded.
++     * True if the link should be strong.
+      */
+-    public boolean isBold = false;
++    public boolean isStrong = false;
+ 
+     /**
+      * True if we should include the type in the link label.  False otherwise.
+diff --git a/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java b/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java
+--- openjdk/langtools/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java
++++ openjdk/langtools/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java
+@@ -94,7 +94,7 @@
+ 
+             // Test the third line of the class tree
+             {
+-"          <IMG SRC=\"../../resources/inherit.gif\" ALT=\"extended by \"><B>p1.subpkg.SSC</B>",
++"          <IMG SRC=\"../../resources/inherit.gif\" ALT=\"extended by \"><STRONG>p1.subpkg.SSC</STRONG>",
+                      TMPDEST_DIR1 + "p1" + FS + "subpkg" + FS +"SSC.html" },
+ 
+         };
+diff --git a/test/com/sun/javadoc/AuthorDD/AuthorDD.java b/test/com/sun/javadoc/AuthorDD/AuthorDD.java
+--- openjdk/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java
++++ openjdk/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java
+@@ -86,12 +86,12 @@
+ 
+              // Test single @since tag:
+ 
+-            { "<DT><B>Since:</B></DT>"+NL+"  <DD>JDK 1.0</DD>",
++            { "<DT><STRONG>Since:</STRONG></DT>"+NL+"  <DD>JDK 1.0</DD>",
+                                   BUGID + FS + "p1" + FS + "C1.html" },
+ 
+             // Test multiple @author tags:
+ 
+-            { "<DT><B>Author:</B></DT>"+NL+"  <DD>Doug Kramer, Jamie, Neal</DD>"+NL,
++            { "<DT><STRONG>Author:</STRONG></DT>"+NL+"  <DD>Doug Kramer, Jamie, Neal</DD>"+NL,
+                                   BUGID + FS + "p1" + FS + "C1.html" },
+ 
+         };
+diff --git a/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java b/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
+--- openjdk/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
++++ openjdk/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
+@@ -48,7 +48,7 @@
+             "<A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/math/BigInteger.html?is-external=true#gcd(java.math.BigInteger)\" " +
+                 "title=\"class or interface in java.math\"><CODE>Link to external member gcd</CODE></A>"},
+         {BUG_ID + FS + "C.html",
+-            "<B>Overrides:</B><DD><CODE>toString</CODE> in class <CODE>java.lang.Object</CODE>"}
++            "<STRONG>Overrides:</STRONG><DD><CODE>toString</CODE> in class <CODE>java.lang.Object</CODE>"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testClassTree/TestClassTree.java b/test/com/sun/javadoc/testClassTree/TestClassTree.java
+--- openjdk/langtools/test/com/sun/javadoc/testClassTree/TestClassTree.java
++++ openjdk/langtools/test/com/sun/javadoc/testClassTree/TestClassTree.java
+@@ -49,12 +49,12 @@
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "package-tree.html",
+             "<LI TYPE=\"circle\">pkg.<A HREF=\"../pkg/ParentClass.html\" " +
+-            "title=\"class in pkg\"><B>ParentClass</B></A><UL>"},
++            "title=\"class in pkg\"><STRONG>ParentClass</STRONG></A><UL>"},
+ 
+         {BUG_ID + FS + "pkg" + FS + "package-tree.html",
+             "Annotation Type Hierarchy" + NL + "</H2>" + NL + "<UL>" + NL +
+             "<LI TYPE=\"circle\">pkg.<A HREF=\"../pkg/AnnotationType.html\" " +
+-            "title=\"annotation in pkg\"><B>AnnotationType</B></A> " +
++            "title=\"annotation in pkg\"><STRONG>AnnotationType</STRONG></A> " +
+             "(implements java.lang.annotation.Annotation)" + NL + "</UL>"},
+ 
+         {BUG_ID + FS + "pkg" + FS + "package-tree.html",
+@@ -65,7 +65,7 @@
+             "<LI TYPE=\"circle\">java.lang.Object<UL>" + NL +
+             "<LI TYPE=\"circle\">java.lang.Enum&lt;E&gt; (implements java.lang.Comparable&lt;T&gt;, java.io.Serializable)" + NL +
+             "<UL>" + NL +
+-            "<LI TYPE=\"circle\">pkg.<A HREF=\"../pkg/Coin.html\" title=\"enum in pkg\"><B>Coin</B></A></UL>" + NL +
++            "<LI TYPE=\"circle\">pkg.<A HREF=\"../pkg/Coin.html\" title=\"enum in pkg\"><STRONG>Coin</STRONG></A></UL>" + NL +
+             "</UL>" + NL +
+             "</UL>"
+         },
+@@ -73,7 +73,7 @@
+     private static final String[][] NEGATED_TEST = {
+         {BUG_ID + FS + "pkg" + FS + "package-tree.html",
+             "<LI TYPE=\"circle\">class pkg.<A HREF=\"../pkg/ParentClass.html\" " +
+-            "title=\"class in pkg\"><B>ParentClass</B></A><UL>"}
++            "title=\"class in pkg\"><STRONG>ParentClass</STRONG></A><UL>"}
+         };
+ 
+     /**
+diff --git a/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java b/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
+--- openjdk/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
++++ openjdk/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
+@@ -46,7 +46,7 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "C.html", "<DL>"+NL+"<DD>This is just a simple constructor."+ NL +
+-            "<P>"+NL+"<DL>"+NL+"<DT><B>Parameters:</B><DD><CODE>i</CODE> - a param.</DL>"+NL +
++            "<P>"+NL+"<DL>"+NL+"<DT><STRONG>Parameters:</STRONG><DD><CODE>i</CODE> - a param.</DL>"+NL +
+             "</DL>"
+         }
+     };
+diff --git a/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java b/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
+--- openjdk/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
++++ openjdk/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
+@@ -76,25 +76,25 @@
+         {TARGET_FILE, "pkg.DeprecatedClassByAnnotation.method()"},
+         {TARGET_FILE, "pkg.DeprecatedClassByAnnotation.field"},
+ 
+-        {TARGET_FILE2, "<B>Deprecated.</B>" + NL +
++        {TARGET_FILE2, "<STRONG>Deprecated.</STRONG>" + NL +
+                 "<P>" + NL +
+             "<DL>" + NL +
+             "<DT><PRE><FONT SIZE=\"-1\">@Deprecated" + NL +
+-            "</FONT>public class <B>DeprecatedClassByAnnotation</B>"},
++            "</FONT>public class <STRONG>DeprecatedClassByAnnotation</STRONG>"},
+ 
+-        {TARGET_FILE2, "public int <B>field</B></PRE>" + NL +
++        {TARGET_FILE2, "public int <STRONG>field</STRONG></PRE>" + NL +
+             "<DL>" + NL +
+-            "<DD><B>Deprecated.</B>&nbsp;<DL>"},
++            "<DD><STRONG>Deprecated.</STRONG>&nbsp;<DL>"},
+ 
+         {TARGET_FILE2, "<FONT SIZE=\"-1\">@Deprecated" + NL +
+-            "</FONT>public <B>DeprecatedClassByAnnotation</B>()</PRE>" + NL +
++            "</FONT>public <STRONG>DeprecatedClassByAnnotation</STRONG>()</PRE>" + NL +
+             "<DL>" + NL +
+-            "<DD><B>Deprecated.</B>"},
++            "<DD><STRONG>Deprecated.</STRONG>"},
+ 
+         {TARGET_FILE2, "<FONT SIZE=\"-1\">@Deprecated" + NL +
+-            "</FONT>public void <B>method</B>()</PRE>" + NL +
++            "</FONT>public void <STRONG>method</STRONG>()</PRE>" + NL +
+             "<DL>" + NL +
+-            "<DD><B>Deprecated.</B>"},
++            "<DD><STRONG>Deprecated.</STRONG>"},
+     };
+ 
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java b/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
+--- openjdk/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
++++ openjdk/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
+@@ -39,13 +39,13 @@
+     private static final String BUG_ID = "4857717";
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "XReader.html",
+-            "<B>Overrides:</B><DD><CODE><A HREF=\"" +
++            "<STRONG>Overrides:</STRONG><DD><CODE><A HREF=\"" +
+             "http://java.sun.com/j2se/1.4.1/docs/api/java/io/FilterReader.html?is-external=true#read()\"" +
+                 " title=\"class or interface in java.io\">read</A></CODE> in class " +
+                 "<CODE><A HREF=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/FilterReader.html?is-external=true\"" +
+                 " title=\"class or interface in java.io\">FilterReader</A>"},
+         {BUG_ID + FS + "pkg" + FS + "XReader.html",
+-            "<B>Specified by:</B><DD><CODE><A HREF=\"" +
++            "<STRONG>Specified by:</STRONG><DD><CODE><A HREF=\"" +
+             "http://java.sun.com/j2se/1.4.1/docs/api/java/io/DataInput.html?is-external=true#readInt()\"" +
+             " title=\"class or interface in java.io\">readInt</A></CODE> in interface " +
+             "<CODE><A HREF=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/DataInput.html?is-external=true\"" +
+diff --git a/test/com/sun/javadoc/testHeadings/TestHeadings.java b/test/com/sun/javadoc/testHeadings/TestHeadings.java
+--- openjdk/langtools/test/com/sun/javadoc/testHeadings/TestHeadings.java
++++ openjdk/langtools/test/com/sun/javadoc/testHeadings/TestHeadings.java
+@@ -48,16 +48,16 @@
+         //Package summary
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
+             "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+-            "<B>Class Summary</B></FONT></TH>"
++            "<STRONG>Class Summary</STRONG></FONT></TH>"
+         },
+ 
+         // Class documentation
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+             "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+-            "<B>Field Summary</B></FONT></TH>"
++            "<STRONG>Field Summary</STRONG></FONT></TH>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+-            "<TH ALIGN=\"left\"><B>Methods inherited from class " +            "java.lang.Object</B></TH>"
++            "<TH ALIGN=\"left\"><STRONG>Methods inherited from class " +            "java.lang.Object</STRONG></TH>"
+         },
+ 
+         // Class use documentation
+@@ -76,7 +76,7 @@
+         // Deprecated
+         {BUG_ID + FS + "deprecated-list.html",
+             "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+-            "<B>Deprecated Methods</B></FONT></TH>"
++            "<STRONG>Deprecated Methods</STRONG></FONT></TH>"
+         },
+ 
+         // Constant values
+@@ -90,20 +90,20 @@
+         // Serialized Form
+         {BUG_ID + FS + "serialized-form.html",
+             "<TH ALIGN=\"center\"><FONT SIZE=\"+2\">" + NL +
+-            "<B>Package</B> <B>pkg1</B></FONT></TH>"
++            "<STRONG>Package</STRONG> <STRONG>pkg1</STRONG></FONT></TH>"
+         },
+         {BUG_ID + FS + "serialized-form.html",
+             "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+-            "<B>Class <A HREF=\"pkg1/C1.html\" " +            "title=\"class in pkg1\">pkg1.C1</A> extends java.lang.Object " +            "implements Serializable</B></FONT></TH>"
++            "<STRONG>Class <A HREF=\"pkg1/C1.html\" " +            "title=\"class in pkg1\">pkg1.C1</A> extends java.lang.Object " +            "implements Serializable</STRONG></FONT></TH>"
+         },
+         {BUG_ID + FS + "serialized-form.html",
+             "<TH ALIGN=\"left\" COLSPAN=\"1\"><FONT SIZE=\"+2\">" + NL +
+-            "<B>Serialized Fields</B></FONT></TH>"
++            "<STRONG>Serialized Fields</STRONG></FONT></TH>"
+         },
+ 
+         // Overview Frame
+         {BUG_ID + FS + "overview-frame.html",
+-            "<TH ALIGN=\"left\" NOWRAP><FONT size=\"+1\" " +            "CLASS=\"FrameTitleFont\">" + NL + "<B>Test Files</B></FONT></TH>"
++            "<TH ALIGN=\"left\" NOWRAP><FONT size=\"+1\" " +            "CLASS=\"FrameTitleFont\">" + NL + "<STRONG>Test Files</STRONG></FONT></TH>"
+         },
+         {BUG_ID + FS + "overview-frame.html",
+             "<TITLE>" + NL +
+diff --git a/test/com/sun/javadoc/testHelpOption/TestHelpOption.java b/test/com/sun/javadoc/testHelpOption/TestHelpOption.java
+--- openjdk/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java
++++ openjdk/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java
+@@ -91,7 +91,8 @@
+ 
+     private static final String[][] TEST2 = {
+         {BUG_ID + FS + "TestHelpOption.html",
+-            "<A HREF=\"help-doc.html\"><FONT CLASS=\"NavBarFont1\">" +
            "<B>Help</B></FONT></A>"
++            "<A HREF=\"help-doc.html\"><FONT CLASS=\"NavBarFont1\">" +
++            "<STRONG>Help</STRONG></FONT></A>"
+         },
+     };
+     private static final String[][] NEGATED_TEST2 = NO_TEST;
+diff --git a/test/com/sun/javadoc/testHref/TestHref.java b/test/com/sun/javadoc/testHref/TestHref.java
+--- openjdk/langtools/test/com/sun/javadoc/testHref/TestHref.java
++++ openjdk/langtools/test/com/sun/javadoc/testHref/TestHref.java
+@@ -67,7 +67,7 @@
+         },
+         //@see test.
+         {BUG_ID + FS + "pkg" + FS + "C2.html",
+-            "See Also:</B><DD><A HREF=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
++            "See Also:</STRONG><DD><A HREF=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
+         },
+ 
+         //Header does not link to the page itself.
+@@ -77,7 +77,7 @@
+ 
+         //Signature does not link to the page itself.
+         {BUG_ID + FS + "pkg" + FS + "C4.html",
+-            "public abstract class <B>C4&lt;E extends C4&lt;E&gt;&gt;</B>"
++            "public abstract class <STRONG>C4&lt;E extends C4&lt;E&gt;&gt;</STRONG>"
+         },
+     };
+     private static final String[][] NEGATED_TEST =
+diff --git a/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java b/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java
+@@ -0,0 +1,82 @@
++/*
++ * Copyright 1999-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.  Sun designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Sun in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/*
++ * @test
++ * @bug 6786028
++ * @summary This test verifys the use of <strong> HTML tag instead of <B> by Javadoc std doclet.
++ * @author Bhavesh Patel
++ * @library ../lib/
++ * @build JavadocTester
++ * @build TestHtmlStrongTag
++ * @run main TestHtmlStrongTag
++ */
++
++public class TestHtmlStrongTag extends JavadocTester {
++
++    private static final String BUG_ID = "6786028";
++    private static final String[][] TEST1 = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<STRONG>Method Summary</STRONG>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<STRONG>See Also:</STRONG>"},
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<STRONG>Class Summary</STRONG>"}};
++    private static final String[][] NEGATED_TEST1 = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<B>"}};
++    private static final String[][] TEST2 = {
++        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<STRONG>Method Summary</STRONG>"},
++        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<B>Comments:</B>"},
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<STRONG>Class Summary</STRONG>"}};
++
++    private static final String[] ARGS1 =
++        new String[] {
++            "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
++    private static final String[] ARGS2 =
++        new String[] {
++            "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg2"};
++
++    /**
++     * The entry point of the test.
++     * @param args the array of command line arguments.
++     */
++    public static void main(String[] args) {
++        TestHtmlStrongTag tester = new TestHtmlStrongTag();
++        run(tester, ARGS1, TEST1, NEGATED_TEST1);
++        run(tester, ARGS2, TEST2, NO_TEST);
++        tester.printSummary();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getBugId() {
++        return BUG_ID;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getBugName() {
++        return getClass().getName();
++    }
++}
+diff --git a/test/com/sun/javadoc/testHtmlStrongTag/pkg1/C1.java b/test/com/sun/javadoc/testHtmlStrongTag/pkg1/C1.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlStrongTag/pkg1/C1.java
+@@ -0,0 +1,36 @@
++/*
++ * Copyright 1999-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.  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 pkg1;
++
++/**
++ * @see java.lang.Object#wait(long, int)
++ */
++public class C1 {
++
++    public void method(int param1, int param2) {
++
++    }
++}
+diff --git a/test/com/sun/javadoc/testHtmlStrongTag/pkg2/C2.java b/test/com/sun/javadoc/testHtmlStrongTag/pkg2/C2.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlStrongTag/pkg2/C2.java
+@@ -0,0 +1,31 @@
++/*
++ * Copyright 1999-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.  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 pkg2;
++
++/**
++ * <B>Comments:</B> Class 2
++ */
++public class C2 {}
+diff --git a/test/com/sun/javadoc/testIndex/TestIndex.java b/test/com/sun/javadoc/testIndex/TestIndex.java
+--- openjdk/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
++++ openjdk/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
+@@ -54,27 +54,27 @@
+ 
+         //Test index-all.html
+         {BUG_ID + FS + "index-all.html",
+-            "<A HREF=\"./pkg/C.html\" title=\"class in pkg\"><B>C</B></A>" +
++            "<A HREF=\"./pkg/C.html\" title=\"class in pkg\"><STRONG>C</STRONG></A>" +
+             " - Class in <A HREF=\"./pkg/package-summary.html\">pkg</A>"},
+         {BUG_ID + FS + "index-all.html",
+             "<A HREF=\"./pkg/Interface.html\" title=\"interface in pkg\">" +
+-            "<B>Interface</B></A> - Interface in " +
++            "<STRONG>Interface</STRONG></A> - Interface in " +
+             "<A HREF=\"./pkg/package-summary.html\">pkg</A>"},
+         {BUG_ID + FS + "index-all.html",
+             "<A HREF=\"./pkg/AnnotationType.html\" title=\"annotation in pkg\">" +
+-            "<B>AnnotationType</B></A> - Annotation Type in " +
++            "<STRONG>AnnotationType</STRONG></A> - Annotation Type in " +
+             "<A HREF=\"./pkg/package-summary.html\">pkg</A>"},
+         {BUG_ID + FS + "index-all.html",
+             "<A HREF=\"./pkg/Coin.html\" title=\"enum in pkg\">" +
+-            "<B>Coin</B></A> - Enum in " +
++            "<STRONG>Coin</STRONG></A> - Enum in " +
+             "<A HREF=\"./pkg/package-summary.html\">pkg</A>"},
+         {BUG_ID + FS + "index-all.html",
+             "Class in <A HREF=\"./package-summary.html\">&lt;Unnamed&gt;</A>"},
+         {BUG_ID + FS + "index-all.html",
+-            "<DT><A HREF=\"./pkg/C.html#Java\"><B>Java</B></A> - " + NL +
++            "<DT><A HREF=\"./pkg/C.html#Java\"><STRONG>Java</STRONG></A> - " + NL +
+             "Static variable in class pkg.<A HREF=\"./pkg/C.html\" title=\"class in pkg\">C</A>" + NL +
+             "<DD>&nbsp;" + NL +
+-            "<DT><A HREF=\"./pkg/C.html#JDK\"><B>JDK</B></A> - " + NL +
++            "<DT><A HREF=\"./pkg/C.html#JDK\"><STRONG>JDK</STRONG></A> - " + NL +
+             "Static variable in class pkg.<A HREF=\"./pkg/C.html\" title=\"class in pkg\">C</A>" + NL +
+             "<DD>&nbsp;"},
+     };
+diff --git a/test/com/sun/javadoc/testInterface/TestInterface.java b/test/com/sun/javadoc/testInterface/TestInterface.java
+--- openjdk/langtools/test/com/sun/javadoc/testInterface/TestInterface.java
++++ openjdk/langtools/test/com/sun/javadoc/testInterface/TestInterface.java
+@@ -48,14 +48,14 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "int <B>method</B>()"},
++            "int <STRONG>method</STRONG>()"},
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "static final int <B>field</B>"},
++            "static final int <STRONG>field</STRONG>"},
+ 
+ 
+         // Make sure known implementing class list is correct and omits type parameters.
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "<DT><B>All Known Implementing Classes:</B> " +
++            "<DT><STRONG>All Known Implementing Classes:</STRONG> " +
+             "<DD><A HREF=\"../pkg/Child.html\" " +
+             "title=\"class in pkg\">Child</A>, " +
+             "<A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">" +
+@@ -63,34 +63,34 @@
+ 
+          // Make sure "All Implemented Interfaces": has substituted type parameters
+          {BUG_ID + FS + "pkg" + FS + "Child.html",
+-            "<B>All Implemented Interfaces:</B> <DD><A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">Interface</A>&lt;T&gt;"
++            "<STRONG>All Implemented Interfaces:</STRONG> <DD><A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">Interface</A>&lt;T&gt;"
+          },
+          //Make sure Class Tree has substituted type parameters.
+          {BUG_ID + FS + "pkg" + FS + "Child.html",
+             "<PRE>" + NL +
+             "java.lang.Object" + NL +
+             "  <IMG SRC=\"../resources/inherit.gif\" ALT=\"extended by \"><A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">pkg.Parent</A>&lt;T&gt;" + NL +
+-            "      <IMG SRC=\"../resources/inherit.gif\" ALT=\"extended by \"><B>pkg.Child&lt;T&gt;</B>" + NL +
++            "      <IMG SRC=\"../resources/inherit.gif\" ALT=\"extended by \"><STRONG>pkg.Child&lt;T&gt;</STRONG>" + NL +
+             "</PRE>"
+          },
+          //Make sure "Direct Know Subclasses" omits type parameters
+         {BUG_ID + FS + "pkg" + FS + "Parent.html",
+-            "<B>Direct Known Subclasses:</B> <DD><A HREF=\"../pkg/Child.html\" title=\"class in pkg\">Child</A>"
++            "<STRONG>Direct Known Subclasses:</STRONG> <DD><A HREF=\"../pkg/Child.html\" title=\"class in pkg\">Child</A>"
+         },
+         //Make sure "Specified By" has substituted type parameters.
+         {BUG_ID + FS + "pkg" + FS + "Child.html",
+-            "<B>Specified by:</B><DD><CODE><A HREF=\"../pkg/Interface.html#method()\">method</A></CODE> in interface <CODE><A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">Interface</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
++            "<STRONG>Specified by:</STRONG><DD><CODE><A HREF=\"../pkg/Interface.html#method()\">method</A></CODE> in interface <CODE><A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">Interface</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
+          },
+         //Make sure "Overrides" has substituted type parameters.
+         {BUG_ID + FS + "pkg" + FS + "Child.html",
+-            "<B>Overrides:</B><DD><CODE><A HREF=\"../pkg/Parent.html#method()\">method</A></CODE> in class <CODE><A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">Parent</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
++            "<STRONG>Overrides:</STRONG><DD><CODE><A HREF=\"../pkg/Parent.html#method()\">method</A></CODE> in class <CODE><A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">Parent</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
+          },
+     };
+     private static final String[][] NEGATED_TEST = {
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "public int <B>method</B>()"},
++            "public int <STRONG>method</STRONG>()"},
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "public static final int <B>field</B>"},
++            "public static final int <STRONG>field</STRONG>"},
+     };
+ 
+     /**
+diff --git a/test/com/sun/javadoc/testJavascript/TestJavascript.java b/test/com/sun/javadoc/testJavascript/TestJavascript.java
+--- openjdk/langtools/test/com/sun/javadoc/testJavascript/TestJavascript.java
++++ openjdk/langtools/test/com/sun/javadoc/testJavascript/TestJavascript.java
+@@ -45,9 +45,9 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<A HREF=\"../index.html?pkg/C.html\" target=\"_top\"><B>FRAMES</B></A>"},
++            "<A HREF=\"../index.html?pkg/C.html\" target=\"_top\"><STRONG>FRAMES</STRONG></A>"},
+         {BUG_ID + FS + "TestJavascript.html",
+-            "<A HREF=\"index.html?TestJavascript.html\" target=\"_top\"><B>FRAMES</B></A>"},
++            "<A HREF=\"index.html?TestJavascript.html\" target=\"_top\"><STRONG>FRAMES</STRONG></A>"},
+         {BUG_ID + FS + "index.html",
+             "<SCRIPT type=\"text/javascript\">" + NL +
+                         "    targetPage = \"\" + window.location.search;" + NL +
+diff --git a/test/com/sun/javadoc/testLinkOption/TestLinkOption.java b/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
+--- openjdk/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
++++ openjdk/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
+@@ -63,7 +63,7 @@
+             "title=\"class or interface in java.lang\">Object</A>&nbsp;p3)"
+         },
+         {BUG_ID + "-1" + FS + "java" + FS + "lang" + FS + "StringBuilderChild.html",
+-                "public abstract class <B>StringBuilderChild</B><DT>extends <A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true\" title=\"class or interface in java.lang\">Object</A>"
++                "public abstract class <STRONG>StringBuilderChild</STRONG><DT>extends <A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true\" title=\"class or interface in java.lang\">Object</A>"
+         },
+ 
+     };
+diff --git a/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java b/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
+--- openjdk/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
++++ openjdk/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
+@@ -59,7 +59,7 @@
+             " Link to another inner class: <A HREF=\"../pkg/C.InnerC2.html\" title=\"class in pkg\"><CODE>C.InnerC2</CODE></A>"
+         },
+         {BUG_ID + FS + "pkg" + FS + "C.InnerC2.html",
+-            "Enclosing class:</B><DD><A HREF=\"../pkg/C.html\" title=\"class in pkg\">C</A>"
++            "Enclosing class:</STRONG><DD><A HREF=\"../pkg/C.html\" title=\"class in pkg\">C</A>"
+         },
+     };
+     private static final String[][] NEGATED_TEST = {
+diff --git a/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java b/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
+--- openjdk/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
++++ openjdk/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
+@@ -64,13 +64,17 @@
+ 
+         // New labels as of 1.5.0
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-         "<B>Nested classes/interfaces inherited from class pkg." +
         "<A HREF=\"../pkg/BaseClass.html\" title=\"class in pkg\">" +
         "BaseClass</A></B>"},
++         "<STRONG>Nested classes/interfaces inherited from class pkg." +
++         "<A HREF=\"../pkg/BaseClass.html\" title=\"class in pkg\">" +
++         "BaseClass</A></STRONG>"},
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-         "<B>Nested classes/interfaces inherited from interface pkg." +
         "<A HREF=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">" +
         "BaseInterface</A></B>"},
++         "<STRONG>Nested classes/interfaces inherited from interface pkg." +
++         "<A HREF=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">" +
++         "BaseInterface</A></STRONG>"},
+ 
+          // Test overriding/implementing methods with generic parameters.
+                  {BUG_ID + FS + "pkg" + FS + "BaseClass.html",
+-         "<DT><B>Specified by:</B><DD><CODE><A HREF=\"../pkg/BaseInterface.html#getAnnotation(java.lang.Class)\">getAnnotation</A></CODE> in interface <CODE><A HREF=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">BaseInterface</A></CODE></DL>"},
++         "<DT><STRONG>Specified by:</STRONG><DD><CODE><A HREF=\"../pkg/BaseInterface.html#getAnnotation(java.lang.Class)\">getAnnotation</A></CODE> in interface <CODE><A HREF=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">BaseInterface</A></CODE></DL>"},
+ 
+          // Test diamond inheritence member summary (6256068)
+                  {BUG_ID + FS + "diamond" + FS + "Z.html",
+diff --git a/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java b/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java
+--- openjdk/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java
++++ openjdk/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java
+@@ -50,14 +50,14 @@
+         {BUG_ID + FS + "pkg" + FS + "PublicChild.html",
+             "<CODE>&nbsp;<A HREF=\"../pkg/PublicChild.html\" " +
+             "title=\"class in pkg\">PublicChild</A></CODE></FONT></TD>" + NL +
+-            "<TD><CODE><B><A HREF=\"../pkg/PublicChild.html#" +
+-            "returnTypeTest()\">returnTypeTest</A></B>()</CODE>"
++            "<TD><CODE><STRONG><A HREF=\"../pkg/PublicChild.html#" +
++            "returnTypeTest()\">returnTypeTest</A></STRONG>()</CODE>"
+         },
+         // Check return type in member detail.
+         {BUG_ID + FS + "pkg" + FS + "PublicChild.html",
+             "public <A HREF=\"../pkg/PublicChild.html\" " +
+             "title=\"class in pkg\">PublicChild</A> " +
+-            "<B>returnTypeTest</B>()"
++            "<STRONG>returnTypeTest</STRONG>()"
+         },
+ 
+          // Legacy anchor dimensions (6290760)
+diff --git a/test/com/sun/javadoc/testNavagation/TestNavagation.java b/test/com/sun/javadoc/testNavagation/TestNavagation.java
+--- openjdk/langtools/test/com/sun/javadoc/testNavagation/TestNavagation.java
++++ openjdk/langtools/test/com/sun/javadoc/testNavagation/TestNavagation.java
+@@ -47,17 +47,17 @@
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "A.html", "&nbsp;PREV CLASS&nbsp;"},
+         {BUG_ID + FS + "pkg" + FS + "A.html",
+-            "<A HREF=\"../pkg/C.html\" title=\"class in pkg\"><B>NEXT CLASS</B></A>"},
++            "<A HREF=\"../pkg/C.html\" title=\"class in pkg\"><STRONG>NEXT CLASS</STRONG></A>"},
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<A HREF=\"../pkg/A.html\" title=\"annotation in pkg\"><B>PREV CLASS</B></A>"},
++            "<A HREF=\"../pkg/A.html\" title=\"annotation in pkg\"><STRONG>PREV CLASS</STRONG></A>"},
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<A HREF=\"../pkg/E.html\" title=\"enum in pkg\"><B>NEXT CLASS</B></A>"},
++            "<A HREF=\"../pkg/E.html\" title=\"enum in pkg\"><STRONG>NEXT CLASS</STRONG></A>"},
+         {BUG_ID + FS + "pkg" + FS + "E.html",
+-            "<A HREF=\"../pkg/C.html\" title=\"class in pkg\"><B>PREV CLASS</B></A>"},
++            "<A HREF=\"../pkg/C.html\" title=\"class in pkg\"><STRONG>PREV CLASS</STRONG></A>"},
+         {BUG_ID + FS + "pkg" + FS + "E.html",
+-            "<A HREF=\"../pkg/I.html\" title=\"interface in pkg\"><B>NEXT CLASS</B></A>"},
++            "<A HREF=\"../pkg/I.html\" title=\"interface in pkg\"><STRONG>NEXT CLASS</STRONG></A>"},
+         {BUG_ID + FS + "pkg" + FS + "I.html",
+-            "<A HREF=\"../pkg/E.html\" title=\"enum in pkg\"><B>PREV CLASS</B></A>"},
++            "<A HREF=\"../pkg/E.html\" title=\"enum in pkg\"><STRONG>PREV CLASS</STRONG></A>"},
+         {BUG_ID + FS + "pkg" + FS + "I.html", "&nbsp;NEXT CLASS"},
+         // Test for 4664607
+         {BUG_ID + FS + "pkg" + FS + "I.html",
+diff --git a/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java b/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+--- openjdk/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
++++ openjdk/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+@@ -54,14 +54,14 @@
+             {BUG_ID + FS + "pkg" + FS + "Coin.html", "Enum Coin</H2>"},
+             //Make sure enum signature is correct.
+             {BUG_ID + FS + "pkg" + FS + "Coin.html", "public enum "+
+-                "<B>Coin</B><DT>extends java.lang.Enum&lt;" +
++                "<STRONG>Coin</STRONG><DT>extends java.lang.Enum&lt;" +
+                 "<A HREF=\"../pkg/Coin.html\" title=\"enum in pkg\">Coin</A>&gt;"
+             },
+             //Check for enum constant section
+-            {BUG_ID + FS + "pkg" + FS + "Coin.html", "<B>Enum Constant Summary</B>"},
++            {BUG_ID + FS + "pkg" + FS + "Coin.html", "<STRONG>Enum Constant Summary</STRONG>"},
+             //Detail for enum constant
+             {BUG_ID + FS + "pkg" + FS + "Coin.html",
+-                "<B><A HREF=\"../pkg/Coin.html#Dime\">Dime</A></B>"},
++                "<STRONG><A HREF=\"../pkg/Coin.html#Dime\">Dime</A></STRONG>"},
+             //Automatically insert documentation for values() and valueOf().
+             {BUG_ID + FS + "pkg" + FS + "Coin.html",
+                 "Returns an array containing the constants of this enum type,"},
+@@ -79,11 +79,11 @@
+                 "Class TypeParameters&lt;E&gt;</H2>"},
+             //Check class type parameters section.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<DT><B>Type Parameters:</B><DD><CODE>E</CODE> - " +
++                "<DT><STRONG>Type Parameters:</STRONG><DD><CODE>E</CODE> - " +
+                 "the type parameter for this class."},
+             //Type parameters in @see/@link
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<DT><B>See Also:</B><DD><A HREF=\"../pkg/TypeParameters.html\" " +
++                "<DT><STRONG>See Also:</STRONG><DD><A HREF=\"../pkg/TypeParameters.html\" " +
+                     "title=\"class in pkg\"><CODE>TypeParameters</CODE></A></DL>"},
+             //Method that uses class type parameter.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+@@ -91,13 +91,13 @@
+                     "parameter in TypeParameters\">E</A>&nbsp;param)"},
+             //Method type parameter section.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<B>Type Parameters:</B><DD><CODE>T</CODE> - This is the first " +
++                "<STRONG>Type Parameters:</STRONG><DD><CODE>T</CODE> - This is the first " +
+                     "type parameter.<DD><CODE>V</CODE> - This is the second type " +
+                     "parameter."},
+             //Signature of method with type parameters
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+                 "public &lt;T extends java.util.List,V&gt; " +
+-                    "java.lang.String[] <B>methodThatHasTypeParameters</B>"},
++                    "java.lang.String[] <STRONG>methodThatHasTypeParameters</STRONG>"},
+             //Wildcard testing.
+             {BUG_ID + FS + "pkg" + FS + "Wildcards.html",
+                 "<A HREF=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
+@@ -116,18 +116,18 @@
+ 
+             //Signature of subclass that has type parameters.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameterSubClass.html",
+-                "public class <B>TypeParameterSubClass&lt;T extends java.lang.String&gt;" +
+-                "</B><DT>extends <A HREF=\"../pkg/TypeParameterSuperClass.html\" " +
++                "public class <STRONG>TypeParameterSubClass&lt;T extends java.lang.String&gt;" +
++                "</STRONG><DT>extends <A HREF=\"../pkg/TypeParameterSuperClass.html\" " +
+                 "title=\"class in pkg\">TypeParameterSuperClass</A>&lt;T&gt;"},
+ 
+             //Interface generic parameter substitution
+             //Signature of subclass that has type parameters.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<B>All Implemented Interfaces:</B> <DD><A HREF=\"../pkg/SubInterface.html\" title=\"interface in pkg\">SubInterface</A>&lt;E&gt;, <A HREF=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">SuperInterface</A>&lt;E&gt;</DD>"},
++                "<STRONG>All Implemented Interfaces:</STRONG> <DD><A HREF=\"../pkg/SubInterface.html\" title=\"interface in pkg\">SubInterface</A>&lt;E&gt;, <A HREF=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">SuperInterface</A>&lt;E&gt;</DD>"},
+             {BUG_ID + FS + "pkg" + FS + "SuperInterface.html",
+-                "<B>All Known Subinterfaces:</B> <DD><A HREF=\"../pkg/SubInterface.html\" title=\"interface in pkg\">SubInterface</A>&lt;V&gt;</DD>"},
++                "<STRONG>All Known Subinterfaces:</STRONG> <DD><A HREF=\"../pkg/SubInterface.html\" title=\"interface in pkg\">SubInterface</A>&lt;V&gt;</DD>"},
+             {BUG_ID + FS + "pkg" + FS + "SubInterface.html",
+-                "<B>All Superinterfaces:</B> <DD><A HREF=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">SuperInterface</A>&lt;V&gt;</DD>"},
++                "<STRONG>All Superinterfaces:</STRONG> <DD><A HREF=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">SuperInterface</A>&lt;V&gt;</DD>"},
+ 
+             //=================================
+             // VAR ARG TESTING
+@@ -155,18 +155,18 @@
+                 "Annotation Type AnnotationType</H2>"},
+             //Make sure the signature is correct.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "public @interface <B>AnnotationType</B>"},
++                "public @interface <STRONG>AnnotationType</STRONG>"},
+             //Make sure member summary headings are correct.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "<B>Required Element Summary</B>"},
++                "<STRONG>Required Element Summary</STRONG>"},
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "<B>Optional Element Summary</B>"},
++                "<STRONG>Optional Element Summary</STRONG>"},
+             //Make sure element detail heading is correct
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+                 "Element Detail"},
+             //Make sure default annotation type value is printed when necessary.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "<B>Default:</B><DD>\"unknown\"</DD>"},
++                "<STRONG>Default:</STRONG><DD>\"unknown\"</DD>"},
+ 
+             //=================================
+             // ANNOTATION TYPE USAGE TESTING
+@@ -182,40 +182,40 @@
+                 "<FONT SIZE=\"-1\">" +
+                 "<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Class Annotation\","+NL +
+                 "                <A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)"+NL +
+-                "</FONT>public class <B>AnnotationTypeUsage</B><DT>extends java.lang.Object</DL>"},
++                "</FONT>public class <STRONG>AnnotationTypeUsage</STRONG><DT>extends java.lang.Object</DL>"},
+ 
+             //FIELD
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+                 "<FONT SIZE=\"-1\">" +
+                 "<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Field Annotation\","+NL +
+                 "                <A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)"+NL +
+-                "</FONT>public int <B>field</B>"},
++                "</FONT>public int <STRONG>field</STRONG>"},
+ 
+             //CONSTRUCTOR
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+                 "<FONT SIZE=\"-1\">" +
+                 "<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Constructor Annotation\","+NL +
+                 "                <A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)"+NL +
+-                "</FONT>public <B>AnnotationTypeUsage</B>()"},
++                "</FONT>public <STRONG>AnnotationTypeUsage</STRONG>()"},
+ 
+             //METHOD
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+                 "<FONT SIZE=\"-1\">" +
+                 "<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Method Annotation\","+NL +
+                 "                <A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)"+NL +
+-                "</FONT>public void <B>method</B>()"},
++                "</FONT>public void <STRONG>method</STRONG>()"},
+ 
+             //METHOD PARAMS
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+                 "<PRE>" + NL +
+-                "public void <B>methodWithParams</B>(<FONT SIZE=\"-1\"><A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Parameter Annotation\",<A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)</FONT>" + NL +
++                "public void <STRONG>methodWithParams</STRONG>(<FONT SIZE=\"-1\"><A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Parameter Annotation\",<A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)</FONT>" + NL +
+                 "                             int&nbsp;documented," + NL +
+                 "                             int&nbsp;undocmented)</PRE>"},
+ 
+             //CONSTRUCTOR PARAMS
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+                 "<PRE>" + NL +
+-                                "public <B>AnnotationTypeUsage</B>(<FONT SIZE=\"-1\"><A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Constructor Param Annotation\",<A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)</FONT>" + NL +
++                                "public <STRONG>AnnotationTypeUsage</STRONG>(<FONT SIZE=\"-1\"><A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Constructor Param Annotation\",<A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)</FONT>" + NL +
+                                 "                           int&nbsp;documented," + NL +
+                 "                           int&nbsp;undocmented)</PRE>"},
+ 
+@@ -270,7 +270,7 @@
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+                 "<PRE><FONT SIZE=\"-1\"><A HREF=\"../pkg1/A.html\" title=\"annotation in pkg1\">@A</A>"},
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "</FONT>public interface <B>B</B></DL>" + NL +
++                "</FONT>public interface <STRONG>B</STRONG></DL>" + NL +
+                     "</PRE>"},
+ 
+ 
+@@ -278,7 +278,7 @@
+             // Handle multiple bounds.
+             //==============================================================
+             {BUG_ID + FS + "pkg" + FS + "MultiTypeParameters.html",
+-                "public &lt;T extends java.lang.Number & java.lang.Runnable&gt; T <B>foo</B>(T&nbsp;t)"},
++                "public &lt;T extends java.lang.Number & java.lang.Runnable&gt; T <STRONG>foo</STRONG>(T&nbsp;t)"},
+ 
+             //==============================================================
+             // Test Class-Use Documenation for Type Parameters.
+@@ -289,13 +289,13 @@
+                  "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                "<TD><CODE><B><A HREF=\"../../pkg2/ClassUseTest1.html\" title=\"class in pkg2\">ClassUseTest1&lt;T extends Foo & Foo2&gt;</A></B></CODE>"
++                "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html\" title=\"class in pkg2\">ClassUseTest1&lt;T extends Foo & Foo2&gt;</A></STRONG></CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                "<TD><CODE><B>ClassUseTest1.</B><B><A HREF=\"../../pkg2/ClassUseTest1.html#method(T)\">method</A></B>(T&nbsp;t)</CODE>"
++                "<TD><CODE><STRONG>ClassUseTest1.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A></FONT></TH>"
+@@ -315,13 +315,13 @@
+             "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">Foo2</A></FONT></TH>"
+            },
+            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+-            "<TD><CODE><B><A HREF=\"../../pkg2/ClassUseTest1.html\" title=\"class in pkg2\">ClassUseTest1&lt;T extends Foo & Foo2&gt;</A></B></CODE>"
++            "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html\" title=\"class in pkg2\">ClassUseTest1&lt;T extends Foo & Foo2&gt;</A></STRONG></CODE>"
+            },
+            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+                "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">Foo2</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+-               "<TD><CODE><B>ClassUseTest1.</B><B><A HREF=\"../../pkg2/ClassUseTest1.html#method(T)\">method</A></B>(T&nbsp;t)</CODE>"
++               "<TD><CODE><STRONG>ClassUseTest1.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+ 
+             //ClassUseTest2: <T extends ParamTest<Foo3>>
+@@ -329,13 +329,13 @@
+               "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-              "<TD><CODE><B><A HREF=\"../../pkg2/ClassUseTest2.html\" title=\"class in pkg2\">ClassUseTest2&lt;T extends ParamTest&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;</A></B></CODE>"
++              "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html\" title=\"class in pkg2\">ClassUseTest2&lt;T extends ParamTest&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;</A></STRONG></CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+               "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-              "<TD><CODE><B>ClassUseTest2.</B><B><A HREF=\"../../pkg2/ClassUseTest2.html#method(T)\">method</A></B>(T&nbsp;t)</CODE>"
++              "<TD><CODE><STRONG>ClassUseTest2.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+               "<TH ALIGN=\"left\" COLSPAN=\"2\">Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> declared as <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A></FONT></TH>"
+@@ -354,13 +354,13 @@
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                "<TD><CODE><B><A HREF=\"../../pkg2/ClassUseTest2.html\" title=\"class in pkg2\">ClassUseTest2&lt;T extends ParamTest&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;</A></B></CODE>"
++                "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html\" title=\"class in pkg2\">ClassUseTest2&lt;T extends ParamTest&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;</A></STRONG></CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                "<TD><CODE><B>ClassUseTest2.</B><B><A HREF=\"../../pkg2/ClassUseTest2.html#method(T)\">method</A></B>(T&nbsp;t)</CODE>"
++                "<TD><CODE><STRONG>ClassUseTest2.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> that return types with arguments of type <A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A></FONT></TH>"
+@@ -374,13 +374,13 @@
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">ParamTest2</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                "<TD><CODE><B><A HREF=\"../../pkg2/ClassUseTest3.html\" title=\"class in pkg2\">ClassUseTest3&lt;T extends ParamTest2&lt;java.util.List&lt;? extends Foo4&gt;&gt;&gt;</A></B></CODE>"
++                "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html\" title=\"class in pkg2\">ClassUseTest3&lt;T extends ParamTest2&lt;java.util.List&lt;? extends Foo4&gt;&gt;&gt;</A></STRONG></CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">ParamTest2</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                "<TD><CODE><B>ClassUseTest3.</B><B><A HREF=\"../../pkg2/ClassUseTest3.html#method(T)\">method</A></B>(T&nbsp;t)</CODE>"
++                "<TD><CODE><STRONG>ClassUseTest3.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">ParamTest2</A></FONT></TH>"
+@@ -393,13 +393,13 @@
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                "<TD><CODE><B><A HREF=\"../../pkg2/ClassUseTest3.html\" title=\"class in pkg2\">ClassUseTest3&lt;T extends ParamTest2&lt;java.util.List&lt;? extends Foo4&gt;&gt;&gt;</A></B></CODE>"
++                "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html\" title=\"class in pkg2\">ClassUseTest3&lt;T extends ParamTest2&lt;java.util.List&lt;? extends Foo4&gt;&gt;&gt;</A></STRONG></CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A></FONT></TH>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                "<TD><CODE><B>ClassUseTest3.</B><B><A HREF=\"../../pkg2/ClassUseTest3.html#method(T)\">method</A></B>(T&nbsp;t)</CODE>"
++                "<TD><CODE><STRONG>ClassUseTest3.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> that return types with arguments of type <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A></FONT></TH>"
+@@ -415,13 +415,13 @@
+                 "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+                 "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+                 "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
+-                "<TD><CODE><B>ClassUseTest3.</B><B><A HREF=\"../../pkg2/ClassUseTest3.html#method(java.util.Set)\">method</A></B>(java.util.Set&lt;<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A>&gt;&nbsp;p)</CODE>"
++                "<TD><CODE><STRONG>ClassUseTest3.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#method(java.util.Set)\">method</A></STRONG>(java.util.Set&lt;<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A>&gt;&nbsp;p)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Constructor parameters in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type arguments of type <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A></FONT></TH>" + NL +
+                 "</TR>" + NL +
+                 "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD><CODE><B><A HREF=\"../../pkg2/ClassUseTest3.html#ClassUseTest3(java.util.Set)\">ClassUseTest3</A></B>(java.util.Set&lt;<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A>&gt;&nbsp;p)</CODE>"
++                "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#ClassUseTest3(java.util.Set)\">ClassUseTest3</A></STRONG>(java.util.Set&lt;<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A>&gt;&nbsp;p)</CODE>"
+             },
+ 
+             //=================================
+@@ -432,7 +432,7 @@
+                 "Packages with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" title=\"annotation in pkg\">AnnotationType</A></FONT></TH>" + NL +
+                 "</TR>" + NL +
+                 "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD><A HREF=\"../../pkg/package-summary.html\"><B>pkg</B></A></TD>"
++                "<TD><A HREF=\"../../pkg/package-summary.html\"><STRONG>pkg</STRONG></A></TD>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+@@ -441,7 +441,7 @@
+                 "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+                 "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+                 "<CODE>&nbsp;class</CODE></FONT></TD>" + NL +
+-                "<TD><CODE><B><A HREF=\"../../pkg/AnnotationTypeUsage.html\" title=\"class in pkg\">AnnotationTypeUsage</A></B></CODE>"
++                "<TD><CODE><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html\" title=\"class in pkg\">AnnotationTypeUsage</A></STRONG></CODE>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+@@ -450,7 +450,7 @@
+                 "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+                 "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+                 "<CODE>&nbsp;int</CODE></FONT></TD>" + NL +
+-                "<TD><CODE><B>AnnotationTypeUsage.</B><B><A HREF=\"../../pkg/AnnotationTypeUsage.html#field\">field</A></B></CODE>"
++                "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html#field\">field</A></STRONG></CODE>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+@@ -459,7 +459,7 @@
+                 "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+                 "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+                 "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
+-                "<TD><CODE><B>AnnotationTypeUsage.</B><B><A HREF=\"../../pkg/AnnotationTypeUsage.html#method()\">method</A></B>()</CODE>"
++                "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html#method()\">method</A></STRONG>()</CODE>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+@@ -468,7 +468,7 @@
+                 "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+                 "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+                 "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
+-                "<TD><CODE><B>AnnotationTypeUsage.</B><B><A HREF=\"../../pkg/AnnotationTypeUsage.html#methodWithParams(int, int)\">methodWithParams</A></B>(int&nbsp;documented," + NL +
++                "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html#methodWithParams(int, int)\">methodWithParams</A></STRONG>(int&nbsp;documented," + NL +
+                 "                 int&nbsp;undocmented)</CODE>"
+             },
+ 
+@@ -476,14 +476,14 @@
+                 "Constructors in <A HREF=\"../../pkg/package-summary.html\">pkg</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" title=\"annotation in pkg\">AnnotationType</A></FONT></TH>" + NL +
+                 "</TR>" + NL +
+                 "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD><CODE><B><A HREF=\"../../pkg/AnnotationTypeUsage.html#AnnotationTypeUsage()\">AnnotationTypeUsage</A></B>()</CODE>"
++                "<TD><CODE><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html#AnnotationTypeUsage()\">AnnotationTypeUsage</A></STRONG>()</CODE>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+                 "Constructor parameters in <A HREF=\"../../pkg/package-summary.html\">pkg</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" title=\"annotation in pkg\">AnnotationType</A></FONT></TH>" + NL +
+                 "</TR>" + NL +
+                 "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD><CODE><B><A HREF=\"../../pkg/AnnotationTypeUsage.html#AnnotationTypeUsage(int, int)\">AnnotationTypeUsage</A></B>(int&nbsp;documented," + NL +
++                "<TD><CODE><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html#AnnotationTypeUsage(int, int)\">AnnotationTypeUsage</A></STRONG>(int&nbsp;documented," + NL +
+                 "                    int&nbsp;undocmented)</CODE>"
+             },
+ 
+@@ -491,13 +491,13 @@
+             // TYPE PARAMETER IN INDEX
+             //=================================
+             {BUG_ID + FS + "index-all.html",
+-                "<A HREF=\"./pkg2/Foo.html#method(java.util.Vector)\"><B>method(Vector&lt;Object&gt;)</B></A>"
++                "<A HREF=\"./pkg2/Foo.html#method(java.util.Vector)\"><STRONG>method(Vector&lt;Object&gt;)</STRONG></A>"
+             },
+             //=================================
+             // TYPE PARAMETER IN INDEX
+             //=================================
+             {BUG_ID + FS + "index-all.html",
+-                "<A HREF=\"./pkg2/Foo.html#method(java.util.Vector)\"><B>method(Vector&lt;Object&gt;)</B></A>"
++                "<A HREF=\"./pkg2/Foo.html#method(java.util.Vector)\"><STRONG>method(Vector&lt;Object&gt;)</STRONG></A>"
+             },
+         };
+     private static final String[][] NEGATED_TEST = {
+@@ -505,7 +505,7 @@
+         // ENUM TESTING
+         //=================================
+         //NO constructor section
+-        {BUG_ID + FS + "pkg" + FS + "Coin.html", "<B>Constructor Summary</B>"},
++        {BUG_ID + FS + "pkg" + FS + "Coin.html", "<STRONG>Constructor Summary</STRONG>"},
+         //=================================
+         // TYPE PARAMETER TESTING
+         //=================================
+@@ -525,28 +525,28 @@
+             "<FONT SIZE=\"-1\">" + NL +
+             "<A HREF=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</A>(<A HREF=\"../pkg/AnnotationType.html#optional\">optional</A>=\"Class Annotation\"," + NL +
+             "                <A HREF=\"../pkg/AnnotationType.html#required\">required</A>=1994)" + NL +
+-            "</FONT>public class <B>AnnotationTypeUsage</B><DT>extends java.lang.Object</DL>"},
++            "</FONT>public class <STRONG>AnnotationTypeUsage</STRONG><DT>extends java.lang.Object</DL>"},
+ 
+         //FIELD
+         {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+             "<FONT SIZE=\"-1\">" + NL +
+             "<A HREF=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</A>(<A HREF=\"../pkg/AnnotationType.html#optional\">optional</A>=\"Field Annotation\"," + NL +
+             "                <A HREF=\"../pkg/AnnotationType.html#required\">required</A>=1994)" + NL +
+-            "</FONT>public int <B>field</B>"},
++            "</FONT>public int <STRONG>field</STRONG>"},
+ 
+         //CONSTRUCTOR
+         {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+             "<FONT SIZE=\"-1\">" + NL +
+             "<A HREF=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</A>(<A HREF=\"../pkg/AnnotationType.html#optional\">optional</A>=\"Constructor Annotation\"," + NL +
+             "                <A HREF=\"../pkg/AnnotationType.html#required\">required</A>=1994)" + NL +
+-            "</FONT>public <B>AnnotationTypeUsage</B>()"},
++            "</FONT>public <STRONG>AnnotationTypeUsage</STRONG>()"},
+ 
+         //METHOD
+         {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+             "<FONT SIZE=\"-1\">" + NL +
+             "<A HREF=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</A>(<A HREF=\"../pkg/AnnotationType.html#optional\">optional</A>=\"Method Annotation\"," + NL +
+             "                <A HREF=\"../pkg/AnnotationType.html#required\">required</A>=1994)" + NL +
+-            "</FONT>public void <B>method</B>()"},
++            "</FONT>public void <STRONG>method</STRONG>()"},
+ 
+         //=================================
+         // Make sure annotation types do not
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java
+@@ -46,9 +46,9 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-            "<B>Description copied from class: <CODE>" +
++            "<STRONG>Description copied from class: <CODE>" +
+             "<A HREF=\"../pkg1/BaseClass.html#overridenMethodWithDocsToCopy()\">" +
+-            "BaseClass</A></CODE></B>"
++            "BaseClass</A></CODE></STRONG>"
+         }
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
+@@ -40,11 +40,11 @@
+     private static final String[][] TEST = {
+         //The public method should be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
+ 
+         //The public method in different package should be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"}
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"}
+     };
+ 
+     private static final String[][] NEGATED_TEST = {
+@@ -52,20 +52,20 @@
+         //The package private method should be overriden since the base and sub class are in the same
+         //package.  However, the link should not show up because the package private methods are not documented.
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
+ 
+         //The private method in should not be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The private method in different package should not be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The package private method should not be overriden since the base and sub class are in
+         //different packages.
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
+     };
+ 
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java
+@@ -40,32 +40,32 @@
+     private static final String[][] TEST = {
+         //The public method should be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
+ 
+         //The public method in different package should be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
+ 
+         //The package private method should be overriden since the base and sub class are in the same
+         //package.
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
+     };
+ 
+     private static final String[][] NEGATED_TEST = {
+ 
+         //The private method in should not be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The private method in different package should not be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The package private method should not be overriden since the base and sub class are in
+         //different packages.
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
+     };
+ 
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java
+@@ -40,32 +40,32 @@
+     private static final String[][] TEST = {
+         //The public method should be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
+ 
+         //The package private method should be overriden since the base and sub class are in the same
+         //package.
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
+ 
+         //The public method in different package should be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
+     };
+ 
+     private static final String[][] NEGATED_TEST = {
+ 
+         //The private method in should not be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The private method in different package should not be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The package private method should not be overriden since the base and sub class are in
+         //different packages.
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</B><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
++         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
+ 
+ 
+     };
+diff --git a/test/com/sun/javadoc/testPackagePage/TestPackagePage.java b/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
+--- openjdk/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
++++ openjdk/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
+@@ -43,23 +43,24 @@
+         },
+         //With just one package, all general pages link to the single package page.
+         {BUG_ID + "-1" + FS + "com" + FS + "pkg" + FS + "C.html",
+-            "<A HREF=\"../../com/pkg/package-summary.html\">" +
            "<FONT CLASS=\"NavBarFont1\"><B>Package</B></FONT></A>"
++            "<A HREF=\"../../com/pkg/package-summary.html\">" +
++            "<FONT CLASS=\"NavBarFont1\"><STRONG>Package</STRONG></FONT></A>"
+         },
+         {BUG_ID + "-1" + FS + "com" + FS + "pkg" + FS + "package-tree.html",
+             "<A HREF=\"../../com/pkg/package-summary.html\">" +
+-            "<FONT CLASS=\"NavBarFont1\"><B>Package</B></FONT></A>"
++            "<FONT CLASS=\"NavBarFont1\"><STRONG>Package</STRONG></FONT></A>"
+         },
+         {BUG_ID + "-1" + FS + "deprecated-list.html",
+             "<A HREF=\"com/pkg/package-summary.html\">" +
+-            "<FONT CLASS=\"NavBarFont1\"><B>Package</B></FONT></A>"
++            "<FONT CLASS=\"NavBarFont1\"><STRONG>Package</STRONG></FONT></A>"
+         },
+         {BUG_ID + "-1" + FS + "index-all.html",
+             "<A HREF=\"./com/pkg/package-summary.html\">" +
+-            "<FONT CLASS=\"NavBarFont1\"><B>Package</B></FONT></A>"
++            "<FONT CLASS=\"NavBarFont1\"><STRONG>Package</STRONG></FONT></A>"
+         },
+         {BUG_ID + "-1" + FS + "help-doc.html",
+             "<A HREF=\"com/pkg/package-summary.html\">" +
+-            "<FONT CLASS=\"NavBarFont1\"><B>Package</B></FONT></A>"
++            "<FONT CLASS=\"NavBarFont1\"><STRONG>Package</STRONG></FONT></A>"
+         },
+     };
+ 
+diff --git a/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java b/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
+--- openjdk/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
++++ openjdk/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
+@@ -48,12 +48,12 @@
+     private static final String[][] TEST = {
+         //Regular param tags.
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<B>Parameters:</B><DD><CODE>param1</CODE> - testing 1 2 3." +
++            "<STRONG>Parameters:</STRONG><DD><CODE>param1</CODE> - testing 1 2 3." +
+                 "<DD><CODE>param2</CODE> - testing 1 2 3."
+         },
+         //Param tags that don't match with any real parameters.
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<B>Parameters:</B><DD><CODE><I>p1</I></CODE> - testing 1 2 3." +
++            "<STRONG>Parameters:</STRONG><DD><CODE><I>p1</I></CODE> - testing 1 2 3." +
+                 "<DD><CODE><I>p2</I></CODE> - testing 1 2 3."
+         },
+         //{@inherit} doc misuse does not cause doclet to throw exception.
+diff --git a/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java b/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
+--- openjdk/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
++++ openjdk/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
+@@ -85,22 +85,22 @@
+             "<PRE>" + NL +
+                 "java.lang.Object" + NL +
+                 "  <IMG SRC=\"../resources/inherit.gif\" " +
+-                "ALT=\"extended by \"><B>pkg.PublicChild</B>" + NL +
++                "ALT=\"extended by \"><STRONG>pkg.PublicChild</STRONG>" + NL +
+             "</PRE>"
+         },
+ 
+         // Method is documented as though it is declared in the inheriting method.
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-            "public void <B>methodInheritedFromParent</B>(int&nbsp;p1)"
++            "public void <STRONG>methodInheritedFromParent</STRONG>(int&nbsp;p1)"
+         },
+ 
+         //Make sure implemented interfaces from private superclass are inherited
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
+-            "<B>All Known Implementing Classes:</B> <DD><A HREF=\"../pkg/PublicChild.html\" " +
++            "<STRONG>All Known Implementing Classes:</STRONG> <DD><A HREF=\"../pkg/PublicChild.html\" " +
+             "title=\"class in pkg\">PublicChild</A>"},
+ 
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-            "<B>All Implemented Interfaces:</B> <DD><A HREF=\"../pkg/PublicInterface.html\" " +
++            "<STRONG>All Implemented Interfaces:</STRONG> <DD><A HREF=\"../pkg/PublicInterface.html\" " +
+             "title=\"interface in pkg\">PublicInterface</A>"},
+ 
+         //Generic interface method test.
+@@ -110,12 +110,12 @@
+     private static final String[][] NEGATED_TEST1 = {
+        // Should not document that a method overrides method from private class.
+       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-        "<B>Overrides:</B>"},
++        "<STRONG>Overrides:</STRONG>"},
+       // Should not document that a method specified by private interface.
+       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-        "<B>Specified by:</B>"},
++        "<STRONG>Specified by:</STRONG>"},
+       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
+-        "<B>Specified by:</B>"},
++        "<STRONG>Specified by:</STRONG>"},
+       // Should not mention that any documentation was copied.
+       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+         "Description copied from"},
+@@ -137,7 +137,7 @@
+         //Do not inherit private interface method with generic parameters.
+         //This method has been implemented.
+         {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html",
+-            "<B><A HREF=\"../pkg2/I.html#hello(T)\">hello</A></B>"},
++            "<STRONG><A HREF=\"../pkg2/I.html#hello(T)\">hello</A></STRONG>"},
+     };
+ 
+     // Test output when -private flag is used.
+@@ -174,14 +174,14 @@
+         },
+         // Should document that a method overrides method from private class.
+        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-            "<B>Overrides:</B><DD><CODE>" +
++            "<STRONG>Overrides:</STRONG><DD><CODE>" +
+             "<A HREF=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" +
+             "methodOverridenFromParent</A></CODE> in class <CODE>" +
+             "<A HREF=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
+             "PrivateParent</A></CODE></DL>"},
+        // Should document that a method is specified by private interface.
+        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-            "<B>Specified by:</B><DD><CODE>" +
++            "<STRONG>Specified by:</STRONG><DD><CODE>" +
+             "<A HREF=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
+             "methodInterface</A></CODE> in interface <CODE>" +
+             "<A HREF=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
+@@ -209,12 +209,12 @@
+ 
+       //Make sure implemented interfaces from private superclass are inherited
+       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
+-        "<B>All Known Implementing Classes:</B> <DD><A HREF=\"../pkg/PrivateParent.html\" " +
++        "<STRONG>All Known Implementing Classes:</STRONG> <DD><A HREF=\"../pkg/PrivateParent.html\" " +
+         "title=\"class in pkg\">PrivateParent</A>, " +
+         "<A HREF=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild</A>"},
+ 
+       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-        "<B>All Implemented Interfaces:</B> <DD><A HREF=\"../pkg/PrivateInterface.html\" " +
++        "<STRONG>All Implemented Interfaces:</STRONG> <DD><A HREF=\"../pkg/PrivateInterface.html\" " +
+         "title=\"interface in pkg\">PrivateInterface</A>, " +
+         "<A HREF=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
+         "PublicInterface</A>"},
+@@ -222,10 +222,13 @@
+       //Since private flag is used, we can document that private interface method
+       //with generic parameters has been implemented.
+       {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
+-            "<B>Description copied from interface: " +
            "<CODE><A HREF=\"../pkg2/I.html#hello(T)\">I</A></CODE></B>"},
++            "<STRONG>Description copied from interface: " +
++            "<CODE><A HREF=\"../pkg2/I.html#hello(T)\">I</A></CODE></STRONG>"},
+ 
+       {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
+-            "<B>Specified by:</B><DD><CODE><A HREF=\"../pkg2/I.html#hello(T)\">" +
            "hello</A></CODE> in interface <CODE><A HREF=\"../pkg2/I.html\" " +
            "title=\"interface in pkg2\">I</A>"},
++            "<STRONG>Specified by:</STRONG><DD><CODE><A HREF=\"../pkg2/I.html#hello(T)\">" +
++            "hello</A></CODE> in interface <CODE><A HREF=\"../pkg2/I.html\" " +
++            "title=\"interface in pkg2\">I</A>"},
+     };
+     private static final String[][] NEGATED_TEST2 = NO_TEST;
+ 
+diff --git a/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java b/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java
+--- openjdk/langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java
++++ openjdk/langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java
+@@ -47,11 +47,11 @@
+ 
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "serialized-form.html",
+-            "protected java.lang.Object <B>readResolve</B>()"},
++            "protected java.lang.Object <STRONG>readResolve</STRONG>()"},
+         {BUG_ID + FS + "serialized-form.html",
+-            "protected java.lang.Object <B>writeReplace</B>()"},
++            "protected java.lang.Object <STRONG>writeReplace</STRONG>()"},
+         {BUG_ID + FS + "serialized-form.html",
+-            "protected java.lang.Object <B>readObjectNoData</B>()"},
++            "protected java.lang.Object <STRONG>readObjectNoData</STRONG>()"},
+         {BUG_ID + FS + "serialized-form.html",
+             "See Also"},
+     };
+diff --git a/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java b/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java
+@@ -42,13 +42,13 @@
+     private static final String[][] TEST =
+         new String[][] {
+             {"./" + BUG_ID + "/C.html",
+-                "<B>Todo:</B>"},
++                "<STRONG>Todo:</STRONG>"},
+             {"./" + BUG_ID + "/C.html",
+-                "<B>EJB Beans:</B>"},
++                "<STRONG>EJB Beans:</STRONG>"},
+             {"./" + BUG_ID + "/C.html",
+-                "<B>Regular Tag:</B>"},
++                "<STRONG>Regular Tag:</STRONG>"},
+             {"./" + BUG_ID + "/C.html",
+-                "<B>Back-Slash-Tag:</B>"},
++                "<STRONG>Back-Slash-Tag:</STRONG>"},
+         };
+ 
+     private static final String[] ARGS = new String[] {
+diff --git a/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java b/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java
+--- openjdk/langtools/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java
++++ openjdk/langtools/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java
+@@ -46,7 +46,7 @@
+ 
+     //Input for string search tests.
+     private static final String[][] TEST = {
+-        {BUG_ID + FS + "C.html",  "<B>Method Summary</B>"}
++        {BUG_ID + FS + "C.html",  "<STRONG>Method Summary</STRONG>"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+ 
+diff --git a/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java b/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java
+--- openjdk/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java
++++ openjdk/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java
+@@ -38,7 +38,7 @@
+ 
+     private static final String BUG_ID = "4530727";
+     private static final String[][] TEST = {
+-        {BUG_ID + FS + "C.html", "<DT><B>Throws:</B>"}
++        {BUG_ID + FS + "C.html", "<DT><STRONG>Throws:</STRONG>"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+     private static final String[] ARGS = new String[] {
+diff --git a/test/com/sun/javadoc/testValueTag/TestValueTag.java b/test/com/sun/javadoc/testValueTag/TestValueTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java
+@@ -88,7 +88,7 @@
+             "Result: <A HREF=\"../pkg2/Class3.html#TEST_17_PASSES\">\"Test 17 passes\"</A>"},
+         //Test @value tag used with custom tag.
+         {BUG_ID + FS + "pkg1" + FS + "CustomTagUsage.html",
+-            "<DT><B>Todo:</B></DT>" + NL +
++            "<DT><STRONG>Todo:</STRONG></DT>" + NL +
+                 "  <DD>the value of this constant is 55.</DD>"},
+         //Test @value warning printed when used with non-constant.
+         {WARNING_OUTPUT,"warning - @value tag (which references nonConstant) " +
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6786682-wcag_lang.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,274 @@
+# HG changeset patch
+# User bpatel
+# Date 1232068871 28800
+# Node ID 92a90d8c955b6cc619d16975e02d9143715dedaa
+# Parent  a50f3556d6954decf0897aa984c8ba43def77b9e
+6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
+Reviewed-by: jjg
+
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java
+@@ -493,4 +493,14 @@
+     public Comparator getMemberComparator() {
+         return null;
+     }
++
++    /**
++     * {@inheritDoc}
++     */
++    public Locale getLocale() {
++        if (root instanceof com.sun.tools.javadoc.RootDocImpl)
++            return ((com.sun.tools.javadoc.RootDocImpl)root).getLocale();
++        else
++            return Locale.getDefault();
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+@@ -85,7 +85,7 @@
+      * Print &lt;HTML&gt; tag. Add a newline character at the end.
+      */
+     public void html() {
+-        println("<HTML>");
++        println("<HTML lang=\"" + configuration.getLocale().getLanguage() + "\">");
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java
+@@ -707,6 +707,11 @@
+     }
+ 
+     /**
++     * Return the Locale for this document.
++     */
++    public abstract Locale getLocale();
++
++    /**
+      * Return the comparator that will be used to sort member documentation.
+      * To no do any sorting, return null.
+      *
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java
+@@ -155,7 +155,7 @@
+                 reader.close();
+             }
+             output = addLineNumbers(output.toString());
+-            output.insert(0, getHeader());
++            output.insert(0, getHeader(configuration));
+             output.append(getFooter());
+             writeToFile(output.toString(), outputdir, cd.name(), configuration);
+         } catch (Exception e){
+@@ -205,10 +205,11 @@
+ 
+     /**
+      * Get the header.
++     * @param configuration the Doclet configuration
+      * @return the header to the output file
+      */
+-    protected static String getHeader() {
+-        StringBuffer result = new StringBuffer("<HTML>" + DocletConstants.NL);
++    protected static String getHeader(Configuration configuration) {
++        StringBuffer result = new StringBuffer("<HTML lang=\"" + configuration.getLocale().getLanguage() + "\">" + DocletConstants.NL);
+         result.append("<BODY BGCOLOR=\""+ BGCOLOR + "\">" + DocletConstants.NL);
+         result.append("<PRE>" + DocletConstants.NL);
+         return result.toString();
+diff --git a/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java b/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
+@@ -36,6 +36,7 @@
+ import com.sun.tools.javac.util.List;
+ import com.sun.tools.javac.util.ListBuffer;
+ import com.sun.tools.javac.util.Position;
++import java.util.Locale;
+ 
+ /**
+  * This class holds the information from one run of javadoc.
+@@ -361,4 +362,11 @@
+     public Locale getLocale() {
+         return env.doclocale.locale;
+     }
++
++    /**
++     * Return the locale provided by the user or the default locale value.
++     */
++    public Locale getLocale() {
++        return env.doclocale.locale;
++    }
+ }
+diff --git a/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java b/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java
+@@ -0,0 +1,93 @@
++/*
++ * 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.  Sun designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Sun in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/*
++ * @test
++ * @bug 6786682
++ * @summary This test verifies the use of lang attribute by <HTML>.
++ * @author Bhavesh Patel
++ * @library ../lib/
++ * @build JavadocTester
++ * @build TestHtmlTag
++ * @run main TestHtmlTag
++ */
++
++import java.util.Locale;
++
++public class TestHtmlTag extends JavadocTester {
++
++    private static final String BUG_ID = "6786682";
++    private static final String[][] TEST1 = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML lang=\"" + Locale.getDefault().getLanguage() + "\">"},
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<HTML lang=\"" + Locale.getDefault().getLanguage() + "\">"}};
++    private static final String[][] NEGATED_TEST1 = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML>"}};
++    private static final String[][] TEST2 = {
++        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<HTML lang=\"ja\">"},
++        {BUG_ID + FS + "pkg2" + FS + "package-summary.html", "<HTML lang=\"ja\">"}};
++    private static final String[][] NEGATED_TEST2 = {
++        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<HTML>"}};
++    private static final String[][] TEST3 = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML lang=\"en\">"},
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<HTML lang=\"en\">"}};
++    private static final String[][] NEGATED_TEST3 = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML>"}};
++
++    private static final String[] ARGS1 =
++        new String[] {
++            "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
++    private static final String[] ARGS2 =
++        new String[] {
++            "-locale", "ja", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg2"};
++    private static final String[] ARGS3 =
++        new String[] {
++            "-locale", "en_US", "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
++
++    /**
++     * The entry point of the test.
++     * @param args the array of command line arguments.
++     */
++    public static void main(String[] args) {
++        TestHtmlTag tester = new TestHtmlTag();
++        run(tester, ARGS1, TEST1, NEGATED_TEST1);
++        run(tester, ARGS2, TEST2, NEGATED_TEST2);
++        run(tester, ARGS3, TEST3, NEGATED_TEST3);
++        tester.printSummary();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getBugId() {
++        return BUG_ID;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getBugName() {
++        return getClass().getName();
++    }
++}
+diff --git a/test/com/sun/javadoc/testHtmlTag/pkg1/C1.java b/test/com/sun/javadoc/testHtmlTag/pkg1/C1.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTag/pkg1/C1.java
+@@ -0,0 +1,33 @@
++/*
++ * 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.  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 pkg1;
++
++public class C1 {
++
++    public void method(int param1, int param2) {
++
++    }
++}
+diff --git a/test/com/sun/javadoc/testHtmlTag/pkg2/C2.java b/test/com/sun/javadoc/testHtmlTag/pkg2/C2.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTag/pkg2/C2.java
+@@ -0,0 +1,31 @@
++/*
++ * 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.  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 pkg2;
++
++/**
++ * <B>Comments:</B> Class 2
++ */
++public class C2 {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6786688-wcag_table.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,2828 @@
+# HG changeset patch
+# User andrew
+# Date 1371572266 18000
+# Node ID 694e895f2b866d36ed7f8d4ea08ec64677d3fba1
+# Parent  9cad0410f52a47fdd3b294a10f076e7456a47e9a
+6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
+Reviewed-by: jjg
+
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+@@ -60,7 +60,11 @@
+ 
+     /*** abstracts ***/
+ 
+-    public abstract void printSummaryLabel(ClassDoc cd);
++    public abstract void printSummaryLabel();
++
++    public abstract void printTableSummary();
++
++    public abstract void printSummaryTableHeader(ProgramElementDoc member);
+ 
+     public abstract void printInheritedSummaryLabel(ClassDoc cd);
+ 
+@@ -342,12 +346,13 @@
+      * format for listing the API. Call methods from the sub-class to complete
+      * the generation.
+      */
+-    protected void printDeprecatedAPI(List deprmembers, String headingKey) {
++    protected void printDeprecatedAPI(List<Doc> deprmembers, String headingKey, String tableSummary, String[] tableHeader) {
+         if (deprmembers.size() > 0) {
+-            writer.tableIndexSummary();
+-            writer.tableHeaderStart("#CCCCFF");
+-            writer.strongText(headingKey);
+-            writer.tableHeaderEnd();
++            writer.tableIndexSummary(tableSummary);
++            writer.tableCaptionStart();
++            writer.printText(headingKey);
++            writer.tableCaptionEnd();
++            writer.summaryTableHeader(tableHeader, "col");
+             for (int i = 0; i < deprmembers.size(); i++) {
+                 ProgramElementDoc member =(ProgramElementDoc)deprmembers.get(i);
+                 writer.trBgcolorStyle("white", "TableRowColor");
+@@ -370,19 +375,26 @@
+     /**
+      * Print use info.
+      */
+-    protected void printUseInfo(Object mems, String heading) {
++    protected void printUseInfo(List<? extends ProgramElementDoc> mems, String heading, String tableSummary) {
+         if (mems == null) {
+             return;
+         }
+         List members = (List)mems;
++        boolean printedUseTableHeader = false;
+         if (members.size() > 0) {
+-            writer.tableIndexSummary();
+-            writer.tableUseInfoHeaderStart("#CCCCFF");
++            writer.tableIndexSummary(tableSummary);
++            writer.tableSubCaptionStart();
+             writer.print(heading);
+-            writer.tableHeaderEnd();
++            writer.tableCaptionEnd();
+             for (Iterator it = members.iterator(); it.hasNext(); ) {
+                 ProgramElementDoc pgmdoc = (ProgramElementDoc)it.next();
+                 ClassDoc cd = pgmdoc.containingClass();
++                if (!printedUseTableHeader) {
++                    // Passing ProgramElementDoc helps decides printing
++                    // interface or class header in case of nested classes.
++                    this.printSummaryTableHeader(pgmdoc);
++                    printedUseTableHeader = true;
++                }
+ 
+                 writer.printSummaryLinkType(this, pgmdoc);
+                 if (cd != null && !(pgmdoc instanceof ConstructorDoc)
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
+@@ -35,6 +35,7 @@
+  * generate overview-frame.html as well as overview-summary.html.
+  *
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter {
+ 
+@@ -61,7 +62,7 @@
+ 
+     protected abstract void printOverviewHeader();
+ 
+-    protected abstract void printIndexHeader(String text);
++    protected abstract void printIndexHeader(String text, String tableSummary);
+ 
+     protected abstract void printIndexRow(PackageDoc pkg);
+ 
+@@ -101,7 +102,10 @@
+      * Generate the frame or non-frame package index.
+      */
+     protected void generateIndex() {
+-        printIndexContents(packages, "doclet.Package_Summary");
++        printIndexContents(packages, "doclet.Package_Summary",
++                configuration.getText("doclet.Member_Table_Summary",
++                configuration.getText("doclet.Package_Summary"),
++                configuration.getText("doclet.packages")));
+     }
+ 
+     /**
+@@ -111,10 +115,10 @@
+      * @param packages Array of packages to be documented.
+      * @param text     String which will be used as the heading.
+      */
+-    protected void printIndexContents(PackageDoc[] packages, String text) {
++    protected void printIndexContents(PackageDoc[] packages, String text, String tableSummary) {
+         if (packages.length > 0) {
+             Arrays.sort(packages);
+-            printIndexHeader(text);
++            printIndexHeader(text, tableSummary);
+             printAllClassesPackagesLink();
+             for(int i = 0; i < packages.length; i++) {
+                 if (packages[i] != null) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+@@ -34,6 +34,7 @@
+  * Writes annotation type optional member documentation in HTML format.
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  */
+ public class AnnotationTypeOptionalMemberWriterImpl extends
+         AnnotationTypeRequiredMemberWriterImpl
+@@ -89,8 +90,27 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void printSummaryLabel(ClassDoc cd) {
+-        writer.strongText("doclet.Annotation_Type_Optional_Member_Summary");
++    public void printSummaryLabel() {
++        writer.printText("doclet.Annotation_Type_Optional_Member_Summary");
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void printTableSummary() {
++        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++                configuration().getText("doclet.Annotation_Type_Optional_Member_Summary"),
++                configuration().getText("doclet.annotation_type_optional_members")));
++    }
++
++    public void printSummaryTableHeader(ProgramElementDoc member) {
++        String[] header = new String[] {
++            writer.getModifierTypeHeader(),
++            configuration().getText("doclet.0_and_1",
++                    configuration().getText("doclet.Annotation_Type_Optional_Member"),
++                    configuration().getText("doclet.Description"))
++        };
++        writer.summaryTableHeader(header, "col");
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+@@ -34,6 +34,7 @@
+  * Writes annotation type required member documentation in HTML format.
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  */
+ public class AnnotationTypeRequiredMemberWriterImpl extends AbstractMemberWriter
+     implements AnnotationTypeRequiredMemberWriter, MemberSummaryWriter {
+@@ -178,8 +179,27 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void printSummaryLabel(ClassDoc cd) {
+-        writer.strongText("doclet.Annotation_Type_Required_Member_Summary");
++    public void printSummaryLabel() {
++        writer.printText("doclet.Annotation_Type_Required_Member_Summary");
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void printTableSummary() {
++        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++                configuration().getText("doclet.Annotation_Type_Required_Member_Summary"),
++                configuration().getText("doclet.annotation_type_required_members")));
++    }
++
++    public void printSummaryTableHeader(ProgramElementDoc member) {
++        String[] header = new String[] {
++            writer.getModifierTypeHeader(),
++            configuration().getText("doclet.0_and_1",
++                    configuration().getText("doclet.Annotation_Type_Required_Member"),
++                    configuration().getText("doclet.Description"))
++        };
++        writer.summaryTableHeader(header, "col");
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+@@ -34,6 +34,7 @@
+  * Generate class usage information.
+  *
+  * @author Robert G. Field
++ * @author Bhavesh Patel (Modified)
+  */
+ public class ClassUseWriter extends SubWriterHolderWriter {
+ 
+@@ -65,6 +66,13 @@
+     final ConstructorWriterImpl constrSubWriter;
+     final FieldWriterImpl fieldSubWriter;
+     final NestedClassWriterImpl classSubWriter;
++    // Summary for various use tables.
++    final String classUseTableSummary;
++    final String subclassUseTableSummary;
++    final String subinterfaceUseTableSummary;
++    final String fieldUseTableSummary;
++    final String methodUseTableSummary;
++    final String constructorUseTableSummary;
+ 
+ 
+     /**
+@@ -116,6 +124,18 @@
+         constrSubWriter = new ConstructorWriterImpl(this);
+         fieldSubWriter = new FieldWriterImpl(this);
+         classSubWriter = new NestedClassWriterImpl(this);
++        classUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
++                configuration.getText("doclet.classes"));
++        subclassUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
++                configuration.getText("doclet.subclasses"));
++        subinterfaceUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
++                configuration.getText("doclet.subinterfaces"));
++        fieldUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
++                configuration.getText("doclet.fields"));
++        methodUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
++                configuration.getText("doclet.methods"));
++        constructorUseTableSummary = configuration.getText("doclet.Use_Table_Summary",
++                configuration.getText("doclet.constructors"));
+     }
+ 
+     /**
+@@ -213,12 +233,13 @@
+     }
+ 
+     protected void generatePackageList() throws IOException {
+-        tableIndexSummary();
+-        tableHeaderStart("#CCCCFF");
++        tableIndexSummary(useTableSummary);
++        tableCaptionStart();
+         printText("doclet.ClassUse_Packages.that.use.0",
+             getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
+                 false)));
+-        tableHeaderEnd();
++        tableCaptionEnd();
++        summaryTableHeader(packageTableHeader, "col");
+ 
+         for (Iterator it = pkgSet.iterator(); it.hasNext();) {
+             PackageDoc pkg = (PackageDoc)it.next();
+@@ -234,12 +255,13 @@
+                pkgToPackageAnnotations == null ||
+                pkgToPackageAnnotations.size() == 0)
+             return;
+-        tableIndexSummary();
+-        tableHeaderStart("#CCCCFF");
++        tableIndexSummary(useTableSummary);
++        tableCaptionStart();
+         printText("doclet.ClassUse_PackageAnnotation",
+             getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
+                 false)));
+-        tableHeaderEnd();
++        tableCaptionEnd();
++        summaryTableHeader(packageTableHeader, "col");
+         for (Iterator it = pkgToPackageAnnotations.iterator(); it.hasNext();) {
+             PackageDoc pkg = (PackageDoc)it.next();
+             trBgcolorStyle("white", "TableRowColor");
+@@ -300,83 +322,68 @@
+             LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false));
+         String pkgLink = getPackageLink(pkg, Util.getPackageName(pkg), false);
+         classSubWriter.printUseInfo(pkgToClassAnnotations.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_Annotation", classLink,
+-            pkgLink));
+-
++                configuration.getText("doclet.ClassUse_Annotation", classLink,
++                pkgLink), classUseTableSummary);
+         classSubWriter.printUseInfo(pkgToClassTypeParameter.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_TypeParameter", classLink,
+-            pkgLink));
++                configuration.getText("doclet.ClassUse_TypeParameter", classLink,
++                pkgLink), classUseTableSummary);
+         classSubWriter.printUseInfo(pkgToSubclass.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_Subclass", classLink,
+-            pkgLink));
++                configuration.getText("doclet.ClassUse_Subclass", classLink,
++                pkgLink), subclassUseTableSummary);
+         classSubWriter.printUseInfo(pkgToSubinterface.get(pkg.name()),
+-                                    configuration.getText("doclet.ClassUse_Subinterface",
+-                                            classLink,
+-                                            pkgLink));
++                configuration.getText("doclet.ClassUse_Subinterface", classLink,
++                pkgLink), subinterfaceUseTableSummary);
+         classSubWriter.printUseInfo(pkgToImplementingClass.get(pkg.name()),
+-                                    configuration.getText("doclet.ClassUse_ImplementingClass",
+-                                            classLink,
+-                                            pkgLink));
++                configuration.getText("doclet.ClassUse_ImplementingClass", classLink,
++                pkgLink), classUseTableSummary);
+         fieldSubWriter.printUseInfo(pkgToField.get(pkg.name()),
+-                                    configuration.getText("doclet.ClassUse_Field",
+-                                            classLink,
+-                                            pkgLink));
++                configuration.getText("doclet.ClassUse_Field", classLink,
++                pkgLink), fieldUseTableSummary);
+         fieldSubWriter.printUseInfo(pkgToFieldAnnotations.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_FieldAnnotations",
+-            classLink,
+-            pkgLink));
++                configuration.getText("doclet.ClassUse_FieldAnnotations", classLink,
++                pkgLink), fieldUseTableSummary);
+         fieldSubWriter.printUseInfo(pkgToFieldTypeParameter.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_FieldTypeParameter",
+-            classLink,
+-            pkgLink));
++                configuration.getText("doclet.ClassUse_FieldTypeParameter", classLink,
++                pkgLink), fieldUseTableSummary);
+         methodSubWriter.printUseInfo(pkgToMethodAnnotations.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_MethodAnnotations", classLink,
+-            pkgLink));
++                configuration.getText("doclet.ClassUse_MethodAnnotations", classLink,
++                pkgLink), methodUseTableSummary);
+         methodSubWriter.printUseInfo(pkgToMethodParameterAnnotations.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_MethodParameterAnnotations", classLink,
+-            pkgLink));
++                configuration.getText("doclet.ClassUse_MethodParameterAnnotations", classLink,
++                pkgLink), methodUseTableSummary);
+         methodSubWriter.printUseInfo(pkgToMethodTypeParameter.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_MethodTypeParameter", classLink,
+-            pkgLink));
++                configuration.getText("doclet.ClassUse_MethodTypeParameter", classLink,
++                pkgLink), methodUseTableSummary);
+         methodSubWriter.printUseInfo(pkgToMethodReturn.get(pkg.name()),
+-                                     configuration.getText("doclet.ClassUse_MethodReturn",
+-                                             classLink,
+-                                             pkgLink));
++                configuration.getText("doclet.ClassUse_MethodReturn", classLink,
++                pkgLink), methodUseTableSummary);
+         methodSubWriter.printUseInfo(pkgToMethodReturnTypeParameter.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_MethodReturnTypeParameter", classLink,
+-            pkgLink));
++                configuration.getText("doclet.ClassUse_MethodReturnTypeParameter", classLink,
++                pkgLink), methodUseTableSummary);
+         methodSubWriter.printUseInfo(pkgToMethodArgs.get(pkg.name()),
+-                                     configuration.getText("doclet.ClassUse_MethodArgs",
+-                                             classLink,
+-                                             pkgLink));
++                configuration.getText("doclet.ClassUse_MethodArgs", classLink,
++                pkgLink), methodUseTableSummary);
+         methodSubWriter.printUseInfo(pkgToMethodArgTypeParameter.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_MethodArgsTypeParameters",
+-            classLink,
+-            pkgLink));
++                configuration.getText("doclet.ClassUse_MethodArgsTypeParameters", classLink,
++                pkgLink), methodUseTableSummary);
+         methodSubWriter.printUseInfo(pkgToMethodThrows.get(pkg.name()),
+-                                     configuration.getText("doclet.ClassUse_MethodThrows",
+-                                             classLink,
+-                                             pkgLink));
++                configuration.getText("doclet.ClassUse_MethodThrows", classLink,
++                pkgLink), methodUseTableSummary);
+         constrSubWriter.printUseInfo(pkgToConstructorAnnotations.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_ConstructorAnnotations",
+-                classLink,
+-                pkgLink));
++                configuration.getText("doclet.ClassUse_ConstructorAnnotations", classLink,
++                pkgLink), constructorUseTableSummary);
+         constrSubWriter.printUseInfo(pkgToConstructorParameterAnnotations.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_ConstructorParameterAnnotations",
+-                classLink,
+-                pkgLink));
++                configuration.getText("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
++                pkgLink), constructorUseTableSummary);
+         constrSubWriter.printUseInfo(pkgToConstructorArgs.get(pkg.name()),
+-                                     configuration.getText("doclet.ClassUse_ConstructorArgs",
+-                                             classLink,
+-                                             pkgLink));
++                configuration.getText("doclet.ClassUse_ConstructorArgs", classLink,
++                pkgLink), constructorUseTableSummary);
+         constrSubWriter.printUseInfo(pkgToConstructorArgTypeParameter.get(pkg.name()),
+-            configuration.getText("doclet.ClassUse_ConstructorArgsTypeParameters",
+-            classLink,
+-            pkgLink));
++                configuration.getText("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
++                pkgLink), constructorUseTableSummary);
+         constrSubWriter.printUseInfo(pkgToConstructorThrows.get(pkg.name()),
+-                                     configuration.getText("doclet.ClassUse_ConstructorThrows",
+-                                             classLink,
+-                                             pkgLink));
++                configuration.getText("doclet.ClassUse_ConstructorThrows", classLink,
++                pkgLink), constructorUseTableSummary);
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
+@@ -35,6 +35,7 @@
+  * Write the Constants Summary Page in HTML format.
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.4
+  */
+ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter
+@@ -50,6 +51,10 @@
+      */
+     private ClassDoc currentClassDoc;
+ 
++    private final String constantsTableSummary;
++
++    private final String[] constantsTableHeader;
++
+     /**
+      * Construct a ConstantsSummaryWriter.
+      * @param configuration the configuration used in this run
+@@ -59,6 +64,13 @@
+             throws IOException {
+         super(configuration, ConfigurationImpl.CONSTANTS_FILE_NAME);
+         this.configuration = configuration;
++        constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
++                configuration.getText("doclet.Constants_Summary"));
++        constantsTableHeader = new String[] {
++            getModifierTypeHeader(),
++            configuration.getText("doclet.ConstantField"),
++            configuration.getText("doclet.Value")
++        };
+     }
+ 
+     /**
+@@ -151,12 +163,11 @@
+      * @param classStr the heading to print.
+      */
+     protected void writeClassName(String classStr) {
+-        table(1, 3, 0);
+-        trBgcolorStyle("#EEEEFF", "TableSubHeadingColor");
+-        thAlignColspan("left", 3);
++        table(1, 3, 0, constantsTableSummary);
++        tableSubCaptionStart();
+         write(classStr);
+-        thEnd();
+-        trEnd();
++        tableCaptionEnd();
++        summaryTableHeader(constantsTableHeader, "col");
+     }
+ 
+     private void tableFooter(boolean isHeader) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+@@ -37,6 +37,7 @@
+  *
+  * @author Robert Field
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class ConstructorWriterImpl extends AbstractExecutableMemberWriter
+     implements ConstructorWriter, MemberSummaryWriter {
+@@ -211,8 +212,34 @@
+         this.foundNonPubConstructor = foundNonPubConstructor;
+     }
+ 
+-    public void printSummaryLabel(ClassDoc cd) {
+-        writer.strongText("doclet.Constructor_Summary");
++    public void printSummaryLabel() {
++        writer.printText("doclet.Constructor_Summary");
++    }
++
++    public void printTableSummary() {
++        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++                configuration().getText("doclet.Constructor_Summary"),
++                configuration().getText("doclet.constructors")));
++    }
++
++    public void printSummaryTableHeader(ProgramElementDoc member) {
++        String[] header;
++        if (foundNonPubConstructor) {
++            header = new String[] {
++                configuration().getText("doclet.Modifier"),
++                configuration().getText("doclet.0_and_1",
++                        configuration().getText("doclet.Constructor"),
++                        configuration().getText("doclet.Description"))
++            };
++        }
++        else {
++            header = new String[] {
++                configuration().getText("doclet.0_and_1",
++                        configuration().getText("doclet.Constructor"),
++                        configuration().getText("doclet.Description"))
++            };
++        }
++        writer.summaryTableHeader(header, "col");
+     }
+ 
+     public void printSummaryAnchor(ClassDoc cd) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
+@@ -35,6 +35,7 @@
+  *
+  * @see java.util.List
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class DeprecatedListWriter extends SubWriterHolderWriter {
+ 
+@@ -55,6 +56,28 @@
+         "doclet.Deprecated_Annotation_Type_Members"
+     };
+ 
++    private static final String[] SUMMARY_KEYS = new String[] {
++        "doclet.deprecated_interfaces", "doclet.deprecated_classes",
++        "doclet.deprecated_enums", "doclet.deprecated_exceptions",
++        "doclet.deprecated_errors",
++        "doclet.deprecated_annotation_types",
++        "doclet.deprecated_fields",
++        "doclet.deprecated_methods", "doclet.deprecated_constructors",
++        "doclet.deprecated_enum_constants",
++        "doclet.deprecated_annotation_type_members"
++    };
++
++    private static final String[] HEADER_KEYS = new String[] {
++        "doclet.Interface", "doclet.Class",
++        "doclet.Enum", "doclet.Exceptions",
++        "doclet.Errors",
++        "doclet.AnnotationType",
++        "doclet.Field",
++        "doclet.Method", "doclet.Constructor",
++        "doclet.Enum_Constant",
++        "doclet.Annotation_Type_Member"
++    };
++
+     private AbstractMemberWriter[] writers;
+ 
+     private ConfigurationImpl configuration;
+@@ -119,11 +142,20 @@
+         ulEnd();
+         println();
+ 
++        String memberTableSummary;
++        String[] memberTableHeader = new String[1];
+         for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
+             if (deprapi.hasDocumentation(i)) {
+                 writeAnchor(deprapi, i);
++                memberTableSummary =
++                        configuration.getText("doclet.Member_Table_Summary",
++                        configuration.getText(HEADING_KEYS[i]),
++                        configuration.getText(SUMMARY_KEYS[i]));
++                memberTableHeader[0] = configuration.getText("doclet.0_and_1",
++                        configuration.getText(HEADER_KEYS[i]),
++                        configuration.getText("doclet.Description"));
+                 writers[i].printDeprecatedAPI(deprapi.getList(i),
+-                    HEADING_KEYS[i]);
++                    HEADING_KEYS[i], memberTableSummary, memberTableHeader);
+             }
+         }
+         printDeprecatedFooter();
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+@@ -35,6 +35,7 @@
+  * Writes enum constant documentation in HTML format.
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  */
+ public class EnumConstantWriterImpl extends AbstractMemberWriter
+     implements EnumConstantWriter, MemberSummaryWriter {
+@@ -194,8 +195,23 @@
+         return VisibleMemberMap.ENUM_CONSTANTS;
+     }
+ 
+-    public void printSummaryLabel(ClassDoc cd) {
+-        writer.strongText("doclet.Enum_Constant_Summary");
++    public void printSummaryLabel() {
++        writer.printText("doclet.Enum_Constant_Summary");
++    }
++
++    public void printTableSummary() {
++        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++                configuration().getText("doclet.Enum_Constant_Summary"),
++                configuration().getText("doclet.enum_constants")));
++    }
++
++    public void printSummaryTableHeader(ProgramElementDoc member) {
++        String[] header = new String[] {
++            configuration().getText("doclet.0_and_1",
++                    configuration().getText("doclet.Enum_Constant"),
++                    configuration().getText("doclet.Description"))
++        };
++        writer.summaryTableHeader(header, "col");
+     }
+ 
+     public void printSummaryAnchor(ClassDoc cd) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+@@ -37,6 +37,7 @@
+  * @author Robert Field
+  * @author Atul M Dambalkar
+  * @author Jamie Ho (rewrite)
++ * @author Bhavesh Patel (Modified)
+  */
+ public class FieldWriterImpl extends AbstractMemberWriter
+     implements FieldWriter, MemberSummaryWriter {
+@@ -236,8 +237,24 @@
+         return VisibleMemberMap.FIELDS;
+     }
+ 
+-    public void printSummaryLabel(ClassDoc cd) {
+-        writer.strongText("doclet.Field_Summary");
++    public void printSummaryLabel() {
++        writer.printText("doclet.Field_Summary");
++    }
++
++    public void printTableSummary() {
++        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++                configuration().getText("doclet.Field_Summary"),
++                configuration().getText("doclet.fields")));
++    }
++
++    public void printSummaryTableHeader(ProgramElementDoc member) {
++        String[] header = new String[] {
++            writer.getModifierTypeHeader(),
++            configuration().getText("doclet.0_and_1",
++                    configuration().getText("doclet.Field"),
++                    configuration().getText("doclet.Description"))
++        };
++        writer.summaryTableHeader(header, "col");
+     }
+ 
+     public void printSummaryAnchor(ClassDoc cd) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+@@ -785,6 +785,15 @@
+     }
+ 
+     /**
++     * Print the Html table tag for the index summary tables.
++     *
++     * @param summary the summary for the table tag summary attribute.
++     */
++    public void tableIndexSummary(String summary) {
++        table(1, "100%", 3, 0, summary);
++    }
++
++    /**
+      * Same as {@link #tableIndexSummary()}.
+      */
+     public void tableIndexDetail() {
+@@ -800,6 +809,40 @@
+     }
+ 
+     /**
++     * Print table caption.
++     */
++    public void tableCaptionStart() {
++        captionStyle("TableCaption");
++    }
++
++    /**
++     * Print table sub-caption.
++     */
++    public void tableSubCaptionStart() {
++        captionStyle("TableSubCaption");
++    }
++
++    /**
++     * Print table caption end tags.
++     */
++    public void tableCaptionEnd() {
++        captionEnd();
++    }
++
++    /**
++     * Print summary table header.
++     */
++    public void summaryTableHeader(String[] header, String scope) {
++        tr();
++        for ( int i=0; i < header.length; i++ ) {
++            thScopeNoWrap("TableHeader", scope);
++            print(header[i]);
++            thEnd();
++        }
++        trEnd();
++    }
++
++    /**
+      * Prine table header information about color, column span and the font.
+      *
+      * @param color Background color.
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+@@ -38,6 +38,7 @@
+  * @author Robert Field
+  * @author Atul M Dambalkar
+  * @author Jamie Ho (rewrite)
++ * @author Bhavesh Patel (Modified)
+  */
+ public class MethodWriterImpl extends AbstractExecutableMemberWriter
+         implements MethodWriter, MemberSummaryWriter {
+@@ -255,8 +256,24 @@
+         return VisibleMemberMap.METHODS;
+     }
+ 
+-    public void printSummaryLabel(ClassDoc cd) {
+-        writer.strongText("doclet.Method_Summary");
++    public void printSummaryLabel() {
++        writer.printText("doclet.Method_Summary");
++    }
++
++    public void printTableSummary() {
++        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++                configuration().getText("doclet.Method_Summary"),
++                configuration().getText("doclet.methods")));
++    }
++
++    public void printSummaryTableHeader(ProgramElementDoc member) {
++        String[] header = new String[] {
++            writer.getModifierTypeHeader(),
++            configuration().getText("doclet.0_and_1",
++                    configuration().getText("doclet.Method"),
++                    configuration().getText("doclet.Description"))
++        };
++        writer.summaryTableHeader(header, "col");
+     }
+ 
+     public void printSummaryAnchor(ClassDoc cd) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+@@ -37,6 +37,7 @@
+  * @author Robert Field
+  * @author Atul M Dambalkar
+  * @author Jamie Ho (rewrite)
++ * @author Bhavesh Patel (Modified)
+  */
+ public class NestedClassWriterImpl extends AbstractMemberWriter
+     implements MemberSummaryWriter {
+@@ -147,8 +148,35 @@
+         return VisibleMemberMap.INNERCLASSES;
+     }
+ 
+-    public void printSummaryLabel(ClassDoc cd) {
+-        writer.strongText("doclet.Nested_Class_Summary");
++    public void printSummaryLabel() {
++        writer.printText("doclet.Nested_Class_Summary");
++    }
++
++    public void printTableSummary() {
++        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++                configuration().getText("doclet.Nested_Class_Summary"),
++                configuration().getText("doclet.nested_classes")));
++    }
++
++    public void printSummaryTableHeader(ProgramElementDoc member) {
++        String[] header;
++        if (member.isInterface()) {
++            header = new String[] {
++                writer.getModifierTypeHeader(),
++                configuration().getText("doclet.0_and_1",
++                        configuration().getText("doclet.Interface"),
++                        configuration().getText("doclet.Description"))
++            };
++        }
++        else {
++            header = new String[] {
++                writer.getModifierTypeHeader(),
++                configuration().getText("doclet.0_and_1",
++                        configuration().getText("doclet.Class"),
++                        configuration().getText("doclet.Description"))
++            };
++        }
++        writer.summaryTableHeader(header, "col");
+     }
+ 
+     public void printSummaryAnchor(ClassDoc cd) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
+@@ -114,7 +114,7 @@
+      *
+      * @param text Text string will not be used in this method.
+      */
+-    protected void printIndexHeader(String text) {
++    protected void printIndexHeader(String text, String tableSummary) {
+         printTableHeader(false);
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
+@@ -36,6 +36,7 @@
+  * with the "pacakge-summary.html" file for the clicked package.
+  *
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class PackageIndexWriter extends AbstractPackageIndexWriter {
+ 
+@@ -124,7 +125,10 @@
+             if (list != null && list.size() > 0) {
+                 printIndexContents((PackageDoc[])list.
+                                        toArray(new PackageDoc[list.size()]),
+-                                    groupname);
++                        groupname,
++                        configuration.getText("doclet.Member_Table_Summary",
++                        groupname,
++                        configuration.getText("doclet.packages")));
+             }
+         }
+     }
+@@ -150,11 +154,12 @@
+     /**
+      * Print Html tags for the table for this package index.
+      */
+-    protected void printIndexHeader(String text) {
+-        tableIndexSummary();
+-        tableHeaderStart("#CCCCFF");
+-        strong(text);
+-        tableHeaderEnd();
++    protected void printIndexHeader(String text, String tableSummary) {
++        tableIndexSummary(tableSummary);
++        tableCaptionStart();
++        print(text);
++        tableCaptionEnd();
++        summaryTableHeader(packageTableHeader, "col");
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+@@ -34,6 +34,7 @@
+  * Generate package usage information.
+  *
+  * @author Robert G. Field
++ * @author Bhavesh Patel (Modified)
+  */
+ public class PackageUseWriter extends SubWriterHolderWriter {
+ 
+@@ -131,11 +132,12 @@
+     }
+ 
+     protected void generatePackageList() throws IOException {
+-        tableIndexSummary();
+-        tableHeaderStart("#CCCCFF");
++        tableIndexSummary(useTableSummary);
++        tableCaptionStart();
+         printText("doclet.ClassUse_Packages.that.use.0",
+             getPackageLink(pkgdoc, Util.getPackageName(pkgdoc), false));
+-        tableHeaderEnd();
++        tableCaptionEnd();
++        summaryTableHeader(packageTableHeader, "col");
+         Iterator it = usingPackageToUsedClasses.keySet().iterator();
+         while (it.hasNext()) {
+             PackageDoc pkg = configuration.root.packageNamed((String)it.next());
+@@ -147,6 +149,11 @@
+     }
+ 
+     protected void generateClassList() throws IOException {
++        String[] classTableHeader = new String[] {
++            configuration.getText("doclet.0_and_1",
++                    configuration.getText("doclet.Class"),
++                    configuration.getText("doclet.Description"))
++        };
+         Iterator itp = usingPackageToUsedClasses.keySet().iterator();
+         while (itp.hasNext()) {
+             String packageName = (String)itp.next();
+@@ -154,12 +161,14 @@
+             if (usingPackage != null) {
+                 anchor(usingPackage.name());
+             }
+-            tableIndexSummary();
+-            tableHeaderStart("#CCCCFF");
++            tableIndexSummary(configuration.getText("doclet.Use_Table_Summary",
++                    configuration.getText("doclet.classes")));
++            tableCaptionStart();
+             printText("doclet.ClassUse_Classes.in.0.used.by.1",
+                 getPackageLink(pkgdoc, Util.getPackageName(pkgdoc), false),
+                 getPackageLink(usingPackage,Util.getPackageName(usingPackage), false));
+-            tableHeaderEnd();
++            tableCaptionEnd();
++            summaryTableHeader(classTableHeader, "col");
+             Iterator itc =
+                 ((Collection)usingPackageToUsedClasses.get(packageName))
+                 .iterator();
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
+@@ -38,6 +38,7 @@
+  * class-kind will update the frame with the clicked class-kind page.
+  *
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class PackageWriterImpl extends HtmlDocletWriter
+     implements PackageSummaryWriter {
+@@ -107,14 +108,15 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeClassesSummary(ClassDoc[] classes, String label) {
++    public void writeClassesSummary(ClassDoc[] classes, String label, String tableSummary, String[] tableHeader) {
+         if(classes.length > 0) {
+             Arrays.sort(classes);
+-            tableIndexSummary();
++            tableIndexSummary(tableSummary);
+             boolean printedHeading = false;
+             for (int i = 0; i < classes.length; i++) {
+                 if (!printedHeading) {
+-                    printFirstRow(label);
++                    printTableCaption(label);
++                    printFirstRow(tableHeader);
+                     printedHeading = true;
+                 }
+                 if (!Util.isCoreClass(classes[i]) ||
+@@ -149,14 +151,23 @@
+     }
+ 
+     /**
++     * Print the table caption for the class-listing.
++     *
++     * @param label label for the Class kind listing.
++     */
++    protected void printTableCaption(String label) {
++        tableCaptionStart();
++        print(label);
++        tableCaptionEnd();
++    }
++
++    /**
+      * Print the table heading for the class-listing.
+      *
+-     * @param label Label for the Class kind listing.
++     * @param tableHeader table header string for the Class listing.
+      */
+-    protected void printFirstRow(String label) {
+-        tableHeaderStart("#CCCCFF");
+-        strong(label);
+-        tableHeaderEnd();
++    protected void printFirstRow(String[] tableHeader) {
++        summaryTableHeader(tableHeader, "col");
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/StylesheetWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/StylesheetWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/StylesheetWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/StylesheetWriter.java
+@@ -33,6 +33,7 @@
+  * Writes the style sheet for the doclet output.
+  *
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class StylesheetWriter extends HtmlDocletWriter {
+ 
+@@ -115,6 +116,13 @@
+         println("background-color:#FFFFFF; color:#000000}");
+         print(".NavBarCell3    { font-family: Arial, Helvetica, sans-serif; ");
+         println("background-color:#FFFFFF; color:#000000}");
++
++        print("/* "); printText("doclet.Style_line_12"); println(" */");
++        print(".TableCaption     { background: #CCCCFF; color:#000000; text-align: left; font-size: 150%; font-weight: bold; border-left: 2px ridge; border-right: 2px ridge; border-top: 2px ridge; padding-left: 5px; }");
++        print(" /* "); printText("doclet.Style_line_5"); println(" */");
++        print(".TableSubCaption  { background: #EEEEFF; color:#000000; text-align: left; font-weight: bold; border-left: 2px ridge; border-right: 2px ridge; border-top: 2px ridge; padding-left: 5px; }");
++        print(" /* "); printText("doclet.Style_line_6"); println(" */");
++        print(".TableHeader     { text-align: center; font-size: 80%; font-weight: bold; }");
+         println("");
+ 
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
+@@ -43,6 +43,7 @@
+  *
+  * @author Robert Field
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public abstract class SubWriterHolderWriter extends HtmlDocletWriter {
+ 
+@@ -72,10 +73,11 @@
+ 
+     public void printSummaryHeader(AbstractMemberWriter mw, ClassDoc cd) {
+         mw.printSummaryAnchor(cd);
+-        tableIndexSummary();
+-        tableHeaderStart("#CCCCFF");
+-        mw.printSummaryLabel(cd);
+-        tableHeaderEnd();
++        mw.printTableSummary();
++        tableCaptionStart();
++        mw.printSummaryLabel();
++        tableCaptionEnd();
++        mw.printSummaryTableHeader(cd);
+     }
+ 
+     public void printTableHeadingBackground(String str) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+@@ -37,6 +37,7 @@
+  *
+  * @since 1.2
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class HtmlWriter extends PrintWriter {
+ 
+@@ -67,6 +68,21 @@
+     protected boolean memberDetailsListPrinted;
+ 
+     /**
++     * Header for tables displaying packages and description..
++     */
++    protected final String[] packageTableHeader;
++
++    /**
++     * Summary for use tables displaying class and package use.
++     */
++    protected final String useTableSummary;
++
++    /**
++     * Column header for class docs displaying Modifier and Type header.
++     */
++    protected final String modifierTypeHeader;
++
++    /**
+      * Constructor.
+      *
+      * @param path The directory path to be created for this file
+@@ -86,6 +102,15 @@
+         this.configuration = configuration;
+         htmlFilename = filename;
+         this.memberDetailsListPrinted = false;
++        packageTableHeader = new String[] {
++            configuration.getText("doclet.Package"),
++            configuration.getText("doclet.Description")
++        };
++        useTableSummary = configuration.getText("doclet.Use_Table_Summary",
++                configuration.getText("doclet.packages"));
++        modifierTypeHeader = configuration.getText("doclet.0_and_1",
++                configuration.getText("doclet.Modifier"),
++                configuration.getText("doclet.Type"));
+     }
+ 
+     /**
+@@ -803,6 +828,26 @@
+     }
+ 
+     /**
++     * Print HTML &lt;TABLE BORDER="border" WIDTH="width"
++     * CELLPADDING="cellpadding" CELLSPACING="cellspacing" SUMMARY="summary"&gt; tag.
++     *
++     * @param border       Border size.
++     * @param width        Width of the table.
++     * @param cellpadding  Cellpadding for the table cells.
++     * @param cellspacing  Cellspacing for the table cells.
++     * @param summary      Table summary.
++     */
++    public void table(int border, String width, int cellpadding,
++                      int cellspacing, String summary) {
++        println(DocletConstants.NL +
++                "<TABLE BORDER=\"" + border +
++                "\" WIDTH=\"" + width +
++                "\" CELLPADDING=\"" + cellpadding +
++                "\" CELLSPACING=\"" + cellspacing +
++                "\" SUMMARY=\"" + summary + "\">");
++    }
++
++    /**
+      * Print HTML &lt;TABLE BORDER="border" CELLPADDING="cellpadding"
+      * CELLSPACING="cellspacing"&gt; tag.
+      *
+@@ -819,6 +864,23 @@
+     }
+ 
+     /**
++     * Print HTML &lt;TABLE BORDER="border" CELLPADDING="cellpadding"
++     * CELLSPACING="cellspacing" SUMMARY="summary"&gt; tag.
++     *
++     * @param border       Border size.
++     * @param cellpadding  Cellpadding for the table cells.
++     * @param cellspacing  Cellspacing for the table cells.
++     * @param summary      Table summary.
++     */
++    public void table(int border, int cellpadding, int cellspacing, String summary) {
++        println(DocletConstants.NL +
++                "<TABLE BORDER=\"" + border +
++                "\" CELLPADDING=\"" + cellpadding +
++                "\" CELLSPACING=\"" + cellspacing +
++                "\" SUMMARY=\"" + summary + "\">");
++    }
++
++    /**
+      * Print HTML &lt;TABLE BORDER="border" WIDTH="width"&gt;
+      *
+      * @param border       Border size.
+@@ -913,6 +975,23 @@
+     }
+ 
+     /**
++     * Print &lt;CAPTION CLASS="stylename"&gt; tag. Adds a newline character
++     * at the end.
++     *
++     * @param stylename style to be applied.
++     */
++    public void captionStyle(String stylename) {
++        println("<CAPTION CLASS=\"" + stylename + "\">");
++    }
++
++    /**
++     * Print &lt;/CAPTION&gt; tag. Add a newline character at the end.
++     */
++    public void captionEnd() {
++        println("</CAPTION>");
++    }
++
++    /**
+      * Print &lt;TR BGCOLOR="color" CLASS="stylename"&gt; tag. Adds a newline character
+      * at the end.
+      *
+@@ -953,6 +1032,23 @@
+     }
+ 
+     /**
++     * Print &lt;TH CLASS="stylename" SCOPE="scope" NOWRAP&gt; tag.
++     *
++     * @param stylename style to be applied.
++     * @param scope the scope attribute.
++     */
++    public void thScopeNoWrap(String stylename, String scope) {
++        print("<TH CLASS=\"" + stylename + "\" SCOPE=\"" + scope + "\" NOWRAP>");
++    }
++
++    /*
++     * Returns a header for Modifier and Type column of a table.
++     */
++    public String getModifierTypeHeader() {
++        return modifierTypeHeader;
++    }
++
++    /**
+      * Print &lt;TH align="align" COLSPAN=i&gt; tag.
+      *
+      * @param align the align attribute.
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
+@@ -83,6 +83,17 @@
+ doclet.Deprecated_Methods=Deprecated Methods
+ doclet.Deprecated_Enum_Constants=Deprecated Enum Constants
+ doclet.Deprecated_Annotation_Type_Members=Deprecated Annotation Type Elements
++doclet.deprecated_classes=deprecated classes
++doclet.deprecated_enums=deprecated enums
++doclet.deprecated_interfaces=deprecated interfaces
++doclet.deprecated_exceptions=deprecated exceptions
++doclet.deprecated_annotation_types=deprecated annotation types
++doclet.deprecated_errors=deprecated errors
++doclet.deprecated_fields=deprecated fields
++doclet.deprecated_constructors=deprecated constructors
++doclet.deprecated_methods=deprecated methods
++doclet.deprecated_enum_constants=deprecated enum constants
++doclet.deprecated_annotation_type_members=deprecated annotation type elements
+ doclet.Frame_Output=Frame Output
+ doclet.Docs_generated_by_Javadoc=Documentation generated by Javadoc.
+ doclet.Generated_Docs_Untitled=Generated Documentation (Untitled)
+@@ -171,6 +182,7 @@
+ doclet.Style_line_9=Example of smaller, sans-serif font in frames
+ doclet.Style_line_10=Navigation bar fonts and colors
+ doclet.Style_line_11=Dark Blue
++doclet.Style_line_12=Table caption style
+ doclet.ClassUse_Packages.that.use.0=Packages that use {0}
+ doclet.ClassUse_Uses.of.0.in.1=Uses of {0} in {1}
+ doclet.ClassUse_Classes.in.0.used.by.1=Classes in {0} used by {1}
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java
+@@ -64,7 +64,7 @@
+      * @param classes the array of classes to document.
+      * @param label the label for this table.
+      */
+-    public abstract void writeClassesSummary(ClassDoc[] classes, String label);
++    public abstract void writeClassesSummary(ClassDoc[] classes, String label, String tableSummary, String[] tableHeader);
+ 
+     /**
+      * Write the header for the summary.
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
+@@ -40,6 +40,7 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class PackageSummaryBuilder extends AbstractBuilder {
+@@ -184,7 +185,15 @@
+          * Build the summary for the classes in this package.
+          */
+         public void buildClassSummary() {
+-                ClassDoc[] classes =
++            String classTableSummary =
++                    configuration.getText("doclet.Member_Table_Summary",
++                    configuration.getText("doclet.Class_Summary"),
++                    configuration.getText("doclet.classes"));
++            String[] classTableHeader = new String[] {
++                configuration.getText("doclet.Class"),
++                configuration.getText("doclet.Description")
++            };
++            ClassDoc[] classes =
+                         packageDoc.isIncluded()
+                                 ? packageDoc.ordinaryClasses()
+                                 : configuration.classDocCatalog.ordinaryClasses(
+@@ -192,7 +201,8 @@
+                 if (classes.length > 0) {
+                         packageWriter.writeClassesSummary(
+                                 classes,
+-                                configuration.getText("doclet.Class_Summary"));
++                                configuration.getText("doclet.Class_Summary"),
++                                classTableSummary, classTableHeader);
+                 }
+         }
+ 
+@@ -200,7 +210,15 @@
+          * Build the summary for the interfaces in this package.
+          */
+         public void buildInterfaceSummary() {
+-                ClassDoc[] interfaces =
++            String interfaceTableSummary =
++                    configuration.getText("doclet.Member_Table_Summary",
++                    configuration.getText("doclet.Interface_Summary"),
++                    configuration.getText("doclet.interfaces"));
++            String[] interfaceTableHeader = new String[] {
++                configuration.getText("doclet.Interface"),
++                configuration.getText("doclet.Description")
++            };
++            ClassDoc[] interfaces =
+                         packageDoc.isIncluded()
+                                 ? packageDoc.interfaces()
+                                 : configuration.classDocCatalog.interfaces(
+@@ -208,7 +226,8 @@
+                 if (interfaces.length > 0) {
+                         packageWriter.writeClassesSummary(
+                                 interfaces,
+-                                configuration.getText("doclet.Interface_Summary"));
++                                configuration.getText("doclet.Interface_Summary"),
++                                interfaceTableSummary, interfaceTableHeader);
+                 }
+         }
+ 
+@@ -216,7 +235,15 @@
+          * Build the summary for the enums in this package.
+          */
+         public void buildAnnotationTypeSummary() {
+-                ClassDoc[] annotationTypes =
++            String annotationtypeTableSummary =
++                    configuration.getText("doclet.Member_Table_Summary",
++                    configuration.getText("doclet.Annotation_Types_Summary"),
++                    configuration.getText("doclet.annotationtypes"));
++            String[] annotationtypeTableHeader = new String[] {
++                configuration.getText("doclet.AnnotationType"),
++                configuration.getText("doclet.Description")
++            };
++            ClassDoc[] annotationTypes =
+                         packageDoc.isIncluded()
+                                 ? packageDoc.annotationTypes()
+                                 : configuration.classDocCatalog.annotationTypes(
+@@ -224,7 +251,8 @@
+                 if (annotationTypes.length > 0) {
+                         packageWriter.writeClassesSummary(
+                                 annotationTypes,
+-                                configuration.getText("doclet.Annotation_Types_Summary"));
++                                configuration.getText("doclet.Annotation_Types_Summary"),
++                                annotationtypeTableSummary, annotationtypeTableHeader);
+                 }
+         }
+ 
+@@ -232,7 +260,15 @@
+          * Build the summary for the enums in this package.
+          */
+         public void buildEnumSummary() {
+-                ClassDoc[] enums =
++            String enumTableSummary =
++                    configuration.getText("doclet.Member_Table_Summary",
++                    configuration.getText("doclet.Enum_Summary"),
++                    configuration.getText("doclet.enums"));
++            String[] enumTableHeader = new String[] {
++                configuration.getText("doclet.Enum"),
++                configuration.getText("doclet.Description")
++            };
++            ClassDoc[] enums =
+                         packageDoc.isIncluded()
+                                 ? packageDoc.enums()
+                                 : configuration.classDocCatalog.enums(
+@@ -240,7 +276,8 @@
+                 if (enums.length > 0) {
+                         packageWriter.writeClassesSummary(
+                                 enums,
+-                                configuration.getText("doclet.Enum_Summary"));
++                                configuration.getText("doclet.Enum_Summary"),
++                                enumTableSummary, enumTableHeader);
+                 }
+         }
+ 
+@@ -248,7 +285,15 @@
+          * Build the summary for the exceptions in this package.
+          */
+         public void buildExceptionSummary() {
+-                ClassDoc[] exceptions =
++            String exceptionTableSummary =
++                    configuration.getText("doclet.Member_Table_Summary",
++                    configuration.getText("doclet.Exception_Summary"),
++                    configuration.getText("doclet.exceptions"));
++            String[] exceptionTableHeader = new String[] {
++                configuration.getText("doclet.Exception"),
++                configuration.getText("doclet.Description")
++            };
++            ClassDoc[] exceptions =
+                         packageDoc.isIncluded()
+                                 ? packageDoc.exceptions()
+                                 : configuration.classDocCatalog.exceptions(
+@@ -256,7 +301,8 @@
+                 if (exceptions.length > 0) {
+                         packageWriter.writeClassesSummary(
+                                 exceptions,
+-                                configuration.getText("doclet.Exception_Summary"));
++                                configuration.getText("doclet.Exception_Summary"),
++                                exceptionTableSummary, exceptionTableHeader);
+                 }
+         }
+ 
+@@ -264,7 +310,15 @@
+          * Build the summary for the errors in this package.
+          */
+         public void buildErrorSummary() {
+-                ClassDoc[] errors =
++            String errorTableSummary =
++                    configuration.getText("doclet.Member_Table_Summary",
++                    configuration.getText("doclet.Error_Summary"),
++                    configuration.getText("doclet.errors"));
++            String[] errorTableHeader = new String[] {
++                configuration.getText("doclet.Error"),
++                configuration.getText("doclet.Description")
++            };
++            ClassDoc[] errors =
+                         packageDoc.isIncluded()
+                                 ? packageDoc.errors()
+                                 : configuration.classDocCatalog.errors(
+@@ -272,7 +326,8 @@
+                 if (errors.length > 0) {
+                         packageWriter.writeClassesSummary(
+                                 errors,
+-                                configuration.getText("doclet.Error_Summary"));
++                                configuration.getText("doclet.Error_Summary"),
++                                errorTableSummary, errorTableHeader);
+                 }
+         }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
+@@ -82,6 +82,7 @@
+ doclet.Errors=Errors
+ doclet.Classes=Classes
+ doclet.Packages=Packages
++doclet.packages=packages
+ doclet.All_Classes=All Classes
+ doclet.All_Superinterfaces=All Superinterfaces:
+ doclet.All_Implemented_Interfaces=All Implemented Interfaces:
+@@ -92,14 +93,20 @@
+ doclet.Class=Class
+ doclet.AnnotationType=Annotation Type
+ doclet.annotationtype=annotation type
++doclet.annotationtypes=annotation types
+ doclet.Enum=Enum
+ doclet.enum=enum
++doclet.enums=enums
+ doclet.interface=interface
++doclet.interfaces=interfaces
+ doclet.class=class
++doclet.classes=classes
+ doclet.Error=Error
+ doclet.error=error
++doclet.errors=errors
+ doclet.Exception=Exception
+ doclet.exception=exception
++doclet.exceptions=exceptions
+ doclet.extended_by=extended by
+ doclet.extends=extends
+ doclet.Package_private=(package private)
+@@ -125,6 +132,32 @@
+ doclet.value_tag_invalid_constant=@value tag (which references {0}) can only be used in constants.
+ doclet.dest_dir_create=Creating destination directory: "{0}"
+ doclet.in={0} in {1}
++doclet.Use_Table_Summary=Use table, listing {0}, and an explanation
++doclet.Constants_Table_Summary={0} table, listing constant fields, and values
++doclet.Member_Table_Summary={0} table, listing {1}, and an explanation
++doclet.fields=fields
++doclet.constructors=constructors
++doclet.methods=methods
++doclet.annotation_type_optional_members=optional elements
++doclet.annotation_type_required_members=required elements
++doclet.enum_constants=enum constants
++doclet.nested_classes=nested classes
++doclet.subclasses=subclasses
++doclet.subinterfaces=subinterfaces
++doclet.Modifier=Modifier
++doclet.Type=Type
++doclet.Field=Field
++doclet.Constructor=Constructor
++doclet.Method=Method
++doclet.Annotation_Type_Optional_Member=Optional Element
++doclet.Annotation_Type_Required_Member=Required Element
++doclet.Annotation_Type_Member=Annotation Type Element
++doclet.Enum_Constant=Enum Constant
++doclet.Class=Class
++doclet.Description=Description
++doclet.ConstantField=Constant Field
++doclet.Value=Value
++doclet.0_and_1={0} and {1}
+ 
+ #Documentation for Enums
+ doclet.enum_values_doc=\n\
+diff --git a/test/com/sun/javadoc/testHeadings/TestHeadings.java b/test/com/sun/javadoc/testHeadings/TestHeadings.java
+--- openjdk/langtools/test/com/sun/javadoc/testHeadings/TestHeadings.java
++++ openjdk/langtools/test/com/sun/javadoc/testHeadings/TestHeadings.java
+@@ -47,14 +47,16 @@
+     private static final String[][] TEST = {
+         //Package summary
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+-            "<STRONG>Class Summary</STRONG></FONT></TH>"
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Class</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++            " NOWRAP>Description</TH>"
+         },
+ 
+         // Class documentation
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+-            "<STRONG>Field Summary</STRONG></FONT></TH>"
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Field and Description</TH>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+             "<TH ALIGN=\"left\"><STRONG>Methods inherited from class " +            "java.lang.Object</STRONG></TH>"
+@@ -62,29 +64,32 @@
+ 
+         // Class use documentation
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+-            "Packages that use <A HREF=\"../../pkg1/C1.html\" " +            "title=\"class in pkg1\">C1</A></FONT></TH>"
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Description</TH>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+             "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+             "Uses of <A HREF=\"../../pkg1/C1.html\" " +            "title=\"class in pkg1\">C1</A> in " +            "<A HREF=\"../../pkg2/package-summary.html\">pkg2</A></FONT></TH>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"2\">Fields in " +            "<A HREF=\"../../pkg2/package-summary.html\">pkg2</A> " +            "declared as <A HREF=\"../../pkg1/C1.html\" " +            "title=\"class in pkg1\">C1</A></FONT></TH>"
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Field and Description</TH>"
+         },
+ 
+         // Deprecated
+         {BUG_ID + FS + "deprecated-list.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+-            "<STRONG>Deprecated Methods</STRONG></FONT></TH>"
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Method and Description</TH>"
+         },
+ 
+         // Constant values
+         {BUG_ID + FS + "constant-values.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"3\">pkg1.<A HREF=\"pkg1/C1.html\" " +            "title=\"class in pkg1\">C1</A></TH>"
+-        },
+-        {BUG_ID + FS + "constant-values.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"3\">pkg1.<A HREF=\"pkg1/C1.html\" " +            "title=\"class in pkg1\">C1</A></TH>"
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Constant Field</TH>" + NL +
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>Value</TH>"
+         },
+ 
+         // Serialized Form
+diff --git a/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java b/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java
+@@ -38,14 +38,15 @@
+ 
+     private static final String BUG_ID = "6786028";
+     private static final String[][] TEST1 = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<STRONG>See Also:</STRONG>"}};
++    private static final String[][] NEGATED_TEST1 = {
+         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<STRONG>Method Summary</STRONG>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<STRONG>See Also:</STRONG>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<B>"},
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<STRONG>Class Summary</STRONG>"}};
+-    private static final String[][] NEGATED_TEST1 = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<B>"}};
+     private static final String[][] TEST2 = {
++        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<B>Comments:</B>"}};
++    private static final String[][] NEGATED_TEST2 = {
+         {BUG_ID + FS + "pkg2" + FS + "C2.html", "<STRONG>Method Summary</STRONG>"},
+-        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<B>Comments:</B>"},
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<STRONG>Class Summary</STRONG>"}};
+ 
+     private static final String[] ARGS1 =
+@@ -62,7 +63,7 @@
+     public static void main(String[] args) {
+         TestHtmlStrongTag tester = new TestHtmlStrongTag();
+         run(tester, ARGS1, TEST1, NEGATED_TEST1);
+-        run(tester, ARGS2, TEST2, NO_TEST);
++        run(tester, ARGS2, TEST2, NEGATED_TEST2);
+         tester.printSummary();
+     }
+ 
+diff --git a/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java b/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java
+@@ -0,0 +1,478 @@
++/*
++ * 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      6786688
++ * @summary  HTML tables should have table summary, caption and table headers.
++ * @author   Bhavesh Patel
++ * @library  ../lib/
++ * @build    JavadocTester
++ * @build    TestHtmlTableTags
++ * @run main TestHtmlTableTags
++ */
++
++public class TestHtmlTableTags extends JavadocTester {
++
++    //Test information.
++    private static final String BUG_ID = "6786688";
++
++    //Javadoc arguments.
++    private static final String[] ARGS = new String[] {
++        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
++    };
++
++    //Input for string tests for HTML table tags.
++    private static final String[][] TABLE_TAGS_TEST = {
++        /*
++         * Test for validating summary for HTML tables
++         */
++
++        //Package summary
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Class Summary table, " +
++            "listing classes, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Interface Summary table, " +
++            "listing interfaces, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Enum Summary table, " +
++            "listing enums, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Annotation Types Summary table, " +
++            "listing annotation types, and an explanation\">"
++        },
++        // Class documentation
++        {BUG_ID + FS + "pkg1" + FS + "C1.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Field Summary table, " +
++            "listing fields, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "C1.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Method Summary table, " +
++            "listing methods, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C2.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Nested Class Summary table, " +
++            "listing nested classes, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C2.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Constructor Summary table, " +
++            "listing constructors, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C2.ModalExclusionType.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Enum Constant Summary table, " +
++            "listing enum constants, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C3.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Required Element Summary table, " +
++            "listing required elements, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C4.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Optional Element Summary table, " +
++            "listing optional elements, and an explanation\">"
++        },
++        // Class use documentation
++        {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "I1.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing packages, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing fields, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing methods, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing fields, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing methods, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.ModalExclusionType.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing packages, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.ModalExclusionType.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing methods, and an explanation\">"
++        },
++        // Package use documentation
++        {BUG_ID + FS + "pkg1" + FS + "package-use.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing packages, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "package-use.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing classes, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-use.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing packages, and an explanation\">"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-use.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
++            "listing classes, and an explanation\">"
++        },
++        // Deprecated
++        {BUG_ID + FS + "deprecated-list.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Deprecated Fields table, " +
++            "listing deprecated fields, and an explanation\">"
++        },
++        {BUG_ID + FS + "deprecated-list.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Deprecated Methods table, " +
++            "listing deprecated methods, and an explanation\">"
++        },
++        // Constant values
++        {BUG_ID + FS + "constant-values.html",
++            "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" " +
++            "SUMMARY=\"Constant Field Values table, listing " +
++            "constant fields, and values\">"
++        },
++        // Overview Summary
++        {BUG_ID + FS + "overview-summary.html",
++            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
++            "CELLSPACING=\"0\" SUMMARY=\"Packages table, " +
++            "listing packages, and an explanation\">"
++        },
++
++        /*
++         * Test for validating caption for HTML tables
++         */
++
++        //Package summary
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Class Summary</CAPTION>"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Interface Summary</CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Enum Summary</CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Annotation Types Summary</CAPTION>"
++        },
++        // Class documentation
++        {BUG_ID + FS + "pkg1" + FS + "C1.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Field Summary</CAPTION>"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "C1.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Method Summary</CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C2.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Nested Class Summary</CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C2.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Constructor Summary</CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C2.ModalExclusionType.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Enum Constant Summary</CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C3.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Required Element Summary</CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C4.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Optional Element Summary</CAPTION>"
++        },
++        // Class use documentation
++        {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "I1.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Packages that use <A HREF=\"../../pkg1/I1.html\" " +
++            "title=\"interface in pkg1\">I1</A></CAPTION>"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
++            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++            "Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> " +
++            "declared as <A HREF=\"../../pkg1/C1.html\" title=\"class in pkg1\">" +
++            "C1</A></CAPTION>"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
++            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++            "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> " +
++            "with parameters of type <A HREF=\"../../pkg1/C1.html\" " +
++            "title=\"class in pkg1\">C1</A></CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
++            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++            "Fields in <A HREF=\"../../pkg1/package-summary.html\">pkg1</A> " +
++            "declared as <A HREF=\"../../pkg2/C2.html\" title=\"class in pkg2\">" +
++            "C2</A></CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
++            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++            "Methods in <A HREF=\"../../pkg1/package-summary.html\">pkg1</A> " +
++            "with parameters of type <A HREF=\"../../pkg2/C2.html\" " +
++            "title=\"class in pkg2\">C2</A></CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.ModalExclusionType.html",
++            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++            "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> " +
++            "that return <A HREF=\"../../pkg2/C2.ModalExclusionType.html\" " +
++            "title=\"enum in pkg2\">C2.ModalExclusionType</A></CAPTION>"
++        },
++        // Package use documentation
++        {BUG_ID + FS + "pkg1" + FS + "package-use.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Packages that use <A HREF=\"../pkg1/package-summary.html\">" +
++            "pkg1</A></CAPTION>"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "package-use.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Classes in <A HREF=\"../pkg1/package-summary.html\">pkg1</A> " +
++            "used by <A HREF=\"../pkg1/package-summary.html\">pkg1</A></CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-use.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Packages that use <A HREF=\"../pkg2/package-summary.html\">" +
++            "pkg2</A></CAPTION>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-use.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Classes in <A HREF=\"../pkg2/package-summary.html\">pkg2</A> " +
++            "used by <A HREF=\"../pkg1/package-summary.html\">pkg1</A></CAPTION>"
++        },
++        // Deprecated
++        {BUG_ID + FS + "deprecated-list.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Deprecated Fields</CAPTION>"
++        },
++        {BUG_ID + FS + "deprecated-list.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Deprecated Methods</CAPTION>"
++        },
++        // Constant values
++        {BUG_ID + FS + "constant-values.html",
++            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++            "pkg1.<A HREF=\"pkg1/C1.html\" title=\"class in pkg1\">C1</A></CAPTION>"
++        },
++        // Overview Summary
++        {BUG_ID + FS + "overview-summary.html",
++            "<CAPTION CLASS=\"TableCaption\">" + NL +
++            "Packages</CAPTION>"
++        },
++
++        /*
++         * Test for validating headers for HTML tables
++         */
++
++        //Package summary
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Class</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++            " NOWRAP>Description</TH>"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Interface</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++            " NOWRAP>Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Enum</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++            " NOWRAP>Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Annotation Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Description</TH>"
++        },
++        // Class documentation
++        {BUG_ID + FS + "pkg1" + FS + "C1.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Field and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "C1.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Method and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C2.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Class and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C2.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Constructor and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C2.ModalExclusionType.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Enum Constant and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C3.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Required Element and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "C4.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Optional Element and Description</TH>"
++        },
++        // Class use documentation
++        {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "I1.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++            " NOWRAP>Description</TH>"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Field and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Method and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Field and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Method and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.ModalExclusionType.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++            " NOWRAP>Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.ModalExclusionType.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Method and Description</TH>"
++        },
++        // Package use documentation
++        {BUG_ID + FS + "pkg1" + FS + "package-use.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++            " NOWRAP>Description</TH>"
++        },
++        {BUG_ID + FS + "pkg1" + FS + "package-use.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Class and Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-use.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++            " NOWRAP>Description</TH>"
++        },
++        {BUG_ID + FS + "pkg2" + FS + "package-use.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Class and Description</TH>"
++        },
++        // Deprecated
++        {BUG_ID + FS + "deprecated-list.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Field and Description</TH>"
++        },
++        {BUG_ID + FS + "deprecated-list.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Method and Description</TH>"
++        },
++        // Constant values
++        {BUG_ID + FS + "constant-values.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
++            " SCOPE=\"col\" NOWRAP>Constant Field</TH>" + NL +
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>Value</TH>"
++        },
++        // Overview Summary
++        {BUG_ID + FS + "overview-summary.html",
++            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
++            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++            " NOWRAP>Description</TH>"
++        }
++    };
++    private static final String[][] NEGATED_TEST = NO_TEST;
++
++    /**
++     * The entry point of the test.
++     * @param args the array of command line arguments.
++     */
++    public static void main(String[] args) {
++        TestHtmlTableTags tester = new TestHtmlTableTags();
++        run(tester, ARGS, TABLE_TAGS_TEST, NEGATED_TEST);
++        tester.printSummary();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getBugId() {
++        return BUG_ID;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getBugName() {
++        return getClass().getName();
++    }
++}
+diff --git a/test/com/sun/javadoc/testHtmlTableTags/pkg1/C1.java b/test/com/sun/javadoc/testHtmlTableTags/pkg1/C1.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTableTags/pkg1/C1.java
+@@ -0,0 +1,81 @@
++/*
++ * 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.
++ */
++
++package pkg1;
++
++import pkg2.*;
++
++/**
++ * A test class.
++ *
++ * @author Bhavesh Patel
++ */
++public class C1 implements I1 {
++
++    /**
++     * Test field for class.
++     */
++    public C2 field;
++
++    /**
++     * Constant value.
++     */
++    public static final String CONSTANT1 = "C1";
++
++    /**
++     * A test constructor.
++     */
++    C1() {
++    }
++
++    /**
++     * Method thats does some processing.
++     *
++     * @param param some parameter that is passed.
++     * @return a sample object.
++     */
++    public C2 method(C2 param) {
++        return param;
++    }
++
++    /**
++     * Method that is implemented.
++     *
++     * @param a some random value.
++     * @param b some random value.
++     */
++    public void method1(int a, int b) {
++    }
++
++    /**
++     * Another inherited method.
++     * @param c some value.
++     */
++    public void method2(int c) {
++    }
++
++    /**
++     * @deprecated don't use this anymore.
++     */
++    public void deprecatedMethod() {}
++}
+diff --git a/test/com/sun/javadoc/testHtmlTableTags/pkg1/I1.java b/test/com/sun/javadoc/testHtmlTableTags/pkg1/I1.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTableTags/pkg1/I1.java
+@@ -0,0 +1,48 @@
++/*
++ * 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.
++ */
++
++package pkg1;
++
++/**
++ * A sample interface used to test table tags.
++ *
++ * @author Bhavesh Patel
++ */
++public interface I1 {
++
++    /**
++     * A test method.
++     *
++     * @param a blah.
++     * @param b blah.
++     */
++    void method1(int a, int b);
++
++    /**
++     * Another test method.
++     *
++     * @param c blah.
++     */
++    void method2(int c);
++
++}
+diff --git a/test/com/sun/javadoc/testHtmlTableTags/pkg1/package-info.java b/test/com/sun/javadoc/testHtmlTableTags/pkg1/package-info.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTableTags/pkg1/package-info.java
+@@ -0,0 +1,27 @@
++/*
++ * 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 package 1 used to test table tags.
++ */
++package pkg1;
+diff --git a/test/com/sun/javadoc/testHtmlTableTags/pkg2/C2.java b/test/com/sun/javadoc/testHtmlTableTags/pkg2/C2.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTableTags/pkg2/C2.java
+@@ -0,0 +1,73 @@
++/*
++ * 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.
++ */
++
++package pkg2;
++
++import pkg1.*;
++
++/**
++ * Another test class.
++ *
++ * @author Bhavesh Patel
++ */
++public class C2 {
++
++    /**
++     * A test field.
++     */
++    public C1 field;
++
++    /**
++     * @deprecated don't use this field anymore.
++     */
++    public C1 dep_field;
++
++    /**
++     * A sample enum.
++     */
++    public static enum ModalExclusionType {
++        /**
++         * Test comment.
++         */
++        NO_EXCLUDE,
++        /**
++         * Another comment.
++         */
++        APPLICATION_EXCLUDE
++    };
++
++    /**
++     * A string constant.
++     */
++    public static final String CONSTANT1 = "C2";
++
++    /**
++     * A sample method.
++     *
++     * @param param some parameter.
++     * @return a test object.
++     */
++    public C1 method(C1 param) {
++        return param;
++    }
++}
+diff --git a/test/com/sun/javadoc/testHtmlTableTags/pkg2/C3.java b/test/com/sun/javadoc/testHtmlTableTags/pkg2/C3.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTableTags/pkg2/C3.java
+@@ -0,0 +1,40 @@
++/*
++ * 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.  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 pkg2;
++
++import java.lang.annotation.*;
++
++/**
++ * Test Annotation class.
++ *
++ * @author Bhavesh Patel
++ */
++public @interface C3 {
++    /**
++     * Comment.
++     */
++    String[] value();
++}
+diff --git a/test/com/sun/javadoc/testHtmlTableTags/pkg2/C4.java b/test/com/sun/javadoc/testHtmlTableTags/pkg2/C4.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTableTags/pkg2/C4.java
+@@ -0,0 +1,35 @@
++/*
++ * 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.  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 pkg2;
++
++import java.lang.annotation.*;
++
++/*
++ * A sample interface.
++ */
++public @interface C4 {
++    boolean value() default true;
++}
+diff --git a/test/com/sun/javadoc/testHtmlTableTags/pkg2/package-info.java b/test/com/sun/javadoc/testHtmlTableTags/pkg2/package-info.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTableTags/pkg2/package-info.java
+@@ -0,0 +1,27 @@
++/*
++ * 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 package 2 used to test table tags.
++ */
++package pkg2;
+diff --git a/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java b/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+--- openjdk/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
++++ openjdk/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+@@ -58,7 +58,8 @@
+                 "<A HREF=\"../pkg/Coin.html\" title=\"enum in pkg\">Coin</A>&gt;"
+             },
+             //Check for enum constant section
+-            {BUG_ID + FS + "pkg" + FS + "Coin.html", "<STRONG>Enum Constant Summary</STRONG>"},
++            {BUG_ID + FS + "pkg" + FS + "Coin.html", "<CAPTION CLASS=\"TableCaption\">" + NL +
++                     "Enum Constant Summary</CAPTION>"},
+             //Detail for enum constant
+             {BUG_ID + FS + "pkg" + FS + "Coin.html",
+                 "<STRONG><A HREF=\"../pkg/Coin.html#Dime\">Dime</A></STRONG>"},
+@@ -158,9 +159,11 @@
+                 "public @interface <STRONG>AnnotationType</STRONG>"},
+             //Make sure member summary headings are correct.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "<STRONG>Required Element Summary</STRONG>"},
++                "<CAPTION CLASS=\"TableCaption\">" + NL +
++                "Required Element Summary</CAPTION>"},
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "<STRONG>Optional Element Summary</STRONG>"},
++                "<CAPTION CLASS=\"TableCaption\">" + NL +
++                "Optional Element Summary</CAPTION>"},
+             //Make sure element detail heading is correct
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+                 "Element Detail"},
+@@ -286,39 +289,57 @@
+ 
+             //ClassUseTest1: <T extends Foo & Foo2>
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                 "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" " +
++                     "title=\"class in pkg2\">Foo</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+                 "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html\" title=\"class in pkg2\">ClassUseTest1&lt;T extends Foo & Foo2&gt;</A></STRONG></CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" " +
++                     "title=\"class in pkg2\">Foo</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+                 "<TD><CODE><STRONG>ClassUseTest1.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" " +
++                     "title=\"class in pkg2\">Foo</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+                 "<A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A>&lt;<A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A>&gt;</CODE></FONT></TD>"
+             },
+ 
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> declared as <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> declared as <A HREF=\"../../pkg2/ParamTest.html\" " +
++                     "title=\"class in pkg2\">ParamTest</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+                 "<A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A>&lt;<A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A>&gt;</CODE></FONT></TD>"
+             },
+ 
+            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">Foo2</A></FONT></TH>"
++                    "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                    "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                    "</A> with type parameters of type <A HREF=\"../../pkg2/Foo2.html\" " +
++                    "title=\"interface in pkg2\">Foo2</A></CAPTION>"
+            },
+            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+             "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html\" title=\"class in pkg2\">ClassUseTest1&lt;T extends Foo & Foo2&gt;</A></STRONG></CODE>"
+            },
+            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+-               "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo2.html\" title=\"interface in pkg2\">Foo2</A></FONT></TH>"
++                    "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                    "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                    "</A> with type parameters of type <A HREF=\"../../pkg2/Foo2.html\" " +
++                    "title=\"interface in pkg2\">Foo2</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+                "<TD><CODE><STRONG>ClassUseTest1.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+@@ -326,44 +347,66 @@
+ 
+             //ClassUseTest2: <T extends ParamTest<Foo3>>
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-              "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" " +
++                     "title=\"class in pkg2\">ParamTest</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+               "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html\" title=\"class in pkg2\">ClassUseTest2&lt;T extends ParamTest&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;</A></STRONG></CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-              "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" " +
++                     "title=\"class in pkg2\">ParamTest</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+               "<TD><CODE><STRONG>ClassUseTest2.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-              "<TH ALIGN=\"left\" COLSPAN=\"2\">Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> declared as <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> declared as <A HREF=\"../../pkg2/ParamTest.html\" " +
++                     "title=\"class in pkg2\">ParamTest</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+               "<A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A>&lt;<A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A>&gt;</CODE></FONT></TD>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-              "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" " +
++                     "title=\"class in pkg2\">ParamTest</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+               "&lt;T extends <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A>&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;"
+             },
+ 
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo3.html\" " +
++                     "title=\"class in pkg2\">Foo3</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+                 "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html\" title=\"class in pkg2\">ClassUseTest2&lt;T extends ParamTest&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;</A></STRONG></CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo3.html\" " +
++                     "title=\"class in pkg2\">Foo3</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+                 "<TD><CODE><STRONG>ClassUseTest2.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> that return types with arguments of type <A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> that return types with arguments of type " +
++                     "<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">" +
++                     "Foo3</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+                 "&lt;T extends <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A>&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;"
+@@ -371,38 +414,61 @@
+ 
+             //ClassUseTest3: <T extends ParamTest2<List<? extends Foo4>>>
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">ParamTest2</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type " +
++                     "<A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
++                     "ParamTest2</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+                 "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html\" title=\"class in pkg2\">ClassUseTest3&lt;T extends ParamTest2&lt;java.util.List&lt;? extends Foo4&gt;&gt;&gt;</A></STRONG></CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">ParamTest2</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type " +
++                     "<A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
++                     "ParamTest2</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+                 "<TD><CODE><STRONG>ClassUseTest3.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">ParamTest2</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type " +
++                     "<A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
++                     "ParamTest2</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+                 "&lt;T extends <A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">ParamTest2</A>&lt;java.util.List&lt;? extends <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A>&gt;&gt;&gt;"
+             },
+ 
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type " +
++                     "<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">" +
++                     "Foo4</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+                 "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html\" title=\"class in pkg2\">ClassUseTest3&lt;T extends ParamTest2&lt;java.util.List&lt;? extends Foo4&gt;&gt;&gt;</A></STRONG></CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type parameters of type <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo4.html\" " +
++                     "title=\"class in pkg2\">Foo4</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+                 "<TD><CODE><STRONG>ClassUseTest3.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> that return types with arguments of type <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A></FONT></TH>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> that return types with arguments of type " +
++                     "<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">" +
++                     "Foo4</A></CAPTION>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+                 "&lt;T extends <A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">ParamTest2</A>&lt;java.util.List&lt;? extends <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A>&gt;&gt;&gt;"
+@@ -410,81 +476,147 @@
+ 
+             //Type parameters in constructor and method args
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Method parameters in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type arguments of type <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A></FONT></TH>" + NL +
+-                "</TR>" + NL +
+-                "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+-                "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
+-                "<TD><CODE><STRONG>ClassUseTest3.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#method(java.util.Set)\">method</A></STRONG>(java.util.Set&lt;<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A>&gt;&nbsp;p)</CODE>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Method parameters in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
++                     "</A> with type arguments of type <A HREF=\"../../pkg2/Foo4.html\" " +
++                     "title=\"class in pkg2\">Foo4</A></CAPTION>" + NL +
++                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Modifier and Type" +
++                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Method and Description</TH>" + NL +
++                     "</TR>" + NL +
++                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
++                     "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
++                     "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
++                     "<TD><CODE><STRONG>ClassUseTest3.</STRONG><STRONG>" +
++                     "<A HREF=\"../../pkg2/ClassUseTest3.html#method(java.util.Set)\">" +
++                     "method</A></STRONG>(java.util.Set&lt;<A HREF=\"../../pkg2/Foo4.html\" " +
++                     "title=\"class in pkg2\">Foo4</A>&gt;&nbsp;p)</CODE>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                "<TH ALIGN=\"left\" COLSPAN=\"2\">Constructor parameters in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> with type arguments of type <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A></FONT></TH>" + NL +
+-                "</TR>" + NL +
+-                "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#ClassUseTest3(java.util.Set)\">ClassUseTest3</A></STRONG>(java.util.Set&lt;<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A>&gt;&nbsp;p)</CODE>"
++                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
++                     "Constructor parameters in <A HREF=\"../../pkg2/package-summary.html\">" +
++                     "pkg2</A> with type arguments of type <A HREF=\"../../pkg2/Foo4.html\" " +
++                     "title=\"class in pkg2\">Foo4</A></CAPTION>" + NL +
++                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Constructor and Description" +
++                     "</TH>" + NL + "</TR>" + NL +
++                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
++                     "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#ClassUseTest3" +
++                     "(java.util.Set)\">ClassUseTest3</A></STRONG>(java.util.Set&lt;" +
++                     "<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">" +
++                     "Foo4</A>&gt;&nbsp;p)</CODE>"
+             },
+ 
+             //=================================
+             // Annotatation Type Usage
+             //=================================
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                "<FONT SIZE=\"+2\">" + NL +
+-                "Packages with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" title=\"annotation in pkg\">AnnotationType</A></FONT></TH>" + NL +
+-                "</TR>" + NL +
+-                "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD><A HREF=\"../../pkg/package-summary.html\"><STRONG>pkg</STRONG></A></TD>"
++                     "Packages with annotations of type " +
++                     "<A HREF=\"../../pkg/AnnotationType.html\" " +
++                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
++                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Package" +
++                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Description</TH>" + NL + "</TR>" + NL +
++                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
++                     "<TD><A HREF=\"../../pkg/package-summary.html\"><STRONG>pkg" +
++                     "</STRONG></A></TD>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                "Classes in <A HREF=\"../../pkg/package-summary.html\">pkg</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" title=\"annotation in pkg\">AnnotationType</A></FONT></TH>" + NL +
+-                "</TR>" + NL +
+-                "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+-                "<CODE>&nbsp;class</CODE></FONT></TD>" + NL +
+-                "<TD><CODE><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html\" title=\"class in pkg\">AnnotationTypeUsage</A></STRONG></CODE>"
++                     "Classes in <A HREF=\"../../pkg/package-summary.html\">pkg" +
++                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
++                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
++                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Modifier and Type" +
++                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Class and Description</TH>" + NL +
++                     "</TR>" + NL +
++                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
++                     "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
++                     "<CODE>&nbsp;class</CODE></FONT></TD>" + NL +
++                     "<TD><CODE><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html\" " +
++                     "title=\"class in pkg\">AnnotationTypeUsage</A></STRONG></CODE>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                "Fields in <A HREF=\"../../pkg/package-summary.html\">pkg</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" title=\"annotation in pkg\">AnnotationType</A></FONT></TH>" + NL +
+-                "</TR>" + NL +
+-                "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+-                "<CODE>&nbsp;int</CODE></FONT></TD>" + NL +
+-                "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html#field\">field</A></STRONG></CODE>"
++                     "Fields in <A HREF=\"../../pkg/package-summary.html\">pkg" +
++                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
++                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
++                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Modifier and Type" +
++                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Field and Description</TH>" + NL +
++                     "</TR>" + NL +
++                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
++                     "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
++                     "<CODE>&nbsp;int</CODE></FONT></TD>" + NL +
++                     "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG>" +
++                     "<A HREF=\"../../pkg/AnnotationTypeUsage.html#field\">field" +
++                     "</A></STRONG></CODE>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                "Methods in <A HREF=\"../../pkg/package-summary.html\">pkg</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" title=\"annotation in pkg\">AnnotationType</A></FONT></TH>" + NL +
+-                "</TR>" + NL +
+-                "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+-                "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
+-                "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html#method()\">method</A></STRONG>()</CODE>"
++                     "Methods in <A HREF=\"../../pkg/package-summary.html\">pkg" +
++                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
++                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
++                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Modifier and Type" +
++                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Method and Description</TH>" + NL +
++                     "</TR>" + NL +
++                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
++                     "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
++                     "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
++                     "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG>" +
++                     "<A HREF=\"../../pkg/AnnotationTypeUsage.html#method()\">" +
++                     "method</A></STRONG>()</CODE>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                "Method parameters in <A HREF=\"../../pkg/package-summary.html\">pkg</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" title=\"annotation in pkg\">AnnotationType</A></FONT></TH>" + NL +
+-                "</TR>" + NL +
+-                "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+-                "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
+-                "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html#methodWithParams(int, int)\">methodWithParams</A></STRONG>(int&nbsp;documented," + NL +
+-                "                 int&nbsp;undocmented)</CODE>"
++                     "Method parameters in <A HREF=\"../../pkg/package-summary.html\">pkg" +
++                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
++                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
++                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Modifier and Type" +
++                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Method and Description</TH>" + NL +
++                     "</TR>" + NL +
++                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
++                     "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
++                     "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
++                     "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG>" +
++                     "<A HREF=\"../../pkg/AnnotationTypeUsage.html#methodWithParams" +
++                     "(int, int)\">methodWithParams</A></STRONG>(int&nbsp;documented," + NL +
++                     "                 int&nbsp;undocmented)</CODE>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                "Constructors in <A HREF=\"../../pkg/package-summary.html\">pkg</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" title=\"annotation in pkg\">AnnotationType</A></FONT></TH>" + NL +
+-                "</TR>" + NL +
+-                "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD><CODE><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html#AnnotationTypeUsage()\">AnnotationTypeUsage</A></STRONG>()</CODE>"
++                     "Constructors in <A HREF=\"../../pkg/package-summary.html\">pkg" +
++                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
++                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
++                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Constructor and Description" +
++                     "</TH>" + NL + "</TR>" + NL +
++                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
++                     "<TD><CODE><STRONG><A HREF=\"../../pkg/" +
++                     "AnnotationTypeUsage.html#AnnotationTypeUsage()\">" +
++                     "AnnotationTypeUsage</A></STRONG>()</CODE>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                "Constructor parameters in <A HREF=\"../../pkg/package-summary.html\">pkg</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" title=\"annotation in pkg\">AnnotationType</A></FONT></TH>" + NL +
+-                "</TR>" + NL +
+-                "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                "<TD><CODE><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html#AnnotationTypeUsage(int, int)\">AnnotationTypeUsage</A></STRONG>(int&nbsp;documented," + NL +
+-                "                    int&nbsp;undocmented)</CODE>"
++                     "Constructor parameters in <A HREF=\"../../pkg/package-summary.html\">pkg" +
++                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
++                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
++                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
++                     " NOWRAP>Constructor and Description" +
++                     "</TH>" + NL + "</TR>" + NL +
++                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
++                     "<TD><CODE><STRONG><A HREF=\"../../pkg/" +
++                     "AnnotationTypeUsage.html#AnnotationTypeUsage(int, int)\">" +
++                     "AnnotationTypeUsage</A></STRONG>(int&nbsp;documented," + NL +
++                     "                    int&nbsp;undocmented)</CODE>"
+             },
+ 
+             //=================================
+diff --git a/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java b/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java
+--- openjdk/langtools/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java
++++ openjdk/langtools/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java
+@@ -46,7 +46,8 @@
+ 
+     //Input for string search tests.
+     private static final String[][] TEST = {
+-        {BUG_ID + FS + "C.html",  "<STRONG>Method Summary</STRONG>"}
++        {BUG_ID + FS + "C.html",  "<CAPTION CLASS=\"TableCaption\">" + NL +
++                 "Method Summary</CAPTION>"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6786690-wcag_dl.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,3230 @@
+# HG changeset patch
+# User andrew
+# Date 1371571959 18000
+# Node ID 9cad0410f52a47fdd3b294a10f076e7456a47e9a
+# Parent  9b884c583c41a545352b035d11d1ccacb96fbb2f
+6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
+Reviewed-by: jjg
+
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
+@@ -25,11 +25,11 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
+-import com.sun.tools.doclets.internal.toolkit.util.*;
++import java.io.*;
++import java.util.*;
+ 
+ import com.sun.javadoc.*;
+-import java.io.*;
+-import java.util.*;
++import com.sun.tools.doclets.internal.toolkit.util.*;
+ 
+ /**
+  * Generate Index for all the Member Names with Indexing in
+@@ -100,18 +100,22 @@
+         h2();
+         strong(unicode.toString());
+         h2End();
+-        dl();
+-        for (int i = 0; i < memberlist.size(); i++) {
+-            Doc element = (Doc)memberlist.get(i);
+-            if (element instanceof MemberDoc) {
+-                printDescription((MemberDoc)element);
+-            } else if (element instanceof ClassDoc) {
+-                printDescription((ClassDoc)element);
+-            } else if (element instanceof PackageDoc) {
+-                printDescription((PackageDoc)element);
++        int memberListSize = memberlist.size();
++        // Display the list only if there are elements to be displayed.
++        if (memberListSize > 0) {
++            dl();
++            for (int i = 0; i < memberListSize; i++) {
++                Doc element = memberlist.get(i);
++                if (element instanceof MemberDoc) {
++                    printDescription((MemberDoc)element);
++                } else if (element instanceof ClassDoc) {
++                    printDescription((ClassDoc)element);
++                } else if (element instanceof PackageDoc) {
++                    printDescription((PackageDoc)element);
++                }
+             }
++            dlEnd();
+         }
+-        dlEnd();
+         hr();
+     }
+ 
+@@ -126,8 +130,10 @@
+         printPackageLink(pkg, Util.getPackageName(pkg), true);
+         print(" - ");
+         print(configuration.getText("doclet.package") + " " + pkg.name());
++        dtEnd();
+         dd();
+         printSummaryComment(pkg);
++        ddEnd();
+     }
+ 
+     /**
+@@ -140,8 +146,10 @@
+         printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true));
+         print(" - ");
+         printClassInfo(cd);
++        dtEnd();
+         dd();
+         printComment(cd);
++        ddEnd();
+     }
+ 
+     /**
+@@ -178,8 +186,10 @@
+         println(" - ");
+         printMemberDesc(member);
+         println();
++        dtEnd();
+         dd();
+         printComment(member);
++        ddEnd();
+         println();
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+@@ -25,19 +25,20 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.lang.reflect.Modifier;
++import java.util.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ 
+-import com.sun.javadoc.*;
+-import java.util.*;
+-import java.lang.reflect.Modifier;
+-
+ /**
+  * The base class for member writers.
+  *
+  * @author Robert Field
+  * @author Atul M Dambalkar
+  * @author Jamie Ho (Re-write)
++ * @author Bhavesh Patel (Modified)
+  */
+ public abstract class AbstractMemberWriter {
+ 
+@@ -232,10 +233,26 @@
+         }
+     }
+ 
++    /**
++     * Print the deprecated output for the given member.
++     *
++     * @param member the member being documented.
++     */
++    protected void printDeprecated(ProgramElementDoc member) {
++        String output = (new DeprecatedTaglet()).getTagletOutput(member,
++            writer.getTagletWriterInstance(false)).toString().trim();
++        if (!output.isEmpty()) {
++            writer.printMemberDetailsListStartTag();
++            writer.print(output);
++        }
++    }
++
+     protected void printComment(ProgramElementDoc member) {
+         if (member.inlineTags().length > 0) {
++            writer.printMemberDetailsListStartTag();
+             writer.dd();
+             writer.printInlineComment(member);
++            writer.ddEnd();
+         }
+     }
+ 
+@@ -267,6 +284,14 @@
+     }
+ 
+     /**
++     * Write the member footer.
++     */
++    protected void printMemberFooter() {
++        writer.printMemberDetailsListEndTag();
++        assert !writer.getMemberDetailsListPrinted();
++    }
++
++    /**
+      * Forward to containing writer
+      */
+     public void printSummaryHeader(ClassDoc cd) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+@@ -25,10 +25,10 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+-import com.sun.javadoc.*;
+-
+-import java.io.*;
+ 
+ /**
+  * Writes annotation type optional member documentation in HTML format.
+@@ -63,14 +63,20 @@
+      * {@inheritDoc}
+      */
+     public void writeDefaultValueInfo(MemberDoc member) {
+-        writer.dl();
+-        writer.dt();
+-        writer.strong(ConfigurationImpl.getInstance().
+-            getText("doclet.Default"));
+-        writer.dd();
+-        writer.print(((AnnotationTypeElementDoc) member).defaultValue());
+-        writer.ddEnd();
+-        writer.dlEnd();
++        if (((AnnotationTypeElementDoc) member).defaultValue() != null) {
++            writer.printMemberDetailsListStartTag();
++            writer.dd();
++            writer.dl();
++            writer.dt();
++            writer.strong(ConfigurationImpl.getInstance().
++                getText("doclet.Default"));
++            writer.dtEnd();
++            writer.dd();
++            writer.print(((AnnotationTypeElementDoc) member).defaultValue());
++            writer.ddEnd();
++            writer.dlEnd();
++            writer.ddEnd();
++        }
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+@@ -25,11 +25,10 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+-import com.sun.tools.doclets.internal.toolkit.taglets.*;
+-import com.sun.javadoc.*;
+-
+-import java.io.*;
+ 
+ /**
+  * Writes annotation type required member documentation in HTML format.
+@@ -134,17 +133,14 @@
+             strong(member.name());
+         }
+         writer.preEnd();
+-        writer.dl();
++        assert !writer.getMemberDetailsListPrinted();
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+     public void writeComments(MemberDoc member) {
+-        if (member.inlineTags().length > 0) {
+-            writer.dd();
+-            writer.printInlineComment(member);
+-        }
++        printComment(member);
+     }
+ 
+     /**
+@@ -160,7 +156,7 @@
+      * Write the annotation type member footer.
+      */
+     public void writeMemberFooter() {
+-        writer.dlEnd();
++        printMemberFooter();
+     }
+ 
+     /**
+@@ -267,9 +263,7 @@
+      * {@inheritDoc}
+      */
+     public void writeDeprecated(MemberDoc member) {
+-        print(((TagletOutputImpl)
+-            (new DeprecatedTaglet()).getTagletOutput(member,
+-            writer.getTagletWriterInstance(false))).toString());
++        printDeprecated(member);
+     }
+ 
+     private Type getType(MemberDoc member) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
+@@ -25,10 +25,10 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.builders.*;
+-import com.sun.javadoc.*;
+ 
+ /**
+  * Generate the Class Information Page.
+@@ -165,8 +165,6 @@
+      * {@inheritDoc}
+      */
+     public void writeAnnotationTypeSignature(String modifiers) {
+-        dl();
+-        dt();
+         preNoNewLine();
+         writeAnnotationInfo(annotationType);
+         print(modifiers);
+@@ -178,7 +176,6 @@
+         } else {
+             strong(name);
+         }
+-        dlEnd();
+         preEnd();
+         p();
+     }
+@@ -334,6 +331,7 @@
+             } else {
+                 strongText("doclet.Enclosing_Class");
+             }
++            dtEnd();
+             dd();
+             printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
+                 false));
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+@@ -25,12 +25,12 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.util.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.builders.*;
+-import com.sun.javadoc.*;
+-
+-import java.util.*;
+ import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ 
+ /**
+@@ -171,8 +171,6 @@
+      */
+     public void writeClassSignature(String modifiers) {
+         boolean isInterface = classDoc.isInterface();
+-        dl();
+-        dt();
+         preNoNewLine();
+         writeAnnotationInfo(classDoc);
+         print(modifiers);
+@@ -191,7 +189,7 @@
+             Type superclass = Util.getFirstVisibleSuperClass(classDoc,
+                 configuration());
+             if (superclass != null) {
+-                dt();
++                println();
+                 print("extends ");
+                 printLink(new LinkInfoImpl(
+                     LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
+@@ -208,7 +206,7 @@
+                     continue;
+                 }
+                 if (counter == 0) {
+-                    dt();
++                    println();
+                     print(isInterface? "extends " : "implements ");
+                 } else {
+                     print(", ");
+@@ -219,7 +217,6 @@
+                 counter++;
+             }
+         }
+-        dlEnd();
+         preEnd();
+         p();
+     }
+@@ -342,6 +339,7 @@
+             TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc,
+                 getTagletWriterInstance(false));
+             print(output.toString());
++            dtEnd();
+             dlEnd();
+         }
+     }
+@@ -360,8 +358,10 @@
+                 dl();
+                 dt();
+                 strongText("doclet.Subclasses");
++                dtEnd();
+                 writeClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES,
+                     subclasses);
++                dlEnd();
+             }
+         }
+     }
+@@ -376,8 +376,10 @@
+                 dl();
+                 dt();
+                 strongText("doclet.Subinterfaces");
++                dtEnd();
+                 writeClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES,
+                     subInterfaces);
++                dlEnd();
+             }
+         }
+     }
+@@ -398,8 +400,10 @@
+             dl();
+             dt();
+             strongText("doclet.Implementing_Classes");
++            dtEnd();
+             writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES,
+                 implcl);
++            dlEnd();
+         }
+     }
+ 
+@@ -414,8 +418,10 @@
+             dl();
+             dt();
+             strongText("doclet.All_Implemented_Interfaces");
++            dtEnd();
+             writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES,
+                 interfaceArray);
++            dlEnd();
+         }
+     }
+ 
+@@ -430,8 +436,10 @@
+             dl();
+             dt();
+             strongText("doclet.All_Superinterfaces");
++            dtEnd();
+             writeClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES,
+                 interfaceArray);
++            dlEnd();
+         }
+     }
+ 
+@@ -455,7 +463,6 @@
+             }
+         }
+         ddEnd();
+-        dlEnd();
+     }
+ 
+     protected void navLinkTree() {
+@@ -574,6 +581,7 @@
+             } else {
+                 strongText("doclet.Enclosing_Class");
+             }
++            dtEnd();
+             dd();
+             printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
+                 false));
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+@@ -25,12 +25,12 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++import java.util.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.tools.doclets.internal.toolkit.taglets.*;
+-import com.sun.javadoc.*;
+-import java.util.*;
+-import java.io.*;
+ 
+ /**
+  * Writes constructor documentation.
+@@ -149,7 +149,7 @@
+         writeParameters(constructor);
+         writeExceptions(constructor);
+         writer.preEnd();
+-        writer.dl();
++        assert !writer.getMemberDetailsListPrinted();
+     }
+ 
+     /**
+@@ -158,12 +158,7 @@
+      * @param constructor the constructor being documented.
+      */
+     public void writeDeprecated(ConstructorDoc constructor) {
+-        String output = ((TagletOutputImpl)
+-            (new DeprecatedTaglet()).getTagletOutput(constructor,
+-            writer.getTagletWriterInstance(false))).toString();
+-        if (output != null && output.trim().length() > 0) {
+-            writer.print(output);
+-        }
++        printDeprecated(constructor);
+     }
+ 
+     /**
+@@ -172,10 +167,7 @@
+      * @param constructor the constructor being documented.
+      */
+     public void writeComments(ConstructorDoc constructor) {
+-        if (constructor.inlineTags().length > 0) {
+-            writer.dd();
+-            writer.printInlineComment(constructor);
+-        }
++        printComment(constructor);
+     }
+ 
+     /**
+@@ -191,7 +183,7 @@
+      * Write the constructor footer.
+      */
+     public void writeConstructorFooter() {
+-        writer.dlEnd();
++        printMemberFooter();
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+@@ -25,12 +25,11 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+-import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+-
+-import java.io.*;
+ 
+ /**
+  * Writes enum constant documentation in HTML format.
+@@ -146,26 +145,21 @@
+             strong(enumConstant.name());
+         }
+         writer.preEnd();
+-        writer.dl();
++        assert !writer.getMemberDetailsListPrinted();
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+     public void writeDeprecated(FieldDoc enumConstant) {
+-        print(((TagletOutputImpl)
+-            (new DeprecatedTaglet()).getTagletOutput(enumConstant,
+-            writer.getTagletWriterInstance(false))).toString());
++        printDeprecated(enumConstant);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+     public void writeComments(FieldDoc enumConstant) {
+-        if (enumConstant.inlineTags().length > 0) {
+-            writer.dd();
+-            writer.printInlineComment(enumConstant);
+-        }
++        printComment(enumConstant);
+     }
+ 
+     /**
+@@ -179,7 +173,7 @@
+      * {@inheritDoc}
+      */
+     public void writeEnumConstantFooter() {
+-        writer.dlEnd();
++        printMemberFooter();
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+@@ -25,12 +25,11 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+-import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+-
+-import java.io.*;
+ 
+ /**
+  * Writes field documentation in HTML format.
+@@ -156,7 +155,7 @@
+             strong(field.name());
+         }
+         writer.preEnd();
+-        writer.dl();
++        assert !writer.getMemberDetailsListPrinted();
+     }
+ 
+     /**
+@@ -165,9 +164,7 @@
+      * @param field the field being documented.
+      */
+     public void writeDeprecated(FieldDoc field) {
+-        print(((TagletOutputImpl)
+-            (new DeprecatedTaglet()).getTagletOutput(field,
+-            writer.getTagletWriterInstance(false))).toString());
++        printDeprecated(field);
+     }
+ 
+     /**
+@@ -178,10 +175,12 @@
+     public void writeComments(FieldDoc field) {
+         ClassDoc holder = field.containingClass();
+         if (field.inlineTags().length > 0) {
++            writer.printMemberDetailsListStartTag();
+             if (holder.equals(classdoc) ||
+                 (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
+                 writer.dd();
+                 writer.printInlineComment(field);
++                writer.ddEnd();
+             } else {
+                 String classlink = writer.codeText(
+                     writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
+@@ -196,6 +195,7 @@
+                 writer.ddEnd();
+                 writer.dd();
+                 writer.printInlineComment(field);
++                writer.ddEnd();
+             }
+         }
+     }
+@@ -213,7 +213,7 @@
+      * Write the field footer.
+      */
+     public void writeFieldFooter() {
+-        writer.dlEnd();
++        printMemberFooter();
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+@@ -24,17 +24,16 @@
+  */
+ 
+ package com.sun.tools.doclets.formats.html;
+-import com.sun.tools.doclets.formats.html.markup.*;
+ 
+-import com.sun.tools.doclets.internal.toolkit.*;
+-import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.tools.doclets.internal.toolkit.taglets.*;
+-
+-import com.sun.javadoc.*;
+ import java.io.*;
+ import java.text.SimpleDateFormat;
+ import java.util.*;
+ 
++import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ 
+ /**
+  * Class for the Html Format Code Generation specific to JavaDoc.
+@@ -44,6 +43,7 @@
+  * @since 1.2
+  * @author Atul M Dambalkar
+  * @author Robert Field
++ * @author Bhavesh Patel (Modified)
+  */
+ public class HtmlDocletWriter extends HtmlDocWriter {
+ 
+@@ -205,7 +205,13 @@
+     private void printMethodInfo(MethodDoc method) {
+         ClassDoc[] intfacs = method.containingClass().interfaces();
+         MethodDoc overriddenMethod = method.overriddenMethod();
+-        if (intfacs.length > 0 || overriddenMethod != null) {
++        // Check whether there is any implementation or overridden info to be
++        // printed. If no overridden or implementation info needs to be
++        // printed, do not print this section.
++        if ((intfacs.length > 0 &&
++                new ImplementedMethods(method, this.configuration).build().length > 0) ||
++                overriddenMethod != null) {
++            printMemberDetailsListStartTag();
+             dd();
+             printTagsInfoHeader();
+             MethodWriterImpl.printImplementsInfo(this, method);
+@@ -216,7 +222,6 @@
+             printTagsInfoFooter();
+             ddEnd();
+         }
+-        dd();
+     }
+ 
+     protected void printTags(Doc doc) {
+@@ -230,41 +235,35 @@
+         TagletWriter.genTagOuput(configuration.tagletManager, doc,
+             configuration.tagletManager.getCustomTags(doc),
+                 getTagletWriterInstance(false), output);
+-        if (output.toString().trim().length() > 0) {
++        String outputString = output.toString().trim();
++        // For RootDoc and ClassDoc, this section is not the definition description
++        // but the start of definition list.
++        if (!outputString.isEmpty()) {
++            if (!(doc instanceof RootDoc || doc instanceof ClassDoc)) {
++                printMemberDetailsListStartTag();
++                dd();
++            }
+             printTagsInfoHeader();
+-            print(output.toString());
++            print(outputString);
+             printTagsInfoFooter();
+-        } else if (! (doc instanceof ConstructorDoc ||
+-            doc instanceof RootDoc || doc instanceof ClassDoc)) {
+-            //To be consistent with 1.4.2 output.
+-            //I hate to do this but we have to pass the diff test to prove
+-            //nothing has broken.
+-            printTagsInfoHeader();
+-            printTagsInfoFooter();
++            if (!(doc instanceof RootDoc || doc instanceof ClassDoc))
++                ddEnd();
+         }
+     }
+ 
+     /**
+-     * Check whether there are any tags to be printed.
++     * Check whether there are any tags for Serialization Overview
++     * section to be printed.
+      *
+-     * @param doc the Doc object to check for tags.
++     * @param field the FieldDoc object to check for tags.
+      * @return true if there are tags to be printed else return false.
+      */
+-    protected boolean hasTagsToPrint(Doc doc) {
+-        if (doc instanceof MethodDoc) {
+-            ClassDoc[] intfacs = ((MethodDoc)doc).containingClass().interfaces();
+-            MethodDoc overriddenMethod = ((MethodDoc)doc).overriddenMethod();
+-            if ((intfacs.length > 0 &&
+-                new ImplementedMethods((MethodDoc)doc, this.configuration).build().length > 0) ||
+-                overriddenMethod != null) {
+-                return true;
+-            }
+-        }
++    protected boolean hasSerializationOverviewTags(FieldDoc field) {
+         TagletOutputImpl output = new TagletOutputImpl("");
+-        TagletWriter.genTagOuput(configuration.tagletManager, doc,
+-            configuration.tagletManager.getCustomTags(doc),
++        TagletWriter.genTagOuput(configuration.tagletManager, field,
++            configuration.tagletManager.getCustomTags(field),
+                 getTagletWriterInstance(false), output);
+-        return (output.toString().trim().isEmpty());
++        return (!output.toString().trim().isEmpty());
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+@@ -25,11 +25,12 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.util.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+-import java.util.*;
+ 
+ /**
+  * Generate serialized form for serializable fields.
+@@ -37,6 +38,7 @@
+  * <code>serialField</code> is processed.
+  *
+  * @author Joe Fialli
++ * @author Bhavesh Patel (Modified)
+  */
+ public class HtmlSerialFieldWriter extends FieldWriterImpl
+     implements SerializedFormWriter.SerialFieldWriter {
+@@ -75,7 +77,7 @@
+             writer.println();
+             if (heading.equals(
+                    configuration().getText("doclet.Serialized_Form_class"))) {
+-                writer.dl();
++                assert !writer.getMemberDetailsListPrinted();
+             }
+         } else {
+             writer.printTableHeadingBackground(heading);
+@@ -102,7 +104,7 @@
+         print(fieldDimensions + ' ');
+         strong(fieldName);
+         writer.preEnd();
+-        writer.dl();
++        assert !writer.getMemberDetailsListPrinted();
+     }
+ 
+     /**
+@@ -111,9 +113,7 @@
+      * @param field the field to document.
+      */
+     public void writeMemberDeprecatedInfo(FieldDoc field) {
+-        print(((TagletOutputImpl)
+-            (new DeprecatedTaglet()).getTagletOutput(field,
+-            writer.getTagletWriterInstance(false))).toString());
++        printDeprecated(field);
+     }
+ 
+     /**
+@@ -123,14 +123,17 @@
+      */
+     public void writeMemberDescription(FieldDoc field) {
+         if (field.inlineTags().length > 0) {
++            writer.printMemberDetailsListStartTag();
+             writer.dd();
+             writer.printInlineComment(field);
++            writer.ddEnd();
+         }
+         Tag[] tags = field.tags("serial");
+         if (tags.length > 0) {
+-            writer.dt();
++            writer.printMemberDetailsListStartTag();
+             writer.dd();
+             writer.printInlineComment(field, tags[0]);
++            writer.ddEnd();
+         }
+     }
+ 
+@@ -140,9 +143,14 @@
+      * @param serialFieldTag the field to document (represented by tag).
+      */
+     public void writeMemberDescription(SerialFieldTag serialFieldTag) {
+-        writer.dd();
+-        writer.print(serialFieldTag.description());
+-        writer.dlEnd();
++        String serialFieldTagDesc = serialFieldTag.description().trim();
++        if (!serialFieldTagDesc.isEmpty()) {
++            writer.dl();
++            writer.dd();
++            writer.print(serialFieldTagDesc);
++            writer.ddEnd();
++            writer.dlEnd();
++        }
+     }
+ 
+     /**
+@@ -151,33 +159,57 @@
+      * @param field the field to document.
+      */
+     public void writeMemberTags(FieldDoc field) {
+-        writer.dl();
+         TagletOutputImpl output = new TagletOutputImpl("");
+         TagletWriter.genTagOuput(configuration().tagletManager, field,
+             configuration().tagletManager.getCustomTags(field),
+                 writer.getTagletWriterInstance(false), output);
+-        if (output.toString().length() > 0) {
+-            print(output.toString());
++        String outputString = output.toString().trim();
++        if (!outputString.isEmpty()) {
++            writer.printMemberDetailsListStartTag();
++            writer.dd();
++            writer.dl();
++            print(outputString);
++            writer.dlEnd();
++            writer.ddEnd();
+         }
+-        writer.dlEnd();
+-    }
+-    public void writeMemberFooter(FieldDoc member) {
+-        writer.dlEnd();
+     }
+ 
+     /**
+-     * Check to see if member details should be printed. If
++     * Check to see if overview details should be printed. If
+      * nocomment option set or if there is no text to be printed
+-     * for deprecation info, inline comment, no serial tag or inline tags,
+-     * do not print member details.
++     * for deprecation info, comment or tags, do not print overview details.
++     *
++     * @param field the field to check overview details for.
++     * @return true if overview details need to be printed
+      */
+-    public boolean shouldPrintMemberDetails(FieldDoc field) {
+-        if (!configuration().nocomment)
+-            if((field.inlineTags().length > 0) ||
+-                (field.tags("serial").length > 0) || (writer.hasTagsToPrint(field)))
++    public boolean shouldPrintOverview(FieldDoc field) {
++        if (!configuration().nocomment) {
++            if(!field.commentText().isEmpty() ||
++                    writer.hasSerializationOverviewTags(field))
+                 return true;
+-        if (!Util.isDeprecated(field))
++        }
++        if (field.tags("deprecated").length > 0)
+             return true;
+         return false;
+     }
++
++    public void writeMemberFooter() {
++        printMemberFooter();
++    }
++
++    /**
++     * Write the footer information. If the serilization overview section was
++     * printed, check for definition list and close list tag.
++     *
++     * @param heading the heading that was written.
++     */
++    public void writeFooter(String heading) {
++        if (printedOverallAnchor) {
++            if (heading.equals(
++                   configuration().getText("doclet.Serialized_Form_class"))) {
++                writer.printMemberDetailsListEndTag();
++                assert !writer.getMemberDetailsListPrinted();
++            }
++        }
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
+@@ -25,9 +25,9 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.taglets.*;
+-import com.sun.javadoc.*;
+ 
+ /**
+  * Generate serialized form for Serializable/Externalizable methods.
+@@ -66,14 +66,12 @@
+         writeSignature(member);
+     }
+ 
+-    public void writeMemberFooter(MethodDoc member) {
+-        writer.dlEnd();
++    public void writeMemberFooter() {
++        printMemberFooter();
+     }
+ 
+     public void writeDeprecatedMemberInfo(MethodDoc member) {
+-        print(((TagletOutputImpl)
+-            (new DeprecatedTaglet()).getTagletOutput(member,
+-            writer.getTagletWriterInstance(false))).toString());
++        printDeprecated(member);
+     }
+ 
+     public void writeMemberDescription(MethodDoc member) {
+@@ -81,23 +79,27 @@
+     }
+ 
+     public void writeMemberTags(MethodDoc member) {
+-        writer.dd();
+-        writer.dl();
+         TagletOutputImpl output = new TagletOutputImpl("");
+         TagletManager tagletManager =
+             ConfigurationImpl.getInstance().tagletManager;
+         TagletWriter.genTagOuput(tagletManager, member,
+             tagletManager.getSerializedFormTags(),
+             writer.getTagletWriterInstance(false), output);
+-        print(output.toString());
++        String outputString = output.toString().trim();
++        if (!outputString.isEmpty()) {
++            writer.printMemberDetailsListStartTag();
++            writer.dd();
++            writer.dl();
++            print(outputString);
++            writer.dlEnd();
++            writer.ddEnd();
++        }
+         MethodDoc method = (MethodDoc)member;
+         if (method.name().compareTo("writeExternal") == 0
+                 && method.tags("serialData").length == 0) {
+             serialWarning(member.position(), "doclet.MissingSerialDataTag",
+                 method.containingClass().qualifiedName(), method.name());
+         }
+-        writer.ddEnd();
+-        writer.dlEnd();
+     }
+ 
+     protected void printTypeLinkNoDimension(Type type) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+@@ -25,13 +25,13 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ 
+-import java.io.*;
+-import com.sun.javadoc.*;
+-
+ /**
+  * Writes method documentation in HTML format.
+  *
+@@ -172,7 +172,7 @@
+         writeParameters(method);
+         writeExceptions(method);
+         writer.preEnd();
+-        writer.dl();
++        assert !writer.getMemberDetailsListPrinted();
+     }
+ 
+     /**
+@@ -181,12 +181,7 @@
+      * @param method the method being documented.
+      */
+     public void writeDeprecated(MethodDoc method) {
+-        String output = ((TagletOutputImpl)
+-            (new DeprecatedTaglet()).getTagletOutput(method,
+-            writer.getTagletWriterInstance(false))).toString();
+-        if (output != null && output.trim().length() > 0) {
+-            writer.print(output);
+-        }
++        printDeprecated(method);
+     }
+ 
+     /**
+@@ -197,11 +192,13 @@
+     public void writeComments(Type holder, MethodDoc method) {
+         ClassDoc holderClassDoc = holder.asClassDoc();
+         if (method.inlineTags().length > 0) {
++            writer.printMemberDetailsListStartTag();
+             if (holder.asClassDoc().equals(classdoc) ||
+                 (! (holderClassDoc.isPublic() ||
+                     Util.isLinkable(holderClassDoc, configuration())))) {
+                 writer.dd();
+                 writer.printInlineComment(method);
++                writer.ddEnd();
+             } else {
+                 String classlink = writer.codeText(
+                     writer.getDocLink(LinkInfoImpl.CONTEXT_METHOD_DOC_COPY,
+@@ -217,6 +214,7 @@
+                 writer.ddEnd();
+                 writer.dd();
+                 writer.printInlineComment(method);
++                writer.ddEnd();
+             }
+         }
+     }
+@@ -234,8 +232,7 @@
+      * Write the method footer.
+      */
+     public void writeMethodFooter() {
+-        writer.ddEnd();
+-        writer.dlEnd();
++        printMemberFooter();
+     }
+ 
+     /**
+@@ -318,6 +315,7 @@
+             String name = method.name();
+             writer.dt();
+             writer.strongText(label);
++            writer.dtEnd();
+             writer.dd();
+             String methLink = writer.codeText(
+                 writer.getLink(
+@@ -326,6 +324,7 @@
+                         writer.getAnchor(method), name, false)
+                 ));
+             writer.printText("doclet.in_class", methLink, overriddenTypeLink);
++            writer.ddEnd();
+         }
+     }
+ 
+@@ -364,11 +363,13 @@
+                     LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac)));
+             writer.dt();
+             writer.strongText("doclet.Specified_By");
++            writer.dtEnd();
+             writer.dd();
+             methlink = writer.codeText(writer.getDocLink(
+                 LinkInfoImpl.CONTEXT_MEMBER, implementedMeth,
+                 implementedMeth.name(), false));
+             writer.printText("doclet.in_interface", methlink, intfaclink);
++            writer.ddEnd();
+         }
+ 
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+@@ -25,11 +25,11 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+-
+-import java.io.*;
+ 
+ /**
+  * Writes nested class documentation in HTML format.
+@@ -129,7 +129,6 @@
+             writer.println("");
+         }
+         writer.anchor(nestedClass.name());
+-        writer.dl();
+         writer.h3();
+         writer.print(nestedClass.name());
+         writer.h3End();
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
+@@ -25,9 +25,10 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+-import java.io.*;
+ 
+ /**
+  * Class to generate Tree page for a package. The name of the file generated is
+@@ -145,8 +146,10 @@
+         dl();
+         dt();
+         strongText("doclet.Package_Hierarchies");
++        dtEnd();
+         dd();
+         navLinkMainTree(configuration.getText("doclet.All_Packages"));
++        ddEnd();
+         dlEnd();
+         hr();
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
+@@ -25,17 +25,18 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder;
+ import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+ 
+ /**
+  * The taglet writer that writes HTML.
+  *
+  * @since 1.5
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  */
+ 
+ public class TagletWriterImpl extends TagletWriter {
+@@ -99,11 +100,12 @@
+                     output.append(DocletConstants.NL + "<P>" +
+                         DocletConstants.NL);
+                 }
++                output.append("</DD>");
+             } else {
+                 if (Util.isDeprecated(member.containingClass())) {
+                     output.append("<DD><STRONG>" +
+                     ConfigurationImpl.getInstance().
+-                            getText("doclet.Deprecated") + "</STRONG>&nbsp;");
++                            getText("doclet.Deprecated") + "</STRONG>&nbsp;</DD>");
+                 }
+             }
+         }
+@@ -123,7 +125,7 @@
+     public TagletOutput getParamHeader(String header) {
+         StringBuffer result = new StringBuffer();
+         result.append("<DT>");
+-        result.append("<STRONG>" +  header + "</STRONG>");
++        result.append("<STRONG>" +  header + "</STRONG></DT>");
+         return new TagletOutputImpl(result.toString());
+     }
+ 
+@@ -132,7 +134,7 @@
+      */
+     public TagletOutput paramTagOutput(ParamTag paramTag, String paramName) {
+         TagletOutput result = new TagletOutputImpl("<DD><CODE>" + paramName + "</CODE>"
+-         + " - " + htmlWriter.commentTagsToString(paramTag, null, paramTag.inlineTags(), false));
++         + " - " + htmlWriter.commentTagsToString(paramTag, null, paramTag.inlineTags(), false) + "</DD>");
+         return result;
+     }
+ 
+@@ -142,9 +144,9 @@
+     public TagletOutput returnTagOutput(Tag returnTag) {
+         TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "<DT>" +
+             "<STRONG>" + htmlWriter.configuration.getText("doclet.Returns") +
+-            "</STRONG>" + "<DD>" +
++            "</STRONG>" + "</DT>" + "<DD>" +
+             htmlWriter.commentTagsToString(returnTag, null, returnTag.inlineTags(),
+-            false));
++            false) + "</DD>");
+         return result;
+     }
+ 
+@@ -174,22 +176,21 @@
+         }
+         if (holder.isClass() && ((ClassDoc)holder).isSerializable()) {
+             //Automatically add link to serialized form page for serializable classes.
+-            if (!(SerializedFormBuilder.serialInclude(holder) &&
++            if ((SerializedFormBuilder.serialInclude(holder) &&
+                       SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) {
+-                return result.equals("") ? null : new TagletOutputImpl(result);
++                result = addSeeHeader(result);
++                result += htmlWriter.getHyperLink(htmlWriter.relativePath + "serialized-form.html",
++                        ((ClassDoc)holder).qualifiedName(), htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
+             }
+-            result = addSeeHeader(result);
+-            result += htmlWriter.getHyperLink(htmlWriter.relativePath + "serialized-form.html",
+-                ((ClassDoc)holder).qualifiedName(), htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
+         }
+-        return result.equals("") ? null : new TagletOutputImpl(result);
++        return result.equals("") ? null : new TagletOutputImpl(result + "</DD>");
+     }
+ 
+     private String addSeeHeader(String result) {
+         if (result != null && result.length() > 0) {
+             return result + ", " + DocletConstants.NL;
+         } else {
+-            return "<DT><STRONG>" + htmlWriter.configuration().getText("doclet.See_Also") + "</STRONG><DD>";
++            return "<DT><STRONG>" + htmlWriter.configuration().getText("doclet.See_Also") + "</STRONG></DT><DD>";
+         }
+      }
+ 
+@@ -205,7 +206,8 @@
+             }
+             result += htmlWriter.commentTagsToString(simpleTags[i], null, simpleTags[i].inlineTags(), false);
+         }
+-         return new TagletOutputImpl(result + "</DD>" + DocletConstants.NL);
++        result += "</DD>" + DocletConstants.NL;
++        return new TagletOutputImpl(result);
+     }
+ 
+     /**
+@@ -222,7 +224,7 @@
+      */
+     public TagletOutput getThrowsHeader() {
+         return new TagletOutputImpl(DocletConstants.NL + "<DT>" + "<STRONG>" +
+-            htmlWriter.configuration().getText("doclet.Throws") + "</STRONG>");
++            htmlWriter.configuration().getText("doclet.Throws") + "</STRONG></DT>");
+     }
+ 
+     /**
+@@ -241,6 +243,7 @@
+         if (text != null && text.toString().length() > 0) {
+             result += " - " + text;
+         }
++        result += "</DD>";
+         return new TagletOutputImpl(result);
+     }
+ 
+@@ -250,7 +253,7 @@
+     public TagletOutput throwsTagOutput(Type throwsType) {
+         return new TagletOutputImpl(DocletConstants.NL + "<DD>" +
+             htmlWriter.codeText(htmlWriter.getLink(
+-                new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, throwsType))));
++                new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "</DD>");
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
+@@ -25,9 +25,11 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+-import java.io.*;
++
+ /**
+  * Generate Class Hierarchy page for all the Classes in this run.  Use
+  * ClassTree for building the Tree. The name of
+@@ -120,6 +122,7 @@
+             dl();
+             dt();
+             strongText("doclet.Package_Hierarchies");
++            dtEnd();
+             dd();
+             for (int i = 0; i < packages.length; i++) {
+                 if (packages[i].name().length() == 0) {
+@@ -131,6 +134,7 @@
+                     print(", ");
+                 }
+             }
++            ddEnd();
+             dlEnd();
+             hr();
+         }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
+@@ -245,6 +245,31 @@
+     }
+ 
+     /**
++     * Keep track of member details list. Print the definition list start tag
++     * if it is not printed yet.
++     */
++    public void printMemberDetailsListStartTag () {
++        if (!getMemberDetailsListPrinted()) {
++            dl();
++            memberDetailsListPrinted = true;
++        }
++    }
++
++    /**
++     * Print the definition list end tag if the list start tag was printed.
++     */
++    public void printMemberDetailsListEndTag () {
++        if (getMemberDetailsListPrinted()) {
++            dlEnd();
++            memberDetailsListPrinted = false;
++        }
++    }
++
++    public boolean getMemberDetailsListPrinted() {
++        return memberDetailsListPrinted;
++    }
++
++    /**
+      * Print the frameset version of the Html file header.
+      * Called only when generating an HTML frameset file.
+      *
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+@@ -25,9 +25,10 @@
+ 
+ package com.sun.tools.doclets.formats.html.markup;
+ 
++import java.io.*;
++
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import java.io.*;
+ 
+ /**
+  * Class for the Html format code generation.
+@@ -61,6 +62,11 @@
+     protected Configuration configuration;
+ 
+     /**
++     * The flag to indicate whether a member details list is printed or not.
++     */
++    protected boolean memberDetailsListPrinted;
++
++    /**
+      * Constructor.
+      *
+      * @param path The directory path to be created for this file
+@@ -79,6 +85,7 @@
+         super(Util.genWriter(configuration, path, filename, docencoding));
+         this.configuration = configuration;
+         htmlFilename = filename;
++        this.memberDetailsListPrinted = false;
+     }
+ 
+     /**
+@@ -529,7 +536,14 @@
+     }
+ 
+     /**
+-     * Print &lt;DT&gt; tag.
++     * Print &lt;/DT&gt; tag.
++     */
++    public void dtEnd() {
++        print("</DT>");
++    }
++
++    /**
++     * Print &lt;DD&gt; tag.
+      */
+     public void dd() {
+         print("<DD>");
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
+@@ -25,8 +25,9 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit;
+ 
++import java.io.*;
++
+ import com.sun.javadoc.*;
+-import java.io.*;
+ 
+ /**
+  * The interface for writing serialized form output.
+@@ -147,22 +148,27 @@
+             String fieldDimensions, String fieldName);
+ 
+         /**
++         * Write the member footer.
++         */
++        public void writeMemberFooter();
++
++        /**
++         * Check to see if overview details should be printed. If
++         * nocomment option set or if there is no text to be printed
++         * for deprecation info, inline comment or tags,
++         * do not print overview details.
++         *
++         * @param field the field to check overview details for.
++         * @return true if overview details need to be printed
++         */
++        public boolean shouldPrintOverview(FieldDoc field);
++
++        /**
+          * Write the footer.
+          *
+-         * @param member the member to write the header for.
++         * @param heading the heading that was written.
+          */
+-        public void writeMemberFooter(FieldDoc member);
+-
+-        /**
+-         * Check to see if member details should be printed. If
+-         * nocomment option set or if there is no text to be printed
+-         * for deprecation info, inline comment, no serial tag or inline tags,
+-         * do not print member details.
+-         *
+-         * @param member the member to check details for.
+-         * @return true if details need to be printed
+-         */
+-        public boolean shouldPrintMemberDetails(FieldDoc member);
++        public void writeFooter (String heading);
+     }
+ 
+     /**
+@@ -193,10 +199,8 @@
+ 
+         /**
+          * Write the footer.
+-         *
+-         * @param member the member to write the header for.
+          */
+-        public void writeMemberFooter(MethodDoc member);
++        public void writeMemberFooter();
+ 
+         /**
+          * Write the deprecated information for this member.
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+@@ -25,13 +25,14 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
+-import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.tools.doclets.internal.toolkit.*;
+-import com.sun.javadoc.*;
+ import java.io.*;
+ import java.lang.reflect.*;
+ import java.util.*;
+ 
++import com.sun.javadoc.*;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.internal.toolkit.*;
++
+ /**
+  * Builds the serialized form.
+  *
+@@ -40,6 +41,7 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class SerializedFormBuilder extends AbstractBuilder {
+@@ -379,7 +381,7 @@
+      * Build the method footer.
+      */
+     public void buildMethodFooter() {
+-        methodWriter.writeMemberFooter((MethodDoc) currentMember);
++        methodWriter.writeMemberFooter();
+     }
+ 
+     /**
+@@ -407,13 +409,17 @@
+             // information to be printed.
+             if (fieldWriter.shouldPrintMemberDetails(serialPersistentField)) {
+                 fieldWriter.writeHeader(
+-                    configuration.getText("doclet.Serialized_Form_class"));
++                        configuration.getText("doclet.Serialized_Form_class"));
+                 fieldWriter.writeMemberDeprecatedInfo(serialPersistentField);
+                 if (!configuration.nocomment) {
+                     fieldWriter.writeMemberDescription(serialPersistentField);
+                     fieldWriter.writeMemberTags(serialPersistentField);
+                 }
+                 fieldWriter.writeMemberFooter(serialPersistentField);
++                // Footer required to close the definition list tag
++                // for serialization overview.
++                fieldWriter.writeFooter(
++                        configuration.getText("doclet.Serialized_Form_class"));
+             }
+         }
+     }
+@@ -476,11 +482,11 @@
+     }
+ 
+     /**
+-     * Build the field footer.
++     * Build the field sub footer.
+      */
+-    public void buildFieldFooter() {
++    public void buildFieldSubFooter() {
+         if (! currentClass.definesSerializableFields()) {
+-            fieldWriter.writeMemberFooter((FieldDoc) currentMember);
++            fieldWriter.writeMemberFooter();
+         }
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
+@@ -26,180 +26,180 @@
+ -->
+ 
+ 
+-<Doclet>
+-
+-    <PackageDoc>
+-        <PackageHeader/>
+-        <Summary>
+-            <SummaryHeader/>
+-            <InterfaceSummary/>
+-            <ClassSummary/>
+-            <EnumSummary/>
+-            <ExceptionSummary/>
+-            <ErrorSummary/>
+-            <AnnotationTypeSummary/>
+-            <SummaryFooter/>
+-        </Summary>
+-        <PackageDescription/>
+-        <PackageTags/>
+-        <PackageFooter/>
+-    </PackageDoc>
+-    
+-    <AnnotationTypeDoc>
+-        <AnnotationTypeHeader/>
+-        <DeprecationInfo/>
+-        <AnnotationTypeSignature/>
+-        <AnnotationTypeDescription/>
+-        <AnnotationTypeTagInfo/>
+-        <MemberSummary>
+-        	<AnnotationTypeRequiredMemberSummary/>
+-            <AnnotationTypeOptionalMemberSummary/>
+-        </MemberSummary>
+-        <AnnotationTypeRequiredMemberDetails>
+-            <Header/>
+-            <AnnotationTypeRequiredMember>
+-                <MemberHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <MemberComments/>
+-                <TagInfo/>
+-                <MemberFooter/>
+-            </AnnotationTypeRequiredMember>
+-        </AnnotationTypeRequiredMemberDetails>
+-        <AnnotationTypeOptionalMemberDetails>
+-            <AnnotationTypeOptionalMember>
+-                <MemberHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <MemberComments/>
+-                <TagInfo/>
+-                <DefaultValueInfo/>
+-                <MemberFooter/>
+-            </AnnotationTypeOptionalMember>
+-            <Footer/>
+-        </AnnotationTypeOptionalMemberDetails>        
+-        <AnnotationTypeFooter/>
+-    </AnnotationTypeDoc>
+-    
+-    <ClassDoc>
+-        <ClassHeader/>
+-        <ClassTree/>
+-        <TypeParamInfo/>
+-        <SuperInterfacesInfo/>
+-        <ImplementedInterfacesInfo/>        
+-        <SubClassInfo/>
+-        <SubInterfacesInfo/>
+-        <InterfaceUsageInfo/>
+-        <NestedClassInfo/>
+-        <DeprecationInfo/>
+-        <ClassSignature/>
+-        <ClassDescription/>
+-        <ClassTagInfo/>
+-        <MemberSummary>
+-            <NestedClassesSummary/>
+-            <NestedClassesInheritedSummary/>
+-            <EnumConstantsSummary/>
+-            <FieldsSummary/>
+-            <FieldsInheritedSummary/>  
+-            <ConstructorsSummary/>
+-            <MethodsSummary/>
+-            <MethodsInheritedSummary/>
+-        </MemberSummary>
+-        <EnumConstantsDetails>
+-            <Header/>
+-            <EnumConstant>
+-                <EnumConstantHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <EnumConstantComments/>
+-                <TagInfo/>
+-                <EnumConstantFooter/>
+-            </EnumConstant>
+-            <Footer/>
+-        </EnumConstantsDetails>
+-        <FieldDetails>
+-            <Header/>
+-            <FieldDoc>
+-                <FieldHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <FieldComments/>
+-                <TagInfo/>
+-                <FieldFooter/>
+-            </FieldDoc>
+-            <Footer/>
+-        </FieldDetails>
+-        <ConstructorDetails>
+-            <Header/>
+-            <ConstructorDoc>
+-                <ConstructorHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <ConstructorComments/>
+-                <TagInfo/>
+-                <ConstructorFooter/>
+-            </ConstructorDoc>
+-            <Footer/>
+-        </ConstructorDetails>
+-        <MethodDetails>
+-            <Header/>
+-            <MethodDoc>
+-                <MethodHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <MethodComments/>
+-                <TagInfo/>
+-                <MethodFooter/>
+-            </MethodDoc>
+-            <Footer/>
+-        </MethodDetails>
+-        <ClassFooter/>
+-    </ClassDoc>
+-    
+-    <ConstantSummary>
+-        <Header/>
+-        <Contents/>
+-        <ConstantSummaries>
+-            <PackageConstantSummary>
+-                <PackageHeader/>
+-                <ClassConstantSummary>
+-                    <ClassHeader/>
+-                    <ConstantMembers/>
+-                    <ClassFooter/>
+-                </ClassConstantSummary>     
+-            </PackageConstantSummary>
+-        </ConstantSummaries>    
+-        <Footer/>
+-    </ConstantSummary>
+-    
+-    <SerializedForm>
+-        <Header/>
+-        <SerializedFormSummaries>
+-            <PackageSerializedForm>
+-                <PackageHeader/>
+-                <ClassSerializedForm>
+-                    <ClassHeader/>
+-                    <SerialUIDInfo/>
+-                    <MethodHeader/>
+-                    <SerializableMethods>
+-                        <MethodSubHeader/>
+-                        <DeprecatedMethodInfo/>
+-                        <MethodInfo>
+-                            <MethodDescription/>
+-                            <MethodTags/>
+-                        </MethodInfo>
+-                        <MethodFooter/>
+-                    </SerializableMethods>
+-                    <FieldHeader/>
+-                    <SerializableFields>
+-                        <FieldSubHeader/>
+-                        <FieldDeprecationInfo/>
+-                        <FieldInfo/>
+-                        <FieldFooter/>
+-                    </SerializableFields>                  
+-                </ClassSerializedForm>
+-            </PackageSerializedForm>
+-        </SerializedFormSummaries>
+-        <Footer/>
+-    </SerializedForm>
+-</Doclet>
++<Doclet>
++
++    <PackageDoc>
++        <PackageHeader/>
++        <Summary>
++            <SummaryHeader/>
++            <InterfaceSummary/>
++            <ClassSummary/>
++            <EnumSummary/>
++            <ExceptionSummary/>
++            <ErrorSummary/>
++            <AnnotationTypeSummary/>
++            <SummaryFooter/>
++        </Summary>
++        <PackageDescription/>
++        <PackageTags/>
++        <PackageFooter/>
++    </PackageDoc>
++    
++    <AnnotationTypeDoc>
++        <AnnotationTypeHeader/>
++        <DeprecationInfo/>
++        <AnnotationTypeSignature/>
++        <AnnotationTypeDescription/>
++        <AnnotationTypeTagInfo/>
++        <MemberSummary>
++        	<AnnotationTypeRequiredMemberSummary/>
++            <AnnotationTypeOptionalMemberSummary/>
++        </MemberSummary>
++        <AnnotationTypeRequiredMemberDetails>
++            <Header/>
++           <AnnotationTypeRequiredMember>
++                <MemberHeader/>
++                <Signature/>
++                <DeprecationInfo/>
++                <MemberComments/>
++                <TagInfo/>
++                <MemberFooter/>
++            </AnnotationTypeRequiredMember>
++        </AnnotationTypeRequiredMemberDetails>
++        <AnnotationTypeOptionalMemberDetails>
++            <AnnotationTypeOptionalMember>
++                <MemberHeader/>
++                <Signature/>
++                <DeprecationInfo/>
++                <MemberComments/>
++                <TagInfo/>
++                <DefaultValueInfo/>
++                <MemberFooter/>
++            </AnnotationTypeOptionalMember>
++            <Footer/>
++        </AnnotationTypeOptionalMemberDetails>        
++        <AnnotationTypeFooter/>
++    </AnnotationTypeDoc>
++    
++    <ClassDoc>
++        <ClassHeader/>
++        <ClassTree/>
++        <TypeParamInfo/>
++        <SuperInterfacesInfo/>
++        <ImplementedInterfacesInfo/>        
++        <SubClassInfo/>
++        <SubInterfacesInfo/>
++        <InterfaceUsageInfo/>
++        <NestedClassInfo/>
++        <DeprecationInfo/>
++        <ClassSignature/>
++        <ClassDescription/>
++        <ClassTagInfo/>
++        <MemberSummary>
++            <NestedClassesSummary/>
++            <NestedClassesInheritedSummary/>
++            <EnumConstantsSummary/>
++            <FieldsSummary/>
++            <FieldsInheritedSummary/>  
++            <ConstructorsSummary/>
++            <MethodsSummary/>
++            <MethodsInheritedSummary/>
++        </MemberSummary>
++        <EnumConstantsDetails>
++           <Header/>
++            <EnumConstant>
++                <EnumConstantHeader/>
++                <Signature/>
++                <DeprecationInfo/>
++                <EnumConstantComments/>
++                <TagInfo/>
++                <EnumConstantFooter/>
++            </EnumConstant>
++            <Footer/>
++        </EnumConstantsDetails>
++        <FieldDetails>
++            <Header/>
++            <FieldDoc>
++                <FieldHeader/>
++                <Signature/>
++                <DeprecationInfo/>
++                <FieldComments/>
++                <TagInfo/>
++                <FieldFooter/>
++            </FieldDoc>
++            <Footer/>
++        </FieldDetails>
++        <ConstructorDetails>
++            <Header/>
++            <ConstructorDoc>
++                <ConstructorHeader/>
++                <Signature/>
++                <DeprecationInfo/>
++                <ConstructorComments/>
++                <TagInfo/>
++                <ConstructorFooter/>
++            </ConstructorDoc>
++            <Footer/>
++        </ConstructorDetails>
++        <MethodDetails>
++            <Header/>
++            <MethodDoc>
++                <MethodHeader/>
++                <Signature/>
++                <DeprecationInfo/>
++                <MethodComments/>
++                <TagInfo/>
++                <MethodFooter/>
++            </MethodDoc>
++            <Footer/>
++        </MethodDetails>
++        <ClassFooter/>
++    </ClassDoc>
++    
++    <ConstantSummary>
++        <Header/>
++        <Contents/>
++        <ConstantSummaries>
++            <PackageConstantSummary>
++                <PackageHeader/>
++                <ClassConstantSummary>
++                    <ClassHeader/>
++                    <ConstantMembers/>
++                    <ClassFooter/>
++                </ClassConstantSummary>     
++            </PackageConstantSummary>
++        </ConstantSummaries>    
++        <Footer/>
++    </ConstantSummary>
++    
++    <SerializedForm>
++        <Header/>
++        <SerializedFormSummaries>
++            <PackageSerializedForm>
++                <PackageHeader/>
++                <ClassSerializedForm>
++                    <ClassHeader/>
++                    <SerialUIDInfo/>
++                    <MethodHeader/>
++                    <SerializableMethods>
++                        <MethodSubHeader/>
++                        <DeprecatedMethodInfo/>
++                        <MethodInfo>
++                            <MethodDescription/>
++                            <MethodTags/>
++                        </MethodInfo>
++                        <MethodFooter/>
++                    </SerializableMethods>
++                    <FieldHeader/>
++                    <SerializableFields>
++                        <FieldSubHeader/>
++                        <FieldDeprecationInfo/>
++                        <FieldInfo/>
++                        <FieldSubFooter/>
++                    </SerializableFields>
++                </ClassSerializedForm>
++            </PackageSerializedForm>
++        </SerializedFormSummaries>
++        <Footer/>
++    </SerializedForm>
++</Doclet>
+diff --git a/test/com/sun/javadoc/AuthorDD/AuthorDD.java b/test/com/sun/javadoc/AuthorDD/AuthorDD.java
+--- openjdk/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java
++++ openjdk/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java
+@@ -91,7 +91,7 @@
+ 
+             // Test multiple @author tags:
+ 
+-            { "<DT><STRONG>Author:</STRONG></DT>"+NL+"  <DD>Doug Kramer, Jamie, Neal</DD>"+NL,
++            { "<DT><STRONG>Author:</STRONG></DT>"+NL+"  <DD>Doug Kramer, Jamie, Neal</DD>",
+                                   BUGID + FS + "p1" + FS + "C1.html" },
+ 
+         };
+diff --git a/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java b/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
+--- openjdk/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
++++ openjdk/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
+@@ -48,7 +48,7 @@
+             "<A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/math/BigInteger.html?is-external=true#gcd(java.math.BigInteger)\" " +
+                 "title=\"class or interface in java.math\"><CODE>Link to external member gcd</CODE></A>"},
+         {BUG_ID + FS + "C.html",
+-            "<STRONG>Overrides:</STRONG><DD><CODE>toString</CODE> in class <CODE>java.lang.Object</CODE>"}
++            "<STRONG>Overrides:</STRONG></DT><DD><CODE>toString</CODE> in class <CODE>java.lang.Object</CODE>"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java b/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
+--- openjdk/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
++++ openjdk/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
+@@ -45,9 +45,10 @@
+ 
+     //Input for string search tests.
+     private static final String[][] TEST = {
+-        {BUG_ID + FS + "C.html", "<DL>"+NL+"<DD>This is just a simple constructor."+ NL +
+-            "<P>"+NL+"<DL>"+NL+"<DT><STRONG>Parameters:</STRONG><DD><CODE>i</CODE> - a param.</DL>"+NL +
+-            "</DL>"
++        {BUG_ID + FS + "C.html", "<DL>" + NL + "<DD>This is just a simple constructor." + NL +
++            "<P>" + NL + "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Parameters:</STRONG>" +
++            "</DT><DD><CODE>i</CODE> - a param.</DD></DL>" + NL +
++            "</DD>" + NL + "</DL>"
+         }
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java b/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
+--- openjdk/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
++++ openjdk/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
+@@ -78,13 +78,12 @@
+ 
+         {TARGET_FILE2, "<STRONG>Deprecated.</STRONG>" + NL +
+                 "<P>" + NL +
+-            "<DL>" + NL +
+-            "<DT><PRE><FONT SIZE=\"-1\">@Deprecated" + NL +
++            "<PRE><FONT SIZE=\"-1\">@Deprecated" + NL +
+             "</FONT>public class <STRONG>DeprecatedClassByAnnotation</STRONG>"},
+ 
+         {TARGET_FILE2, "public int <STRONG>field</STRONG></PRE>" + NL +
+             "<DL>" + NL +
+-            "<DD><STRONG>Deprecated.</STRONG>&nbsp;<DL>"},
++            "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD></DL>"},
+ 
+         {TARGET_FILE2, "<FONT SIZE=\"-1\">@Deprecated" + NL +
+             "</FONT>public <STRONG>DeprecatedClassByAnnotation</STRONG>()</PRE>" + NL +
+diff --git a/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java b/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
+--- openjdk/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
++++ openjdk/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
+@@ -39,13 +39,13 @@
+     private static final String BUG_ID = "4857717";
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "XReader.html",
+-            "<STRONG>Overrides:</STRONG><DD><CODE><A HREF=\"" +
++            "<STRONG>Overrides:</STRONG></DT><DD><CODE><A HREF=\"" +
+             "http://java.sun.com/j2se/1.4.1/docs/api/java/io/FilterReader.html?is-external=true#read()\"" +
+                 " title=\"class or interface in java.io\">read</A></CODE> in class " +
+                 "<CODE><A HREF=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/FilterReader.html?is-external=true\"" +
+                 " title=\"class or interface in java.io\">FilterReader</A>"},
+         {BUG_ID + FS + "pkg" + FS + "XReader.html",
+-            "<STRONG>Specified by:</STRONG><DD><CODE><A HREF=\"" +
++            "<STRONG>Specified by:</STRONG></DT><DD><CODE><A HREF=\"" +
+             "http://java.sun.com/j2se/1.4.1/docs/api/java/io/DataInput.html?is-external=true#readInt()\"" +
+             " title=\"class or interface in java.io\">readInt</A></CODE> in interface " +
+             "<CODE><A HREF=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/DataInput.html?is-external=true\"" +
+diff --git a/test/com/sun/javadoc/testHref/TestHref.java b/test/com/sun/javadoc/testHref/TestHref.java
+--- openjdk/langtools/test/com/sun/javadoc/testHref/TestHref.java
++++ openjdk/langtools/test/com/sun/javadoc/testHref/TestHref.java
+@@ -67,7 +67,7 @@
+         },
+         //@see test.
+         {BUG_ID + FS + "pkg" + FS + "C2.html",
+-            "See Also:</STRONG><DD><A HREF=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
++            "See Also:</STRONG></DT><DD><A HREF=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
+         },
+ 
+         //Header does not link to the page itself.
+diff --git a/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java b/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
+@@ -0,0 +1,370 @@
++/*
++ * 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.  Sun designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Sun in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/*
++ * @test
++ * @bug 6786690
++ * @summary This test verifies the nesting of definition list tags.
++ * @author Bhavesh Patel
++ * @library ../lib/
++ * @build JavadocTester
++ * @build TestHtmlDefinitionListTag
++ * @run main TestHtmlDefinitionListTag
++ */
++
++public class TestHtmlDefinitionListTag extends JavadocTester {
++
++    private static final String BUG_ID = "6786690";
++
++    // Test common to all runs of javadoc. The class signature should print
++    // properly enclosed definition list tags and the Annotation Type
++    // Optional Element should print properly nested definition list tags
++    // for default value.
++    private static final String[][] TEST_ALL = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<PRE>public class " +
++                 "<STRONG>C1</STRONG>" + NL + "extends " +
++                 "java.lang.Object" + NL + "implements " +
++                 "java.io.Serializable</PRE>"},
++        {BUG_ID + FS + "pkg1" + FS + "C4.html", "<DL>" + NL + "<DD><DL>" + NL +
++                 "<DT><STRONG>Default:</STRONG></DT><DD>true</DD>" + NL +
++                 "</DL>" + NL + "</DD>" + NL + "</DL>"}};
++
++    // Test for normal run of javadoc in which various ClassDocs and
++    // serialized form should have properly nested definition list tags
++    // enclosing comments, tags and deprecated information.
++    private static final String[][] TEST_CMNT_DEPR = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
++                 "<DT><STRONG>Since:</STRONG></DT>" + NL +
++                 "  <DD>JDK1.0</DD>" + NL + "<DT><STRONG>See Also:</STRONG></DT><DD>" +
++                 "<A HREF=\"../pkg1/C2.html\" title=\"class in pkg1\">" +
++                 "<CODE>C2</CODE></A>, " + NL +
++                 "<A HREF=\"../serialized-form.html#pkg1.C1\">" +
++                 "Serialized Form</A></DD></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++                 " 1.5, replaced by" + NL +
++                 " <A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I></DD>" +
++                 "<DD>This field indicates whether the C1 is undecorated." + NL +
++                 "<P>" + NL + "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>" +
++                 "Since:</STRONG></DT>" + NL + "  <DD>1.4</DD>" + NL + "<DT>" +
++                 "<STRONG>See Also:</STRONG></DT><DD>" +
++                 "<A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
++                 "setUndecorated(boolean)</CODE></A></DD></DL>" + NL +"</DD>" + NL +
++                 "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
++                 "<DD>Constructor." + NL + "<P>" + NL + "</DD>" + NL +
++                 "<DD><DL>" + NL + "<DT><STRONG>Parameters:</STRONG></DT><DD>" +
++                 "<CODE>title</CODE> - the title</DD><DD><CODE>test</CODE>" +
++                 " - boolean value</DD>" + NL + "<DT><STRONG>Throws:</STRONG></DT>" + NL +
++                 "<DD><CODE>java.lang.IllegalArgumentException</CODE>" +
++                 " - if the <code>owner</code>'s" + NL + "     <code>GraphicsConfiguration" +
++                 "</code> is not from a screen device</DD>" + NL +"<DD><CODE>" +
++                 "HeadlessException</CODE></DD></DL>" + NL + "</DD>" + NL +
++                 "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
++                 "<DD>Method comments." + NL + "<P>" + NL +
++                 "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Parameters:" +
++                 "</STRONG></DT><DD><CODE>undecorated</CODE> - <code>true</code>" +
++                 " if no decorations are" + NL + "         to be enabled;" + NL +
++                 "         <code>false</code> if decorations are to be enabled." +
++                 "</DD><DT><STRONG>Since:</STRONG></DT>" + NL +
++                 "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG></DT>" +
++                 "<DD><A HREF=\"../pkg1/C1.html#readObject()\"><CODE>" +
++                 "readObject()</CODE></A></DD></DL>" + NL + "</DD>" + NL +
++                 "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL + "<DD><DL>" + NL +
++                 "<DT><STRONG>Throws:</STRONG></DT>" + NL + "<DD><CODE>" +
++                 "java.io.IOException</CODE></DD><DT><STRONG>See Also:" +
++                 "</STRONG></DT><DD>" +
++                 "<A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<DL>" + NL +
++                 "<DD>No modal exclusion." + NL + "<P>" + NL +"</DD>" + NL +
++                 "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL>" + NL + "<DD>Constructor." + NL +
++                 "<P>" + NL +"</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced " +
++                 "by" + NL + " <A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
++                 "</DD><DD>Set visible." + NL + "<P>" + NL + "</DD>" +NL +
++                 "<DD><DL>" + NL + "<DT><STRONG>Parameters:</STRONG></DT><DD>" +
++                 "<CODE>set</CODE> - boolean</DD><DT><STRONG>Since:</STRONG></DT>" + NL +
++                 "  <DD>1.4</DD></DL>" + NL + "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C3.html", "<DL>" + NL + "<DD>Comment." + NL +
++                 "<P>" + NL + "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><DL>" + NL +
++                 "<DT><STRONG>Throws:</STRONG></DT>" + NL + "<DD><CODE>" +
++                 "java.io.IOException</CODE></DD><DT><STRONG>See Also:</STRONG>" +
++                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version " +
++                 "1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I></DD>" +
++                 "<DD>This field indicates whether the C1 is undecorated." + NL +
++                 "<P>" + NL + "</DD>" + NL + "<DD>&nbsp;</DD>" + NL +
++                 "<DD><DL>" + NL + "<DT><STRONG>Since:</STRONG></DT>" + NL +
++                 "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG>" +
++                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++                 " 1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
++                 "</DD><DD>Reads the object stream." + NL + "<P>" + NL +
++                 "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Throws:" +
++                 "</STRONG></DT>" + NL + "<DD><CODE><code>" +
++                 "IOException</code></CODE></DD>" + NL +
++                 "<DD><CODE>java.io.IOException</CODE></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD><DD>" +
++                 "The name for this class." + NL + "<P>" + NL + "</DD>" + NL +
++                 "<DD>&nbsp;</DD>" + NL + "</DL>"}};
++
++    // Test with -nocomment option. The ClassDocs and serialized form should
++    // have properly nested definition list tags enclosing deprecated
++    // information and should not display definition lists for comments
++    // and tags.
++    private static final String[][] TEST_NOCMNT = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced by" + NL +
++                 " <A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
++                 "setUndecorated(boolean)</CODE></A>.</I></DD></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++                 " 1.5, replaced by" + NL +
++                 " <A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
++                 "</DD></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C5.html", "<PRE>" + NL +
++                 "protected <STRONG>C5</STRONG>()</PRE>" + NL + "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C5.html", "<PRE>" + NL +
++                 "public void <STRONG>printInfo</STRONG>()</PRE>" + NL + "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD></DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "boolean <STRONG>" +
++                 "undecorated</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
++                 "setUndecorated(boolean)</CODE></A>.</I></DD></DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++                 " 1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
++                 "</DD></DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "int <STRONG>" +
++                 "publicKey</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;</DD></DL>"}};
++
++    // Test with -nodeprecated option. The ClassDocs should have properly nested
++    // definition list tags enclosing comments and tags. The ClassDocs should not
++    // display definition list for deprecated information. The serialized form
++    // should display properly nested definition list tags for comments, tags
++    // and deprecated information.
++    private static final String[][] TEST_NODEPR = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
++                 "<DT><STRONG>Since:</STRONG></DT>" + NL +
++                 "  <DD>JDK1.0</DD>" + NL + "<DT><STRONG>See Also:</STRONG></DT><DD>" +
++                 "<A HREF=\"../pkg1/C2.html\" title=\"class in pkg1\">" +
++                 "<CODE>C2</CODE></A>, " + NL +
++                 "<A HREF=\"../serialized-form.html#pkg1.C1\">" +
++                 "Serialized Form</A></DD></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
++                 "<DD>Constructor." + NL + "<P>" + NL + "</DD>" + NL +
++                 "<DD><DL>" + NL + "<DT><STRONG>Parameters:</STRONG></DT><DD>" +
++                 "<CODE>title</CODE> - the title</DD><DD><CODE>test</CODE>" +
++                 " - boolean value</DD>" + NL + "<DT><STRONG>Throws:</STRONG></DT>" + NL +
++                 "<DD><CODE>java.lang.IllegalArgumentException</CODE>" +
++                 " - if the <code>owner</code>'s" + NL + "     <code>GraphicsConfiguration" +
++                 "</code> is not from a screen device</DD>" + NL +"<DD><CODE>" +
++                 "HeadlessException</CODE></DD></DL>" + NL + "</DD>" + NL +
++                 "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
++                 "<DD>Method comments." + NL + "<P>" + NL +
++                 "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Parameters:" +
++                 "</STRONG></DT><DD><CODE>undecorated</CODE> - <code>true</code>" +
++                 " if no decorations are" + NL + "         to be enabled;" + NL +
++                 "         <code>false</code> if decorations are to be enabled." +
++                 "</DD><DT><STRONG>Since:</STRONG></DT>" + NL +
++                 "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG></DT>" +
++                 "<DD><A HREF=\"../pkg1/C1.html#readObject()\"><CODE>" +
++                 "readObject()</CODE></A></DD></DL>" + NL + "</DD>" + NL +
++                 "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL + "<DD><DL>" + NL +
++                 "<DT><STRONG>Throws:</STRONG></DT>" + NL + "<DD><CODE>" +
++                 "java.io.IOException</CODE></DD><DT><STRONG>See Also:" +
++                 "</STRONG></DT><DD>" +
++                 "<A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<DL>" + NL +
++                 "<DD>No modal exclusion." + NL + "<P>" + NL +"</DD>" + NL +
++                 "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL>" + NL + "<DD>Constructor." + NL +
++                 "<P>" + NL +"</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C3.html", "<DL>" + NL + "<DD>Comment." + NL +
++                 "<P>" + NL + "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><DL>" + NL +
++                 "<DT><STRONG>Throws:</STRONG></DT>" + NL + "<DD><CODE>" +
++                 "java.io.IOException</CODE></DD><DT><STRONG>See Also:</STRONG>" +
++                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version " +
++                 "1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I></DD>" +
++                 "<DD>This field indicates whether the C1 is undecorated." + NL +
++                 "<P>" + NL + "</DD>" + NL + "<DD>&nbsp;</DD>" + NL +
++                 "<DD><DL>" + NL + "<DT><STRONG>Since:</STRONG></DT>" + NL +
++                 "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG>" +
++                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++                 " 1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
++                 "</DD><DD>Reads the object stream." + NL + "<P>" + NL +
++                 "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Throws:" +
++                 "</STRONG></DT>" + NL + "<DD><CODE><code>" +
++                 "IOException</code></CODE></DD>" + NL +
++                 "<DD><CODE>java.io.IOException</CODE></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD><DD>" +
++                 "The name for this class." + NL + "<P>" + NL + "</DD>" + NL +
++                 "<DD>&nbsp;</DD>" + NL + "</DL>"}};
++
++    // Test with -nocomment and -nodeprecated options. The ClassDocs whould
++    // not display definition lists for any member details. The serialized
++    // form should display properly nested definition list tags for
++    // deprecated information only.
++    private static final String[][] TEST_NOCMNT_NODEPR = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<PRE>" + NL + "public void " +
++                 "<STRONG>readObject</STRONG>()" + NL + "                throws" +
++                 " java.io.IOException</PRE>" + NL + "<HR>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<PRE>" +NL + "public <STRONG>" +
++                 "C2</STRONG>()</PRE>" + NL + "<HR>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<PRE>" + NL +
++                 "public static final " +
++                 "<A HREF=\"../pkg1/C1.ModalExclusionType.html\" " +
++                 "title=\"enum in pkg1\">C1.ModalExclusionType</A> <STRONG>" +
++                 "APPLICATION_EXCLUDE</STRONG></PRE>" + NL + "<HR>"},
++        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "boolean <STRONG>" +
++                 "undecorated</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
++                 "setUndecorated(boolean)</CODE></A>.</I></DD></DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++                 " 1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
++                 "</DD></DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "int <STRONG>" +
++                 "publicKey</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;</DD></DL>"}};
++
++    // Test for valid HTML generation which should not comprise of empty
++    // definition list tags.
++    private static final String[][] NEGATED_TEST = {
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<DL></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.ModalType.html", "<DL></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.ModalType.html", "<DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C3.html", "<DL></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C3.html", "<DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C4.html", "<DL></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C4.html", "<DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C5.html", "<DL></DL>"},
++        {BUG_ID + FS + "pkg1" + FS + "C5.html", "<DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "overview-tree.html", "<DL></DL>"},
++        {BUG_ID + FS + "overview-tree.html", "<DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL></DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "</DL>"}};
++
++    private static final String[] ARGS1 =
++        new String[] {
++            "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
++
++    private static final String[] ARGS2 =
++        new String[] {
++            "-d", BUG_ID, "-nocomment", "-sourcepath", SRC_DIR, "pkg1"};
++
++    private static final String[] ARGS3 =
++        new String[] {
++            "-d", BUG_ID, "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
++
++    private static final String[] ARGS4 =
++        new String[] {
++            "-d", BUG_ID, "-nocomment", "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
++
++    /**
++     * The entry point of the test.
++     * @param args the array of command line arguments.
++     */
++    public static void main(String[] args) {
++        TestHtmlDefinitionListTag tester = new TestHtmlDefinitionListTag();
++        run(tester, ARGS1, TEST_ALL, NEGATED_TEST);
++        run(tester, ARGS1, TEST_CMNT_DEPR, NEGATED_TEST);
++        run(tester, ARGS2, TEST_ALL, NEGATED_TEST);
++        run(tester, ARGS2, TEST_NOCMNT, TEST_CMNT_DEPR);
++        run(tester, ARGS3, TEST_ALL, NEGATED_TEST);
++        run(tester, ARGS3, TEST_NODEPR, TEST_NOCMNT_NODEPR);
++        run(tester, ARGS4, TEST_ALL, NEGATED_TEST);
++        run(tester, ARGS4, TEST_NOCMNT_NODEPR, TEST_CMNT_DEPR);
++        tester.printSummary();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getBugId() {
++        return BUG_ID;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getBugName() {
++        return getClass().getName();
++    }
++}
+diff --git a/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C1.java b/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C1.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C1.java
+@@ -0,0 +1,108 @@
++/*
++ * 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.  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 pkg1;
++
++import java.io.IOException;
++import java.io.Serializable;
++
++/**
++ * A class comment for testing.
++ *
++ * @author      Bhavesh Patel
++ * @see C2
++ * @since       JDK1.0
++ */
++
++public class C1 implements Serializable {
++
++    /**
++     * This field indicates whether the C1 is undecorated.
++     *
++     * @see #setUndecorated(boolean)
++     * @since 1.4
++     * @serial
++     * @deprecated As of JDK version 1.5, replaced by
++     * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
++     */
++     @Deprecated
++    public boolean undecorated = false;
++
++    private String title;
++
++    /**
++     * This enum specifies the possible modal exclusion types.
++     *
++     * @since 1.6
++     */
++    public static enum ModalExclusionType {
++        /**
++         * No modal exclusion.
++         */
++        NO_EXCLUDE,
++        /**
++         * <code>APPLICATION_EXCLUDE</code> indicates that a top-level window
++         * won't be blocked by any application-modal dialogs. Also, it isn't
++         * blocked by document-modal dialogs from outside of its child hierarchy.
++         */
++        APPLICATION_EXCLUDE
++    };
++
++    /**
++     * Constructor.
++     *
++     * @param title the title
++     * @param test boolean value
++     * @exception IllegalArgumentException if the <code>owner</code>'s
++     *     <code>GraphicsConfiguration</code> is not from a screen device
++     * @exception HeadlessException
++     */
++     public C1(String title, boolean test) {
++
++     }
++
++     public C1(String title) {
++
++     }
++
++    /**
++     * Method comments.
++     * @param  undecorated <code>true</code> if no decorations are
++     *         to be enabled;
++     *         <code>false</code> if decorations are to be enabled.
++     * @see    #readObject()
++     * @since 1.4
++     */
++    public void setUndecorated(boolean undecorated) {
++        /* Make sure we don't run in the middle of peer creation.*/
++    }
++
++    /**
++     * @see #setUndecorated(boolean)
++     */
++    public void readObject() throws IOException {
++
++    }
++}
+diff --git a/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java b/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C2.java
+@@ -0,0 +1,86 @@
++/*
++ * 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.  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 pkg1;
++
++import java.io.ObjectInputStream;
++import java.io.IOException;
++import java.io.Serializable;
++
++/**
++ * A class comment for testing.
++ *
++ * @author      Bhavesh Patel
++ * @see C1
++ * @since       JDK1.0
++ */
++
++public class C2 implements Serializable {
++
++    /**
++     * This field indicates title.
++     */
++    String title;
++
++    public static enum ModalType {
++        NO_EXCLUDE
++    };
++
++    /**
++     * Constructor.
++     *
++     */
++     public C2() {
++
++     }
++
++     public C2(String title) {
++
++     }
++
++     /**
++     * Set visible.
++     *
++     * @param set boolean
++     * @since 1.4
++     * @deprecated As of JDK version 1.5, replaced by
++     * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
++     */
++     @Deprecated
++     public void setVisible(boolean set) {
++     }
++
++     /**
++     * Reads the object stream.
++     *
++     * @param s ObjectInputStream
++     * @throws <code>IOException</code>
++     * @deprecated As of JDK version 1.5, replaced by
++     * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
++     */
++     @Deprecated
++     public void readObject(ObjectInputStream s) throws IOException {
++     }
++}
+diff --git a/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C3.java b/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C3.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C3.java
+@@ -0,0 +1,42 @@
++/*
++ * 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.  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 pkg1;
++
++import java.lang.annotation.*;
++
++/**
++ * Test Annotation class.
++ *
++ * @author Bhavesh Patel
++ * @since 1.5
++ */
++@Retention(RetentionPolicy.SOURCE)
++public @interface C3 {
++    /**
++     * Comment.
++     */
++    String[] value();
++}
+diff --git a/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C4.java b/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C4.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C4.java
+@@ -0,0 +1,39 @@
++/*
++ * 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.  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 pkg1;
++
++import java.lang.annotation.*;
++
++/*
++ * The @Inherited annotation has no effect when applied to an interface.
++ */
++@Documented
++@Retention(RetentionPolicy.RUNTIME)
++@Target(ElementType.TYPE)
++@Inherited
++public @interface C4 {
++    boolean value() default true;
++}
+diff --git a/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C5.java b/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C5.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/pkg1/C5.java
+@@ -0,0 +1,65 @@
++/*
++ * 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.  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 pkg1;
++
++import java.io.Serializable;
++
++/**
++ * Test for Serializable
++ *
++ * @author Bhavesh Patel
++ * @deprecated This class is no longer used.
++ */
++@Deprecated
++public abstract class C5 implements Serializable {
++
++    /**
++     * The name for this class.
++     *
++     * @serial
++     */
++    private String name;
++
++    /**
++     * @serial
++     */
++    private int publicKey;
++
++    /**
++     * Constructor for serialization only.
++     */
++    protected C5() {
++
++    }
++
++    /**
++     * Prints general information.
++     *
++     */
++    public void printInfo() {
++
++    }
++}
+diff --git a/test/com/sun/javadoc/testIndex/TestIndex.java b/test/com/sun/javadoc/testIndex/TestIndex.java
+--- openjdk/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
++++ openjdk/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
+@@ -73,10 +73,10 @@
+         {BUG_ID + FS + "index-all.html",
+             "<DT><A HREF=\"./pkg/C.html#Java\"><STRONG>Java</STRONG></A> - " + NL +
+             "Static variable in class pkg.<A HREF=\"./pkg/C.html\" title=\"class in pkg\">C</A>" + NL +
+-            "<DD>&nbsp;" + NL +
++            "</DT><DD>&nbsp;</DD>" + NL + NL +
+             "<DT><A HREF=\"./pkg/C.html#JDK\"><STRONG>JDK</STRONG></A> - " + NL +
+             "Static variable in class pkg.<A HREF=\"./pkg/C.html\" title=\"class in pkg\">C</A>" + NL +
+-            "<DD>&nbsp;"},
++            "</DT><DD>&nbsp;</DD>"},
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+ 
+diff --git a/test/com/sun/javadoc/testInterface/TestInterface.java b/test/com/sun/javadoc/testInterface/TestInterface.java
+--- openjdk/langtools/test/com/sun/javadoc/testInterface/TestInterface.java
++++ openjdk/langtools/test/com/sun/javadoc/testInterface/TestInterface.java
+@@ -55,7 +55,7 @@
+ 
+         // Make sure known implementing class list is correct and omits type parameters.
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "<DT><STRONG>All Known Implementing Classes:</STRONG> " +
++            "<DT><STRONG>All Known Implementing Classes:</STRONG></DT> " +
+             "<DD><A HREF=\"../pkg/Child.html\" " +
+             "title=\"class in pkg\">Child</A>, " +
+             "<A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">" +
+@@ -63,7 +63,9 @@
+ 
+          // Make sure "All Implemented Interfaces": has substituted type parameters
+          {BUG_ID + FS + "pkg" + FS + "Child.html",
+-            "<STRONG>All Implemented Interfaces:</STRONG> <DD><A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">Interface</A>&lt;T&gt;"
++            "<STRONG>All Implemented Interfaces:</STRONG></DT> <DD>" +
++            "<A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">" +
++            "Interface</A>&lt;T&gt;"
+          },
+          //Make sure Class Tree has substituted type parameters.
+          {BUG_ID + FS + "pkg" + FS + "Child.html",
+@@ -75,15 +77,15 @@
+          },
+          //Make sure "Direct Know Subclasses" omits type parameters
+         {BUG_ID + FS + "pkg" + FS + "Parent.html",
+-            "<STRONG>Direct Known Subclasses:</STRONG> <DD><A HREF=\"../pkg/Child.html\" title=\"class in pkg\">Child</A>"
++            "<STRONG>Direct Known Subclasses:</STRONG></DT> <DD><A HREF=\"../pkg/Child.html\" title=\"class in pkg\">Child</A>"
+         },
+         //Make sure "Specified By" has substituted type parameters.
+         {BUG_ID + FS + "pkg" + FS + "Child.html",
+-            "<STRONG>Specified by:</STRONG><DD><CODE><A HREF=\"../pkg/Interface.html#method()\">method</A></CODE> in interface <CODE><A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">Interface</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
++            "<STRONG>Specified by:</STRONG></DT><DD><CODE><A HREF=\"../pkg/Interface.html#method()\">method</A></CODE> in interface <CODE><A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">Interface</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
+          },
+         //Make sure "Overrides" has substituted type parameters.
+         {BUG_ID + FS + "pkg" + FS + "Child.html",
+-            "<STRONG>Overrides:</STRONG><DD><CODE><A HREF=\"../pkg/Parent.html#method()\">method</A></CODE> in class <CODE><A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">Parent</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
++            "<STRONG>Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg/Parent.html#method()\">method</A></CODE> in class <CODE><A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">Parent</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
+          },
+     };
+     private static final String[][] NEGATED_TEST = {
+diff --git a/test/com/sun/javadoc/testLinkOption/TestLinkOption.java b/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
+--- openjdk/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
++++ openjdk/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
+@@ -63,7 +63,8 @@
+             "title=\"class or interface in java.lang\">Object</A>&nbsp;p3)"
+         },
+         {BUG_ID + "-1" + FS + "java" + FS + "lang" + FS + "StringBuilderChild.html",
+-                "public abstract class <STRONG>StringBuilderChild</STRONG><DT>extends <A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true\" title=\"class or interface in java.lang\">Object</A>"
++                "public abstract class <STRONG>StringBuilderChild</STRONG>" + NL +
++                "extends <A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true\" title=\"class or interface in java.lang\">Object</A>"
+         },
+ 
+     };
+diff --git a/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java b/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
+--- openjdk/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
++++ openjdk/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
+@@ -59,7 +59,7 @@
+             " Link to another inner class: <A HREF=\"../pkg/C.InnerC2.html\" title=\"class in pkg\"><CODE>C.InnerC2</CODE></A>"
+         },
+         {BUG_ID + FS + "pkg" + FS + "C.InnerC2.html",
+-            "Enclosing class:</STRONG><DD><A HREF=\"../pkg/C.html\" title=\"class in pkg\">C</A>"
++            "Enclosing class:</STRONG></DT><DD><A HREF=\"../pkg/C.html\" title=\"class in pkg\">C</A>"
+         },
+     };
+     private static final String[][] NEGATED_TEST = {
+diff --git a/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java b/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
+--- openjdk/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
++++ openjdk/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
+@@ -74,7 +74,7 @@
+ 
+          // Test overriding/implementing methods with generic parameters.
+                  {BUG_ID + FS + "pkg" + FS + "BaseClass.html",
+-         "<DT><STRONG>Specified by:</STRONG><DD><CODE><A HREF=\"../pkg/BaseInterface.html#getAnnotation(java.lang.Class)\">getAnnotation</A></CODE> in interface <CODE><A HREF=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">BaseInterface</A></CODE></DL>"},
++         "<DT><STRONG>Specified by:</STRONG></DT><DD><CODE><A HREF=\"../pkg/BaseInterface.html#getAnnotation(java.lang.Class)\">getAnnotation</A></CODE> in interface <CODE><A HREF=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">BaseInterface</A></CODE></DD>"+NL+"</DL>"},
+ 
+          // Test diamond inheritence member summary (6256068)
+                  {BUG_ID + FS + "diamond" + FS + "Z.html",
+diff --git a/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java b/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+--- openjdk/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
++++ openjdk/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+@@ -54,7 +54,7 @@
+             {BUG_ID + FS + "pkg" + FS + "Coin.html", "Enum Coin</H2>"},
+             //Make sure enum signature is correct.
+             {BUG_ID + FS + "pkg" + FS + "Coin.html", "public enum "+
+-                "<STRONG>Coin</STRONG><DT>extends java.lang.Enum&lt;" +
++                "<STRONG>Coin</STRONG>" + NL + "extends java.lang.Enum&lt;" +
+                 "<A HREF=\"../pkg/Coin.html\" title=\"enum in pkg\">Coin</A>&gt;"
+             },
+             //Check for enum constant section
+@@ -79,20 +79,20 @@
+                 "Class TypeParameters&lt;E&gt;</H2>"},
+             //Check class type parameters section.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<DT><STRONG>Type Parameters:</STRONG><DD><CODE>E</CODE> - " +
++                "<DT><STRONG>Type Parameters:</STRONG></DT><DD><CODE>E</CODE> - " +
+                 "the type parameter for this class."},
+             //Type parameters in @see/@link
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<DT><STRONG>See Also:</STRONG><DD><A HREF=\"../pkg/TypeParameters.html\" " +
+-                    "title=\"class in pkg\"><CODE>TypeParameters</CODE></A></DL>"},
++                "<DT><STRONG>See Also:</STRONG></DT><DD><A HREF=\"../pkg/TypeParameters.html\" " +
++                    "title=\"class in pkg\"><CODE>TypeParameters</CODE></A></DD></DL>"},
+             //Method that uses class type parameter.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+                 "(<A HREF=\"../pkg/TypeParameters.html\" title=\"type " +
+                     "parameter in TypeParameters\">E</A>&nbsp;param)"},
+             //Method type parameter section.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<STRONG>Type Parameters:</STRONG><DD><CODE>T</CODE> - This is the first " +
+-                    "type parameter.<DD><CODE>V</CODE> - This is the second type " +
++                "<STRONG>Type Parameters:</STRONG></DT><DD><CODE>T</CODE> - This is the first " +
++                    "type parameter.</DD><DD><CODE>V</CODE> - This is the second type " +
+                     "parameter."},
+             //Signature of method with type parameters
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+@@ -117,17 +117,17 @@
+             //Signature of subclass that has type parameters.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameterSubClass.html",
+                 "public class <STRONG>TypeParameterSubClass&lt;T extends java.lang.String&gt;" +
+-                "</STRONG><DT>extends <A HREF=\"../pkg/TypeParameterSuperClass.html\" " +
++                "</STRONG>" + NL + "extends <A HREF=\"../pkg/TypeParameterSuperClass.html\" " +
+                 "title=\"class in pkg\">TypeParameterSuperClass</A>&lt;T&gt;"},
+ 
+             //Interface generic parameter substitution
+             //Signature of subclass that has type parameters.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<STRONG>All Implemented Interfaces:</STRONG> <DD><A HREF=\"../pkg/SubInterface.html\" title=\"interface in pkg\">SubInterface</A>&lt;E&gt;, <A HREF=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">SuperInterface</A>&lt;E&gt;</DD>"},
++                "<STRONG>All Implemented Interfaces:</STRONG></DT> <DD><A HREF=\"../pkg/SubInterface.html\" title=\"interface in pkg\">SubInterface</A>&lt;E&gt;, <A HREF=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">SuperInterface</A>&lt;E&gt;</DD>"},
+             {BUG_ID + FS + "pkg" + FS + "SuperInterface.html",
+-                "<STRONG>All Known Subinterfaces:</STRONG> <DD><A HREF=\"../pkg/SubInterface.html\" title=\"interface in pkg\">SubInterface</A>&lt;V&gt;</DD>"},
++                "<STRONG>All Known Subinterfaces:</STRONG></DT> <DD><A HREF=\"../pkg/SubInterface.html\" title=\"interface in pkg\">SubInterface</A>&lt;V&gt;</DD>"},
+             {BUG_ID + FS + "pkg" + FS + "SubInterface.html",
+-                "<STRONG>All Superinterfaces:</STRONG> <DD><A HREF=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">SuperInterface</A>&lt;V&gt;</DD>"},
++                "<STRONG>All Superinterfaces:</STRONG></DT> <DD><A HREF=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">SuperInterface</A>&lt;V&gt;</DD>"},
+ 
+             //=================================
+             // VAR ARG TESTING
+@@ -166,7 +166,7 @@
+                 "Element Detail"},
+             //Make sure default annotation type value is printed when necessary.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "<STRONG>Default:</STRONG><DD>\"unknown\"</DD>"},
++                "<STRONG>Default:</STRONG></DT><DD>\"unknown\"</DD>"},
+ 
+             //=================================
+             // ANNOTATION TYPE USAGE TESTING
+@@ -182,7 +182,8 @@
+                 "<FONT SIZE=\"-1\">" +
+                 "<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Class Annotation\","+NL +
+                 "                <A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)"+NL +
+-                "</FONT>public class <STRONG>AnnotationTypeUsage</STRONG><DT>extends java.lang.Object</DL>"},
++                "</FONT>public class <STRONG>AnnotationTypeUsage</STRONG>" + NL +
++                "extends java.lang.Object"},
+ 
+             //FIELD
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+@@ -270,8 +271,7 @@
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+                 "<PRE><FONT SIZE=\"-1\"><A HREF=\"../pkg1/A.html\" title=\"annotation in pkg1\">@A</A>"},
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "</FONT>public interface <STRONG>B</STRONG></DL>" + NL +
+-                    "</PRE>"},
++                "</FONT>public interface <STRONG>B</STRONG></PRE>"},
+ 
+ 
+             //==============================================================
+@@ -525,7 +525,7 @@
+             "<FONT SIZE=\"-1\">" + NL +
+             "<A HREF=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</A>(<A HREF=\"../pkg/AnnotationType.html#optional\">optional</A>=\"Class Annotation\"," + NL +
+             "                <A HREF=\"../pkg/AnnotationType.html#required\">required</A>=1994)" + NL +
+-            "</FONT>public class <STRONG>AnnotationTypeUsage</STRONG><DT>extends java.lang.Object</DL>"},
++            "</FONT>public class <STRONG>AnnotationTypeUsage</STRONG></DT><DT>extends java.lang.Object</DT></DL>"},
+ 
+         //FIELD
+         {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
+@@ -40,11 +40,11 @@
+     private static final String[][] TEST = {
+         //The public method should be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
+ 
+         //The public method in different package should be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"}
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"}
+     };
+ 
+     private static final String[][] NEGATED_TEST = {
+@@ -52,20 +52,20 @@
+         //The package private method should be overriden since the base and sub class are in the same
+         //package.  However, the link should not show up because the package private methods are not documented.
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
+ 
+         //The private method in should not be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The private method in different package should not be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The package private method should not be overriden since the base and sub class are in
+         //different packages.
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
+     };
+ 
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java
+@@ -40,32 +40,32 @@
+     private static final String[][] TEST = {
+         //The public method should be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
+ 
+         //The public method in different package should be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
+ 
+         //The package private method should be overriden since the base and sub class are in the same
+         //package.
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
+     };
+ 
+     private static final String[][] NEGATED_TEST = {
+ 
+         //The private method in should not be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The private method in different package should not be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The package private method should not be overriden since the base and sub class are in
+         //different packages.
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
+     };
+ 
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java
+@@ -40,32 +40,32 @@
+     private static final String[][] TEST = {
+         //The public method should be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
+ 
+         //The package private method should be overriden since the base and sub class are in the same
+         //package.
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
+ 
+         //The public method in different package should be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
+     };
+ 
+     private static final String[][] NEGATED_TEST = {
+ 
+         //The private method in should not be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The private method in different package should not be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The package private method should not be overriden since the base and sub class are in
+         //different packages.
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
++         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
+ 
+ 
+     };
+diff --git a/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java b/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
+--- openjdk/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
++++ openjdk/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
+@@ -48,12 +48,12 @@
+     private static final String[][] TEST = {
+         //Regular param tags.
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<STRONG>Parameters:</STRONG><DD><CODE>param1</CODE> - testing 1 2 3." +
++            "<STRONG>Parameters:</STRONG></DT><DD><CODE>param1</CODE> - testing 1 2 3.</DD>" +
+                 "<DD><CODE>param2</CODE> - testing 1 2 3."
+         },
+         //Param tags that don't match with any real parameters.
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<STRONG>Parameters:</STRONG><DD><CODE><I>p1</I></CODE> - testing 1 2 3." +
++            "<STRONG>Parameters:</STRONG></DT><DD><CODE><I>p1</I></CODE> - testing 1 2 3.</DD>" +
+                 "<DD><CODE><I>p2</I></CODE> - testing 1 2 3."
+         },
+         //{@inherit} doc misuse does not cause doclet to throw exception.
+diff --git a/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java b/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
+--- openjdk/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
++++ openjdk/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
+@@ -96,11 +96,11 @@
+ 
+         //Make sure implemented interfaces from private superclass are inherited
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
+-            "<STRONG>All Known Implementing Classes:</STRONG> <DD><A HREF=\"../pkg/PublicChild.html\" " +
++            "<STRONG>All Known Implementing Classes:</STRONG></DT> <DD><A HREF=\"../pkg/PublicChild.html\" " +
+             "title=\"class in pkg\">PublicChild</A>"},
+ 
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-            "<STRONG>All Implemented Interfaces:</STRONG> <DD><A HREF=\"../pkg/PublicInterface.html\" " +
++            "<STRONG>All Implemented Interfaces:</STRONG></DT> <DD><A HREF=\"../pkg/PublicInterface.html\" " +
+             "title=\"interface in pkg\">PublicInterface</A>"},
+ 
+         //Generic interface method test.
+@@ -174,18 +174,18 @@
+         },
+         // Should document that a method overrides method from private class.
+        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-            "<STRONG>Overrides:</STRONG><DD><CODE>" +
++            "<STRONG>Overrides:</STRONG></DT><DD><CODE>" +
+             "<A HREF=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" +
+             "methodOverridenFromParent</A></CODE> in class <CODE>" +
+             "<A HREF=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
+-            "PrivateParent</A></CODE></DL>"},
++            "PrivateParent</A></CODE></DD>" + NL + "</DL>"},
+        // Should document that a method is specified by private interface.
+        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-            "<STRONG>Specified by:</STRONG><DD><CODE>" +
++            "<STRONG>Specified by:</STRONG></DT><DD><CODE>" +
+             "<A HREF=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
+             "methodInterface</A></CODE> in interface <CODE>" +
+             "<A HREF=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
+-            "PrivateInterface</A></CODE></DL>" + NL + "</DD>"},
++            "PrivateInterface</A></CODE></DD>" + NL + "</DL>" + NL + "</DD>"},
+        // Method inheritence from non-public superinterface.
+        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
+             "Methods inherited from interface " +
+@@ -209,12 +209,12 @@
+ 
+       //Make sure implemented interfaces from private superclass are inherited
+       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
+-        "<STRONG>All Known Implementing Classes:</STRONG> <DD><A HREF=\"../pkg/PrivateParent.html\" " +
++        "<STRONG>All Known Implementing Classes:</STRONG></DT> <DD><A HREF=\"../pkg/PrivateParent.html\" " +
+         "title=\"class in pkg\">PrivateParent</A>, " +
+         "<A HREF=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild</A>"},
+ 
+       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-        "<STRONG>All Implemented Interfaces:</STRONG> <DD><A HREF=\"../pkg/PrivateInterface.html\" " +
++        "<STRONG>All Implemented Interfaces:</STRONG></DT> <DD><A HREF=\"../pkg/PrivateInterface.html\" " +
+         "title=\"interface in pkg\">PrivateInterface</A>, " +
+         "<A HREF=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
+         "PublicInterface</A>"},
+@@ -226,7 +226,7 @@
+             "<CODE><A HREF=\"../pkg2/I.html#hello(T)\">I</A></CODE></STRONG>"},
+ 
+       {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
+-            "<STRONG>Specified by:</STRONG><DD><CODE><A HREF=\"../pkg2/I.html#hello(T)\">" +
++            "<STRONG>Specified by:</STRONG></DT><DD><CODE><A HREF=\"../pkg2/I.html#hello(T)\">" +
+             "hello</A></CODE> in interface <CODE><A HREF=\"../pkg2/I.html\" " +
+             "title=\"interface in pkg2\">I</A>"},
+     };
+diff --git a/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java b/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
+--- openjdk/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
++++ openjdk/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
+@@ -41,39 +41,39 @@
+     // Test for normal run of javadoc. The serialized-form.html should
+     // display the inline comments, tags and deprecation information if any.
+     private static final String[][] TEST_CMNT_DEPR = {
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><DL>" + NL + NL +
+-                 "<DT><STRONG>Throws:</STRONG>" + NL + "<DD><CODE>" +
+-                 "java.io.IOException</CODE><DT><STRONG>See Also:</STRONG>" +
+-                 "<DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD>" + NL +
+-                 "</DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><DL>" + NL +
++                 "<DT><STRONG>Throws:</STRONG></DT>" + NL + "<DD><CODE>" +
++                 "java.io.IOException</CODE></DD><DT><STRONG>See Also:</STRONG>" +
++                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
+         {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
+-                 " 1.5, replaced by" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version " +
++                 "1.5, replaced by" + NL +
+                  " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I></DD>" +
+                  "<DD>This field indicates whether the C1 is undecorated." + NL +
+-                 "<P>" + NL + "<DT><DD>&nbsp;<DL>" + NL +
+-                 "<DT><STRONG>Since:</STRONG></DT>" + NL +
++                 "<P>" + NL + "</DD>" + NL + "<DD>&nbsp;</DD>" + NL +
++                 "<DD><DL>" + NL + "<DT><STRONG>Since:</STRONG></DT>" + NL +
+                  "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG>" +
+-                 "<DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DL>" + NL +
+-                 "</DL>"},
++                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
+         {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+                  "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
+                  " 1.5, replaced by" + NL +
+                  " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+                  "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
+-                 "<DD>Reads the object stream." + NL + "<P>" + NL +
+-                 "<DD><DL>" + NL + NL + "<DT><STRONG>Throws:" +
+-                 "</STRONG>" + NL + "<DD><CODE><code>" +
+-                 "IOException</code></CODE>" + NL +
+-                 "<DD><CODE>java.io.IOException</CODE></DD>" + NL +
+-                 "</DL>" + NL + "</DL>"},
++                 "</DD><DD>Reads the object stream." + NL + "<P>" + NL +
++                 "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Throws:" +
++                 "</STRONG></DT>" + NL + "<DD><CODE><code>" +
++                 "IOException</code></CODE></DD>" + NL +
++                 "<DD><CODE>java.io.IOException</CODE></DD></DL>" + NL +
++                 "</DD>" + NL + "</DL>"},
+         {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<DD>" +
+-                 "The name for this class." + NL + "<P>" + NL +
+-                 "<DT><DD>&nbsp;<DL>" + NL + "</DL>" + NL + "</DL>"}};
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD><DD>" +
++                 "The name for this class." + NL + "<P>" + NL + "</DD>" + NL +
++                 "<DD>&nbsp;</DD>" + NL + "</DL>"}};
+ 
+     // Test with -nocomment option. The serialized-form.html should
+     // not display the inline comments and tags but should display deprecation
+@@ -83,16 +83,16 @@
+                  "undecorated</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
+                  "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced by" + NL +
+                  " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
+-                 "setUndecorated(boolean)</CODE></A>.</I></DL>"},
++                 "setUndecorated(boolean)</CODE></A>.</I></DD></DL>"},
+         {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><STRONG>" +
+                  "Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
+                  " 1.5, replaced by" + NL +
+                  " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+                  "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
+-                 "</DL>"},
++                 "</DD></DL>"},
+         {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "int <STRONG>" +
+                  "publicKey</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;</DL>"}};
++                 "Deprecated.</STRONG>&nbsp;</DD></DL>"}};
+ 
+     // Test with -nodeprecated option. The serialized-form.html should
+     // ignore the -nodeprecated tag and display the deprecation info. This
+diff --git a/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java b/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java
+@@ -46,14 +46,14 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<DD><CODE><A HREF=\"../pkg/T1.html\" title=\"class in pkg\">T1</A></CODE> - the first throws tag." + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T2.html\" title=\"class in pkg\">T2</A></CODE> - the second throws tag." + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T3.html\" title=\"class in pkg\">T3</A></CODE> - the third throws tag." + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T4.html\" title=\"class in pkg\">T4</A></CODE> - the fourth throws tag." + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T5.html\" title=\"class in pkg\">T5</A></CODE> - the first inherited throws tag." + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T6.html\" title=\"class in pkg\">T6</A></CODE> - the second inherited throws tag." + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T7.html\" title=\"class in pkg\">T7</A></CODE> - the third inherited throws tag." + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T8.html\" title=\"class in pkg\">T8</A></CODE> - the fourth inherited throws tag."
++            "<DD><CODE><A HREF=\"../pkg/T1.html\" title=\"class in pkg\">T1</A></CODE> - the first throws tag.</DD>" + NL +
++            "<DD><CODE><A HREF=\"../pkg/T2.html\" title=\"class in pkg\">T2</A></CODE> - the second throws tag.</DD>" + NL +
++            "<DD><CODE><A HREF=\"../pkg/T3.html\" title=\"class in pkg\">T3</A></CODE> - the third throws tag.</DD>" + NL +
++            "<DD><CODE><A HREF=\"../pkg/T4.html\" title=\"class in pkg\">T4</A></CODE> - the fourth throws tag.</DD>" + NL +
++            "<DD><CODE><A HREF=\"../pkg/T5.html\" title=\"class in pkg\">T5</A></CODE> - the first inherited throws tag.</DD>" + NL +
++            "<DD><CODE><A HREF=\"../pkg/T6.html\" title=\"class in pkg\">T6</A></CODE> - the second inherited throws tag.</DD>" + NL +
++            "<DD><CODE><A HREF=\"../pkg/T7.html\" title=\"class in pkg\">T7</A></CODE> - the third inherited throws tag.</DD>" + NL +
++            "<DD><CODE><A HREF=\"../pkg/T8.html\" title=\"class in pkg\">T8</A></CODE> - the fourth inherited throws tag.</DD>"
+         },
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6802694-no_deprecated.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,601 @@
+# HG changeset patch
+# User andrew
+# Date 1371571658 18000
+# Node ID 9b884c583c41a545352b035d11d1ccacb96fbb2f
+# Parent  92a90d8c955b6cc619d16975e02d9143715dedaa
+6802694: Javadoc doclet does not display deprecated information with -nocomment option for serialized form
+Reviewed-by: jjg
+
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+@@ -245,6 +245,29 @@
+     }
+ 
+     /**
++     * Check whether there are any tags to be printed.
++     *
++     * @param doc the Doc object to check for tags.
++     * @return true if there are tags to be printed else return false.
++     */
++    protected boolean hasTagsToPrint(Doc doc) {
++        if (doc instanceof MethodDoc) {
++            ClassDoc[] intfacs = ((MethodDoc)doc).containingClass().interfaces();
++            MethodDoc overriddenMethod = ((MethodDoc)doc).overriddenMethod();
++            if ((intfacs.length > 0 &&
++                new ImplementedMethods((MethodDoc)doc, this.configuration).build().length > 0) ||
++                overriddenMethod != null) {
++                return true;
++            }
++        }
++        TagletOutputImpl output = new TagletOutputImpl("");
++        TagletWriter.genTagOuput(configuration.tagletManager, doc,
++            configuration.tagletManager.getCustomTags(doc),
++                getTagletWriterInstance(false), output);
++        return (output.toString().trim().isEmpty());
++    }
++
++    /**
+      * Returns a TagletWriter that knows how to write HTML.
+      *
+      * @return a TagletWriter that knows how to write HTML.
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+@@ -164,4 +164,20 @@
+     public void writeMemberFooter(FieldDoc member) {
+         writer.dlEnd();
+     }
++
++    /**
++     * Check to see if member details should be printed. If
++     * nocomment option set or if there is no text to be printed
++     * for deprecation info, inline comment, no serial tag or inline tags,
++     * do not print member details.
++     */
++    public boolean shouldPrintMemberDetails(FieldDoc field) {
++        if (!configuration().nocomment)
++            if((field.inlineTags().length > 0) ||
++                (field.tags("serial").length > 0) || (writer.hasTagsToPrint(field)))
++                return true;
++        if (!Util.isDeprecated(field))
++            return true;
++        return false;
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/TagletOutputImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/TagletOutputImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletOutputImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletOutputImpl.java
+@@ -67,4 +67,10 @@
+         return output.toString();
+     }
+ 
++    /**
++     * Check whether the taglet output is empty.
++     */
++    public boolean isEmpty() {
++        return (toString().trim().isEmpty());
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
+@@ -152,6 +152,17 @@
+          * @param member the member to write the header for.
+          */
+         public void writeMemberFooter(FieldDoc member);
++
++        /**
++         * Check to see if member details should be printed. If
++         * nocomment option set or if there is no text to be printed
++         * for deprecation info, inline comment, no serial tag or inline tags,
++         * do not print member details.
++         *
++         * @param member the member to check details for.
++         * @return true if details need to be printed
++         */
++        public boolean shouldPrintMemberDetails(FieldDoc member);
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+@@ -403,16 +403,17 @@
+         if (classDoc.definesSerializableFields()) {
+             FieldDoc serialPersistentField =
+                 (FieldDoc)((Util.asList(classDoc.serializableFields()).get(0)));
+-            String comment = serialPersistentField.commentText();
+-            if (comment.length() > 0) {
++            // Check to see if there are inline comments, tags or deprecation
++            // information to be printed.
++            if (fieldWriter.shouldPrintMemberDetails(serialPersistentField)) {
+                 fieldWriter.writeHeader(
+                     configuration.getText("doclet.Serialized_Form_class"));
++                fieldWriter.writeMemberDeprecatedInfo(serialPersistentField);
+                 if (!configuration.nocomment) {
+-                    fieldWriter.writeMemberDeprecatedInfo(serialPersistentField);
+                     fieldWriter.writeMemberDescription(serialPersistentField);
+                     fieldWriter.writeMemberTags(serialPersistentField);
+-                    fieldWriter.writeMemberFooter(serialPersistentField);
+                 }
++                fieldWriter.writeMemberFooter(serialPersistentField);
+             }
+         }
+     }
+@@ -429,6 +430,16 @@
+     }
+ 
+     /**
++     * Build the field deprecation information.
++     */
++    public void buildFieldDeprecationInfo() {
++        if (!currentClass.definesSerializableFields()) {
++            FieldDoc field = (FieldDoc)currentMember;
++            fieldWriter.writeMemberDeprecatedInfo(field);
++        }
++    }
++
++    /**
+      * Build the field information.
+      */
+     public void buildFieldInfo() {
+@@ -459,7 +470,6 @@
+                         "doclet.MissingSerialTag", cd.qualifiedName(),
+                         field.name());
+             }
+-            fieldWriter.writeMemberDeprecatedInfo(field);
+             fieldWriter.writeMemberDescription(field);
+             fieldWriter.writeMemberTags(field);
+         }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
+@@ -183,8 +183,8 @@
+                     <MethodHeader/>
+                     <SerializableMethods>
+                         <MethodSubHeader/>
++                        <DeprecatedMethodInfo/>
+                         <MethodInfo>
+-                            <DeprecatedMethodInfo/>
+                             <MethodDescription/>
+                             <MethodTags/>
+                         </MethodInfo>
+@@ -193,6 +193,7 @@
+                     <FieldHeader/>
+                     <SerializableFields>
+                         <FieldSubHeader/>
++                        <FieldDeprecationInfo/>
+                         <FieldInfo/>
+                         <FieldFooter/>
+                     </SerializableFields>                  
+diff --git a/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java b/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
+@@ -0,0 +1,151 @@
++/*
++ * 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.  Sun designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Sun in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
++ * CA 95054 USA or visit www.sun.com if you need additional information or
++ * have any questions.
++ */
++
++/*
++ * @test
++ * @bug 6802694
++ * @summary This test verifies deprecation info in serialized-form.html.
++ * @author Bhavesh Patel
++ * @library ../lib/
++ * @build JavadocTester
++ * @build TestSerializedFormDeprecationInfo
++ * @run main TestSerializedFormDeprecationInfo
++ */
++
++public class TestSerializedFormDeprecationInfo extends JavadocTester {
++
++    private static final String BUG_ID = "6802694";
++
++    // Test for normal run of javadoc. The serialized-form.html should
++    // display the inline comments, tags and deprecation information if any.
++    private static final String[][] TEST_CMNT_DEPR = {
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><DL>" + NL + NL +
++                 "<DT><STRONG>Throws:</STRONG>" + NL + "<DD><CODE>" +
++                 "java.io.IOException</CODE><DT><STRONG>See Also:</STRONG>" +
++                 "<DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD>" + NL +
++                 "</DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++                 " 1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" +
++                 "<DD>This field indicates whether the C1 is undecorated." + NL +
++                 "<P>" + NL + "<DT><DD>&nbsp;<DL>" + NL +
++                 "<DT><STRONG>Since:</STRONG></DT>" + NL +
++                 "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG>" +
++                 "<DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DL>" + NL +
++                 "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++                 " 1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
++                 "<DD>Reads the object stream." + NL + "<P>" + NL +
++                 "<DD><DL>" + NL + NL + "<DT><STRONG>Throws:" +
++                 "</STRONG>" + NL + "<DD><CODE><code>" +
++                 "IOException</code></CODE>" + NL +
++                 "<DD><CODE>java.io.IOException</CODE></DD>" + NL +
++                 "</DL>" + NL + "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
++                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<DD>" +
++                 "The name for this class." + NL + "<P>" + NL +
++                 "<DT><DD>&nbsp;<DL>" + NL + "</DL>" + NL + "</DL>"}};
++
++    // Test with -nocomment option. The serialized-form.html should
++    // not display the inline comments and tags but should display deprecation
++    // information if any.
++    private static final String[][] TEST_NOCMNT = {
++        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "boolean <STRONG>" +
++                 "undecorated</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
++                 "setUndecorated(boolean)</CODE></A>.</I></DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++                 " 1.5, replaced by" + NL +
++                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
++                 "</DL>"},
++        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "int <STRONG>" +
++                 "publicKey</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
++                 "Deprecated.</STRONG>&nbsp;</DL>"}};
++
++    // Test with -nodeprecated option. The serialized-form.html should
++    // ignore the -nodeprecated tag and display the deprecation info. This
++    // test is similar to the normal run of javadoc in which inline comment, tags
++    // and deprecation information will be displayed.
++    private static final String[][] TEST_NODEPR = TEST_CMNT_DEPR;
++
++    // Test with -nodeprecated and -nocomment options. The serialized-form.html should
++    // ignore the -nodeprecated tag and display the deprecation info but should not
++    // display the inline comments and tags. This test is similar to the test with
++    // -nocomment option.
++    private static final String[][] TEST_NOCMNT_NODEPR = TEST_NOCMNT;
++
++    private static final String[] ARGS1 =
++        new String[] {
++            "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"};
++
++    private static final String[] ARGS2 =
++        new String[] {
++            "-d", BUG_ID, "-nocomment", "-sourcepath", SRC_DIR, "pkg1"};
++
++    private static final String[] ARGS3 =
++        new String[] {
++            "-d", BUG_ID, "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
++
++    private static final String[] ARGS4 =
++        new String[] {
++            "-d", BUG_ID, "-nocomment", "-nodeprecated", "-sourcepath", SRC_DIR, "pkg1"};
++
++    /**
++     * The entry point of the test.
++     * @param args the array of command line arguments.
++     */
++    public static void main(String[] args) {
++        TestSerializedFormDeprecationInfo tester = new TestSerializedFormDeprecationInfo();
++        run(tester, ARGS1, TEST_CMNT_DEPR, TEST_NOCMNT);
++        run(tester, ARGS2, TEST_NOCMNT, TEST_CMNT_DEPR);
++        run(tester, ARGS3, TEST_NODEPR, TEST_NOCMNT_NODEPR);
++        run(tester, ARGS4, TEST_NOCMNT_NODEPR, TEST_NODEPR);
++        tester.printSummary();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getBugId() {
++        return BUG_ID;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getBugName() {
++        return getClass().getName();
++    }
++}
+diff --git a/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C1.java b/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C1.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C1.java
+@@ -0,0 +1,108 @@
++/*
++ * 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.  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 pkg1;
++
++import java.io.IOException;
++import java.io.Serializable;
++
++/**
++ * A class comment for testing.
++ *
++ * @author      Bhavesh Patel
++ * @see C2
++ * @since       JDK1.0
++ */
++
++public class C1 implements Serializable {
++
++    /**
++     * This field indicates whether the C1 is undecorated.
++     *
++     * @see #setUndecorated(boolean)
++     * @since 1.4
++     * @serial
++     * @deprecated As of JDK version 1.5, replaced by
++     * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
++     */
++     @Deprecated
++    public boolean undecorated = false;
++
++    private String title;
++
++    /**
++     * This enum specifies the possible modal exclusion types.
++     *
++     * @since 1.6
++     */
++    public static enum ModalExclusionType {
++        /**
++         * No modal exclusion.
++         */
++        NO_EXCLUDE,
++        /**
++         * <code>APPLICATION_EXCLUDE</code> indicates that a top-level window
++         * won't be blocked by any application-modal dialogs. Also, it isn't
++         * blocked by document-modal dialogs from outside of its child hierarchy.
++         */
++        APPLICATION_EXCLUDE
++    };
++
++    /**
++     * Constructor.
++     *
++     * @param title the title
++     * @param test boolean value
++     * @exception IllegalArgumentException if the <code>owner</code>'s
++     *     <code>GraphicsConfiguration</code> is not from a screen device
++     * @exception HeadlessException
++     */
++     public C1(String title, boolean test) {
++
++     }
++
++     public C1(String title) {
++
++     }
++
++    /**
++     * Method comments.
++     * @param  undecorated <code>true</code> if no decorations are
++     *         to be enabled;
++     *         <code>false</code> if decorations are to be enabled.
++     * @see    #readObject()
++     * @since 1.4
++     */
++    public void setUndecorated(boolean undecorated) {
++        /* Make sure we don't run in the middle of peer creation.*/
++    }
++
++    /**
++     * @see #setUndecorated(boolean)
++     */
++    public void readObject() throws IOException {
++
++    }
++}
+diff --git a/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java b/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C2.java
+@@ -0,0 +1,86 @@
++/*
++ * 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.  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 pkg1;
++
++import java.io.ObjectInputStream;
++import java.io.IOException;
++import java.io.Serializable;
++
++/**
++ * A class comment for testing.
++ *
++ * @author      Bhavesh Patel
++ * @see C1
++ * @since       JDK1.0
++ */
++
++public class C2 implements Serializable {
++
++    /**
++     * This field indicates title.
++     */
++    String title;
++
++    public static enum ModalType {
++        NO_EXCLUDE
++    };
++
++    /**
++     * Constructor.
++     *
++     */
++     public C2() {
++
++     }
++
++     public C2(String title) {
++
++     }
++
++     /**
++     * Set visible.
++     *
++     * @param set boolean
++     * @since 1.4
++     * @deprecated As of JDK version 1.5, replaced by
++     * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
++     */
++     @Deprecated
++     public void setVisible(boolean set) {
++     }
++
++     /**
++     * Reads the object stream.
++     *
++     * @param s ObjectInputStream
++     * @throws <code>IOException</code>
++     * @deprecated As of JDK version 1.5, replaced by
++     * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
++     */
++     @Deprecated
++     public void readObject(ObjectInputStream s) throws IOException {
++     }
++}
+diff --git a/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C3.java b/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C3.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/pkg1/C3.java
+@@ -0,0 +1,65 @@
++/*
++ * 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.  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 pkg1;
++
++import java.io.Serializable;
++
++/**
++ * Test for Serializable
++ *
++ * @author Bhavesh Patel
++ * @deprecated This class is no longer used.
++ */
++@Deprecated
++public abstract class C3 implements Serializable {
++
++    /**
++     * The name for this class.
++     *
++     * @serial
++     */
++    private String name;
++
++    /**
++     * @serial
++     */
++    private int publicKey;
++
++    /**
++     * Constructor for serialization only.
++     */
++    protected C3() {
++
++    }
++
++    /**
++     * Prints general information.
++     *
++     */
++    public void printInfo() {
++
++    }
++}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6851834-restructure.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,26851 @@
+# HG changeset patch
+# User andrew
+# Date 1371730814 18000
+# Node ID 5761891cfee48bc9382dd68e5e1bf164cff9bfbf
+# Parent  741c190d6989de395cb95895dc0320415af6b131
+6851834: Javadoc doclet needs a structured approach to generate the output HTML.
+Reviewed-by: jjg
+
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractExecutableMemberWriter.java
+@@ -26,12 +26,16 @@
+ package com.sun.tools.doclets.formats.html;
+ 
+ import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
++import com.sun.tools.doclets.internal.toolkit.util.*;
+ 
+ /**
+  * Print method and constructor info.
+  *
+  * @author Robert Field
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWriter {
+ 
+@@ -45,82 +49,111 @@
+     }
+ 
+     /**
+-     * Write the type parameters for the executable member.
++     * Add the type parameters for the executable member.
+      *
+      * @param member the member to write type parameters for.
++     * @param htmltree the content tree to which the parameters will be added.
+      * @return the display length required to write this information.
+      */
+-    protected int writeTypeParameters(ExecutableMemberDoc member) {
++    protected int addTypeParameters(ExecutableMemberDoc member, Content htmltree) {
+         LinkInfoImpl linkInfo = new LinkInfoImpl(
+             LinkInfoImpl.CONTEXT_MEMBER_TYPE_PARAMS, member, false);
+         String typeParameters = writer.getTypeParameterLinks(linkInfo);
+         if (linkInfo.displayLength > 0) {
+-            writer.print(typeParameters + " ");
++            Content linkContent = new RawHtml(typeParameters);
++            htmltree.addContent(linkContent);
++            htmltree.addContent(writer.getSpace());
+             writer.displayLength += linkInfo.displayLength + 1;
+         }
+         return linkInfo.displayLength;
+     }
+ 
+-    protected void writeSignature(ExecutableMemberDoc member) {
+-        writer.displayLength = 0;
+-        writer.pre();
+-        writer.writeAnnotationInfo(member);
+-        printModifiers(member);
+-        writeTypeParameters(member);
+-        if (configuration().linksource &&
+-            member.position().line() != classdoc.position().line()) {
+-            writer.printSrcLink(member, member.name());
+-        } else {
+-            strong(member.name());
+-        }
+-        writeParameters(member);
+-        writeExceptions(member);
+-        writer.preEnd();
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getDeprecatedLink(ProgramElementDoc member) {
++        ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
++        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc) emd,
++                emd.qualifiedName() + emd.flatSignature());
+     }
+ 
+-    protected void writeDeprecatedLink(ProgramElementDoc member) {
++    /**
++     * Add the summary link for the member.
++     *
++     * @param context the id of the context where the link will be printed
++     * @param classDoc the classDoc that we should link to
++     * @param member the member being linked to
++     * @param tdSummary the content tree to which the link will be added
++     */
++    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
++            Content tdSummary) {
+         ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
+-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc) emd,
+-            emd.qualifiedName() + emd.flatSignature(), false);
++        String name = emd.name();
++        Content strong = HtmlTree.STRONG(new RawHtml(
++                writer.getDocLink(context, cd, (MemberDoc) emd,
++                name, false)));
++        Content code = HtmlTree.CODE(strong);
++        writer.displayLength = name.length();
++        addParameters(emd, false, code);
++        tdSummary.addContent(code);
+     }
+ 
+-    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
+-        ExecutableMemberDoc emd = (ExecutableMemberDoc)member;
+-        String name = emd.name();
+-        writer.strong();
+-        writer.printDocLink(context, cd, (MemberDoc) emd,
+-            name, false);
+-        writer.strongEnd();
+-        writer.displayLength = name.length();
+-        writeParameters(emd, false);
++    /**
++     * Add the inherited summary link for the member.
++     *
++     * @param classDoc the classDoc that we should link to
++     * @param member the member being linked to
++     * @param linksTree the content tree to which the link will be added
++     */
++    protected void addInheritedSummaryLink(ClassDoc cd,
++            ProgramElementDoc member, Content linksTree) {
++        linksTree.addContent(new RawHtml(
++                writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc) member,
++                member.name(), false)));
+     }
+ 
+-    protected void writeInheritedSummaryLink(ClassDoc cd,
+-            ProgramElementDoc member) {
+-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc) member,
+-            member.name(), false);
+-    }
+-
+-    protected void writeParam(ExecutableMemberDoc member, Parameter param,
+-        boolean isVarArg) {
++    /**
++     * Add the parameter for the executable member.
++     *
++     * @param member the member to write parameter for.
++     * @param param the parameter that needs to be written.
++     * @param isVarArg true if this is a link to var arg.
++     * @param tree the content tree to which the parameter information will be added.
++     */
++    protected void addParam(ExecutableMemberDoc member, Parameter param,
++        boolean isVarArg, Content tree) {
+         if (param.type() != null) {
+-            writer.printLink(new LinkInfoImpl(
+-                LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, param.type(),
+-                isVarArg));
++            Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
++                    LinkInfoImpl.CONTEXT_EXECUTABLE_MEMBER_PARAM, param.type(),
++                    isVarArg)));
++            tree.addContent(link);
+         }
+         if(param.name().length() > 0) {
+-            writer.space();
+-            writer.print(param.name());
++            tree.addContent(writer.getSpace());
++            tree.addContent(param.name());
+         }
+     }
+ 
+-    protected void writeParameters(ExecutableMemberDoc member) {
+-        writeParameters(member, true);
++    /**
++     * Add all the parameters for the executable member.
++     *
++     * @param member the member to write parameters for.
++     * @param tree the content tree to which the parameters information will be added.
++     */
++    protected void addParameters(ExecutableMemberDoc member, Content htmltree) {
++        addParameters(member, true, htmltree);
+     }
+ 
+-    protected void writeParameters(ExecutableMemberDoc member,
+-            boolean includeAnnotations) {
+-        print('(');
++    /**
++     * Add all the parameters for the executable member.
++     *
++     * @param member the member to write parameters for.
++     * @param includeAnnotations true if annotation information needs to be added.
++     * @param tree the content tree to which the parameters information will be added.
++     */
++    protected void addParameters(ExecutableMemberDoc member,
++            boolean includeAnnotations, Content htmltree) {
++        htmltree.addContent("(");
+         Parameter[] params = member.parameters();
+         String indent = makeSpace(writer.displayLength);
+         if (configuration().linksource) {
+@@ -132,58 +165,70 @@
+             Parameter param = params[paramstart];
+             if (!param.name().startsWith("this$")) {
+                 if (includeAnnotations) {
+-                        boolean foundAnnotations =
+-                                writer.writeAnnotationInfo(indent.length(), member, param);
+-                        if (foundAnnotations) {
+-                                writer.println();
+-                                writer.print(indent);
++                    boolean foundAnnotations =
++                            writer.addAnnotationInfo(indent.length(),
++                            member, param, htmltree);
++                    if (foundAnnotations) {
++                        htmltree.addContent(DocletConstants.NL);
++                        htmltree.addContent(indent);
+                     }
+                 }
+-                writeParam(member, param,
+-                    (paramstart == params.length - 1) && member.isVarArgs());
++                addParam(member, param,
++                    (paramstart == params.length - 1) && member.isVarArgs(), htmltree);
+                 break;
+             }
+         }
+ 
+         for (int i = paramstart + 1; i < params.length; i++) {
+-            writer.print(',');
+-            writer.println();
+-            writer.print(indent);
++            htmltree.addContent(",");
++            htmltree.addContent(DocletConstants.NL);
++            htmltree.addContent(indent);
+             if (includeAnnotations) {
+                 boolean foundAnnotations =
+-                    writer.writeAnnotationInfo(indent.length(), member, params[i]);
++                        writer.addAnnotationInfo(indent.length(), member, params[i],
++                        htmltree);
+                 if (foundAnnotations) {
+-                    writer.println();
+-                    writer.print(indent);
++                    htmltree.addContent(DocletConstants.NL);
++                    htmltree.addContent(indent);
+                 }
+             }
+-            writeParam(member, params[i], (i == params.length - 1) && member.isVarArgs());
++            addParam(member, params[i], (i == params.length - 1) && member.isVarArgs(),
++                    htmltree);
+         }
+-        writer.print(')');
++        htmltree.addContent(")");
+     }
+ 
+-    protected void writeExceptions(ExecutableMemberDoc member) {
++    /**
++     * Add exceptions for the executable member.
++     *
++     * @param member the member to write exceptions for.
++     * @param htmltree the content tree to which the exceptions information will be added.
++     */
++    protected void addExceptions(ExecutableMemberDoc member, Content htmltree) {
+         Type[] exceptions = member.thrownExceptionTypes();
+         if(exceptions.length > 0) {
+             LinkInfoImpl memberTypeParam = new LinkInfoImpl(
+-                LinkInfoImpl.CONTEXT_MEMBER, member, false);
++                    LinkInfoImpl.CONTEXT_MEMBER, member, false);
+             int retlen = getReturnTypeLength(member);
+             writer.getTypeParameterLinks(memberTypeParam);
+             retlen += memberTypeParam.displayLength == 0 ?
+                 0 : memberTypeParam.displayLength + 1;
+             String indent = makeSpace(modifierString(member).length() +
+-                member.name().length() + retlen - 4);
+-            writer.println();
+-            writer.print(indent);
+-            writer.print("throws ");
++                    member.name().length() + retlen - 4);
++            htmltree.addContent(DocletConstants.NL);
++            htmltree.addContent(indent);
++            htmltree.addContent("throws ");
+             indent += "       ";
+-            writer.printLink(new LinkInfoImpl(
+-                LinkInfoImpl.CONTEXT_MEMBER, exceptions[0]));
++            Content link = new RawHtml(writer.getLink(new LinkInfoImpl(
++                    LinkInfoImpl.CONTEXT_MEMBER, exceptions[0])));
++            htmltree.addContent(link);
+             for(int i = 1; i < exceptions.length; i++) {
+-                writer.println(",");
+-                writer.print(indent);
+-                writer.printLink(new LinkInfoImpl(
+-                    LinkInfoImpl.CONTEXT_MEMBER, exceptions[i]));
++                htmltree.addContent(",");
++                htmltree.addContent(DocletConstants.NL);
++                htmltree.addContent(indent);
++                Content exceptionLink = new RawHtml(writer.getLink(new LinkInfoImpl(
++                        LinkInfoImpl.CONTEXT_MEMBER, exceptions[i])));
++                htmltree.addContent(exceptionLink);
+             }
+         }
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractIndexWriter.java
+@@ -30,6 +30,8 @@
+ 
+ import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+  * Generate Index for all the Member Names with Indexing in
+@@ -39,6 +41,7 @@
+  *
+  * @see    IndexBuilder
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class AbstractIndexWriter extends HtmlDocletWriter {
+ 
+@@ -78,175 +81,187 @@
+     }
+ 
+     /**
+-     * Print the text "Index" in strong format in the navigation bar.
++     * Get the index label for navigation bar.
++     *
++     * @return a content tree for the tree label
+      */
+-    protected void navLinkIndex() {
+-        navCellRevStart();
+-        fontStyle("NavBarFont1Rev");
+-        strongText("doclet.Index");
+-        fontEnd();
+-        navCellEnd();
++    protected Content getNavLinkIndex() {
++        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, indexLabel);
++        return li;
+     }
+ 
+     /**
+-     * Generate the member information for the unicode character along with the
++     * Add the member information for the unicode character along with the
+      * list of the members.
+      *
+-     * @param unicode Unicode for which member list information to be generated.
+-     * @param memberlist List of members for the unicode character.
++     * @param unicode Unicode for which member list information to be generated
++     * @param memberlist List of members for the unicode character
++     * @param contentTree the content tree to which the information will be added
+      */
+-    protected void generateContents(Character unicode, List memberlist) {
+-        anchor("_" + unicode + "_");
+-        h2();
+-        strong(unicode.toString());
+-        h2End();
++    protected void addContents(Character unicode, List<? extends Doc> memberlist,
++            Content contentTree) {
++        contentTree.addContent(getMarkerAnchor("_" + unicode + "_"));
++        Content headContent = new StringContent(unicode.toString());
++        Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, false,
++                HtmlStyle.title, headContent);
++        contentTree.addContent(heading);
+         int memberListSize = memberlist.size();
+         // Display the list only if there are elements to be displayed.
+         if (memberListSize > 0) {
+-            dl();
++            Content dl = new HtmlTree(HtmlTag.DL);
+             for (int i = 0; i < memberListSize; i++) {
+                 Doc element = memberlist.get(i);
+                 if (element instanceof MemberDoc) {
+-                    printDescription((MemberDoc)element);
++                    addDescription((MemberDoc)element, dl);
+                 } else if (element instanceof ClassDoc) {
+-                    printDescription((ClassDoc)element);
++                    addDescription((ClassDoc)element, dl);
+                 } else if (element instanceof PackageDoc) {
+-                    printDescription((PackageDoc)element);
++                    addDescription((PackageDoc)element, dl);
+                 }
+             }
+-            dlEnd();
++            contentTree.addContent(dl);
+         }
+-        hr();
+-    }
+-
+-
+-    /**
+-     * Print one line summary comment for the package.
+-     *
+-     * @param pkg PackageDoc passed.
+-     */
+-    protected void printDescription(PackageDoc pkg) {
+-        dt();
+-        printPackageLink(pkg, Util.getPackageName(pkg), true);
+-        print(" - ");
+-        print(configuration.getText("doclet.package") + " " + pkg.name());
+-        dtEnd();
+-        dd();
+-        printSummaryComment(pkg);
+-        ddEnd();
+     }
+ 
+     /**
+-     * Print one line summary comment for the class.
++     * Add one line summary comment for the package.
+      *
+-     * @param cd ClassDoc passed.
++     * @param pkg the package to be documented
++     * @param dlTree the content tree to which the description will be added
+      */
+-    protected void printDescription(ClassDoc cd) {
+-        dt();
+-        printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true));
+-        print(" - ");
+-        printClassInfo(cd);
+-        dtEnd();
+-        dd();
+-        printComment(cd);
+-        ddEnd();
++    protected void addDescription(PackageDoc pkg, Content dlTree) {
++        Content link = getPackageLink(pkg, new StringContent(Util.getPackageName(pkg)));
++        Content dt = HtmlTree.DT(link);
++        dt.addContent(" - ");
++        dt.addContent(getResource("doclet.package"));
++        dt.addContent(" " + pkg.name());
++        dlTree.addContent(dt);
++        Content dd = new HtmlTree(HtmlTag.DD);
++        addSummaryComment(pkg, dd);
++        dlTree.addContent(dd);
+     }
+ 
+     /**
+-     * Print the classkind(class, interface, exception, error of the class
++     * Add one line summary comment for the class.
++     *
++     * @param cd the class being documented
++     * @param dlTree the content tree to which the description will be added
++     */
++    protected void addDescription(ClassDoc cd, Content dlTree) {
++        Content link = new RawHtml(
++                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_INDEX, cd, true)));
++        Content dt = HtmlTree.DT(link);
++        dt.addContent(" - ");
++        addClassInfo(cd, dt);
++        dlTree.addContent(dt);
++        Content dd = new HtmlTree(HtmlTag.DD);
++        addComment(cd, dd);
++        dlTree.addContent(dd);
++    }
++
++    /**
++     * Add the classkind(class, interface, exception, error of the class
+      * passed.
+      *
+-     * @param cd ClassDoc.
++     * @param cd the class being documented
++     * @param contentTree the content tree to which the class info will be added
+      */
+-    protected void printClassInfo(ClassDoc cd) {
+-        print(configuration.getText("doclet.in",
+-            Util.getTypeName(configuration, cd, false),
+-            getPackageLink(cd.containingPackage(),
++    protected void addClassInfo(ClassDoc cd, Content contentTree) {
++        contentTree.addContent(getResource("doclet.in",
++                Util.getTypeName(configuration, cd, false),
++                getPackageLinkString(cd.containingPackage(),
+                 Util.getPackageName(cd.containingPackage()), false)));
+     }
+ 
+-
+     /**
+-     * Generate Description for Class, Field, Method or Constructor.
+-     * for Java.* Packages Class Members.
++     * Add description for Class, Field, Method or Constructor.
+      *
+-     * @param member MemberDoc for the member of the Class Kind.
+-     * @see com.sun.javadoc.MemberDoc
++     * @param member MemberDoc for the member of the Class Kind
++     * @param dlTree the content tree to which the description will be added
+      */
+-    protected void printDescription(MemberDoc member) {
++    protected void addDescription(MemberDoc member, Content dlTree) {
+         String name = (member instanceof ExecutableMemberDoc)?
+             member.name() + ((ExecutableMemberDoc)member).flatSignature() :
+             member.name();
+         if (name.indexOf("<") != -1 || name.indexOf(">") != -1) {
+                 name = Util.escapeHtmlChars(name);
+         }
+-        ClassDoc containing = member.containingClass();
+-        dt();
+-        printDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name, true);
+-        println(" - ");
+-        printMemberDesc(member);
+-        println();
+-        dtEnd();
+-        dd();
+-        printComment(member);
+-        ddEnd();
+-        println();
++        Content span = HtmlTree.SPAN(HtmlStyle.strong,
++                getDocLink(LinkInfoImpl.CONTEXT_INDEX, member, name));
++        Content dt = HtmlTree.DT(span);
++        dt.addContent(" - ");
++        addMemberDesc(member, dt);
++        dlTree.addContent(dt);
++        Content dd = new HtmlTree(HtmlTag.DD);
++        addComment(member, dd);
++        dlTree.addContent(dd);
+     }
+ 
+-
+     /**
+-     * Print comment for each element in the index. If the element is deprecated
++     * Add comment for each element in the index. If the element is deprecated
+      * and it has a @deprecated tag, use that comment. Else if the containing
+      * class for this element is deprecated, then add the word "Deprecated." at
+      * the start and then print the normal comment.
+      *
+-     * @param element Index element.
++     * @param element Index element
++     * @param contentTree the content tree to which the comment will be added
+      */
+-    protected void printComment(ProgramElementDoc element) {
++    protected void addComment(ProgramElementDoc element, Content contentTree) {
+         Tag[] tags;
++        Content span = HtmlTree.SPAN(HtmlStyle.strong, deprecatedPhrase);
++        HtmlTree div = new HtmlTree(HtmlTag.DIV);
++        div.addStyle(HtmlStyle.block);
+         if (Util.isDeprecated(element)) {
+-            strongText("doclet.Deprecated"); space();
++            div.addContent(span);
+             if ((tags = element.tags("deprecated")).length > 0)
+-                printInlineDeprecatedComment(element, tags[0]);
++                addInlineDeprecatedComment(element, tags[0], div);
++            contentTree.addContent(div);
+         } else {
+             ClassDoc cont = element.containingClass();
+             while (cont != null) {
+                 if (Util.isDeprecated(cont)) {
+-                    strongText("doclet.Deprecated"); space();
++                    div.addContent(span);
++                    contentTree.addContent(div);
+                     break;
+                 }
+                 cont = cont.containingClass();
+             }
+-            printSummaryComment(element);
++            addSummaryComment(element, contentTree);
+         }
+     }
+ 
+     /**
+-     * Print description about the Static Varible/Method/Constructor for a
++     * Add description about the Static Varible/Method/Constructor for a
+      * member.
+      *
+-     * @param member MemberDoc for the member within the Class Kind.
+-     * @see com.sun.javadoc.MemberDoc
++     * @param member MemberDoc for the member within the Class Kind
++     * @param contentTree the content tree to which the member description will be added
+      */
+-    protected void printMemberDesc(MemberDoc member) {
++    protected void addMemberDesc(MemberDoc member, Content contentTree) {
+         ClassDoc containing = member.containingClass();
+-        String classdesc = Util.getTypeName(configuration, containing, true) + " " +
+-            getPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing,
+-                false);
++        String classdesc = Util.getTypeName(
++                configuration, containing, true) + " ";
+         if (member.isField()) {
+             if (member.isStatic()) {
+-                printText("doclet.Static_variable_in", classdesc);
++                contentTree.addContent(
++                        getResource("doclet.Static_variable_in", classdesc));
+             } else {
+-                printText("doclet.Variable_in", classdesc);
++                contentTree.addContent(
++                        getResource("doclet.Variable_in", classdesc));
+             }
+         } else if (member.isConstructor()) {
+-            printText("doclet.Constructor_for", classdesc);
++            contentTree.addContent(
++                    getResource("doclet.Constructor_for", classdesc));
+         } else if (member.isMethod()) {
+             if (member.isStatic()) {
+-                printText("doclet.Static_method_in", classdesc);
++                contentTree.addContent(
++                        getResource("doclet.Static_method_in", classdesc));
+             } else {
+-                printText("doclet.Method_in", classdesc);
++                contentTree.addContent(
++                        getResource("doclet.Method_in", classdesc));
+             }
+         }
++        addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_INDEX, containing,
++                false, contentTree);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractMemberWriter.java
+@@ -25,10 +25,11 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.util.*;
+ import java.lang.reflect.Modifier;
+-import java.util.*;
+-
+ import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ 
+@@ -60,36 +61,125 @@
+ 
+     /*** abstracts ***/
+ 
+-    public abstract void printSummaryLabel();
++    /**
++     * Add the summary label for the member.
++     *
++     * @param memberTree the content tree to which the label will be added
++     */
++    public abstract void addSummaryLabel(Content memberTree);
+ 
+-    public abstract void printTableSummary();
++    /**
++     * Get the summary for the member summary table.
++     *
++     * @return a string for the table summary
++     */
++    public abstract String getTableSummary();
+ 
+-    public abstract void printSummaryTableHeader(ProgramElementDoc member);
++    /**
++     * Get the caption for the member summary table.
++     *
++     * @return a string for the table caption
++     */
++    public abstract String getCaption();
+ 
+-    public abstract void printInheritedSummaryLabel(ClassDoc cd);
++    /**
++     * Get the summary table header for the member.
++     *
++     * @param member the member to be documented
++     * @return the summary table header
++     */
++    public abstract String[] getSummaryTableHeader(ProgramElementDoc member);
+ 
+-    public abstract void printSummaryAnchor(ClassDoc cd);
++    /**
++     * Add inherited summary lable for the member.
++     *
++     * @param cd the class doc to which to link to
++     * @param inheritedTree the content tree to which the inherited summary label will be added
++     */
++    public abstract void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree);
+ 
+-    public abstract void printInheritedSummaryAnchor(ClassDoc cd);
++    /**
++     * Add the anchor for the summary section of the member.
++     *
++     * @param cd the class doc to be documented
++     * @param memberTree the content tree to which the summary anchor will be added
++     */
++    public abstract void addSummaryAnchor(ClassDoc cd, Content memberTree);
+ 
+-    protected abstract void printSummaryType(ProgramElementDoc member);
++    /**
++     * Add the anchor for the inherited summary section of the member.
++     *
++     * @param cd the class doc to be documented
++     * @param inheritedTree the content tree to which the inherited summary anchor will be added
++     */
++    public abstract void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree);
+ 
+-    protected void writeSummaryLink(ClassDoc cd, ProgramElementDoc member) {
+-        writeSummaryLink(LinkInfoImpl.CONTEXT_MEMBER, cd, member);
++    /**
++     * Add the summary type for the member.
++     *
++     * @param member the member to be documented
++     * @param tdSummaryType the content tree to which the type will be added
++     */
++    protected abstract void addSummaryType(ProgramElementDoc member,
++            Content tdSummaryType);
++
++    /**
++     * Add the summary link for the member.
++     *
++     * @param cd the class doc to be documented
++     * @param member the member to be documented
++     * @param tdSummary the content tree to which the link will be added
++     */
++    protected void addSummaryLink(ClassDoc cd, ProgramElementDoc member,
++            Content tdSummary) {
++        addSummaryLink(LinkInfoImpl.CONTEXT_MEMBER, cd, member, tdSummary);
+     }
+ 
+-    protected abstract void writeSummaryLink(int context,
+-                                             ClassDoc cd,
+-                                             ProgramElementDoc member);
++    /**
++     * Add the summary link for the member.
++     *
++     * @param context the id of the context where the link will be printed
++     * @param cd the class doc to be documented
++     * @param member the member to be documented
++     * @param tdSummary the content tree to which the summary link will be added
++     */
++    protected abstract void addSummaryLink(int context,
++            ClassDoc cd, ProgramElementDoc member, Content tdSummary);
+ 
+-    protected abstract void writeInheritedSummaryLink(ClassDoc cd,
+-                                                     ProgramElementDoc member);
++    /**
++     * Add the inherited summary link for the member.
++     *
++     * @param cd the class doc to be documented
++     * @param member the member to be documented
++     * @param linksTree the content tree to which the inherited summary link will be added
++     */
++    protected abstract void addInheritedSummaryLink(ClassDoc cd,
++            ProgramElementDoc member, Content linksTree);
+ 
+-    protected abstract void writeDeprecatedLink(ProgramElementDoc member);
++    /**
++     * Get the deprecated link.
++     *
++     * @param member the member being linked to
++     * @return a content tree representing the link
++     */
++    protected abstract Content getDeprecatedLink(ProgramElementDoc member);
+ 
+-    protected abstract void printNavSummaryLink(ClassDoc cd, boolean link);
++    /**
++     * Get the navigation summary link.
++     *
++     * @param cd the class doc to be documented
++     * @param link true if its a link else the label to be printed
++     * @return a content tree for the navigation summary link.
++     */
++    protected abstract Content getNavSummaryLink(ClassDoc cd, boolean link);
+ 
+-    protected abstract void printNavDetailLink(boolean link);
++    /**
++     * Add the navigation detail link.
++     *
++     * @param link true if its a link else the label to be printed
++     * @param liNav the content tree to which the navigation detail link will be added
++     */
++    protected abstract void addNavDetailLink(boolean link, Content liNav);
+ 
+     /***  ***/
+ 
+@@ -109,6 +199,17 @@
+     }
+ 
+     /**
++     * Add the member name to the content tree and modifies the display length.
++     *
++     * @param name the member name to be added to the content tree.
++     * @param htmltree the content tree to which the name will be added.
++     */
++    protected void addName(String name, Content htmltree) {
++        htmltree.addContent(name);
++        writer.displayLength += name.length();
++    }
++
++    /**
+      * Return a string describing the access modifier flags.
+      * Don't include native or synchronized.
+      *
+@@ -131,18 +232,24 @@
+         return type;
+     }
+ 
+-    protected void printModifiers(MemberDoc member) {
++    /**
++     * Add the modifier for the member.
++     *
++     * @param member the member for which teh modifier will be added.
++     * @param htmltree the content tree to which the modifier information will be added.
++     */
++    protected void addModifiers(MemberDoc member, Content htmltree) {
+         String mod = modifierString(member);
+         // According to JLS, we should not be showing public modifier for
+         // interface methods.
+         if ((member.isField() || member.isMethod()) &&
+             writer instanceof ClassWriterImpl &&
+-             ((ClassWriterImpl) writer).getClassDoc().isInterface()) {
++            ((ClassWriterImpl) writer).getClassDoc().isInterface()) {
+             mod = Util.replaceText(mod, "public", "").trim();
+         }
+         if(mod.length() > 0) {
+-            print(mod);
+-            print(' ');
++            htmltree.addContent(mod);
++            htmltree.addContent(writer.getSpace());
+         }
+     }
+ 
+@@ -158,66 +265,43 @@
+     }
+ 
+     /**
+-     * Print 'static' if static and type link.
++     * Add the modifier and type for the member in the member summary.
++     *
++     * @param member the member to add the type for
++     * @param type the type to add
++     * @param tdSummaryType the content tree to which the modified and type will be added
+      */
+-    protected void printStaticAndType(boolean isStatic, Type type) {
+-        writer.printTypeSummaryHeader();
+-        if (isStatic) {
+-            print("static");
+-        }
+-        writer.space();
+-        if (type != null) {
+-            writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+-                type));
+-        }
+-        writer.printTypeSummaryFooter();
+-    }
+-
+-    /**
+-     * Print the modifier and type for the member in the member summary.
+-     *
+-     * @param member the member to print the type for.
+-     * @param type   the type to print.
+-     */
+-    protected void printModifierAndType(ProgramElementDoc member, Type type) {
+-        writer.printTypeSummaryHeader();
+-        printModifier(member);
++    protected void addModifierAndType(ProgramElementDoc member, Type type,
++            Content tdSummaryType) {
++        HtmlTree code = new HtmlTree(HtmlTag.CODE);
++        addModifier(member, code);
+         if (type == null) {
+-            writer.space();
+             if (member.isClass()) {
+-                print("class");
++                code.addContent("class");
+             } else {
+-                print("interface");
++                code.addContent("interface");
+             }
++            code.addContent(writer.getSpace());
+         } else {
+             if (member instanceof ExecutableMemberDoc &&
+                     ((ExecutableMemberDoc) member).typeParameters().length > 0) {
+                 //Code to avoid ugly wrapping in member summary table.
+-                writer.table(0,0,0);
+-                writer.trAlignVAlign("right", "");
+-                writer.tdNowrap();
+-                writer.font("-1");
+-                writer.code();
+-                int displayLength = ((AbstractExecutableMemberWriter) this).
+-                writeTypeParameters((ExecutableMemberDoc) member);
++                int displayLength = ((AbstractExecutableMemberWriter) this).addTypeParameters(
++                        (ExecutableMemberDoc) member, code);
+                 if (displayLength > 10) {
+-                    writer.br();
++                    code.addContent(new HtmlTree(HtmlTag.BR));
+                 }
+-                writer.printLink(new LinkInfoImpl(
+-                    LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type));
+-                writer.codeEnd();
+-                writer.fontEnd();
+-                writer.tdEnd();
+-                writer.trEnd();
+-                writer.tableEnd();
++                code.addContent(new RawHtml(
++                        writer.getLink(new LinkInfoImpl(
++                        LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
+             } else {
+-                writer.space();
+-                writer.printLink(new LinkInfoImpl(
+-                    LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type));
++                code.addContent(new RawHtml(
++                        writer.getLink(new LinkInfoImpl(
++                        LinkInfoImpl.CONTEXT_SUMMARY_RETURN_TYPE, type))));
+             }
+ 
+         }
+-        writer.printTypeSummaryFooter();
++        tdSummaryType.addContent(code);
+     }
+ 
+     private void printModifier(ProgramElementDoc member) {
+@@ -238,25 +322,53 @@
+     }
+ 
+     /**
+-     * Print the deprecated output for the given member.
++     * Add the modifier for the member.
++     *
++     * @param member the member to add the type for
++     * @param code the content tree to which the modified will be added
++     */
++    private void addModifier(ProgramElementDoc member, Content code) {
++        if (member.isProtected()) {
++            code.addContent("protected ");
++        } else if (member.isPrivate()) {
++            code.addContent("private ");
++        } else if (!member.isPublic()) { // Package private
++            code.addContent(configuration().getText("doclet.Package_private"));
++            code.addContent(" ");
++        }
++        if (member.isMethod() && ((MethodDoc)member).isAbstract()) {
++            code.addContent("abstract ");
++        }
++        if (member.isStatic()) {
++            code.addContent("static ");
++        }
++    }
++
++    /**
++     * Add the deprecated information for the given member.
+      *
+      * @param member the member being documented.
++     * @param contentTree the content tree to which the deprecated information will be added.
+      */
+-    protected void printDeprecated(ProgramElementDoc member) {
++    protected void addDeprecatedInfo(ProgramElementDoc member, Content contentTree) {
+         String output = (new DeprecatedTaglet()).getTagletOutput(member,
+             writer.getTagletWriterInstance(false)).toString().trim();
+         if (!output.isEmpty()) {
+-            writer.printMemberDetailsListStartTag();
+-            writer.print(output);
++            Content deprecatedContent = new RawHtml(output);
++            Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent);
++            contentTree.addContent(div);
+         }
+     }
+ 
+-    protected void printComment(ProgramElementDoc member) {
++    /**
++     * Add the comment for the given member.
++     *
++     * @param member the member being documented.
++     * @param contentTree the content tree to which the comment will be added.
++     */
++    protected void addComment(ProgramElementDoc member, Content htmltree) {
+         if (member.inlineTags().length > 0) {
+-            writer.printMemberDetailsListStartTag();
+-            writer.dd();
+-            writer.printInlineComment(member);
+-            writer.ddEnd();
++            writer.addInlineComment(member, htmltree);
+         }
+     }
+ 
+@@ -264,67 +376,19 @@
+         return member.name();
+     }
+ 
+-    protected void printHead(MemberDoc member) {
+-        writer.h3();
+-        writer.print(member.name());
+-        writer.h3End();
+-    }
+-
+-    protected void printFullComment(ProgramElementDoc member) {
+-        if(configuration().nocomment){
+-            return;
+-        }
+-        writer.dl();
+-        print(((TagletOutputImpl)
+-            (new DeprecatedTaglet()).getTagletOutput(member,
+-            writer.getTagletWriterInstance(false))).toString());
+-        printCommentAndTags(member);
+-        writer.dlEnd();
+-    }
+-
+-    protected void printCommentAndTags(ProgramElementDoc member) {
+-        printComment(member);
+-        writer.printTags(member);
++    /**
++     * Get the header for the section.
++     *
++     * @param member the member being documented.
++     * @return a header content for the section.
++     */
++    protected Content getHead(MemberDoc member) {
++        Content memberContent = new RawHtml(member.name());
++        Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, memberContent);
++        return heading;
+     }
+ 
+     /**
+-     * Write the member footer.
+-     */
+-    protected void printMemberFooter() {
+-        writer.printMemberDetailsListEndTag();
+-        assert !writer.getMemberDetailsListPrinted();
+-    }
+-
+-    /**
+-     * Forward to containing writer
+-     */
+-    public void printSummaryHeader(ClassDoc cd) {
+-        printedSummaryHeader = true;
+-        writer.printSummaryHeader(this, cd);
+-    }
+-
+-    /**
+-     * Forward to containing writer
+-     */
+-    public void printInheritedSummaryHeader(ClassDoc cd) {
+-        writer.printInheritedSummaryHeader(this, cd);
+-    }
+-
+-    /**
+-     * Forward to containing writer
+-     */
+-    public void printInheritedSummaryFooter(ClassDoc cd) {
+-        writer.printInheritedSummaryFooter(this, cd);
+-    }
+-
+-    /**
+-     * Forward to containing writer
+-     */
+-    public void printSummaryFooter(ClassDoc cd) {
+-        writer.printSummaryFooter(this, cd);
+-    }
+-
+-   /**
+     * Return true if the given <code>ProgramElement</code> is inherited
+     * by the class that is being documented.
+     *
+@@ -340,102 +404,134 @@
+         return true;
+     }
+ 
+-
+     /**
+-     * Generate the code for listing the deprecated APIs. Create the table
+-     * format for listing the API. Call methods from the sub-class to complete
+-     * the generation.
++     * Add deprecated information to the documentation tree
++     *
++     * @param deprmembers list of deprecated members
++     * @param headingKey the caption for the deprecated members table
++     * @param tableSummary the summary for the deprecated members table
++     * @param tableHeader table headers for the deprecated members table
++     * @param contentTree the content tree to which the deprecated members table will be added
+      */
+-    protected void printDeprecatedAPI(List<Doc> deprmembers, String headingKey, String tableSummary, String[] tableHeader) {
++    protected void addDeprecatedAPI(List<Doc> deprmembers, String headingKey,
++            String tableSummary, String[] tableHeader, Content contentTree) {
+         if (deprmembers.size() > 0) {
+-            writer.tableIndexSummary(tableSummary);
+-            writer.tableCaptionStart();
+-            writer.printText(headingKey);
+-            writer.tableCaptionEnd();
+-            writer.summaryTableHeader(tableHeader, "col");
++            Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
++                writer.getTableCaption(configuration().getText(headingKey)));
++            table.addContent(writer.getSummaryTableHeader(tableHeader, "col"));
++            Content tbody = new HtmlTree(HtmlTag.TBODY);
+             for (int i = 0; i < deprmembers.size(); i++) {
+                 ProgramElementDoc member =(ProgramElementDoc)deprmembers.get(i);
+-                writer.trBgcolorStyle("white", "TableRowColor");
+-                writer.summaryRow(0);
+-                writeDeprecatedLink(member);
+-                writer.br();
+-                writer.printNbsps();
++                HtmlTree td = HtmlTree.TD(HtmlStyle.colOne, getDeprecatedLink(member));
+                 if (member.tags("deprecated").length > 0)
+-                    writer.printInlineDeprecatedComment(member, member.tags("deprecated")[0]);
+-                writer.space();
+-                writer.summaryRowEnd();
+-                writer.trEnd();
++                    writer.addInlineDeprecatedComment(member,
++                            member.tags("deprecated")[0], td);
++                HtmlTree tr = HtmlTree.TR(td);
++                if (i%2 == 0)
++                    tr.addStyle(HtmlStyle.altColor);
++                else
++                    tr.addStyle(HtmlStyle.rowColor);
++                tbody.addContent(tr);
+             }
+-            writer.tableEnd();
+-            writer.space();
+-            writer.p();
++            table.addContent(tbody);
++            Content li = HtmlTree.LI(HtmlStyle.blockList, table);
++            Content ul = HtmlTree.UL(HtmlStyle.blockList, li);
++            contentTree.addContent(ul);
+         }
+     }
+ 
+     /**
+-     * Print use info.
++     * Add use information to the documentation tree.
++     *
++     * @param mems list of program elements for which the use information will be added
++     * @param heading the section heading
++     * @param tableSummary the summary for the use table
++     * @param contentTree the content tree to which the use information will be added
+      */
+-    protected void printUseInfo(List<? extends ProgramElementDoc> mems, String heading, String tableSummary) {
++    protected void addUseInfo(List<? extends ProgramElementDoc> mems,
++            String heading, String tableSummary, Content contentTree) {
+         if (mems == null) {
+             return;
+         }
+         List members = (List)mems;
+         boolean printedUseTableHeader = false;
+         if (members.size() > 0) {
+-            writer.tableIndexSummary(tableSummary);
+-            writer.tableSubCaptionStart();
+-            writer.print(heading);
+-            writer.tableCaptionEnd();
+-            for (Iterator it = members.iterator(); it.hasNext(); ) {
++            Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
++                    writer.getTableCaption(heading));
++            Content tbody = new HtmlTree(HtmlTag.TBODY);
++            Iterator<? extends ProgramElementDoc> it = members.iterator();
++            for (int i = 0; it.hasNext(); i++) {
+                 ProgramElementDoc pgmdoc = (ProgramElementDoc)it.next();
+                 ClassDoc cd = pgmdoc.containingClass();
+                 if (!printedUseTableHeader) {
+-                    // Passing ProgramElementDoc helps decides printing
+-                    // interface or class header in case of nested classes.
+-                    this.printSummaryTableHeader(pgmdoc);
++                    table.addContent(writer.getSummaryTableHeader(
++                            this.getSummaryTableHeader(pgmdoc), "col"));
+                     printedUseTableHeader = true;
+                 }
+-
+-                writer.printSummaryLinkType(this, pgmdoc);
++                HtmlTree tr = new HtmlTree(HtmlTag.TR);
++                if (i % 2 == 0) {
++                    tr.addStyle(HtmlStyle.altColor);
++                } else {
++                    tr.addStyle(HtmlStyle.rowColor);
++                }
++                HtmlTree tdFirst = new HtmlTree(HtmlTag.TD);
++                tdFirst.addStyle(HtmlStyle.colFirst);
++                writer.addSummaryType(this, pgmdoc, tdFirst);
++                tr.addContent(tdFirst);
++                HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
++                tdLast.addStyle(HtmlStyle.colLast);
+                 if (cd != null && !(pgmdoc instanceof ConstructorDoc)
+-                               && !(pgmdoc instanceof ClassDoc)) {
+-                    // Add class context
+-                    writer.strong(cd.name() + ".");
++                        && !(pgmdoc instanceof ClassDoc)) {
++                    HtmlTree name = new HtmlTree(HtmlTag.SPAN);
++                    name.addStyle(HtmlStyle.strong);
++                    name.addContent(cd.name() + ".");
++                    tdLast.addContent(name);
+                 }
+-                writeSummaryLink(
+-                    pgmdoc instanceof ClassDoc ?
+-                        LinkInfoImpl.CONTEXT_CLASS_USE : LinkInfoImpl.CONTEXT_MEMBER,
+-                    cd, pgmdoc);
+-                writer.printSummaryLinkComment(this, pgmdoc);
++                addSummaryLink(pgmdoc instanceof ClassDoc ?
++                    LinkInfoImpl.CONTEXT_CLASS_USE : LinkInfoImpl.CONTEXT_MEMBER,
++                    cd, pgmdoc, tdLast);
++                writer.addSummaryLinkComment(this, pgmdoc, tdLast);
++                tr.addContent(tdLast);
++                tbody.addContent(tr);
+             }
+-            writer.tableEnd();
+-            writer.space();
+-            writer.p();
++            table.addContent(tbody);
++            contentTree.addContent(table);
+         }
+     }
+ 
+-    protected void navDetailLink(List members) {
+-            printNavDetailLink(members.size() > 0? true: false);
++    /**
++     * Add the navigation detail link.
++     *
++     * @param members the members to be linked
++     * @param liNav the content tree to which the navigation detail link will be added
++     */
++    protected void addNavDetailLink(List<?> members, Content liNav) {
++        addNavDetailLink(members.size() > 0 ? true : false, liNav);
+     }
+ 
+-
+-    protected void navSummaryLink(List members,
+-            VisibleMemberMap visibleMemberMap) {
++    /**
++     * Add the navigation summary link.
++     *
++     * @param members members to be linked
++     * @param visibleMemberMap the visible inherited members map
++     * @param liNav the content tree to which the navigation summary link will be added
++     */
++    protected void addNavSummaryLink(List<?> members,
++            VisibleMemberMap visibleMemberMap, Content liNav) {
+         if (members.size() > 0) {
+-            printNavSummaryLink(null, true);
++            liNav.addContent(getNavSummaryLink(null, true));
+             return;
+-        } else {
+-            ClassDoc icd = classdoc.superclass();
+-            while (icd != null) {
+-                List inhmembers = visibleMemberMap.getMembersFor(icd);
+-                if (inhmembers.size() > 0) {
+-                    printNavSummaryLink(icd, true);
+-                    return;
+-                }
+-                icd = icd.superclass();
++        }
++        ClassDoc icd = classdoc.superclass();
++        while (icd != null) {
++            List<?> inhmembers = visibleMemberMap.getMembersFor(icd);
++            if (inhmembers.size() > 0) {
++                liNav.addContent(getNavSummaryLink(icd, true));
++                return;
+             }
++            icd = icd.superclass();
+         }
+-        printNavSummaryLink(null, false);
++        liNav.addContent(getNavSummaryLink(null, false));
+     }
+ 
+     protected void serialWarning(SourcePosition pos, String key, String a1, String a2) {
+@@ -453,12 +549,109 @@
+     }
+ 
+     /**
+-     * {@inheritDoc}
++     * Add the member summary for the given class.
++     *
++     * @param classDoc the class that is being documented
++     * @param member the member being documented
++     * @param firstSentenceTags the first sentence tags to be added to the summary
++     * @param tableTree the content tree to which the documentation will be added
++     * @param counter the counter for determing style for the table row
+      */
+-    public void writeMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
+-        Tag[] firstSentenceTags, boolean isFirst, boolean isLast) {
+-        writer.printSummaryLinkType(this, member);
+-        writeSummaryLink(classDoc, member);
+-        writer.printSummaryLinkComment(this, member, firstSentenceTags);
++    public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
++            Tag[] firstSentenceTags, Content tableTree, int counter) {
++        HtmlTree tdSummaryType = new HtmlTree(HtmlTag.TD);
++        tdSummaryType.addStyle(HtmlStyle.colFirst);
++        writer.addSummaryType(this, member, tdSummaryType);
++        HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
++        setSummaryColumnStyle(tdSummary);
++        addSummaryLink(classDoc, member, tdSummary);
++        writer.addSummaryLinkComment(this, member, firstSentenceTags, tdSummary);
++        HtmlTree tr = HtmlTree.TR(tdSummaryType);
++        tr.addContent(tdSummary);
++        if (counter%2 == 0)
++            tr.addStyle(HtmlStyle.altColor);
++        else
++            tr.addStyle(HtmlStyle.rowColor);
++        tableTree.addContent(tr);
++    }
++
++    /**
++     * Set the style for the summary column.
++     *
++     * @param tdTree the column for which the style will be set
++     */
++    public void setSummaryColumnStyle(HtmlTree tdTree) {
++        tdTree.addStyle(HtmlStyle.colLast);
++    }
++
++    /**
++     * Add inherited member summary for the given class and member.
++     *
++     * @param classDoc the class the inherited member belongs to
++     * @param nestedClass the inherited member that is summarized
++     * @param isFirst true if this is the first member in the list
++     * @param isLast true if this is the last member in the list
++     * @param linksTree the content tree to which the summary will be added
++     */
++    public void addInheritedMemberSummary(ClassDoc classDoc,
++            ProgramElementDoc nestedClass, boolean isFirst, boolean isLast,
++            Content linksTree) {
++        writer.addInheritedMemberSummary(this, classDoc, nestedClass, isFirst,
++                linksTree);
++    }
++
++    /**
++     * Get the inherited summary header for the given class.
++     *
++     * @param classDoc the class the inherited member belongs to
++     * @return a content tree for the inherited summary header
++     */
++    public Content getInheritedSummaryHeader(ClassDoc classDoc) {
++        Content inheritedTree = writer.getMemberTreeHeader();
++        writer.addInheritedSummaryHeader(this, classDoc, inheritedTree);
++        return inheritedTree;
++    }
++
++    /**
++     * Get the inherited summary links tree.
++     *
++     * @return a content tree for the inherited summary links
++     */
++    public Content getInheritedSummaryLinksTree() {
++        return new HtmlTree(HtmlTag.CODE);
++    }
++
++    /**
++     * Get the summary table tree for the given class.
++     *
++     * @param classDoc the class for which the summary table is generated
++     * @return a content tree for the summary table
++     */
++    public Content getSummaryTableTree(ClassDoc classDoc) {
++        return writer.getSummaryTableTree(this, classDoc);
++    }
++
++    /**
++     * Get the member tree to be documented.
++     *
++     * @param memberTree the content tree of member to be documented
++     * @return a content tree that will be added to the class documentation
++     */
++    public Content getMemberTree(Content memberTree) {
++        return writer.getMemberTree(memberTree);
++    }
++
++    /**
++     * Get the member tree to be documented.
++     *
++     * @param memberTree the content tree of member to be documented
++     * @param isLastContent true if the content to be added is the last content
++     * @return a content tree that will be added to the class documentation
++     */
++    public Content getMemberTree(Content memberTree, boolean isLastContent) {
++        if (isLastContent)
++            return HtmlTree.UL(HtmlStyle.blockListLast, memberTree);
++        else
++            return HtmlTree.UL(HtmlStyle.blockList, memberTree);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractPackageIndexWriter.java
+@@ -25,9 +25,11 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
+-import com.sun.javadoc.*;
+ import java.io.*;
+ import java.util.*;
++import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+  * Abstract class to generate the overview files in
+@@ -56,105 +58,127 @@
+         packages = configuration.packages;
+     }
+ 
+-    protected abstract void printNavigationBarHeader();
+-
+-    protected abstract void printNavigationBarFooter();
+-
+-    protected abstract void printOverviewHeader();
+-
+-    protected abstract void printIndexHeader(String text, String tableSummary);
+-
+-    protected abstract void printIndexRow(PackageDoc pkg);
+-
+-    protected abstract void printIndexFooter();
++    /**
++     * Adds the navigation bar header to the documentation tree.
++     *
++     * @param body the document tree to which the navigation bar header will be added
++     */
++    protected abstract void addNavigationBarHeader(Content body);
+ 
+     /**
+-     * Generate the contants in the package index file. Call appropriate
++     * Adds the navigation bar footer to the documentation tree.
++     *
++     * @param body the document tree to which the navigation bar footer will be added
++     */
++    protected abstract void addNavigationBarFooter(Content body);
++
++    /**
++     * Adds the overview header to the documentation tree.
++     *
++     * @param body the document tree to which the overview header will be added
++     */
++    protected abstract void addOverviewHeader(Content body);
++
++    /**
++     * Adds the packages list to the documentation tree.
++     *
++     * @param packages an array of packagedoc objects
++     * @param text caption for the table
++     * @param tableSummary summary for the table
++     * @param body the document tree to which the packages list will be added
++     */
++    protected abstract void addPackagesList(PackageDoc[] packages, String text,
++            String tableSummary, Content body);
++
++    /**
++     * Generate and prints the contents in the package index file. Call appropriate
+      * methods from the sub-class in order to generate Frame or Non
+      * Frame format.
++     *
+      * @param title the title of the window.
+      * @param includeScript boolean set true if windowtitle script is to be included
+      */
+-    protected void generatePackageIndexFile(String title, boolean includeScript) throws IOException {
++    protected void buildPackageIndexFile(String title, boolean includeScript) throws IOException {
+         String windowOverview = configuration.getText(title);
+-        printHtmlHeader(windowOverview,
+-            configuration.metakeywords.getOverviewMetaKeywords(title,
+-                configuration.doctitle),
+-            includeScript);
+-        printNavigationBarHeader();
+-        printOverviewHeader();
+-
+-        generateIndex();
+-
+-        printOverview();
+-
+-        printNavigationBarFooter();
+-        printBodyHtmlEnd();
++        Content body = getBody(includeScript, getWindowTitle(windowOverview));
++        addNavigationBarHeader(body);
++        addOverviewHeader(body);
++        addIndex(body);
++        addOverview(body);
++        addNavigationBarFooter(body);
++        printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
++                configuration.doctitle), includeScript, body);
+     }
+ 
+     /**
+-     * Default to no overview, overwrite to add overview.
++     * Default to no overview, override to add overview.
++     *
++     * @param body the document tree to which the overview will be added
+      */
+-    protected void printOverview() throws IOException {
++    protected void addOverview(Content body) throws IOException {
+     }
+ 
+     /**
+-     * Generate the frame or non-frame package index.
++     * Adds the frame or non-frame package index to the documentation tree.
++     *
++     * @param body the document tree to which the index will be added
+      */
+-    protected void generateIndex() {
+-        printIndexContents(packages, "doclet.Package_Summary",
++    protected void addIndex(Content body) {
++        addIndexContents(packages, "doclet.Package_Summary",
+                 configuration.getText("doclet.Member_Table_Summary",
+                 configuration.getText("doclet.Package_Summary"),
+-                configuration.getText("doclet.packages")));
++                configuration.getText("doclet.packages")), body);
+     }
+ 
+     /**
+-     * Generate code for package index contents. Call appropriate methods from
+-     * the sub-classes.
++     * Adds package index contents. Call appropriate methods from
++     * the sub-classes. Adds it to the body HtmlTree
+      *
+-     * @param packages Array of packages to be documented.
+-     * @param text     String which will be used as the heading.
++     * @param packages array of packages to be documented
++     * @param text string which will be used as the heading
++     * @param tableSummary summary for the table
++     * @param body the document tree to which the index contents will be added
+      */
+-    protected void printIndexContents(PackageDoc[] packages, String text, String tableSummary) {
++    protected void addIndexContents(PackageDoc[] packages, String text,
++            String tableSummary, Content body) {
+         if (packages.length > 0) {
+             Arrays.sort(packages);
+-            printIndexHeader(text, tableSummary);
+-            printAllClassesPackagesLink();
+-            for(int i = 0; i < packages.length; i++) {
+-                if (packages[i] != null) {
+-                    printIndexRow(packages[i]);
+-                }
+-            }
+-            printIndexFooter();
++            addAllClassesLink(body);
++            addPackagesList(packages, text, tableSummary, body);
+         }
+     }
+ 
+     /**
+-     * Print the doctitle, if it is specified on the command line.
++     * Adds the doctitle to the documentation tree, if it is specified on the command line.
++     *
++     * @param body the document tree to which the title will be added
+      */
+-    protected void printConfigurationTitle() {
++    protected void addConfigurationTitle(Content body) {
+         if (configuration.doctitle.length() > 0) {
+-            center();
+-            h1(configuration.doctitle);
+-            centerEnd();
++            Content title = new RawHtml(configuration.doctitle);
++            Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
++                    HtmlStyle.title, title);
++            Content div = HtmlTree.DIV(HtmlStyle.header, heading);
++            body.addContent(div);
+         }
+     }
+ 
+     /**
+-     * Highlight "Overview" in the strong format, in the navigation bar as this
+-     * is the overview page.
++     * Returns highlighted "Overview", in the navigation bar as this is the
++     * overview page.
++     *
++     * @return a Content object to be added to the documentation tree
+      */
+-    protected void navLinkContents() {
+-        navCellRevStart();
+-        fontStyle("NavBarFont1Rev");
+-        strongText("doclet.Overview");
+-        fontEnd();
+-        navCellEnd();
++    protected Content getNavLinkContents() {
++        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, overviewLabel);
++        return li;
+     }
+ 
+     /**
+      * Do nothing. This will be overridden in PackageIndexFrameWriter.
++     *
++     * @param body the document tree to which the all classes link will be added
+      */
+-    protected void printAllClassesPackagesLink() {
++    protected void addAllClassesLink(Content body) {
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AbstractTreeWriter.java
+@@ -25,11 +25,12 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
+-import com.sun.tools.doclets.internal.toolkit.util.*;
+-
+-import com.sun.javadoc.*;
+ import java.io.*;
+ import java.util.*;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.internal.toolkit.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.javadoc.*;
+ 
+ /**
+  * Abstract class to print the class hierarchy page for all the Classes. This
+@@ -46,6 +47,8 @@
+      */
+     protected final ClassTree classtree;
+ 
++    private static final String LI_CIRCLE  = "circle";
++
+     /**
+      * Constructor initilises classtree variable. This constructor will be used
+      * while generating global tree file "overview-tree.html".
+@@ -87,55 +90,64 @@
+     }
+ 
+     /**
+-     * Generate each level of the class tree. For each sub-class or
++     * Add each level of the class tree. For each sub-class or
+      * sub-interface indents the next level information.
+-     * Recurses itself to generate subclasses info.
+-     * To iterate is human, to recurse is divine - L. Peter Deutsch.
++     * Recurses itself to add subclasses info.
+      *
+-     * @param parent the superclass or superinterface of the list.
+-     * @param list list of the sub-classes at this level.
+-     * @param isEnum true if we are generating a tree for enums.
++     * @param parent the superclass or superinterface of the list
++     * @param list list of the sub-classes at this level
++     * @param isEnum true if we are generating a tree for enums
++     * @param contentTree the content tree to which the level information will be added
+      */
+-    protected void generateLevelInfo(ClassDoc parent, List list,
+-            boolean isEnum) {
+-        if (list.size() > 0) {
+-            ul();
+-            for (int i = 0; i < list.size(); i++) {
++    protected void addLevelInfo(ClassDoc parent, List<ClassDoc> list,
++            boolean isEnum, Content contentTree) {
++        int size = list.size();
++        if (size > 0) {
++            Content ul = new HtmlTree(HtmlTag.UL);
++            for (int i = 0; i < size; i++) {
+                 ClassDoc local = (ClassDoc)list.get(i);
+-                printPartialInfo(local);
+-                printExtendsImplements(parent, local);
+-                generateLevelInfo(local, classtree.subs(local, isEnum),
+-                    isEnum);   // Recurse
++                HtmlTree li = new HtmlTree(HtmlTag.LI);
++                li.addAttr(HtmlAttr.TYPE, LI_CIRCLE);
++                addPartialInfo(local, li);
++                addExtendsImplements(parent, local, li);
++                addLevelInfo(local, classtree.subs(local, isEnum),
++                        isEnum, li);   // Recurse
++                ul.addContent(li);
+             }
+-            ulEnd();
++            contentTree.addContent(ul);
+         }
+     }
+ 
+     /**
+-     * Generate the heading for the tree depending upon tree type if it's a
+-     * Class Tree or Interface tree and also print the tree.
++     * Add the heading for the tree depending upon tree type if it's a
++     * Class Tree or Interface tree.
+      *
+      * @param list List of classes which are at the most base level, all the
+-     * other classes in this run will derive from these classes.
+-     * @param heading Heading for the tree.
++     * other classes in this run will derive from these classes
++     * @param heading heading for the tree
++     * @param div the content tree to which the tree will be added
+      */
+-    protected void generateTree(List list, String heading) {
++    protected void addTree(List<ClassDoc> list, String heading, Content div) {
+         if (list.size() > 0) {
+             ClassDoc firstClassDoc = (ClassDoc)list.get(0);
+-            printTreeHeading(heading);
+-            generateLevelInfo(!firstClassDoc.isInterface()? firstClassDoc : null,
+-                list,
+-                list == classtree.baseEnums());
++            Content headingContent = getResource(heading);
++            div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
++                    headingContent));
++            addLevelInfo(!firstClassDoc.isInterface()? firstClassDoc : null,
++                    list, list == classtree.baseEnums(), div);
+         }
+     }
+ 
+     /**
+-     * Print the information regarding the classes which this class extends or
++     * Add information regarding the classes which this class extends or
+      * implements.
+      *
+-     * @param cd The classdoc under consideration.
++     * @param parent the parent class of the class being documented
++     * @param cd the classdoc under consideration
++     * @param contentTree the content tree to which the information will be added
+      */
+-    protected void printExtendsImplements(ClassDoc parent, ClassDoc cd) {
++    protected void addExtendsImplements(ClassDoc parent, ClassDoc cd,
++            Content contentTree) {
+         ClassDoc[] interfaces = cd.interfaces();
+         if (interfaces.length > (cd.isInterface()? 1 : 0)) {
+             Arrays.sort(interfaces);
+@@ -148,53 +160,43 @@
+                     }
+                     if (counter == 0) {
+                         if (cd.isInterface()) {
+-                            print(" (" + configuration.getText("doclet.also") + " extends ");
++                            contentTree.addContent(" (");
++                            contentTree.addContent(getResource("doclet.also"));
++                            contentTree.addContent(" extends ");
+                         } else {
+-                            print(" (implements ");
++                            contentTree.addContent(" (implements ");
+                         }
+                     } else {
+-                        print(", ");
++                        contentTree.addContent(", ");
+                     }
+-                    printPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE,
+-                        interfaces[i]);
++                    addPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE,
++                            interfaces[i], contentTree);
+                     counter++;
+                 }
+             }
+             if (counter > 0) {
+-                println(")");
++                contentTree.addContent(")");
+             }
+         }
+     }
+ 
+     /**
+-     * Print information about the class kind, if it's a "class" or "interface".
++     * Add information about the class kind, if it's a "class" or "interface".
+      *
+-     * @param cd classdoc.
++     * @param cd the class being documented
++     * @param contentTree the content tree to which the information will be added
+      */
+-    protected void printPartialInfo(ClassDoc cd) {
+-        li("circle");
+-        printPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd);
++    protected void addPartialInfo(ClassDoc cd, Content contentTree) {
++        addPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd, contentTree);
+     }
+ 
+     /**
+-     * Print the heading for the tree.
++     * Get the tree label for the navigation bar.
+      *
+-     * @param heading Heading for the tree.
++     * @return a content tree for the tree label
+      */
+-    protected void printTreeHeading(String heading) {
+-        h2();
+-        println(configuration.getText(heading));
+-        h2End();
+-    }
+-
+-    /**
+-     * Highlight "Tree" word in the navigation bar, since this is the tree page.
+-     */
+-    protected void navLinkTree() {
+-        navCellRevStart();
+-        fontStyle("NavBarFont1Rev");
+-        strongText("doclet.Tree");
+-        fontEnd();
+-        navCellEnd();
++    protected Content getNavLinkTree() {
++        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, treeLabel);
++        return li;
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AllClassesFrameWriter.java
+@@ -25,11 +25,14 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
+-import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+ import java.io.*;
+ import java.util.*;
+ 
++import com.sun.javadoc.*;
++import com.sun.tools.doclets.internal.toolkit.*;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++
+ /**
+  * Generate the file with list of all the classes in this run. This page will be
+  * used in the left-hand bottom frame, when "All Classes" link is clicked in
+@@ -38,6 +41,7 @@
+  *
+  * @author Atul M Dambalkar
+  * @author Doug Kramer
++ * @author Bhavesh Patel (Modified)
+  */
+ public class AllClassesFrameWriter extends HtmlDocletWriter {
+ 
+@@ -57,6 +61,11 @@
+     protected IndexBuilder indexbuilder;
+ 
+     /**
++     * BR tag to be used within a document tree.
++     */
++    final HtmlTree BR = new HtmlTree(HtmlTag.BR);
++
++    /**
+      * Construct AllClassesFrameWriter object. Also initilises the indexbuilder
+      * variable in this class.
+      * @throws IOException
+@@ -84,12 +93,12 @@
+         try {
+             allclassgen = new AllClassesFrameWriter(configuration,
+                                                     filename, indexbuilder);
+-            allclassgen.generateAllClassesFile(true);
++            allclassgen.buildAllClassesFile(true);
+             allclassgen.close();
+             filename = OUTPUT_FILE_NAME_NOFRAMES;
+             allclassgen = new AllClassesFrameWriter(configuration,
+                                                     filename, indexbuilder);
+-            allclassgen.generateAllClassesFile(false);
++            allclassgen.buildAllClassesFile(false);
+             allclassgen.close();
+         } catch (IOException exc) {
+             configuration.standardmessage.
+@@ -100,30 +109,34 @@
+     }
+ 
+     /**
+-     * Print all the classes in table format in the file.
++     * Print all the classes in the file.
+      * @param wantFrames True if we want frames.
+      */
+-    protected void generateAllClassesFile(boolean wantFrames) throws IOException {
++    protected void buildAllClassesFile(boolean wantFrames) throws IOException {
+         String label = configuration.getText("doclet.All_Classes");
+-
+-        printHtmlHeader(label, null, false);
+-
+-        printAllClassesTableHeader();
+-        printAllClasses(wantFrames);
+-        printAllClassesTableFooter();
+-
+-        printBodyHtmlEnd();
++        Content body = getBody(false, getWindowTitle(label));
++        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
++                HtmlStyle.bar, allclassesLabel);
++        body.addContent(heading);
++        Content ul = new HtmlTree(HtmlTag.UL);
++        // Generate the class links and add it to the tdFont tree.
++        addAllClasses(ul, wantFrames);
++        Content div = HtmlTree.DIV(HtmlStyle.indexContainer, ul);
++        body.addContent(div);
++        printHtmlDocument(null, false, body);
+     }
+ 
+     /**
+-     * Use the sorted index of all the classes and print all the classes.
++     * Use the sorted index of all the classes and add all the classes to the
++     * content list.
+      *
++     * @param content HtmlTree content to which all classes information will be added
+      * @param wantFrames True if we want frames.
+      */
+-    protected void printAllClasses(boolean wantFrames) {
++    protected void addAllClasses(Content content, boolean wantFrames) {
+         for (int i = 0; i < indexbuilder.elements().length; i++) {
+             Character unicode = (Character)((indexbuilder.elements())[i]);
+-            generateContents(indexbuilder.getMemberList(unicode), wantFrames);
++            addContents(indexbuilder.getMemberList(unicode), wantFrames, content);
+         }
+     }
+ 
+@@ -136,46 +149,25 @@
+      *
+      * @param classlist Sorted list of classes.
+      * @param wantFrames True if we want frames.
++     * @param content HtmlTree content to which the links will be added
+      */
+-    protected void generateContents(List classlist, boolean wantFrames) {
++    protected void addContents(List<Doc> classlist, boolean wantFrames,
++            Content content) {
+         for (int i = 0; i < classlist.size(); i++) {
+             ClassDoc cd = (ClassDoc)(classlist.get(i));
+             if (!Util.isCoreClass(cd)) {
+                 continue;
+             }
+             String label = italicsClassName(cd, false);
++            Content linkContent;
+             if(wantFrames){
+-                printLink(new LinkInfoImpl(LinkInfoImpl.ALL_CLASSES_FRAME, cd,
+-                    label, "classFrame")
+-                );
++                linkContent = new RawHtml(getLink(new LinkInfoImpl(
++                        LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame")));
+             } else {
+-                printLink(new LinkInfoImpl(cd, label));
++                linkContent = new RawHtml(getLink(new LinkInfoImpl(cd, label)));
+             }
+-            br();
++            Content li = HtmlTree.LI(linkContent);
++            content.addContent(li);
+         }
+     }
+-
+-    /**
+-     * Print the heading "All Classes" and also print Html table tag.
+-     */
+-    protected void printAllClassesTableHeader() {
+-        fontSizeStyle("+1", "FrameHeadingFont");
+-        strongText("doclet.All_Classes");
+-        fontEnd();
+-        br();
+-        table();
+-        tr();
+-        tdNowrap();
+-        fontStyle("FrameItemFont");
+-    }
+-
+-    /**
+-     * Print Html closing table tag.
+-     */
+-    protected void printAllClassesTableFooter() {
+-        fontEnd();
+-        tdEnd();
+-        trEnd();
+-        tableEnd();
+-    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeOptionalMemberWriterImpl.java
+@@ -28,6 +28,7 @@
+ import java.io.*;
+ 
+ import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+@@ -54,29 +55,26 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
+-        writer.println("<!-- =========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY =========== -->");
+-        writer.println();
+-        writer.printSummaryHeader(this, classDoc);
++    public Content getMemberSummaryHeader(ClassDoc classDoc,
++            Content memberSummaryTree) {
++        memberSummaryTree.addContent(
++                HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY);
++        Content memberTree = writer.getMemberTreeHeader();
++        writer.addSummaryHeader(this, classDoc, memberTree);
++        return memberTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeDefaultValueInfo(MemberDoc member) {
++    public void addDefaultValueInfo(MemberDoc member, Content annotationDocTree) {
+         if (((AnnotationTypeElementDoc) member).defaultValue() != null) {
+-            writer.printMemberDetailsListStartTag();
+-            writer.dd();
+-            writer.dl();
+-            writer.dt();
+-            writer.strong(ConfigurationImpl.getInstance().
+-                getText("doclet.Default"));
+-            writer.dtEnd();
+-            writer.dd();
+-            writer.print(((AnnotationTypeElementDoc) member).defaultValue());
+-            writer.ddEnd();
+-            writer.dlEnd();
+-            writer.ddEnd();
++            Content dt = HtmlTree.DT(writer.getResource("doclet.Default"));
++            Content dl = HtmlTree.DL(dt);
++            Content dd = HtmlTree.DD(new StringContent(
++                    ((AnnotationTypeElementDoc) member).defaultValue().toString()));
++            dl.addContent(dd);
++            annotationDocTree.addContent(dl);
+         }
+     }
+ 
+@@ -90,45 +88,58 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void printSummaryLabel() {
+-        writer.printText("doclet.Annotation_Type_Optional_Member_Summary");
++    public void addSummaryLabel(Content memberTree) {
++        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
++                writer.getResource("doclet.Annotation_Type_Optional_Member_Summary"));
++        memberTree.addContent(label);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void printTableSummary() {
+-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++    public String getTableSummary() {
++        return configuration().getText("doclet.Member_Table_Summary",
+                 configuration().getText("doclet.Annotation_Type_Optional_Member_Summary"),
+-                configuration().getText("doclet.annotation_type_optional_members")));
++                configuration().getText("doclet.annotation_type_optional_members"));
+     }
+ 
+-    public void printSummaryTableHeader(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    public String getCaption() {
++        return configuration().getText("doclet.Annotation_Type_Optional_Members");
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String[] getSummaryTableHeader(ProgramElementDoc member) {
+         String[] header = new String[] {
+             writer.getModifierTypeHeader(),
+             configuration().getText("doclet.0_and_1",
+                     configuration().getText("doclet.Annotation_Type_Optional_Member"),
+                     configuration().getText("doclet.Description"))
+         };
+-        writer.summaryTableHeader(header, "col");
++        return header;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void printSummaryAnchor(ClassDoc cd) {
+-        writer.anchor("annotation_type_optional_element_summary");
++    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
++        memberTree.addContent(writer.getMarkerAnchor(
++                "annotation_type_optional_element_summary"));
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
++    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
+         if (link) {
+-            writer.printHyperLink("", "annotation_type_optional_element_summary",
+-                    configuration().getText("doclet.navAnnotationTypeOptionalMember"));
++            return writer.getHyperLink("", "annotation_type_optional_element_summary",
++                    writer.getResource("doclet.navAnnotationTypeOptionalMember"));
+         } else {
+-            writer.printText("doclet.navAnnotationTypeOptionalMember");
++            return writer.getResource("doclet.navAnnotationTypeOptionalMember");
+         }
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeRequiredMemberWriterImpl.java
+@@ -28,6 +28,7 @@
+ import java.io.*;
+ 
+ import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+@@ -51,122 +52,102 @@
+     }
+ 
+     /**
+-     * Write the annotation type member summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
++     * {@inheritDoc}
+      */
+-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
+-        writer.println("<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->");
+-        writer.println();
+-        writer.printSummaryHeader(this, classDoc);
+-    }
+-
+-    /**
+-     * Write the annotation type member summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
+-        writer.printSummaryFooter(this, classDoc);
++    public Content getMemberSummaryHeader(ClassDoc classDoc,
++            Content memberSummaryTree) {
++        memberSummaryTree.addContent(
++                HtmlConstants.START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY);
++        Content memberTree = writer.getMemberTreeHeader();
++        writer.addSummaryHeader(this, classDoc, memberTree);
++        return memberTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
+-        //Not appliable.
++    public void addAnnotationDetailsTreeHeader(ClassDoc classDoc,
++            Content memberDetailsTree) {
++        if (!writer.printedAnnotationHeading) {
++            memberDetailsTree.addContent(writer.getMarkerAnchor(
++                    "annotation_type_element_detail"));
++            Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
++                    writer.annotationTypeDetailsLabel);
++            memberDetailsTree.addContent(heading);
++            writer.printedAnnotationHeading = true;
++        }
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummary(ClassDoc classDoc,
+-        ProgramElementDoc member, boolean isFirst, boolean isLast) {
+-        //Not appliable.
++    public Content getAnnotationDocTreeHeader(MemberDoc member,
++            Content annotationDetailsTree) {
++        annotationDetailsTree.addContent(
++                writer.getMarkerAnchor(member.name() +
++                ((ExecutableMemberDoc) member).signature()));
++        Content annotationDocTree = writer.getMemberTreeHeader();
++        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
++        heading.addContent(member.name());
++        annotationDocTree.addContent(heading);
++        return annotationDocTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
+-        //Not appliable.
++    public Content getSignature(MemberDoc member) {
++        Content pre = new HtmlTree(HtmlTag.PRE);
++        writer.addAnnotationInfo(member, pre);
++        addModifiers(member, pre);
++        Content link = new RawHtml(
++                writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
++                getType(member))));
++        pre.addContent(link);
++        pre.addContent(writer.getSpace());
++        if (configuration().linksource) {
++            Content memberName = new StringContent(member.name());
++            writer.addSrcLink(member, memberName, pre);
++        } else {
++            addName(member.name(), pre);
++        }
++        return pre;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeHeader(ClassDoc classDoc, String header) {
+-        writer.println();
+-        writer.println("<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->");
+-        writer.println();
+-        writer.anchor("annotation_type_element_detail");
+-        writer.printTableHeadingBackground(header);
+-        writer.println();
++    public void addDeprecated(MemberDoc member, Content annotationDocTree) {
++        addDeprecatedInfo(member, annotationDocTree);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeMemberHeader(MemberDoc member, boolean isFirst) {
+-        if (! isFirst) {
+-            writer.printMemberHeader();
+-            writer.println("");
+-        }
+-        writer.anchor(member.name() + ((ExecutableMemberDoc) member).signature());
+-        writer.h3();
+-        writer.print(member.name());
+-        writer.h3End();
++    public void addComments(MemberDoc member, Content annotationDocTree) {
++        addComment(member, annotationDocTree);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeSignature(MemberDoc member) {
+-        writer.pre();
+-        writer.writeAnnotationInfo(member);
+-        printModifiers(member);
+-        writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+-            getType(member)));
+-        print(' ');
+-        if (configuration().linksource) {
+-            writer.printSrcLink(member, member.name());
+-        } else {
+-            strong(member.name());
+-        }
+-        writer.preEnd();
+-        assert !writer.getMemberDetailsListPrinted();
++    public void addTags(MemberDoc member, Content annotationDocTree) {
++        writer.addTagsInfo(member, annotationDocTree);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeComments(MemberDoc member) {
+-        printComment(member);
++    public Content getAnnotationDetails(Content annotationDetailsTree) {
++        return getMemberTree(annotationDetailsTree);
+     }
+ 
+     /**
+-     * Write the tag output for the given member.
+-     *
+-     * @param member the member being documented.
++     * {@inheritDoc}
+      */
+-    public void writeTags(MemberDoc member) {
+-        writer.printTags(member);
+-    }
+-
+-    /**
+-     * Write the annotation type member footer.
+-     */
+-    public void writeMemberFooter() {
+-        printMemberFooter();
+-    }
+-
+-    /**
+-     * Write the footer for the annotation type member documentation.
+-     *
+-     * @param classDoc the class that the annotation type member belong to.
+-     */
+-    public void writeFooter(ClassDoc classDoc) {
+-        //No footer to write for annotation type member documentation
++    public Content getAnnotationDoc(Content annotationDocTree,
++            boolean isLastContent) {
++        return getMemberTree(annotationDocTree, isLastContent);
+     }
+ 
+     /**
+@@ -179,113 +160,120 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void printSummaryLabel() {
+-        writer.printText("doclet.Annotation_Type_Required_Member_Summary");
++    public void addSummaryLabel(Content memberTree) {
++        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
++                writer.getResource("doclet.Annotation_Type_Required_Member_Summary"));
++        memberTree.addContent(label);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void printTableSummary() {
+-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++    public String getTableSummary() {
++        return configuration().getText("doclet.Member_Table_Summary",
+                 configuration().getText("doclet.Annotation_Type_Required_Member_Summary"),
+-                configuration().getText("doclet.annotation_type_required_members")));
++                configuration().getText("doclet.annotation_type_required_members"));
+     }
+ 
+-    public void printSummaryTableHeader(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    public String getCaption() {
++        return configuration().getText("doclet.Annotation_Type_Required_Members");
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String[] getSummaryTableHeader(ProgramElementDoc member) {
+         String[] header = new String[] {
+             writer.getModifierTypeHeader(),
+             configuration().getText("doclet.0_and_1",
+                     configuration().getText("doclet.Annotation_Type_Required_Member"),
+                     configuration().getText("doclet.Description"))
+         };
+-        writer.summaryTableHeader(header, "col");
++        return header;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void printSummaryAnchor(ClassDoc cd) {
+-        writer.anchor("annotation_type_required_element_summary");
++    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
++        memberTree.addContent(writer.getMarkerAnchor(
++                "annotation_type_required_element_summary"));
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void printInheritedSummaryAnchor(ClassDoc cd) {
+-    }   // no such
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+-    public void printInheritedSummaryLabel(ClassDoc cd) {
+-        // no such
++    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
+-        writer.strong();
+-        writer.printDocLink(context, (MemberDoc) member, member.name(), false);
+-        writer.strongEnd();
++    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    protected void writeInheritedSummaryLink(ClassDoc cd,
+-            ProgramElementDoc member) {
++    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
++            Content tdSummary) {
++        Content strong = HtmlTree.STRONG(new RawHtml(
++                writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
++        Content code = HtmlTree.CODE(strong);
++        tdSummary.addContent(code);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    protected void addInheritedSummaryLink(ClassDoc cd,
++            ProgramElementDoc member, Content linksTree) {
+         //Not applicable.
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    protected void printSummaryType(ProgramElementDoc member) {
++    protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
+         MemberDoc m = (MemberDoc)member;
+-        printModifierAndType(m, getType(m));
++        addModifierAndType(m, getType(m), tdSummaryType);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    protected void writeDeprecatedLink(ProgramElementDoc member) {
+-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+-            (MemberDoc) member, ((MemberDoc)member).qualifiedName(), false);
++    protected Content getDeprecatedLink(ProgramElementDoc member) {
++        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
++                (MemberDoc) member, ((MemberDoc)member).qualifiedName());
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
++    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
+         if (link) {
+-            writer.printHyperLink("", "annotation_type_required_element_summary",
+-                    configuration().getText("doclet.navAnnotationTypeRequiredMember"));
++            return writer.getHyperLink("", "annotation_type_required_element_summary",
++                    writer.getResource("doclet.navAnnotationTypeRequiredMember"));
+         } else {
+-            writer.printText("doclet.navAnnotationTypeRequiredMember");
++            return writer.getResource("doclet.navAnnotationTypeRequiredMember");
+         }
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    protected void printNavDetailLink(boolean link) {
++    protected void addNavDetailLink(boolean link, Content liNav) {
+         if (link) {
+-            writer.printHyperLink("", "annotation_type_element_detail",
+-                configuration().getText("doclet.navAnnotationTypeMember"));
++            liNav.addContent(writer.getHyperLink("", "annotation_type_element_detail",
++                    writer.getResource("doclet.navAnnotationTypeMember")));
+         } else {
+-            writer.printText("doclet.navAnnotationTypeMember");
++            liNav.addContent(writer.getResource("doclet.navAnnotationTypeMember"));
+         }
+     }
+ 
+-    /**
+-     * {@inheritDoc}
+-     */
+-    public void writeDeprecated(MemberDoc member) {
+-        printDeprecated(member);
+-    }
+-
+     private Type getType(MemberDoc member) {
+         if (member instanceof FieldDoc) {
+             return ((FieldDoc) member).type();
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/AnnotationTypeWriterImpl.java
+@@ -29,6 +29,7 @@
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.builders.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Generate the Class Information Page.
+@@ -40,6 +41,7 @@
+  *
+  * @author Atul M Dambalkar
+  * @author Robert Field
++ * @author Bhavesh Patel (Modified)
+  */
+ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter
+         implements AnnotationTypeWriter {
+@@ -69,126 +71,168 @@
+     }
+ 
+     /**
+-     * Print this package link
++     * Get this package link.
++     *
++     * @return a content tree for the package link
+      */
+-    protected void navLinkPackage() {
+-        navCellStart();
+-        printHyperLink("package-summary.html", "",
+-            configuration.getText("doclet.Package"), true, "NavBarFont1");
+-        navCellEnd();
++    protected Content getNavLinkPackage() {
++        Content linkContent = getHyperLink("package-summary.html", "",
++                packageLabel);
++        Content li = HtmlTree.LI(linkContent);
++        return li;
+     }
+ 
+     /**
+-     * Print class page indicator
++     * Get the class link.
++     *
++     * @return a content tree for the class link
+      */
+-    protected void navLinkClass() {
+-        navCellRevStart();
+-        fontStyle("NavBarFont1Rev");
+-        strongText("doclet.Class");
+-        fontEnd();
+-        navCellEnd();
++    protected Content getNavLinkClass() {
++        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
++        return li;
+     }
+ 
+     /**
+-     * Print class use link
++     * Get the class use link.
++     *
++     * @return a content tree for the class use link
+      */
+-    protected void navLinkClassUse() {
+-        navCellStart();
+-        printHyperLink("class-use/" + filename, "",
+-                       configuration.getText("doclet.navClassUse"), true, "NavBarFont1");
+-        navCellEnd();
++    protected Content getNavLinkClassUse() {
++        Content linkContent = getHyperLink("class-use/" + filename, "", useLabel);
++        Content li = HtmlTree.LI(linkContent);
++        return li;
+     }
+ 
+     /**
+-     * Print previous package link
++     * Get link to previous class.
++     *
++     * @return a content tree for the previous class link
+      */
+-    protected void navLinkPrevious() {
+-        if (prev == null) {
+-            printText("doclet.Prev_Class");
+-        } else {
+-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS,
+-                prev.asClassDoc(), "",
+-                configuration.getText("doclet.Prev_Class"), true));
++    public Content getNavLinkPrevious() {
++        Content li;
++        if (prev != null) {
++            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
++                    LinkInfoImpl.CONTEXT_CLASS, prev.asClassDoc(), "",
++                    configuration.getText("doclet.Prev_Class"), true)));
++            li = HtmlTree.LI(prevLink);
+         }
++        else
++            li = HtmlTree.LI(prevclassLabel);
++        return li;
+     }
+ 
+     /**
+-     * Print next package link
++     * Get link to next class.
++     *
++     * @return a content tree for the next class link
+      */
+-    protected void navLinkNext() {
+-        if (next == null) {
+-            printText("doclet.Next_Class");
+-        } else {
+-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS,
+-                next.asClassDoc(), "",
+-                configuration.getText("doclet.Next_Class"), true));
++    public Content getNavLinkNext() {
++        Content li;
++        if (next != null) {
++            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
++                    LinkInfoImpl.CONTEXT_CLASS, next.asClassDoc(), "",
++                    configuration.getText("doclet.Next_Class"), true)));
++            li = HtmlTree.LI(nextLink);
+         }
++        else
++            li = HtmlTree.LI(nextclassLabel);
++        return li;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeHeader(String header) {
+-
++    public Content getHeader(String header) {
+         String pkgname = (annotationType.containingPackage() != null)?
+             annotationType.containingPackage().name(): "";
+         String clname = annotationType.name();
+-
+-        printHtmlHeader(clname,
+-            configuration.metakeywords.getMetaKeywords(annotationType), true);
+-        printTop();
+-        navLinks(true);
+-        hr();
+-        println("<!-- ======== START OF CLASS DATA ======== -->");
+-        h2();
++        Content bodyTree = getBody(true, getWindowTitle(clname));
++        addTop(bodyTree);
++        addNavLinks(true, bodyTree);
++        bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
++        HtmlTree div = new HtmlTree(HtmlTag.DIV);
++        div.addStyle(HtmlStyle.header);
+         if (pkgname.length() > 0) {
+-            font("-1"); print(pkgname); fontEnd(); br();
++            Content pkgNameContent = new StringContent(pkgname);
++            Content pkgNamePara = HtmlTree.P(HtmlStyle.subTitle, pkgNameContent);
++            div.addContent(pkgNamePara);
+         }
+-        print(header + getTypeParameterLinks(new LinkInfoImpl(
+-            LinkInfoImpl.CONTEXT_CLASS_HEADER,
+-            annotationType, false)));
+-        h2End();
++        LinkInfoImpl linkInfo = new LinkInfoImpl(
++                LinkInfoImpl.CONTEXT_CLASS_HEADER, annotationType, false);
++        Content headerContent = new StringContent(header);
++        Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
++                HtmlStyle.title, headerContent);
++        heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo)));
++        div.addContent(heading);
++        bodyTree.addContent(div);
++        return bodyTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeFooter() {
+-        println("<!-- ========= END OF CLASS DATA ========= -->");
+-        hr();
+-        navLinks(false);
+-        printBottom();
+-        printBodyHtmlEnd();
++    public Content getAnnotationContentHeader() {
++        return getContentHeader();
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeAnnotationTypeSignature(String modifiers) {
+-        preNoNewLine();
+-        writeAnnotationInfo(annotationType);
+-        print(modifiers);
+-        String name = annotationType.name() +
+-            getTypeParameterLinks(new LinkInfoImpl(
+-                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false));
+-        if (configuration().linksource) {
+-            printSrcLink(annotationType, name);
+-        } else {
+-            strong(name);
+-        }
+-        preEnd();
+-        p();
++    public void addFooter(Content contentTree) {
++        contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
++        addNavLinks(false, contentTree);
++        addBottom(contentTree);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeAnnotationTypeDescription() {
++    public void printDocument(Content contentTree) {
++        printHtmlDocument(configuration.metakeywords.getMetaKeywords(annotationType),
++                true, contentTree);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public Content getAnnotationInfoTreeHeader() {
++        return getMemberTreeHeader();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public Content getAnnotationInfo(Content annotationInfoTree) {
++        return getMemberTree(HtmlStyle.description, annotationInfoTree);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree) {
++        annotationInfoTree.addContent(new HtmlTree(HtmlTag.BR));
++        Content pre = new HtmlTree(HtmlTag.PRE);
++        addAnnotationInfo(annotationType, pre);
++        pre.addContent(modifiers);
++        LinkInfoImpl linkInfo = new LinkInfoImpl(
++                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, annotationType, false);
++        Content name = new RawHtml (annotationType.name() +
++                getTypeParameterLinks(linkInfo));
++        if (configuration().linksource) {
++            addSrcLink(annotationType, name, pre);
++        } else {
++            pre.addContent(HtmlTree.STRONG(name));
++        }
++        annotationInfoTree.addContent(pre);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void addAnnotationTypeDescription(Content annotationInfoTree) {
+         if(!configuration.nocomment) {
+-            // generate documentation for the class.
+             if (annotationType.inlineTags().length > 0) {
+-                printInlineComment(annotationType);
+-                p();
++                addInlineComment(annotationType, annotationInfoTree);
+             }
+         }
+     }
+@@ -196,148 +240,152 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeAnnotationTypeTagInfo() {
+-        boolean needHr = annotationType.elements().length > 0;
++    public void addAnnotationTypeTagInfo(Content annotationInfoTree) {
+         if(!configuration.nocomment) {
+-            // Print Information about all the tags here
+-            printTags(annotationType);
+-            if (needHr) {
+-                hr();
+-            }
+-            p();
+-        } else if (needHr) {
+-            hr();
++            addTagsInfo(annotationType, annotationInfoTree);
+         }
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeAnnotationTypeDeprecationInfo() {
+-        hr();
++    public void addAnnotationTypeDeprecationInfo(Content annotationInfoTree) {
++        Content hr = new HtmlTree(HtmlTag.HR);
++        annotationInfoTree.addContent(hr);
+         Tag[] deprs = annotationType.tags("deprecated");
+         if (Util.isDeprecated(annotationType)) {
+-            strongText("doclet.Deprecated");
++            Content strong = HtmlTree.STRONG(deprecatedPhrase);
++            Content div = HtmlTree.DIV(HtmlStyle.block, strong);
+             if (deprs.length > 0) {
+                 Tag[] commentTags = deprs[0].inlineTags();
+                 if (commentTags.length > 0) {
+-
+-                    space();
+-                    printInlineDeprecatedComment(annotationType, deprs[0]);
++                    div.addContent(getSpace());
++                    addInlineDeprecatedComment(annotationType, deprs[0], div);
+                 }
+             }
+-            p();
++            annotationInfoTree.addContent(div);
+         }
+     }
+ 
+-    protected void navLinkTree() {
+-        navCellStart();
+-        printHyperLink("package-tree.html", "",
+-            configuration.getText("doclet.Tree"), true, "NavBarFont1");
+-        navCellEnd();
++    /**
++     * {@inheritDoc}
++     */
++    public void addAnnotationDetailsMarker(Content memberDetails) {
++        memberDetails.addContent(HtmlConstants.START_OF_ANNOTATION_TYPE_DETAILS);
+     }
+ 
+-    protected void printSummaryDetailLinks() {
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getNavLinkTree() {
++        Content treeLinkContent = getHyperLink("package-tree.html",
++                "", treeLabel, "", "");
++        Content li = HtmlTree.LI(treeLinkContent);
++        return li;
++    }
++
++    /**
++     * Add summary details to the navigation bar.
++     *
++     * @param subDiv the content tree to which the summary detail links will be added
++     */
++    protected void addSummaryDetailLinks(Content subDiv) {
+         try {
+-            tr();
+-            tdVAlignClass("top", "NavBarCell3");
+-            font("-2");
+-            print("  ");
+-            navSummaryLinks();
+-            fontEnd();
+-            tdEnd();
+-
+-            tdVAlignClass("top", "NavBarCell3");
+-            font("-2");
+-            navDetailLinks();
+-            fontEnd();
+-            tdEnd();
+-            trEnd();
++            Content div = HtmlTree.DIV(getNavSummaryLinks());
++            div.addContent(getNavDetailLinks());
++            subDiv.addContent(div);
+         } catch (Exception e) {
+             e.printStackTrace();
+             throw new DocletAbortException();
+         }
+     }
+ 
+-    protected void navSummaryLinks() throws Exception {
+-        printText("doclet.Summary");
+-        space();
++    /**
++     * Get summary links for navigation bar.
++     *
++     * @return the content tree for the navigation summary links
++     */
++    protected Content getNavSummaryLinks() throws Exception {
++        Content li = HtmlTree.LI(summaryLabel);
++        li.addContent(getSpace());
++        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
+         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
+-            configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+-        writeNavSummaryLink(memberSummaryBuilder,
+-            "doclet.navAnnotationTypeRequiredMember",
+-            VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED);
+-        navGap();
+-        writeNavSummaryLink(memberSummaryBuilder,
+-            "doclet.navAnnotationTypeOptionalMember",
+-            VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL);
++                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
++        Content liNavReq = new HtmlTree(HtmlTag.LI);
++        addNavSummaryLink(memberSummaryBuilder,
++                "doclet.navAnnotationTypeRequiredMember",
++                VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED, liNavReq);
++        addNavGap(liNavReq);
++        ulNav.addContent(liNavReq);
++        Content liNavOpt = new HtmlTree(HtmlTag.LI);
++        addNavSummaryLink(memberSummaryBuilder,
++                "doclet.navAnnotationTypeOptionalMember",
++                VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, liNavOpt);
++        ulNav.addContent(liNavOpt);
++        return ulNav;
+     }
+ 
+-    private void writeNavSummaryLink(MemberSummaryBuilder builder,
+-            String label, int type) {
++    /**
++     * Add the navigation summary link.
++     *
++     * @param builder builder for the member to be documented
++     * @param label the label for the navigation
++     * @param type type to be documented
++     * @param liNav the content tree to which the navigation summary link will be added
++     */
++    protected void addNavSummaryLink(MemberSummaryBuilder builder,
++            String label, int type, Content liNav) {
+         AbstractMemberWriter writer = ((AbstractMemberWriter) builder.
+-            getMemberSummaryWriter(type));
++                getMemberSummaryWriter(type));
+         if (writer == null) {
+-              printText(label);
++            liNav.addContent(getResource(label));
+         } else {
+-            writer.printNavSummaryLink(null,
+-                ! builder.getVisibleMemberMap(type).noVisibleMembers());
++            liNav.addContent(writer.getNavSummaryLink(null,
++                    ! builder.getVisibleMemberMap(type).noVisibleMembers()));
+         }
+     }
+ 
+     /**
+-     * Method navDetailLinks
++     * Get detail links for the navigation bar.
+      *
+-     * @throws   Exception
+-     *
++     * @return the content tree for the detail links
+      */
+-    protected void navDetailLinks() throws Exception {
+-        printText("doclet.Detail");
+-        space();
++    protected Content getNavDetailLinks() throws Exception {
++        Content li = HtmlTree.LI(detailLabel);
++        li.addContent(getSpace());
++        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
+         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
+-            configuration.getBuilderFactory().getMemberSummaryBuilder(this);
++                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+         AbstractMemberWriter writerOptional =
+-            ((AbstractMemberWriter) memberSummaryBuilder.
++                ((AbstractMemberWriter) memberSummaryBuilder.
+                 getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL));
+         AbstractMemberWriter writerRequired =
+-            ((AbstractMemberWriter) memberSummaryBuilder.
++                ((AbstractMemberWriter) memberSummaryBuilder.
+                 getMemberSummaryWriter(VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED));
+         if (writerOptional != null){
+-            writerOptional.printNavDetailLink(annotationType.elements().length > 0);
++            Content liNavOpt = new HtmlTree(HtmlTag.LI);
++            writerOptional.addNavDetailLink(annotationType.elements().length > 0, liNavOpt);
++            ulNav.addContent(liNavOpt);
+         } else if (writerRequired != null){
+-            writerRequired.printNavDetailLink(annotationType.elements().length > 0);
++            Content liNavReq = new HtmlTree(HtmlTag.LI);
++            writerRequired.addNavDetailLink(annotationType.elements().length > 0, liNavReq);
++            ulNav.addContent(liNavReq);
+         } else {
+-            printText("doclet.navAnnotationTypeMember");
++            Content liNav = HtmlTree.LI(getResource("doclet.navAnnotationTypeMember"));
++            ulNav.addContent(liNav);
+         }
+-    }
+-
+-    protected void navGap() {
+-        space();
+-        print('|');
+-        space();
++        return ulNav;
+     }
+ 
+     /**
+-     * If this is an inner class or interface, write the enclosing class or
+-     * interface.
++     * Add gap between navigation bar elements.
++     *
++     * @param liNav the content tree to which the gap will be added
+      */
+-    public void writeNestedClassInfo() {
+-        ClassDoc outerClass = annotationType.containingClass();
+-        if (outerClass != null) {
+-            dl();
+-            dt();
+-            if (annotationType.isInterface()) {
+-                strongText("doclet.Enclosing_Interface");
+-            } else {
+-                strongText("doclet.Enclosing_Class");
+-            }
+-            dtEnd();
+-            dd();
+-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
+-                false));
+-            ddEnd();
+-            dlEnd();
+-        }
++    protected void addNavGap(Content liNav) {
++        liNav.addContent(getSpace());
++        liNav.addContent("|");
++        liNav.addContent(getSpace());
+     }
+ 
+     /**
+@@ -346,11 +394,4 @@
+     public AnnotationTypeDoc getAnnotationTypeDoc() {
+         return annotationType;
+     }
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+-    public void completeMemberSummaryBuild() {
+-        p();
+-    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+@@ -25,10 +25,12 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
+-import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+ import java.io.*;
+ import java.util.*;
++import com.sun.javadoc.*;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+  * Generate class usage information.
+@@ -207,257 +209,301 @@
+     }
+ 
+     /**
+-     * Print the class use list.
++     * Generate the class use list.
+      */
+     protected void generateClassUseFile() throws IOException {
+-
+-        printClassUseHeader();
+-
++        Content body = getClassUseHeader();
++        HtmlTree div = new HtmlTree(HtmlTag.DIV);
++        div.addStyle(HtmlStyle.classUseContainer);
+         if (pkgSet.size() > 0) {
+-            generateClassUse();
++            addClassUse(div);
+         } else {
+-            printText("doclet.ClassUse_No.usage.of.0",
+-                      classdoc.qualifiedName());
+-            p();
++            div.addContent(getResource("doclet.ClassUse_No.usage.of.0",
++                    classdoc.qualifiedName()));
+         }
+-
+-        printClassUseFooter();
+-    }
+-
+-    protected void generateClassUse() throws IOException {
+-        if (configuration.packages.length > 1) {
+-            generatePackageList();
+-            generatePackageAnnotationList();
+-        }
+-        generateClassList();
+-    }
+-
+-    protected void generatePackageList() throws IOException {
+-        tableIndexSummary(useTableSummary);
+-        tableCaptionStart();
+-        printText("doclet.ClassUse_Packages.that.use.0",
+-            getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
+-                false)));
+-        tableCaptionEnd();
+-        summaryTableHeader(packageTableHeader, "col");
+-
+-        for (Iterator it = pkgSet.iterator(); it.hasNext();) {
+-            PackageDoc pkg = (PackageDoc)it.next();
+-            generatePackageUse(pkg);
+-        }
+-        tableEnd();
+-        space();
+-        p();
+-    }
+-
+-    protected void generatePackageAnnotationList() throws IOException {
+-        if ((! classdoc.isAnnotationType()) ||
+-               pkgToPackageAnnotations == null ||
+-               pkgToPackageAnnotations.size() == 0)
+-            return;
+-        tableIndexSummary(useTableSummary);
+-        tableCaptionStart();
+-        printText("doclet.ClassUse_PackageAnnotation",
+-            getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
+-                false)));
+-        tableCaptionEnd();
+-        summaryTableHeader(packageTableHeader, "col");
+-        for (Iterator it = pkgToPackageAnnotations.iterator(); it.hasNext();) {
+-            PackageDoc pkg = (PackageDoc)it.next();
+-            trBgcolorStyle("white", "TableRowColor");
+-            summaryRow(0);
+-            //Just want an anchor here.
+-            printPackageLink(pkg, pkg.name(), true);
+-            summaryRowEnd();
+-            summaryRow(0);
+-            printSummaryComment(pkg);
+-            space();
+-            summaryRowEnd();
+-            trEnd();
+-        }
+-        tableEnd();
+-        space();
+-        p();
+-    }
+-
+-    protected void generateClassList() throws IOException {
+-        for (Iterator it = pkgSet.iterator(); it.hasNext();) {
+-            PackageDoc pkg = (PackageDoc)it.next();
+-            anchor(pkg.name());
+-            tableIndexSummary();
+-            tableHeaderStart("#CCCCFF");
+-            printText("doclet.ClassUse_Uses.of.0.in.1",
+-                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER,
+-                    classdoc, false)),
+-                getPackageLink(pkg, Util.getPackageName(pkg), false));
+-            tableHeaderEnd();
+-            tableEnd();
+-            space();
+-            p();
+-            generateClassUse(pkg);
+-        }
++        body.addContent(div);
++        addNavLinks(false, body);
++        addBottom(body);
++        printHtmlDocument(null, true, body);
+     }
+ 
+     /**
+-     * Print the package use list.
++     * Add the class use documentation.
++     *
++     * @param contentTree the content tree to which the class use information will be added
+      */
+-    protected void generatePackageUse(PackageDoc pkg) throws IOException {
+-        trBgcolorStyle("white", "TableRowColor");
+-        summaryRow(0);
+-        //Just want an anchor here.
+-        printHyperLink("", pkg.name(), Util.getPackageName(pkg), true);
+-        summaryRowEnd();
+-        summaryRow(0);
+-        printSummaryComment(pkg);
+-        space();
+-        summaryRowEnd();
+-        trEnd();
++    protected void addClassUse(Content contentTree) throws IOException {
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
++        if (configuration.packages.length > 1) {
++            addPackageList(ul);
++            addPackageAnnotationList(ul);
++        }
++        addClassList(ul);
++        contentTree.addContent(ul);
+     }
+ 
+     /**
+-     * Print the class use list.
++     * Add the packages list that use the given class.
++     *
++     * @param contentTree the content tree to which the packages list will be added
+      */
+-    protected void generateClassUse(PackageDoc pkg) throws IOException {
+-        String classLink = getLink(new LinkInfoImpl(
+-            LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false));
+-        String pkgLink = getPackageLink(pkg, Util.getPackageName(pkg), false);
+-        classSubWriter.printUseInfo(pkgToClassAnnotations.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_Annotation", classLink,
+-                pkgLink), classUseTableSummary);
+-        classSubWriter.printUseInfo(pkgToClassTypeParameter.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_TypeParameter", classLink,
+-                pkgLink), classUseTableSummary);
+-        classSubWriter.printUseInfo(pkgToSubclass.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_Subclass", classLink,
+-                pkgLink), subclassUseTableSummary);
+-        classSubWriter.printUseInfo(pkgToSubinterface.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_Subinterface", classLink,
+-                pkgLink), subinterfaceUseTableSummary);
+-        classSubWriter.printUseInfo(pkgToImplementingClass.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_ImplementingClass", classLink,
+-                pkgLink), classUseTableSummary);
+-        fieldSubWriter.printUseInfo(pkgToField.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_Field", classLink,
+-                pkgLink), fieldUseTableSummary);
+-        fieldSubWriter.printUseInfo(pkgToFieldAnnotations.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_FieldAnnotations", classLink,
+-                pkgLink), fieldUseTableSummary);
+-        fieldSubWriter.printUseInfo(pkgToFieldTypeParameter.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_FieldTypeParameter", classLink,
+-                pkgLink), fieldUseTableSummary);
+-        methodSubWriter.printUseInfo(pkgToMethodAnnotations.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_MethodAnnotations", classLink,
+-                pkgLink), methodUseTableSummary);
+-        methodSubWriter.printUseInfo(pkgToMethodParameterAnnotations.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_MethodParameterAnnotations", classLink,
+-                pkgLink), methodUseTableSummary);
+-        methodSubWriter.printUseInfo(pkgToMethodTypeParameter.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_MethodTypeParameter", classLink,
+-                pkgLink), methodUseTableSummary);
+-        methodSubWriter.printUseInfo(pkgToMethodReturn.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_MethodReturn", classLink,
+-                pkgLink), methodUseTableSummary);
+-        methodSubWriter.printUseInfo(pkgToMethodReturnTypeParameter.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_MethodReturnTypeParameter", classLink,
+-                pkgLink), methodUseTableSummary);
+-        methodSubWriter.printUseInfo(pkgToMethodArgs.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_MethodArgs", classLink,
+-                pkgLink), methodUseTableSummary);
+-        methodSubWriter.printUseInfo(pkgToMethodArgTypeParameter.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_MethodArgsTypeParameters", classLink,
+-                pkgLink), methodUseTableSummary);
+-        methodSubWriter.printUseInfo(pkgToMethodThrows.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_MethodThrows", classLink,
+-                pkgLink), methodUseTableSummary);
+-        constrSubWriter.printUseInfo(pkgToConstructorAnnotations.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_ConstructorAnnotations", classLink,
+-                pkgLink), constructorUseTableSummary);
+-        constrSubWriter.printUseInfo(pkgToConstructorParameterAnnotations.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
+-                pkgLink), constructorUseTableSummary);
+-        constrSubWriter.printUseInfo(pkgToConstructorArgs.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_ConstructorArgs", classLink,
+-                pkgLink), constructorUseTableSummary);
+-        constrSubWriter.printUseInfo(pkgToConstructorArgTypeParameter.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
+-                pkgLink), constructorUseTableSummary);
+-        constrSubWriter.printUseInfo(pkgToConstructorThrows.get(pkg.name()),
+-                configuration.getText("doclet.ClassUse_ConstructorThrows", classLink,
+-                pkgLink), constructorUseTableSummary);
++    protected void addPackageList(Content contentTree) throws IOException {
++        Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
++                getTableCaption(configuration().getText(
++                "doclet.ClassUse_Packages.that.use.0",
++                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
++                false)))));
++        table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
++        Content tbody = new HtmlTree(HtmlTag.TBODY);
++        Iterator<PackageDoc> it = pkgSet.iterator();
++        for (int i = 0; it.hasNext(); i++) {
++            PackageDoc pkg = it.next();
++            HtmlTree tr = new HtmlTree(HtmlTag.TR);
++            if (i % 2 == 0) {
++                tr.addStyle(HtmlStyle.altColor);
++            } else {
++                tr.addStyle(HtmlStyle.rowColor);
++            }
++            addPackageUse(pkg, tr);
++            tbody.addContent(tr);
++        }
++        table.addContent(tbody);
++        Content li = HtmlTree.LI(HtmlStyle.blockList, table);
++        contentTree.addContent(li);
+     }
+ 
+     /**
+-     * Print the header for the class use Listing.
++     * Add the package annotation list.
++     *
++     * @param contentTree the content tree to which the package annotation list will be added
+      */
+-    protected void printClassUseHeader() {
+-        String cltype = configuration.getText(classdoc.isInterface()?
+-                                    "doclet.Interface":
+-                                    "doclet.Class");
+-        String clname = classdoc.qualifiedName();
+-        printHtmlHeader(configuration.getText("doclet.Window_ClassUse_Header",
+-                            cltype, clname), null, true);
+-        printTop();
+-        navLinks(true);
+-        hr();
+-        center();
+-        h2();
+-        strongText("doclet.ClassUse_Title", cltype, clname);
+-        h2End();
+-        centerEnd();
++    protected void addPackageAnnotationList(Content contentTree) throws IOException {
++        if ((!classdoc.isAnnotationType()) ||
++                pkgToPackageAnnotations == null ||
++                pkgToPackageAnnotations.size() == 0) {
++            return;
++        }
++        Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
++                getTableCaption(configuration().getText(
++                "doclet.ClassUse_PackageAnnotation",
++                getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc,
++                false)))));
++        table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
++        Content tbody = new HtmlTree(HtmlTag.TBODY);
++        Iterator<PackageDoc> it = pkgToPackageAnnotations.iterator();
++        for (int i = 0; it.hasNext(); i++) {
++            PackageDoc pkg = it.next();
++            HtmlTree tr = new HtmlTree(HtmlTag.TR);
++            if (i % 2 == 0) {
++                tr.addStyle(HtmlStyle.altColor);
++            } else {
++                tr.addStyle(HtmlStyle.rowColor);
++            }
++            Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
++                    getPackageLink(pkg, new StringContent(pkg.name())));
++            tr.addContent(tdFirst);
++            HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
++            tdLast.addStyle(HtmlStyle.colLast);
++            if (pkg != null) {
++                addSummaryComment(pkg, tdLast);
++            } else {
++                tdLast.addContent(getSpace());
++            }
++            tr.addContent(tdLast);
++            tbody.addContent(tr);
++        }
++        table.addContent(tbody);
++        Content li = HtmlTree.LI(HtmlStyle.blockList, table);
++        contentTree.addContent(li);
+     }
+ 
+     /**
+-     * Print the footer for the class use Listing.
++     * Add the class list that use the given class.
++     *
++     * @param contentTree the content tree to which the class list will be added
+      */
+-    protected void printClassUseFooter() {
+-        hr();
+-        navLinks(false);
+-        printBottom();
+-        printBodyHtmlEnd();
+-    }
+-
+-
+-    /**
+-     * Print this package link
+-     */
+-    protected void navLinkPackage() {
+-        navCellStart();
+-        printHyperLink("../package-summary.html", "",
+-                       configuration.getText("doclet.Package"), true, "NavBarFont1");
+-        navCellEnd();
++    protected void addClassList(Content contentTree) throws IOException {
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
++        for (Iterator<PackageDoc> it = pkgSet.iterator(); it.hasNext();) {
++            PackageDoc pkg = it.next();
++            Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name()));
++            Content link = new RawHtml(
++                    configuration.getText("doclet.ClassUse_Uses.of.0.in.1",
++                    getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER,
++                    classdoc, false)),
++                    getPackageLinkString(pkg, Util.getPackageName(pkg), false)));
++            Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link);
++            li.addContent(heading);
++            addClassUse(pkg, li);
++            ul.addContent(li);
++        }
++        Content li = HtmlTree.LI(HtmlStyle.blockList, ul);
++        contentTree.addContent(li);
+     }
+ 
+     /**
+-     * Print class page indicator
++     * Add the package use information.
++     *
++     * @param pkg the package that uses the given class
++     * @param contentTree the content tree to which the package use information will be added
+      */
+-    protected void navLinkClass() {
+-        navCellStart();
+-        printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, "",
+-            configuration.getText("doclet.Class"), true, "NavBarFont1"));
+-        navCellEnd();
++    protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
++        Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
++                getHyperLink("", pkg.name(), new StringContent(Util.getPackageName(pkg))));
++        contentTree.addContent(tdFirst);
++        HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
++        tdLast.addStyle(HtmlStyle.colLast);
++        if (pkg != null)
++            addSummaryComment(pkg, tdLast);
++        else
++            tdLast.addContent(getSpace());
++        contentTree.addContent(tdLast);
+     }
+ 
+     /**
+-     * Print class use link
++     * Add the class use information.
++     *
++     * @param pkg the package that uses the given class
++     * @param contentTree the content tree to which the class use information will be added
+      */
+-    protected void navLinkClassUse() {
+-        navCellRevStart();
+-        fontStyle("NavBarFont1Rev");
+-        strongText("doclet.navClassUse");
+-        fontEnd();
+-        navCellEnd();
++    protected void addClassUse(PackageDoc pkg, Content contentTree) throws IOException {
++        String classLink = getLink(new LinkInfoImpl(
++            LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, false));
++        String pkgLink = getPackageLinkString(pkg, Util.getPackageName(pkg), false);
++        classSubWriter.addUseInfo(pkgToClassAnnotations.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_Annotation", classLink,
++                pkgLink), classUseTableSummary, contentTree);
++        classSubWriter.addUseInfo(pkgToClassTypeParameter.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_TypeParameter", classLink,
++                pkgLink), classUseTableSummary, contentTree);
++        classSubWriter.addUseInfo(pkgToSubclass.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_Subclass", classLink,
++                pkgLink), subclassUseTableSummary, contentTree);
++        classSubWriter.addUseInfo(pkgToSubinterface.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_Subinterface", classLink,
++                pkgLink), subinterfaceUseTableSummary, contentTree);
++        classSubWriter.addUseInfo(pkgToImplementingClass.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_ImplementingClass", classLink,
++                pkgLink), classUseTableSummary, contentTree);
++        fieldSubWriter.addUseInfo(pkgToField.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_Field", classLink,
++                pkgLink), fieldUseTableSummary, contentTree);
++        fieldSubWriter.addUseInfo(pkgToFieldAnnotations.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_FieldAnnotations", classLink,
++                pkgLink), fieldUseTableSummary, contentTree);
++        fieldSubWriter.addUseInfo(pkgToFieldTypeParameter.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_FieldTypeParameter", classLink,
++                pkgLink), fieldUseTableSummary, contentTree);
++        methodSubWriter.addUseInfo(pkgToMethodAnnotations.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_MethodAnnotations", classLink,
++                pkgLink), methodUseTableSummary, contentTree);
++        methodSubWriter.addUseInfo(pkgToMethodParameterAnnotations.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_MethodParameterAnnotations", classLink,
++                pkgLink), methodUseTableSummary, contentTree);
++        methodSubWriter.addUseInfo(pkgToMethodTypeParameter.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_MethodTypeParameter", classLink,
++                pkgLink), methodUseTableSummary, contentTree);
++        methodSubWriter.addUseInfo(pkgToMethodReturn.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_MethodReturn", classLink,
++                pkgLink), methodUseTableSummary, contentTree);
++        methodSubWriter.addUseInfo(pkgToMethodReturnTypeParameter.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_MethodReturnTypeParameter", classLink,
++                pkgLink), methodUseTableSummary, contentTree);
++        methodSubWriter.addUseInfo(pkgToMethodArgs.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_MethodArgs", classLink,
++                pkgLink), methodUseTableSummary, contentTree);
++        methodSubWriter.addUseInfo(pkgToMethodArgTypeParameter.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_MethodArgsTypeParameters", classLink,
++                pkgLink), methodUseTableSummary, contentTree);
++        methodSubWriter.addUseInfo(pkgToMethodThrows.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_MethodThrows", classLink,
++                pkgLink), methodUseTableSummary, contentTree);
++        constrSubWriter.addUseInfo(pkgToConstructorAnnotations.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_ConstructorAnnotations", classLink,
++                pkgLink), constructorUseTableSummary, contentTree);
++        constrSubWriter.addUseInfo(pkgToConstructorParameterAnnotations.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_ConstructorParameterAnnotations", classLink,
++                pkgLink), constructorUseTableSummary, contentTree);
++        constrSubWriter.addUseInfo(pkgToConstructorArgs.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_ConstructorArgs", classLink,
++                pkgLink), constructorUseTableSummary, contentTree);
++        constrSubWriter.addUseInfo(pkgToConstructorArgTypeParameter.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_ConstructorArgsTypeParameters", classLink,
++                pkgLink), constructorUseTableSummary, contentTree);
++        constrSubWriter.addUseInfo(pkgToConstructorThrows.get(pkg.name()),
++                configuration.getText("doclet.ClassUse_ConstructorThrows", classLink,
++                pkgLink), constructorUseTableSummary, contentTree);
+     }
+ 
+-    protected void navLinkTree() {
+-        navCellStart();
+-        if (classdoc.containingPackage().isIncluded()) {
+-            printHyperLink("../package-tree.html", "",
+-                configuration.getText("doclet.Tree"), true, "NavBarFont1");
+-        } else {
+-            printHyperLink(relativePath + "overview-tree.html", "",
+-                configuration.getText("doclet.Tree"), true, "NavBarFont1");
+-        }
+-        navCellEnd();
++    /**
++     * Get the header for the class use Listing.
++     *
++     * @return a content tree representing the class use header
++     */
++    protected Content getClassUseHeader() {
++        String cltype = configuration.getText(classdoc.isInterface()?
++            "doclet.Interface":"doclet.Class");
++        String clname = classdoc.qualifiedName();
++        String title = configuration.getText("doclet.Window_ClassUse_Header",
++                cltype, clname);
++        Content bodyTree = getBody(true, getWindowTitle(title));
++        addTop(bodyTree);
++        addNavLinks(true, bodyTree);
++        Content headContent = getResource("doclet.ClassUse_Title", cltype, clname);
++        Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING,
++                true, HtmlStyle.title, headContent);
++        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
++        bodyTree.addContent(div);
++        return bodyTree;
+     }
+ 
++    /**
++     * Get this package link.
++     *
++     * @return a content tree for the package link
++     */
++    protected Content getNavLinkPackage() {
++        Content linkContent = getHyperLink("../package-summary.html", "",
++                packageLabel);
++        Content li = HtmlTree.LI(linkContent);
++        return li;
++    }
++
++    /**
++     * Get class page link.
++     *
++     * @return a content tree for the class page link
++     */
++    protected Content getNavLinkClass() {
++        Content linkContent = new RawHtml(getLink(new LinkInfoImpl(
++                LinkInfoImpl.CONTEXT_CLASS_USE_HEADER, classdoc, "",
++                configuration.getText("doclet.Class"), false)));
++        Content li = HtmlTree.LI(linkContent);
++        return li;
++    }
++
++    /**
++     * Get the use link.
++     *
++     * @return a content tree for the use link
++     */
++    protected Content getNavLinkClassUse() {
++        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
++        return li;
++    }
++
++    /**
++     * Get the tree link.
++     *
++     * @return a content tree for the tree link
++     */
++    protected Content getNavLinkTree() {
++        Content linkContent = classdoc.containingPackage().isIncluded() ?
++            getHyperLink("../package-tree.html", "", treeLabel) :
++            getHyperLink(relativePath + "overview-tree.html", "", treeLabel);
++        Content li = HtmlTree.LI(linkContent);
++        return li;
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+@@ -32,6 +32,7 @@
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.builders.*;
+ import com.sun.tools.doclets.internal.toolkit.taglets.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Generate the Class Information Page.
+@@ -43,6 +44,7 @@
+  *
+  * @author Atul M Dambalkar
+  * @author Robert Field
++ * @author Bhavesh Patel (Modified)
+  */
+ public class ClassWriterImpl extends SubWriterHolderWriter
+         implements ClassWriter {
+@@ -76,124 +78,173 @@
+     }
+ 
+     /**
+-     * Print this package link
++     * Get this package link.
++     *
++     * @return a content tree for the package link
+      */
+-    protected void navLinkPackage() {
+-        navCellStart();
+-        printHyperLink("package-summary.html", "",
+-            configuration.getText("doclet.Package"), true, "NavBarFont1");
+-        navCellEnd();
++    protected Content getNavLinkPackage() {
++        Content linkContent = getHyperLink("package-summary.html", "",
++                packageLabel);
++        Content li = HtmlTree.LI(linkContent);
++        return li;
+     }
+ 
+     /**
+-     * Print class page indicator
++     * Get the class link.
++     *
++     * @return a content tree for the class link
+      */
+-    protected void navLinkClass() {
+-        navCellRevStart();
+-        fontStyle("NavBarFont1Rev");
+-        strongText("doclet.Class");
+-        fontEnd();
+-        navCellEnd();
++    protected Content getNavLinkClass() {
++        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, classLabel);
++        return li;
+     }
+ 
+     /**
+-     * Print class use link
++     * Get the class use link.
++     *
++     * @return a content tree for the class use link
+      */
+-    protected void navLinkClassUse() {
+-        navCellStart();
+-        printHyperLink("class-use/" + filename, "",
+-                       configuration.getText("doclet.navClassUse"), true, "NavBarFont1");
+-        navCellEnd();
++    protected Content getNavLinkClassUse() {
++        Content linkContent = getHyperLink("class-use/" + filename, "", useLabel);
++        Content li = HtmlTree.LI(linkContent);
++        return li;
+     }
+ 
+     /**
+-     * Print previous package link
++     * Get link to previous class.
++     *
++     * @return a content tree for the previous class link
+      */
+-    protected void navLinkPrevious() {
+-        if (prev == null) {
+-            printText("doclet.Prev_Class");
+-        } else {
+-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, prev, "",
+-                configuration.getText("doclet.Prev_Class"), true));
++    public Content getNavLinkPrevious() {
++        Content li;
++        if (prev != null) {
++            Content prevLink = new RawHtml(getLink(new LinkInfoImpl(
++                    LinkInfoImpl.CONTEXT_CLASS, prev, "",
++                    configuration.getText("doclet.Prev_Class"), true)));
++            li = HtmlTree.LI(prevLink);
+         }
++        else
++            li = HtmlTree.LI(prevclassLabel);
++        return li;
+     }
+ 
+     /**
+-     * Print next package link
++     * Get link to next class.
++     *
++     * @return a content tree for the next class link
+      */
+-    protected void navLinkNext() {
+-        if (next == null) {
+-            printText("doclet.Next_Class");
+-        } else {
+-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, next, "",
+-                configuration.getText("doclet.Next_Class"), true));
++    public Content getNavLinkNext() {
++        Content li;
++        if (next != null) {
++            Content nextLink = new RawHtml(getLink(new LinkInfoImpl(
++                    LinkInfoImpl.CONTEXT_CLASS, next, "",
++                    configuration.getText("doclet.Next_Class"), true)));
++            li = HtmlTree.LI(nextLink);
+         }
++        else
++            li = HtmlTree.LI(nextclassLabel);
++        return li;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeHeader(String header) {
++    public Content getHeader(String header) {
+         String pkgname = (classDoc.containingPackage() != null)?
+             classDoc.containingPackage().name(): "";
+         String clname = classDoc.name();
+-        printHtmlHeader(clname,
+-            configuration.metakeywords.getMetaKeywords(classDoc), true);
+-        printTop();
+-        navLinks(true);
+-        hr();
+-        println("<!-- ======== START OF CLASS DATA ======== -->");
+-        h2();
++        Content bodyTree = getBody(true, getWindowTitle(clname));
++        addTop(bodyTree);
++        addNavLinks(true, bodyTree);
++        bodyTree.addContent(HtmlConstants.START_OF_CLASS_DATA);
++        HtmlTree div = new HtmlTree(HtmlTag.DIV);
++        div.addStyle(HtmlStyle.header);
+         if (pkgname.length() > 0) {
+-            font("-1"); print(pkgname); fontEnd(); br();
++            Content pkgNameContent = new StringContent(pkgname);
++            Content pkgNamePara = HtmlTree.P(HtmlStyle.subTitle, pkgNameContent);
++            div.addContent(pkgNamePara);
+         }
+         LinkInfoImpl linkInfo = new LinkInfoImpl( LinkInfoImpl.CONTEXT_CLASS_HEADER,
+-            classDoc, false);
++                classDoc, false);
+         //Let's not link to ourselves in the header.
+         linkInfo.linkToSelf = false;
+-        print(header + getTypeParameterLinks(linkInfo));
+-        h2End();
++        Content headerContent = new StringContent(header);
++        Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true,
++                HtmlStyle.title, headerContent);
++        heading.addContent(new RawHtml(getTypeParameterLinks(linkInfo)));
++        div.addContent(heading);
++        bodyTree.addContent(div);
++        return bodyTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeFooter() {
+-        println("<!-- ========= END OF CLASS DATA ========= -->");
+-        hr();
+-        navLinks(false);
+-        printBottom();
+-        printBodyHtmlEnd();
++    public Content getClassContentHeader() {
++        return getContentHeader();
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeClassSignature(String modifiers) {
++    public void addFooter(Content contentTree) {
++        contentTree.addContent(HtmlConstants.END_OF_CLASS_DATA);
++        addNavLinks(false, contentTree);
++        addBottom(contentTree);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void printDocument(Content contentTree) {
++        printHtmlDocument(configuration.metakeywords.getMetaKeywords(classDoc),
++                true, contentTree);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public Content getClassInfoTreeHeader() {
++        return getMemberTreeHeader();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public Content getClassInfo(Content classInfoTree) {
++        return getMemberTree(HtmlStyle.description, classInfoTree);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void addClassSignature(String modifiers, Content classInfoTree) {
+         boolean isInterface = classDoc.isInterface();
+-        preNoNewLine();
+-        writeAnnotationInfo(classDoc);
+-        print(modifiers);
++        classInfoTree.addContent(new HtmlTree(HtmlTag.BR));
++        Content pre = new HtmlTree(HtmlTag.PRE);
++        addAnnotationInfo(classDoc, pre);
++        pre.addContent(modifiers);
+         LinkInfoImpl linkInfo = new LinkInfoImpl(
+-            LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false);
++                LinkInfoImpl.CONTEXT_CLASS_SIGNATURE, classDoc, false);
+         //Let's not link to ourselves in the signature.
+         linkInfo.linkToSelf = false;
+-        String name = classDoc.name() +
+-            getTypeParameterLinks(linkInfo);
++        Content name = new RawHtml (classDoc.name() +
++                getTypeParameterLinks(linkInfo));
+         if (configuration().linksource) {
+-            printSrcLink(classDoc, name);
++            addSrcLink(classDoc, name, pre);
+         } else {
+-            strong(name);
++            pre.addContent(HtmlTree.STRONG(name));
+         }
+         if (!isInterface) {
+             Type superclass = Util.getFirstVisibleSuperClass(classDoc,
+-                configuration());
++                    configuration());
+             if (superclass != null) {
+-                println();
+-                print("extends ");
+-                printLink(new LinkInfoImpl(
+-                    LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
+-                    superclass));
++                pre.addContent("\n");
++                pre.addContent("extends ");
++                Content link = new RawHtml(getLink(new LinkInfoImpl(
++                        LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
++                        superclass)));
++                pre.addContent(link);
+             }
+         }
+         Type[] implIntfacs = classDoc.interfaceTypes();
+@@ -202,34 +253,33 @@
+             for (int i = 0; i < implIntfacs.length; i++) {
+                 ClassDoc classDoc = implIntfacs[i].asClassDoc();
+                 if (! (classDoc.isPublic() ||
+-                    Util.isLinkable(classDoc, configuration()))) {
++                        Util.isLinkable(classDoc, configuration()))) {
+                     continue;
+                 }
+                 if (counter == 0) {
+-                    println();
+-                    print(isInterface? "extends " : "implements ");
++                    pre.addContent("\n");
++                    pre.addContent(isInterface? "extends " : "implements ");
+                 } else {
+-                    print(", ");
++                    pre.addContent(", ");
+                 }
+-                printLink(new LinkInfoImpl(
+-                    LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
+-                    implIntfacs[i]));
++                Content link = new RawHtml(getLink(new LinkInfoImpl(
++                        LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
++                        implIntfacs[i])));
++                pre.addContent(link);
+                 counter++;
+             }
+         }
+-        preEnd();
+-        p();
++        classInfoTree.addContent(pre);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeClassDescription() {
++    public void addClassDescription(Content classInfoTree) {
+         if(!configuration.nocomment) {
+             // generate documentation for the class.
+             if (classDoc.inlineTags().length > 0) {
+-                printInlineComment(classDoc);
+-                p();
++                addInlineComment(classDoc, classInfoTree);
+             }
+         }
+     }
+@@ -237,131 +287,118 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeClassTagInfo() {
++    public void addClassTagInfo(Content classInfoTree) {
+         if(!configuration.nocomment) {
+             // Print Information about all the tags here
+-            printTags(classDoc);
+-            hr();
+-            p();
++            addTagsInfo(classDoc, classInfoTree);
++        }
++    }
++
++    /**
++     * Get the class hierarchy tree for the given class.
++     *
++     * @param type the class to print the hierarchy for
++     * @return a content tree for class inheritence
++     */
++    private Content getClassInheritenceTree(Type type) {
++        Type sup;
++        HtmlTree classTreeUl = new HtmlTree(HtmlTag.UL);
++        classTreeUl.addStyle(HtmlStyle.inheritance);
++        Content liTree = null;
++        do {
++            sup = Util.getFirstVisibleSuperClass(
++                    type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(),
++                    configuration());
++            if (sup != null) {
++                HtmlTree ul = new HtmlTree(HtmlTag.UL);
++                ul.addStyle(HtmlStyle.inheritance);
++                ul.addContent(getTreeForClassHelper(type));
++                if (liTree != null)
++                    ul.addContent(liTree);
++                Content li = HtmlTree.LI(ul);
++                liTree = li;
++                type = sup;
++            }
++            else
++                classTreeUl.addContent(getTreeForClassHelper(type));
++        }
++        while (sup != null);
++        if (liTree != null)
++            classTreeUl.addContent(liTree);
++        return classTreeUl;
++    }
++
++    /**
++     * Get the class helper tree for the given class.
++     *
++     * @param type the class to print the helper for
++     * @return a content tree for class helper
++     */
++    private Content getTreeForClassHelper(Type type) {
++        Content li = new HtmlTree(HtmlTag.LI);
++        if (type.equals(classDoc)) {
++            String typeParameters = getTypeParameterLinks(
++                    new LinkInfoImpl(LinkInfoImpl.CONTEXT_TREE,
++                    classDoc, false));
++            if (configuration.shouldExcludeQualifier(
++                    classDoc.containingPackage().name())) {
++                li.addContent(type.asClassDoc().name());
++                li.addContent(new RawHtml(typeParameters));
++            } else {
++                li.addContent(type.asClassDoc().qualifiedName());
++                li.addContent(new RawHtml(typeParameters));
++            }
+         } else {
+-            hr();
++            Content link = new RawHtml(getLink(new LinkInfoImpl(
++                    LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT,
++                    type instanceof ClassDoc ? (ClassDoc) type : type,
++                    configuration.getClassName(type.asClassDoc()), false)));
++            li.addContent(link);
++        }
++        return li;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void addClassTree(Content classContentTree) {
++        if (!classDoc.isClass()) {
++            return;
++        }
++        classContentTree.addContent(getClassInheritenceTree(classDoc));
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void addTypeParamInfo(Content classInfoTree) {
++        if (classDoc.typeParamTags().length > 0) {
++            TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc,
++                    getTagletWriterInstance(false));
++            Content typeParam = new RawHtml(output.toString());
++            Content dl = HtmlTree.DL(typeParam);
++            classInfoTree.addContent(dl);
+         }
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeClassDeprecationInfo() {
+-        hr();
+-        Tag[] deprs = classDoc.tags("deprecated");
+-        if (Util.isDeprecated(classDoc)) {
+-            strongText("doclet.Deprecated");
+-            if (deprs.length > 0) {
+-                Tag[] commentTags = deprs[0].inlineTags();
+-                if (commentTags.length > 0) {
+-                    space();
+-                    printInlineDeprecatedComment(classDoc, deprs[0]);
+-                }
+-            }
+-            p();
+-        }
+-    }
+-
+-    /**
+-     * Generate the indent and get the line image for the class tree.
+-     * For user accessibility, the image includes the alt attribute
+-     * "extended by".  (This method is not intended for a class
+-     * implementing an interface, where "implemented by" would be required.)
+-     *
+-     * indent  integer indicating the number of spaces to indent
+-     */
+-    private void writeStep(int indent) {
+-        print(spaces(4 * indent - 2));
+-        print("<IMG SRC=\"" + relativepathNoSlash + "/resources/inherit.gif\" " +
+-              "ALT=\"" + configuration.getText("doclet.extended_by") + " \">");
+-    }
+-
+-    /**
+-     * Print the class hierarchy tree for the given class.
+-     * @param type the class to print the hierarchy for.
+-     * @return return the amount that should be indented in
+-     * the next level of the tree.
+-     */
+-    private int writeTreeForClassHelper(Type type) {
+-        Type sup = Util.getFirstVisibleSuperClass(
+-            type instanceof ClassDoc ? (ClassDoc) type : type.asClassDoc(),
+-            configuration());
+-        int indent = 0;
+-        if (sup != null) {
+-            indent = writeTreeForClassHelper(sup);
+-            writeStep(indent);
+-        }
+-
+-        if (type.equals(classDoc)) {
+-            String typeParameters = getTypeParameterLinks(
+-                new LinkInfoImpl(
+-                    LinkInfoImpl.CONTEXT_TREE,
+-                    classDoc, false));
+-            if (configuration.shouldExcludeQualifier(
+-                    classDoc.containingPackage().name())) {
+-                strong(type.asClassDoc().name() + typeParameters);
+-            } else {
+-                strong(type.asClassDoc().qualifiedName() + typeParameters);
+-            }
+-        } else {
+-            print(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS_TREE_PARENT,
+-                    type instanceof ClassDoc ? (ClassDoc) type : type,
+-                    configuration.getClassName(type.asClassDoc()), false)));
+-        }
+-        println();
+-        return indent + 1;
+-    }
+-
+-    /**
+-     * Print the class hierarchy tree for this class only.
+-     */
+-    public void writeClassTree() {
+-        if (! classDoc.isClass()) {
+-            return;
+-        }
+-        pre();
+-        writeTreeForClassHelper(classDoc);
+-        preEnd();
+-    }
+-
+-    /**
+-     * Write the type parameter information.
+-     */
+-    public void writeTypeParamInfo() {
+-        if (classDoc.typeParamTags().length > 0) {
+-            dl();
+-            dt();
+-            TagletOutput output = (new ParamTaglet()).getTagletOutput(classDoc,
+-                getTagletWriterInstance(false));
+-            print(output.toString());
+-            dtEnd();
+-            dlEnd();
+-        }
+-    }
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+-    public void writeSubClassInfo() {
++    public void addSubClassInfo(Content classInfoTree) {
+         if (classDoc.isClass()) {
+             if (classDoc.qualifiedName().equals("java.lang.Object") ||
+-                classDoc.qualifiedName().equals("org.omg.CORBA.Object")) {
++                    classDoc.qualifiedName().equals("org.omg.CORBA.Object")) {
+                 return;    // Don't generate the list, too huge
+             }
+             List subclasses = classtree.subs(classDoc, false);
+             if (subclasses.size() > 0) {
+-                dl();
+-                dt();
+-                strongText("doclet.Subclasses");
+-                dtEnd();
+-                writeClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES,
+-                    subclasses);
+-                dlEnd();
++                Content label = getResource(
++                        "doclet.Subclasses");
++                Content dt = HtmlTree.DT(label);
++                Content dl = HtmlTree.DL(dt);
++                dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBCLASSES,
++                        subclasses));
++                classInfoTree.addContent(dl);
+             }
+         }
+     }
+@@ -369,140 +406,196 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeSubInterfacesInfo() {
++    public void addSubInterfacesInfo(Content classInfoTree) {
+         if (classDoc.isInterface()) {
+             List subInterfaces = classtree.allSubs(classDoc, false);
+             if (subInterfaces.size() > 0) {
+-                dl();
+-                dt();
+-                strongText("doclet.Subinterfaces");
+-                dtEnd();
+-                writeClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES,
+-                    subInterfaces);
+-                dlEnd();
++                Content label = getResource(
++                        "doclet.Subinterfaces");
++                Content dt = HtmlTree.DT(label);
++                Content dl = HtmlTree.DL(dt);
++                dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUBINTERFACES,
++                        subInterfaces));
++                classInfoTree.addContent(dl);
+             }
+         }
+     }
+ 
+     /**
+-     * If this is the interface which are the classes, that implement this?
+-     */
+-    public void writeInterfaceUsageInfo () {
+-        if (! classDoc.isInterface()) {
+-            return;
+-        }
+-        if (classDoc.qualifiedName().equals("java.lang.Cloneable") ||
+-            classDoc.qualifiedName().equals("java.io.Serializable")) {
+-            return;   // Don't generate the list, too big
+-        }
+-        List implcl = classtree.implementingclasses(classDoc);
+-        if (implcl.size() > 0) {
+-            dl();
+-            dt();
+-            strongText("doclet.Implementing_Classes");
+-            dtEnd();
+-            writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES,
+-                implcl);
+-            dlEnd();
+-        }
+-    }
+-
+-    /**
+      * {@inheritDoc}
+      */
+-    public void writeImplementedInterfacesInfo() {
+-        //NOTE:  we really should be using ClassDoc.interfaceTypes() here, but
+-        //       it doesn't walk up the tree like we want it to.
+-        List interfaceArray = Util.getAllInterfaces(classDoc, configuration);
+-        if (classDoc.isClass() && interfaceArray.size() > 0) {
+-            dl();
+-            dt();
+-            strongText("doclet.All_Implemented_Interfaces");
+-            dtEnd();
+-            writeClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES,
+-                interfaceArray);
+-            dlEnd();
++    public void addInterfaceUsageInfo (Content classInfoTree) {
++        if (! classDoc.isInterface()) {
++            return;
++        }
++        if (classDoc.qualifiedName().equals("java.lang.Cloneable") ||
++                classDoc.qualifiedName().equals("java.io.Serializable")) {
++            return;   // Don't generate the list, too big
++        }
++        List<ClassDoc> implcl = classtree.implementingclasses(classDoc);
++        if (implcl.size() > 0) {
++            Content label = getResource(
++                    "doclet.Implementing_Classes");
++            Content dt = HtmlTree.DT(label);
++            Content dl = HtmlTree.DL(dt);
++            dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_CLASSES,
++                    implcl));
++            classInfoTree.addContent(dl);
+         }
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeSuperInterfacesInfo() {
++    public void addImplementedInterfacesInfo(Content classInfoTree) {
++        //NOTE:  we really should be using ClassDoc.interfaceTypes() here, but
++        //       it doesn't walk up the tree like we want it to.
++        List<Type> interfaceArray = Util.getAllInterfaces(classDoc, configuration);
++        if (classDoc.isClass() && interfaceArray.size() > 0) {
++            Content label = getResource(
++                    "doclet.All_Implemented_Interfaces");
++            Content dt = HtmlTree.DT(label);
++            Content dl = HtmlTree.DL(dt);
++            dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_IMPLEMENTED_INTERFACES,
++                    interfaceArray));
++            classInfoTree.addContent(dl);
++        }
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void addSuperInterfacesInfo(Content classInfoTree) {
+         //NOTE:  we really should be using ClassDoc.interfaceTypes() here, but
+         //       it doesn't walk up the tree like we want it to.
+         List interfaceArray = Util.getAllInterfaces(classDoc, configuration);
+         if (classDoc.isInterface() && interfaceArray.size() > 0) {
+-            dl();
+-            dt();
+-            strongText("doclet.All_Superinterfaces");
+-            dtEnd();
+-            writeClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES,
+-                interfaceArray);
+-            dlEnd();
++            Content label = getResource(
++                    "doclet.All_Superinterfaces");
++            Content dt = HtmlTree.DT(label);
++            Content dl = HtmlTree.DL(dt);
++            dl.addContent(getClassLinks(LinkInfoImpl.CONTEXT_SUPER_INTERFACES,
++                    interfaceArray));
++            classInfoTree.addContent(dl);
+         }
+     }
+ 
+     /**
+-     * Generate links to the given classes.
++     * {@inheritDoc}
+      */
+-    private void writeClassLinks(int context, List list) {
++    public void addNestedClassInfo(Content classInfoTree) {
++        ClassDoc outerClass = classDoc.containingClass();
++        if (outerClass != null) {
++            Content label;
++            if (outerClass.isInterface()) {
++                label = getResource(
++                        "doclet.Enclosing_Interface");
++            } else {
++                label = getResource(
++                        "doclet.Enclosing_Class");
++            }
++            Content dt = HtmlTree.DT(label);
++            Content dl = HtmlTree.DL(dt);
++            Content dd = new HtmlTree(HtmlTag.DD);
++            dd.addContent(new RawHtml(getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
++                    false))));
++            dl.addContent(dd);
++            classInfoTree.addContent(dl);
++        }
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void addClassDeprecationInfo(Content classInfoTree) {
++        Content hr = new HtmlTree(HtmlTag.HR);
++        classInfoTree.addContent(hr);
++        Tag[] deprs = classDoc.tags("deprecated");
++        if (Util.isDeprecated(classDoc)) {
++            Content strong = HtmlTree.STRONG(deprecatedPhrase);
++            Content div = HtmlTree.DIV(HtmlStyle.block, strong);
++            if (deprs.length > 0) {
++                Tag[] commentTags = deprs[0].inlineTags();
++                if (commentTags.length > 0) {
++                    div.addContent(getSpace());
++                    addInlineDeprecatedComment(classDoc, deprs[0], div);
++                }
++            }
++            classInfoTree.addContent(div);
++        }
++    }
++
++    /**
++     * Get links to the given classes.
++     *
++     * @param context the id of the context where the link will be printed
++     * @param list the list of classes
++     * @return a content tree for the class list
++     */
++    private Content getClassLinks(int context, List<?> list) {
+         Object[] typeList = list.toArray();
+-        //Sort the list to be printed.
+-        print(' ');
+-        dd();
++        Content dd = new HtmlTree(HtmlTag.DD);
+         for (int i = 0; i < list.size(); i++) {
+             if (i > 0) {
+-                print(", ");
++                Content separator = new StringContent(", ");
++                dd.addContent(separator);
+             }
+             if (typeList[i] instanceof ClassDoc) {
+-                printLink(new LinkInfoImpl(context, (ClassDoc)(typeList[i])));
+-
++                Content link = new RawHtml(getLink(
++                        new LinkInfoImpl(context, (ClassDoc)(typeList[i]))));
++                dd.addContent(link);
+             } else {
+-                printLink(new LinkInfoImpl(context, (Type)(typeList[i])));
++                Content link = new RawHtml(getLink(
++                        new LinkInfoImpl(context, (Type)(typeList[i]))));
++                dd.addContent(link);
+             }
+         }
+-        ddEnd();
++        return dd;
+     }
+ 
+-    protected void navLinkTree() {
+-        navCellStart();
+-        printHyperLink("package-tree.html", "",
+-            configuration.getText("doclet.Tree"), true, "NavBarFont1");
+-        navCellEnd();
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getNavLinkTree() {
++        Content treeLinkContent = getHyperLink("package-tree.html",
++                "", treeLabel, "", "");
++        Content li = HtmlTree.LI(treeLinkContent);
++        return li;
+     }
+ 
+-    protected void printSummaryDetailLinks() {
++    /**
++     * Add summary details to the navigation bar.
++     *
++     * @param subDiv the content tree to which the summary detail links will be added
++     */
++    protected void addSummaryDetailLinks(Content subDiv) {
+         try {
+-            tr();
+-            tdVAlignClass("top", "NavBarCell3");
+-            font("-2");
+-            print("  ");
+-            navSummaryLinks();
+-            fontEnd();
+-            tdEnd();
+-            tdVAlignClass("top", "NavBarCell3");
+-            font("-2");
+-            navDetailLinks();
+-            fontEnd();
+-            tdEnd();
+-            trEnd();
++            Content div = HtmlTree.DIV(getNavSummaryLinks());
++            div.addContent(getNavDetailLinks());
++            subDiv.addContent(div);
+         } catch (Exception e) {
+             e.printStackTrace();
+             throw new DocletAbortException();
+         }
+     }
+ 
+-    protected void navSummaryLinks() throws Exception {
+-        printText("doclet.Summary");
+-        space();
++    /**
++     * Get summary links for navigation bar.
++     *
++     * @return the content tree for the navigation summary links
++     */
++    protected Content getNavSummaryLinks() throws Exception {
++        Content li = HtmlTree.LI(summaryLabel);
++        li.addContent(getSpace());
++        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
+         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
+-            configuration.getBuilderFactory().getMemberSummaryBuilder(this);
++                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+         String[] navLinkLabels =  new String[] {
+             "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
+-                "doclet.navMethod"
++            "doclet.navMethod"
+         };
+         for (int i = 0; i < navLinkLabels.length; i++ ) {
++            Content liNav = new HtmlTree(HtmlTag.LI);
+             if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
+                 continue;
+             }
+@@ -511,38 +604,41 @@
+             }
+             AbstractMemberWriter writer =
+                 ((AbstractMemberWriter) memberSummaryBuilder.
+-                    getMemberSummaryWriter(i));
++                getMemberSummaryWriter(i));
+             if (writer == null) {
+-                printText(navLinkLabels[i]);
++                liNav.addContent(getResource(navLinkLabels[i]));
+             } else {
+-                writer.navSummaryLink(
+-                    memberSummaryBuilder.members(i),
+-                    memberSummaryBuilder.getVisibleMemberMap(i));
++                writer.addNavSummaryLink(
++                        memberSummaryBuilder.members(i),
++                        memberSummaryBuilder.getVisibleMemberMap(i), liNav);
+             }
+             if (i < navLinkLabels.length-1) {
+-                navGap();
++                addNavGap(liNav);
+             }
++            ulNav.addContent(liNav);
+         }
++        return ulNav;
+     }
+ 
+     /**
+-     * Method navDetailLinks
++     * Get detail links for the navigation bar.
+      *
+-     * @throws   Exception
+-     *
++     * @return the content tree for the detail links
+      */
+-    protected void navDetailLinks() throws Exception {
+-        printText("doclet.Detail");
+-        space();
++    protected Content getNavDetailLinks() throws Exception {
++        Content li = HtmlTree.LI(detailLabel);
++        li.addContent(getSpace());
++        Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
+         MemberSummaryBuilder memberSummaryBuilder = (MemberSummaryBuilder)
+-            configuration.getBuilderFactory().getMemberSummaryBuilder(this);
++                configuration.getBuilderFactory().getMemberSummaryBuilder(this);
+         String[] navLinkLabels =  new String[] {
+             "doclet.navNested", "doclet.navEnum", "doclet.navField", "doclet.navConstructor",
+-                "doclet.navMethod"
++            "doclet.navMethod"
+         };
+         for (int i = 1; i < navLinkLabels.length; i++ ) {
++            Content liNav = new HtmlTree(HtmlTag.LI);
+             AbstractMemberWriter writer =
+-                ((AbstractMemberWriter) memberSummaryBuilder.
++                    ((AbstractMemberWriter) memberSummaryBuilder.
+                     getMemberSummaryWriter(i));
+             if (i == VisibleMemberMap.ENUM_CONSTANTS && ! classDoc.isEnum()) {
+                 continue;
+@@ -551,43 +647,27 @@
+                 continue;
+             }
+             if (writer == null) {
+-                printText(navLinkLabels[i]);
++                liNav.addContent(getResource(navLinkLabels[i]));
+             } else {
+-                writer.navDetailLink(memberSummaryBuilder.members(i));
++                writer.addNavDetailLink(memberSummaryBuilder.members(i), liNav);
+             }
+             if (i < navLinkLabels.length - 1) {
+-                navGap();
++                addNavGap(liNav);
+             }
++            ulNav.addContent(liNav);
+         }
+-    }
+-
+-    protected void navGap() {
+-        space();
+-        print('|');
+-        space();
++        return ulNav;
+     }
+ 
+     /**
+-     * If this is an inner class or interface, write the enclosing class or
+-     * interface.
++     * Add gap between navigation bar elements.
++     *
++     * @param liNav the content tree to which the gap will be added
+      */
+-    public void writeNestedClassInfo() {
+-        ClassDoc outerClass = classDoc.containingClass();
+-        if (outerClass != null) {
+-            dl();
+-            dt();
+-            if (outerClass.isInterface()) {
+-                strongText("doclet.Enclosing_Interface");
+-            } else {
+-                strongText("doclet.Enclosing_Class");
+-            }
+-            dtEnd();
+-            dd();
+-            printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CLASS, outerClass,
+-                false));
+-            ddEnd();
+-            dlEnd();
+-        }
++    protected void addNavGap(Content liNav) {
++        liNav.addContent(getSpace());
++        liNav.addContent("|");
++        liNav.addContent(getSpace());
+     }
+ 
+     /**
+@@ -598,11 +678,4 @@
+     public ClassDoc getClassDoc() {
+         return classDoc;
+     }
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+-    public void completeMemberSummaryBuild() {
+-        p();
+-    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstantsSummaryWriterImpl.java
+@@ -25,11 +25,12 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++import java.util.*;
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+-import java.io.*;
+-import java.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Write the Constants Summary Page in HTML format.
+@@ -76,67 +77,106 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeHeader() {
+-        printHtmlHeader(configuration.getText("doclet.Constants_Summary"),
+-            null, true);
+-        printTop();
+-        navLinks(true);
+-        hr();
+-
+-        center();
+-        h1(); printText("doclet.Constants_Summary"); h1End();
+-        centerEnd();
+-
+-        hr(4, "noshade");
++    public Content getHeader() {
++        String label = configuration.getText("doclet.Constants_Summary");
++        Content bodyTree = getBody(true, getWindowTitle(label));
++        addTop(bodyTree);
++        addNavLinks(true, bodyTree);
++        return bodyTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeFooter() {
+-        hr();
+-        navLinks(false);
+-        printBottom();
+-        printBodyHtmlEnd();
++    public Content getContentsHeader() {
++        return new HtmlTree(HtmlTag.UL);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeContentsHeader() {
+-        strong(configuration.getText("doclet.Contents"));
+-        ul();
++    public void addLinkToPackageContent(PackageDoc pkg, String parsedPackageName,
++            Set<String> printedPackageHeaders, Content contentListTree) {
++        String packageName = pkg.name();
++        //add link to summary
++        Content link;
++        if (packageName.length() == 0) {
++            link = getHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR,
++                    "", defaultPackageLabel, "", "");
++        } else {
++            Content packageNameContent = getPackageLabel(parsedPackageName);
++            packageNameContent.addContent(".*");
++            link = getHyperLink("#" + parsedPackageName,
++                    "", packageNameContent, "", "");
++            printedPackageHeaders.add(parsedPackageName);
++        }
++        contentListTree.addContent(HtmlTree.LI(link));
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeContentsFooter() {
+-        ulEnd();
+-        println();
++    public Content getContentsList(Content contentListTree) {
++        Content titleContent = getResource(
++                "doclet.Constants_Summary");
++        Content pHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
++                HtmlStyle.title, titleContent);
++        Content div = HtmlTree.DIV(HtmlStyle.header, pHeading);
++        Content headingContent = getResource(
++                "doclet.Contents");
++        div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
++                headingContent));
++        div.addContent(contentListTree);
++        return div;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeLinkToPackageContent(PackageDoc pkg, String parsedPackageName, Set printedPackageHeaders) {
+-        String packageName = pkg.name();
+-        //add link to summary
+-        li();
+-        if (packageName.length() == 0) {
+-            printHyperLink("#" + DocletConstants.UNNAMED_PACKAGE_ANCHOR,
+-                           DocletConstants.DEFAULT_PACKAGE_NAME);
+-        } else {
+-            printHyperLink("#" + parsedPackageName, parsedPackageName + ".*");
+-            printedPackageHeaders.add(parsedPackageName);
+-        }
+-        println();
++    public Content getConstantSummaries() {
++        HtmlTree summariesDiv = new HtmlTree(HtmlTag.DIV);
++        summariesDiv.addStyle(HtmlStyle.constantValuesContainer);
++        return summariesDiv;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeConstantMembersHeader(ClassDoc cd) {
++    public void addPackageName(PackageDoc pkg, String parsedPackageName,
++            Content summariesTree) {
++        Content pkgNameContent;
++        if (parsedPackageName.length() == 0) {
++            summariesTree.addContent(getMarkerAnchor(
++                    DocletConstants.UNNAMED_PACKAGE_ANCHOR));
++            pkgNameContent = defaultPackageLabel;
++        } else {
++            summariesTree.addContent(getMarkerAnchor(
++                    parsedPackageName));
++            pkgNameContent = getPackageLabel(parsedPackageName);
++        }
++        Content headingContent = new StringContent(".*");
++        Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
++                pkgNameContent);
++        heading.addContent(headingContent);
++        summariesTree.addContent(heading);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public Content getClassConstantHeader() {
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
++        return ul;
++    }
++
++    /**
++     * Get the table caption and header for the constant summary table
++     *
++     * @param cd classdoc to be documented
++     * @return constant members header content
++     */
++    public Content getConstantMembersHeader(ClassDoc cd) {
+         //generate links backward only to public classes.
+         String classlink = (cd.isPublic() || cd.isProtected())?
+             getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, cd,
+@@ -144,112 +184,120 @@
+             cd.qualifiedName();
+         String name = cd.containingPackage().name();
+         if (name.length() > 0) {
+-            writeClassName(name + "." + classlink);
++            return getClassName(name + "." + classlink);
+         } else {
+-            writeClassName(classlink);
++            return getClassName(classlink);
+         }
+     }
+ 
+     /**
++     * Get the class name in the table caption and the table header.
++     *
++     * @param classStr the class name to print.
++     * @return the table caption and header
++     */
++    protected Content getClassName(String classStr) {
++        Content table = HtmlTree.TABLE(0, 3, 0, constantsTableSummary,
++                getTableCaption(classStr));
++        table.addContent(getSummaryTableHeader(constantsTableHeader, "col"));
++        return table;
++    }
++
++    /**
+      * {@inheritDoc}
+      */
+-    public void writeConstantMembersFooter(ClassDoc cd) {
+-        tableFooter(false);
+-        p();
++    public void addConstantMembers(ClassDoc cd, List<FieldDoc> fields,
++            Content classConstantTree) {
++        currentClassDoc = cd;
++        Content tbody = new HtmlTree(HtmlTag.TBODY);
++        for (int i = 0; i < fields.size(); ++i) {
++            HtmlTree tr = new HtmlTree(HtmlTag.TR);
++            if (i%2 == 0)
++                tr.addStyle(HtmlStyle.altColor);
++            else
++                tr.addStyle(HtmlStyle.rowColor);
++            addConstantMember(fields.get(i), tr);
++            tbody.addContent(tr);
++        }
++        Content table = getConstantMembersHeader(cd);
++        table.addContent(tbody);
++        Content li = HtmlTree.LI(HtmlStyle.blockList, table);
++        classConstantTree.addContent(li);
+     }
+ 
+     /**
+-     * Print the class name in the table heading.
+-     * @param classStr the heading to print.
++     * Add the row for the constant summary table.
++     *
++     * @param member the field to be documented.
++     * @param trTree an htmltree object for the table row
+      */
+-    protected void writeClassName(String classStr) {
+-        table(1, 3, 0, constantsTableSummary);
+-        tableSubCaptionStart();
+-        write(classStr);
+-        tableCaptionEnd();
+-        summaryTableHeader(constantsTableHeader, "col");
++    private void addConstantMember(FieldDoc member, HtmlTree trTree) {
++        trTree.addContent(getTypeColumn(member));
++        trTree.addContent(getNameColumn(member));
++        trTree.addContent(getValue(member));
+     }
+ 
+-    private void tableFooter(boolean isHeader) {
+-        fontEnd();
+-        if (isHeader) {
+-            thEnd();
+-        } else {
+-            tdEnd();
++    /**
++     * Get the type column for the constant summary table row.
++     *
++     * @param member the field to be documented.
++     * @return the type column of the constant table row
++     */
++    private Content getTypeColumn(FieldDoc member) {
++        Content anchor = getMarkerAnchor(currentClassDoc.qualifiedName() +
++                "." + member.name());
++        Content tdType = HtmlTree.TD(HtmlStyle.colFirst, anchor);
++        Content code = new HtmlTree(HtmlTag.CODE);
++        StringTokenizer mods = new StringTokenizer(member.modifiers());
++        while(mods.hasMoreTokens()) {
++            Content modifier = new StringContent(mods.nextToken());
++            code.addContent(modifier);
++            code.addContent(getSpace());
+         }
+-        trEnd();
+-        tableEnd();
+-        p();
++        Content type = new RawHtml(getLink(new LinkInfoImpl(
++                LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member.type())));
++        code.addContent(type);
++        tdType.addContent(code);
++        return tdType;
++    }
++
++    /**
++     * Get the name column for the constant summary table row.
++     *
++     * @param member the field to be documented.
++     * @return the name column of the constant table row
++     */
++    private Content getNameColumn(FieldDoc member) {
++        Content nameContent = new RawHtml(getDocLink(
++                LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member, member.name(), false));
++        Content code = HtmlTree.CODE(nameContent);
++        return HtmlTree.TD(code);
++    }
++
++    /**
++     * Get the value column for the constant summary table row.
++     *
++     * @param member the field to be documented.
++     * @return the value column of the constant table row
++     */
++    private Content getValue(FieldDoc member) {
++        Content valueContent = new StringContent(member.constantValueExpression());
++        Content code = HtmlTree.CODE(valueContent);
++        return HtmlTree.TD(HtmlStyle.colLast, code);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writePackageName(PackageDoc pkg, String parsedPackageName) {
+-        String pkgname;
+-        if (parsedPackageName.length() == 0) {
+-            anchor(DocletConstants.UNNAMED_PACKAGE_ANCHOR);
+-            pkgname = DocletConstants.DEFAULT_PACKAGE_NAME;
+-        } else {
+-            anchor(parsedPackageName);
+-            pkgname = parsedPackageName;
+-        }
+-        table(1, "100%", 3, 0);
+-        trBgcolorStyle("#CCCCFF", "TableHeadingColor");
+-        thAlign("left");
+-        font("+2");
+-        write(pkgname + ".*");
+-        tableFooter(true);
++    public void addFooter(Content contentTree) {
++        addNavLinks(false, contentTree);
++        addBottom(contentTree);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeConstantMembers(ClassDoc cd, List fields) {
+-        currentClassDoc = cd;
+-        for (int i = 0; i < fields.size(); ++i) {
+-            writeConstantMember((FieldDoc)(fields.get(i)));
+-        }
+-    }
+-
+-    private void writeConstantMember(FieldDoc member) {
+-        trBgcolorStyle("white", "TableRowColor");
+-        anchor(currentClassDoc.qualifiedName() + "." + member.name());
+-        writeTypeColumn(member);
+-        writeNameColumn(member);
+-        writeValue(member);
+-        trEnd();
+-    }
+-
+-    private void writeTypeColumn(FieldDoc member) {
+-        tdAlign("right");
+-        font("-1");
+-        code();
+-        StringTokenizer mods = new StringTokenizer(member.modifiers());
+-        while(mods.hasMoreTokens()) {
+-            print(mods.nextToken() + "&nbsp;");
+-        }
+-        printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY,
+-            member.type()));
+-        codeEnd();
+-        fontEnd();
+-        tdEnd();
+-    }
+-
+-    private void writeNameColumn(FieldDoc member) {
+-        tdAlign("left");
+-        code();
+-        printDocLink(LinkInfoImpl.CONTEXT_CONSTANT_SUMMARY, member,
+-            member.name(), false);
+-        codeEnd();
+-        tdEnd();
+-    }
+-
+-    private void writeValue(FieldDoc member) {
+-        tdAlign("right");
+-        code();
+-        print(Util.escapeHtmlChars(member.constantValueExpression()));
+-        codeEnd();
+-        tdEnd();
++    public void printDocument(Content contentTree) {
++        printHtmlDocument(null, true, contentTree);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ConstructorWriterImpl.java
+@@ -29,6 +29,7 @@
+ import java.util.*;
+ 
+ import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ 
+@@ -43,7 +44,6 @@
+     implements ConstructorWriter, MemberSummaryWriter {
+ 
+     private boolean foundNonPubConstructor = false;
+-    private boolean printedSummaryHeader = false;
+ 
+     /**
+      * Construct a new ConstructorWriterImpl.
+@@ -75,125 +75,112 @@
+     }
+ 
+     /**
+-     * Write the constructors summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
++     * {@inheritDoc}
+      */
+-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
+-        printedSummaryHeader = true;
+-        writer.println();
+-        writer.println("<!-- ======== CONSTRUCTOR SUMMARY ======== -->");
+-        writer.println();
+-        writer.printSummaryHeader(this, classDoc);
++    public Content getMemberSummaryHeader(ClassDoc classDoc,
++            Content memberSummaryTree) {
++        memberSummaryTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_SUMMARY);
++        Content memberTree = writer.getMemberTreeHeader();
++        writer.addSummaryHeader(this, classDoc, memberTree);
++        return memberTree;
+     }
+ 
+     /**
+-     * Write the constructors summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
++     * {@inheritDoc}
+      */
+-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
+-        writer.printSummaryFooter(this, classDoc);
++    public Content getConstructorDetailsTreeHeader(ClassDoc classDoc,
++            Content memberDetailsTree) {
++        memberDetailsTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_DETAILS);
++        Content constructorDetailsTree = writer.getMemberTreeHeader();
++        constructorDetailsTree.addContent(writer.getMarkerAnchor("constructor_detail"));
++        Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
++                writer.constructorDetailsLabel);
++        constructorDetailsTree.addContent(heading);
++        return constructorDetailsTree;
+     }
+ 
+     /**
+-     * Write the header for the constructor documentation.
+-     *
+-     * @param classDoc the class that the constructors belong to.
++     * {@inheritDoc}
+      */
+-    public void writeHeader(ClassDoc classDoc, String header) {
+-        writer.println();
+-        writer.println("<!-- ========= CONSTRUCTOR DETAIL ======== -->");
+-        writer.println();
+-        writer.anchor("constructor_detail");
+-        writer.printTableHeadingBackground(header);
++    public Content getConstructorDocTreeHeader(ConstructorDoc constructor,
++            Content constructorDetailsTree) {
++        String erasureAnchor;
++        if ((erasureAnchor = getErasureAnchor(constructor)) != null) {
++            constructorDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor)));
++        }
++        constructorDetailsTree.addContent(
++                writer.getMarkerAnchor(writer.getAnchor(constructor)));
++        Content constructorDocTree = writer.getMemberTreeHeader();
++        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
++        heading.addContent(constructor.name());
++        constructorDocTree.addContent(heading);
++        return constructorDocTree;
+     }
+ 
+     /**
+-     * Write the constructor header for the given constructor.
+-     *
+-     * @param constructor the constructor being documented.
+-     * @param isFirst the flag to indicate whether or not the constructor is the
+-     *        first to be documented.
++     * {@inheritDoc}
+      */
+-    public void writeConstructorHeader(ConstructorDoc constructor, boolean isFirst) {
+-        if (! isFirst) {
+-            writer.printMemberHeader();
++    public Content getSignature(ConstructorDoc constructor) {
++        writer.displayLength = 0;
++        Content pre = new HtmlTree(HtmlTag.PRE);
++        writer.addAnnotationInfo(constructor, pre);
++        addModifiers(constructor, pre);
++        if (configuration().linksource) {
++            Content constructorName = new StringContent(constructor.name());
++            writer.addSrcLink(constructor, constructorName, pre);
++        } else {
++            addName(constructor.name(), pre);
+         }
+-        writer.println();
+-        String erasureAnchor;
+-        if ((erasureAnchor = getErasureAnchor(constructor)) != null) {
+-            writer.anchor(erasureAnchor);
+-        }
+-        writer.anchor(constructor);
+-        writer.h3();
+-        writer.print(constructor.name());
+-        writer.h3End();
++        addParameters(constructor, pre);
++        addExceptions(constructor, pre);
++        return pre;
+     }
+ 
+     /**
+-     * Write the signature for the given constructor.
+-     *
+-     * @param constructor the constructor being documented.
++     * {@inheritDoc}
+      */
+-    public void writeSignature(ConstructorDoc constructor) {
+-        writer.displayLength = 0;
+-        writer.pre();
+-        writer.writeAnnotationInfo(constructor);
+-        printModifiers(constructor);
+-        //printReturnType((ConstructorDoc)constructor);
+-        if (configuration().linksource) {
+-            writer.printSrcLink(constructor, constructor.name());
+-        } else {
+-            strong(constructor.name());
+-        }
+-        writeParameters(constructor);
+-        writeExceptions(constructor);
+-        writer.preEnd();
+-        assert !writer.getMemberDetailsListPrinted();
++    @Override
++    public void setSummaryColumnStyle(HtmlTree tdTree) {
++        if (foundNonPubConstructor)
++            tdTree.addStyle(HtmlStyle.colLast);
++        else
++            tdTree.addStyle(HtmlStyle.colOne);
+     }
+ 
+     /**
+-     * Write the deprecated output for the given constructor.
+-     *
+-     * @param constructor the constructor being documented.
++     * {@inheritDoc}
+      */
+-    public void writeDeprecated(ConstructorDoc constructor) {
+-        printDeprecated(constructor);
++    public void addDeprecated(ConstructorDoc constructor, Content constructorDocTree) {
++        addDeprecatedInfo(constructor, constructorDocTree);
+     }
+ 
+     /**
+-     * Write the comments for the given constructor.
+-     *
+-     * @param constructor the constructor being documented.
++     * {@inheritDoc}
+      */
+-    public void writeComments(ConstructorDoc constructor) {
+-        printComment(constructor);
++    public void addComments(ConstructorDoc constructor, Content constructorDocTree) {
++        addComment(constructor, constructorDocTree);
+     }
+ 
+     /**
+-     * Write the tag output for the given constructor.
+-     *
+-     * @param constructor the constructor being documented.
++     * {@inheritDoc}
+      */
+-    public void writeTags(ConstructorDoc constructor) {
+-        writer.printTags(constructor);
++    public void addTags(ConstructorDoc constructor, Content constructorDocTree) {
++        writer.addTagsInfo(constructor, constructorDocTree);
+     }
+ 
+     /**
+-     * Write the constructor footer.
++     * {@inheritDoc}
+      */
+-    public void writeConstructorFooter() {
+-        printMemberFooter();
++    public Content getConstructorDetails(Content constructorDetailsTree) {
++        return getMemberTree(constructorDetailsTree);
+     }
+ 
+     /**
+-     * Write the footer for the constructor documentation.
+-     *
+-     * @param classDoc the class that the constructors belong to.
++     * {@inheritDoc}
+      */
+-    public void writeFooter(ClassDoc classDoc) {
+-        //No footer to write for constructor documentation
++    public Content getConstructorDoc(Content constructorDocTree,
++            boolean isLastContent) {
++        return getMemberTree(constructorDocTree, isLastContent);
+     }
+ 
+     /**
+@@ -212,17 +199,35 @@
+         this.foundNonPubConstructor = foundNonPubConstructor;
+     }
+ 
+-    public void printSummaryLabel() {
+-        writer.printText("doclet.Constructor_Summary");
++    /**
++     * {@inheritDoc}
++     */
++    public void addSummaryLabel(Content memberTree) {
++        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
++                writer.getResource("doclet.Constructor_Summary"));
++        memberTree.addContent(label);
+     }
+ 
+-    public void printTableSummary() {
+-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++    /**
++     * {@inheritDoc}
++     */
++    public String getTableSummary() {
++        return configuration().getText("doclet.Member_Table_Summary",
+                 configuration().getText("doclet.Constructor_Summary"),
+-                configuration().getText("doclet.constructors")));
++                configuration().getText("doclet.constructors"));
+     }
+ 
+-    public void printSummaryTableHeader(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    public String getCaption() {
++        return configuration().getText("doclet.Constructors");
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String[] getSummaryTableHeader(ProgramElementDoc member) {
+         String[] header;
+         if (foundNonPubConstructor) {
+             header = new String[] {
+@@ -239,87 +244,73 @@
+                         configuration().getText("doclet.Description"))
+             };
+         }
+-        writer.summaryTableHeader(header, "col");
++        return header;
+     }
+ 
+-    public void printSummaryAnchor(ClassDoc cd) {
+-        writer.anchor("constructor_summary");
++    /**
++     * {@inheritDoc}
++     */
++    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
++        memberTree.addContent(writer.getMarkerAnchor("constructor_summary"));
+     }
+ 
+-    public void printInheritedSummaryAnchor(ClassDoc cd) {
+-    }   // no such
++    /**
++     * {@inheritDoc}
++     */
++    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
++    }
+ 
+-    public void printInheritedSummaryLabel(ClassDoc cd) {
+-        // no such
++    /**
++     * {@inheritDoc}
++     */
++    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
+     }
+ 
+     public int getMemberKind() {
+         return VisibleMemberMap.CONSTRUCTORS;
+     }
+ 
+-    protected void navSummaryLink(List members) {
+-        printNavSummaryLink(classdoc,
+-                members.size() > 0? true: false);
+-    }
+-
+-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
+         if (link) {
+-            writer.printHyperLink("", "constructor_summary",
+-                    ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
++            return writer.getHyperLink("", "constructor_summary",
++                    writer.getResource("doclet.navConstructor"));
+         } else {
+-            writer.printText("doclet.navConstructor");
+-        }
+-    }
+-
+-    protected void printNavDetailLink(boolean link) {
+-        if (link) {
+-            writer.printHyperLink("", "constructor_detail",
+-                    ConfigurationImpl.getInstance().getText("doclet.navConstructor"));
+-        } else {
+-            writer.printText("doclet.navConstructor");
+-        }
+-    }
+-
+-    protected void printSummaryType(ProgramElementDoc member) {
+-        if (foundNonPubConstructor) {
+-            writer.printTypeSummaryHeader();
+-            if (member.isProtected()) {
+-                print("protected ");
+-            } else if (member.isPrivate()) {
+-                print("private ");
+-            } else if (member.isPublic()) {
+-                writer.space();
+-            } else {
+-                writer.printText("doclet.Package_private");
+-            }
+-            writer.printTypeSummaryFooter();
+-        }
+-    }
+-
+-    /**
+-     * Write the inherited member summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
+-        if(! printedSummaryHeader){
+-            //We don't want inherited summary to not be under heading.
+-            writeMemberSummaryHeader(classDoc);
+-            writeMemberSummaryFooter(classDoc);
+-            printedSummaryHeader = true;
++            return writer.getResource("doclet.navConstructor");
+         }
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummary(ClassDoc classDoc,
+-        ProgramElementDoc member, boolean isFirst, boolean isLast) {}
++    protected void addNavDetailLink(boolean link, Content liNav) {
++        if (link) {
++            liNav.addContent(writer.getHyperLink("", "constructor_detail",
++                    writer.getResource("doclet.navConstructor")));
++        } else {
++            liNav.addContent(writer.getResource("doclet.navConstructor"));
++        }
++    }
+ 
+     /**
+-     * Write the inherited member summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
++     * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {}
++    protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
++        if (foundNonPubConstructor) {
++            Content code = new HtmlTree(HtmlTag.CODE);
++            if (member.isProtected()) {
++                code.addContent("protected ");
++            } else if (member.isPrivate()) {
++                code.addContent("private ");
++            } else if (member.isPublic()) {
++                code.addContent(writer.getSpace());
++            } else {
++                code.addContent(
++                        configuration().getText("doclet.Package_private"));
++            }
++            tdSummaryType.addContent(code);
++        }
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/DeprecatedListWriter.java
+@@ -25,9 +25,11 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.DeprecatedAPIListBuilder;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import java.io.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Generate File to list all the deprecated classes and class members with the
+@@ -125,28 +127,21 @@
+     }
+ 
+     /**
+-     * Print the deprecated API list. Separately print all class kinds and
+-     * member kinds.
++     * Generate the deprecated API list.
+      *
+      * @param deprapi list of deprecated API built already.
+      */
+     protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi)
+-             throws IOException {
+-        writeHeader();
+-
+-        strong(configuration.getText("doclet.Contents"));
+-        ul();
+-        for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
+-            writeIndexLink(deprapi, i);
+-        }
+-        ulEnd();
+-        println();
+-
++            throws IOException {
++        Content body = getHeader();
++        body.addContent(getContentsList(deprapi));
+         String memberTableSummary;
+         String[] memberTableHeader = new String[1];
++        HtmlTree div = new HtmlTree(HtmlTag.DIV);
++        div.addStyle(HtmlStyle.contentContainer);
+         for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
+             if (deprapi.hasDocumentation(i)) {
+-                writeAnchor(deprapi, i);
++                addAnchor(deprapi, i, div);
+                 memberTableSummary =
+                         configuration.getText("doclet.Member_Table_Summary",
+                         configuration.getText(HEADING_KEYS[i]),
+@@ -154,66 +149,87 @@
+                 memberTableHeader[0] = configuration.getText("doclet.0_and_1",
+                         configuration.getText(HEADER_KEYS[i]),
+                         configuration.getText("doclet.Description"));
+-                writers[i].printDeprecatedAPI(deprapi.getList(i),
+-                    HEADING_KEYS[i], memberTableSummary, memberTableHeader);
++                writers[i].addDeprecatedAPI(deprapi.getList(i),
++                        HEADING_KEYS[i], memberTableSummary, memberTableHeader, div);
+             }
+         }
+-        printDeprecatedFooter();
++        body.addContent(div);
++        addNavLinks(false, body);
++        addBottom(body);
++        printHtmlDocument(null, true, body);
+     }
+ 
+-    private void writeIndexLink(DeprecatedAPIListBuilder builder,
+-            int type) {
++    /**
++     * Add the index link.
++     *
++     * @param builder the deprecated list builder
++     * @param type the type of list being documented
++     * @param contentTree the content tree to which the index link will be added
++     */
++    private void addIndexLink(DeprecatedAPIListBuilder builder,
++            int type, Content contentTree) {
+         if (builder.hasDocumentation(type)) {
+-            li();
+-            printHyperLink("#" + ANCHORS[type],
+-                configuration.getText(HEADING_KEYS[type]));
+-            println();
+-        }
+-    }
+-
+-    private void writeAnchor(DeprecatedAPIListBuilder builder, int type) {
+-        if (builder.hasDocumentation(type)) {
+-            anchor(ANCHORS[type]);
++            Content li = HtmlTree.LI(getHyperLink("#" + ANCHORS[type],
++                    getResource(HEADING_KEYS[type])));
++            contentTree.addContent(li);
+         }
+     }
+ 
+     /**
+-     * Print the navigation bar and header for the deprecated API Listing.
++     * Get the contents list.
++     *
++     * @param deprapi the deprecated list builder
++     * @return a content tree for the contents list
+      */
+-    protected void writeHeader() {
+-        printHtmlHeader(configuration.getText("doclet.Window_Deprecated_List"),
+-            null, true);
+-        printTop();
+-        navLinks(true);
+-        hr();
+-        center();
+-        h2();
+-        strongText("doclet.Deprecated_API");
+-        h2End();
+-        centerEnd();
+-
+-        hr(4, "noshade");
++    public Content getContentsList(DeprecatedAPIListBuilder deprapi) {
++        Content headContent = getResource("doclet.Deprecated_API");
++        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
++                HtmlStyle.title, headContent);
++        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
++        Content headingContent = getResource("doclet.Contents");
++        div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true,
++                headingContent));
++        Content ul = new HtmlTree(HtmlTag.UL);
++        for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) {
++            addIndexLink(deprapi, i, ul);
++        }
++        div.addContent(ul);
++        return div;
+     }
+ 
+     /**
+-     * Print the navigation bar and the footer for the deprecated API Listing.
++     * Add the anchor.
++     *
++     * @param builder the deprecated list builder
++     * @param type the type of list being documented
++     * @param contentTree the content tree to which the anchor will be added
+      */
+-    protected void printDeprecatedFooter() {
+-        hr();
+-        navLinks(false);
+-        printBottom();
+-        printBodyHtmlEnd();
++    private void addAnchor(DeprecatedAPIListBuilder builder, int type, Content htmlTree) {
++        if (builder.hasDocumentation(type)) {
++            htmlTree.addContent(getMarkerAnchor(ANCHORS[type]));
++        }
+     }
+ 
+     /**
+-     * Highlight the word "Deprecated" in the navigation bar as this is the same
+-     * page.
++     * Get the header for the deprecated API Listing.
++     *
++     * @return a content tree for the header
+      */
+-    protected void navLinkDeprecated() {
+-        navCellRevStart();
+-        fontStyle("NavBarFont1Rev");
+-        strongText("doclet.navDeprecated");
+-        fontEnd();
+-        navCellEnd();
++    public Content getHeader() {
++        String title = configuration.getText("doclet.Window_Deprecated_List");
++        Content bodyTree = getBody(true, getWindowTitle(title));
++        addTop(bodyTree);
++        addNavLinks(true, bodyTree);
++        return bodyTree;
++    }
++
++    /**
++     * Get the deprecated label.
++     *
++     * @return a content tree for the deprecated label
++     */
++    protected Content getNavLinkDeprecated() {
++        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, deprecatedLabel);
++        return li;
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/EnumConstantWriterImpl.java
+@@ -28,6 +28,7 @@
+ import java.io.*;
+ 
+ import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ 
+@@ -40,8 +41,6 @@
+ public class EnumConstantWriterImpl extends AbstractMemberWriter
+     implements EnumConstantWriter, MemberSummaryWriter {
+ 
+-    private boolean printedSummaryHeader = false;
+-
+     public EnumConstantWriterImpl(SubWriterHolderWriter writer,
+         ClassDoc classdoc) {
+         super(writer, classdoc);
+@@ -52,136 +51,98 @@
+     }
+ 
+     /**
+-     * Write the enum constant summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
++     * {@inheritDoc}
+      */
+-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
+-        printedSummaryHeader = true;
+-        writer.println("<!-- =========== ENUM CONSTANT SUMMARY =========== -->");
+-        writer.println();
+-        writer.printSummaryHeader(this, classDoc);
+-    }
+-
+-    /**
+-     * Write the enum constant summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
+-        writer.printSummaryFooter(this, classDoc);
+-    }
+-
+-    /**
+-     * Write the inherited enum constant summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
+-        if(! printedSummaryHeader){
+-            //We don't want inherited summary to not be under heading.
+-            writeMemberSummaryHeader(classDoc);
+-            writeMemberSummaryFooter(classDoc);
+-            printedSummaryHeader = true;
+-        }
+-        writer.printInheritedSummaryHeader(this, classDoc);
++    public Content getMemberSummaryHeader(ClassDoc classDoc,
++            Content memberSummaryTree) {
++        memberSummaryTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_SUMMARY);
++        Content memberTree = writer.getMemberTreeHeader();
++        writer.addSummaryHeader(this, classDoc, memberTree);
++        return memberTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummary(ClassDoc classDoc,
+-        ProgramElementDoc enumConstant, boolean isFirst, boolean isLast) {
+-        writer.printInheritedSummaryMember(this, classDoc, enumConstant, isFirst);
+-    }
+-
+-    /**
+-     * Write the inherited enum constant summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
+-        writer.printInheritedSummaryFooter(this, classDoc);
++    public Content getEnumConstantsDetailsTreeHeader(ClassDoc classDoc,
++            Content memberDetailsTree) {
++        memberDetailsTree.addContent(HtmlConstants.START_OF_ENUM_CONSTANT_DETAILS);
++        Content enumConstantsDetailsTree = writer.getMemberTreeHeader();
++        enumConstantsDetailsTree.addContent(writer.getMarkerAnchor("enum_constant_detail"));
++        Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
++                writer.enumConstantsDetailsLabel);
++        enumConstantsDetailsTree.addContent(heading);
++        return enumConstantsDetailsTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeHeader(ClassDoc classDoc, String header) {
+-        writer.println();
+-        writer.println("<!-- ============ ENUM CONSTANT DETAIL =========== -->");
+-        writer.println();
+-        writer.anchor("enum_constant_detail");
+-        writer.printTableHeadingBackground(header);
+-        writer.println();
++    public Content getEnumConstantsTreeHeader(FieldDoc enumConstant,
++            Content enumConstantsDetailsTree) {
++        enumConstantsDetailsTree.addContent(
++                writer.getMarkerAnchor(enumConstant.name()));
++        Content enumConstantsTree = writer.getMemberTreeHeader();
++        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
++        heading.addContent(enumConstant.name());
++        enumConstantsTree.addContent(heading);
++        return enumConstantsTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeEnumConstantHeader(FieldDoc enumConstant, boolean isFirst) {
+-        if (! isFirst) {
+-            writer.printMemberHeader();
+-            writer.println("");
++    public Content getSignature(FieldDoc enumConstant) {
++        Content pre = new HtmlTree(HtmlTag.PRE);
++        writer.addAnnotationInfo(enumConstant, pre);
++        addModifiers(enumConstant, pre);
++        Content enumConstantLink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
++                enumConstant.type())));
++        pre.addContent(enumConstantLink);
++        pre.addContent(" ");
++        if (configuration().linksource) {
++            Content enumConstantName = new StringContent(enumConstant.name());
++            writer.addSrcLink(enumConstant, enumConstantName, pre);
++        } else {
++            addName(enumConstant.name(), pre);
+         }
+-        writer.anchor(enumConstant.name());
+-        writer.h3();
+-        writer.print(enumConstant.name());
+-        writer.h3End();
++        return pre;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeSignature(FieldDoc enumConstant) {
+-        writer.pre();
+-        writer.writeAnnotationInfo(enumConstant);
+-        printModifiers(enumConstant);
+-        writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+-            enumConstant.type()));
+-        print(' ');
+-        if (configuration().linksource) {
+-            writer.printSrcLink(enumConstant, enumConstant.name());
+-        } else {
+-            strong(enumConstant.name());
+-        }
+-        writer.preEnd();
+-        assert !writer.getMemberDetailsListPrinted();
++    public void addDeprecated(FieldDoc enumConstant, Content enumConstantsTree) {
++        addDeprecatedInfo(enumConstant, enumConstantsTree);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeDeprecated(FieldDoc enumConstant) {
+-        printDeprecated(enumConstant);
++    public void addComments(FieldDoc enumConstant, Content enumConstantsTree) {
++        addComment(enumConstant, enumConstantsTree);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeComments(FieldDoc enumConstant) {
+-        printComment(enumConstant);
++    public void addTags(FieldDoc enumConstant, Content enumConstantsTree) {
++        writer.addTagsInfo(enumConstant, enumConstantsTree);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeTags(FieldDoc enumConstant) {
+-        writer.printTags(enumConstant);
++    public Content getEnumConstantsDetails(Content enumConstantsDetailsTree) {
++        return getMemberTree(enumConstantsDetailsTree);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeEnumConstantFooter() {
+-        printMemberFooter();
+-    }
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+-    public void writeFooter(ClassDoc classDoc) {
+-        //No footer to write for enum constant documentation
++    public Content getEnumConstants(Content enumConstantsTree,
++            boolean isLastContent) {
++        return getMemberTree(enumConstantsTree, isLastContent);
+     }
+ 
+     /**
+@@ -195,75 +156,127 @@
+         return VisibleMemberMap.ENUM_CONSTANTS;
+     }
+ 
+-    public void printSummaryLabel() {
+-        writer.printText("doclet.Enum_Constant_Summary");
++    /**
++     * {@inheritDoc}
++     */
++    public void addSummaryLabel(Content memberTree) {
++        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
++                writer.getResource("doclet.Enum_Constant_Summary"));
++        memberTree.addContent(label);
+     }
+ 
+-    public void printTableSummary() {
+-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++    /**
++     * {@inheritDoc}
++     */
++    public String getTableSummary() {
++        return configuration().getText("doclet.Member_Table_Summary",
+                 configuration().getText("doclet.Enum_Constant_Summary"),
+-                configuration().getText("doclet.enum_constants")));
++                configuration().getText("doclet.enum_constants"));
+     }
+ 
+-    public void printSummaryTableHeader(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    public String getCaption() {
++        return configuration().getText("doclet.Enum_Constants");
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String[] getSummaryTableHeader(ProgramElementDoc member) {
+         String[] header = new String[] {
+             configuration().getText("doclet.0_and_1",
+                     configuration().getText("doclet.Enum_Constant"),
+                     configuration().getText("doclet.Description"))
+         };
+-        writer.summaryTableHeader(header, "col");
++        return header;
+     }
+ 
+-    public void printSummaryAnchor(ClassDoc cd) {
+-        writer.anchor("enum_constant_summary");
++    /**
++     * {@inheritDoc}
++     */
++    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
++        memberTree.addContent(writer.getMarkerAnchor("enum_constant_summary"));
+     }
+ 
+-    public void printInheritedSummaryAnchor(ClassDoc cd) {
+-    }   // no such
+-
+-    public void printInheritedSummaryLabel(ClassDoc cd) {
+-        // no such
++    /**
++     * {@inheritDoc}
++     */
++    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
+     }
+ 
+-    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
+-        writer.strong();
+-        writer.printDocLink(context, (MemberDoc) member, member.name(), false);
+-        writer.strongEnd();
++    /**
++     * {@inheritDoc}
++     */
++    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
+     }
+ 
+-    protected void writeInheritedSummaryLink(ClassDoc cd,
+-            ProgramElementDoc member) {
+-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, (MemberDoc)member,
+-            member.name(), false);
++    /**
++     * {@inheritDoc}
++     */
++    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
++            Content tdSummary) {
++        Content strong = HtmlTree.STRONG(new RawHtml(
++                writer.getDocLink(context, (MemberDoc) member, member.name(), false)));
++        Content code = HtmlTree.CODE(strong);
++        tdSummary.addContent(code);
+     }
+ 
+-    protected void printSummaryType(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    @Override
++    public void setSummaryColumnStyle(HtmlTree tdTree) {
++        tdTree.addStyle(HtmlStyle.colOne);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    protected void addInheritedSummaryLink(ClassDoc cd,
++            ProgramElementDoc member, Content linksTree) {
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
+         //Not applicable.
+     }
+ 
+-    protected void writeDeprecatedLink(ProgramElementDoc member) {
+-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+-            (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getDeprecatedLink(ProgramElementDoc member) {
++        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
++                (MemberDoc) member, ((FieldDoc)member).qualifiedName());
+     }
+ 
+-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
+         if (link) {
+-            writer.printHyperLink("", (cd == null)?
+-                        "enum_constant_summary":
+-                        "enum_constants_inherited_from_class_" +
+-                        configuration().getClassName(cd),
+-                    configuration().getText("doclet.navEnum"));
++            return writer.getHyperLink("", (cd == null)?
++                "enum_constant_summary":
++                "enum_constants_inherited_from_class_" +
++                configuration().getClassName(cd),
++                writer.getResource("doclet.navEnum"));
+         } else {
+-            writer.printText("doclet.navEnum");
++            return writer.getResource("doclet.navEnum");
+         }
+     }
+ 
+-    protected void printNavDetailLink(boolean link) {
++    /**
++     * {@inheritDoc}
++     */
++    protected void addNavDetailLink(boolean link, Content liNav) {
+         if (link) {
+-            writer.printHyperLink("", "enum_constant_detail",
+-                configuration().getText("doclet.navEnum"));
++            liNav.addContent(writer.getHyperLink("", "enum_constant_detail",
++                    writer.getResource("doclet.navEnum")));
+         } else {
+-            writer.printText("doclet.navEnum");
++            liNav.addContent(writer.getResource("doclet.navEnum"));
+         }
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FieldWriterImpl.java
+@@ -28,6 +28,7 @@
+ import java.io.*;
+ 
+ import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ 
+@@ -42,8 +43,6 @@
+ public class FieldWriterImpl extends AbstractMemberWriter
+     implements FieldWriter, MemberSummaryWriter {
+ 
+-    private boolean printedSummaryHeader = false;
+-
+     public FieldWriterImpl(SubWriterHolderWriter writer, ClassDoc classdoc) {
+         super(writer, classdoc);
+     }
+@@ -53,177 +52,118 @@
+     }
+ 
+     /**
+-     * Write the fields summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
++     * {@inheritDoc}
+      */
+-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
+-        printedSummaryHeader = true;
+-        writer.println("<!-- =========== FIELD SUMMARY =========== -->");
+-        writer.println();
+-        writer.printSummaryHeader(this, classDoc);
+-    }
+-
+-    /**
+-     * Write the fields summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
+-        writer.tableEnd();
+-        writer.space();
+-    }
+-
+-    /**
+-     * Write the inherited fields summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
+-        if(! printedSummaryHeader){
+-            //We don't want inherited summary to not be under heading.
+-            writeMemberSummaryHeader(classDoc);
+-            writeMemberSummaryFooter(classDoc);
+-            printedSummaryHeader = true;
+-        }
+-        writer.printInheritedSummaryHeader(this, classDoc);
++    public Content getMemberSummaryHeader(ClassDoc classDoc,
++            Content memberSummaryTree) {
++        memberSummaryTree.addContent(HtmlConstants.START_OF_FIELD_SUMMARY);
++        Content memberTree = writer.getMemberTreeHeader();
++        writer.addSummaryHeader(this, classDoc, memberTree);
++        return memberTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummary(ClassDoc classDoc,
+-        ProgramElementDoc field, boolean isFirst, boolean isLast) {
+-        writer.printInheritedSummaryMember(this, classDoc, field, isFirst);
++    public Content getFieldDetailsTreeHeader(ClassDoc classDoc,
++            Content memberDetailsTree) {
++        memberDetailsTree.addContent(HtmlConstants.START_OF_FIELD_DETAILS);
++        Content fieldDetailsTree = writer.getMemberTreeHeader();
++        fieldDetailsTree.addContent(writer.getMarkerAnchor("field_detail"));
++        Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
++                writer.fieldDetailsLabel);
++        fieldDetailsTree.addContent(heading);
++        return fieldDetailsTree;
+     }
+ 
+     /**
+-     * Write the inherited fields summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
++     * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
+-        writer.printInheritedSummaryFooter(this, classDoc);
++    public Content getFieldDocTreeHeader(FieldDoc field,
++            Content fieldDetailsTree) {
++        fieldDetailsTree.addContent(
++                writer.getMarkerAnchor(field.name()));
++        Content fieldDocTree = writer.getMemberTreeHeader();
++        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
++        heading.addContent(field.name());
++        fieldDocTree.addContent(heading);
++        return fieldDocTree;
+     }
+ 
+     /**
+-     * Write the header for the field documentation.
+-     *
+-     * @param classDoc the class that the fields belong to.
++     * {@inheritDoc}
+      */
+-    public void writeHeader(ClassDoc classDoc, String header) {
+-        writer.println();
+-        writer.println("<!-- ============ FIELD DETAIL =========== -->");
+-        writer.println();
+-        writer.anchor("field_detail");
+-        writer.printTableHeadingBackground(header);
+-        writer.println();
++    public Content getSignature(FieldDoc field) {
++        Content pre = new HtmlTree(HtmlTag.PRE);
++        writer.addAnnotationInfo(field, pre);
++        addModifiers(field, pre);
++        Content fieldlink = new RawHtml(writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
++                field.type())));
++        pre.addContent(fieldlink);
++        pre.addContent(" ");
++        if (configuration().linksource) {
++            Content fieldName = new StringContent(field.name());
++            writer.addSrcLink(field, fieldName, pre);
++        } else {
++            addName(field.name(), pre);
++        }
++        return pre;
+     }
+ 
+     /**
+-     * Write the field header for the given field.
+-     *
+-     * @param field the field being documented.
+-     * @param isFirst the flag to indicate whether or not the field is the
+-     *        first to be documented.
++     * {@inheritDoc}
+      */
+-    public void writeFieldHeader(FieldDoc field, boolean isFirst) {
+-        if (! isFirst) {
+-            writer.printMemberHeader();
+-            writer.println("");
+-        }
+-        writer.anchor(field.name());
+-        writer.h3();
+-        writer.print(field.name());
+-        writer.h3End();
++    public void addDeprecated(FieldDoc field, Content fieldDocTree) {
++        addDeprecatedInfo(field, fieldDocTree);
+     }
+ 
+     /**
+-     * Write the signature for the given field.
+-     *
+-     * @param field the field being documented.
++     * {@inheritDoc}
+      */
+-    public void writeSignature(FieldDoc field) {
+-        writer.pre();
+-        writer.writeAnnotationInfo(field);
+-        printModifiers(field);
+-        writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+-            field.type()));
+-        print(' ');
+-        if (configuration().linksource) {
+-            writer.printSrcLink(field, field.name());
+-        } else {
+-            strong(field.name());
+-        }
+-        writer.preEnd();
+-        assert !writer.getMemberDetailsListPrinted();
+-    }
+-
+-    /**
+-     * Write the deprecated output for the given field.
+-     *
+-     * @param field the field being documented.
+-     */
+-    public void writeDeprecated(FieldDoc field) {
+-        printDeprecated(field);
+-    }
+-
+-    /**
+-     * Write the comments for the given field.
+-     *
+-     * @param field the field being documented.
+-     */
+-    public void writeComments(FieldDoc field) {
++    public void addComments(FieldDoc field, Content fieldDocTree) {
+         ClassDoc holder = field.containingClass();
+         if (field.inlineTags().length > 0) {
+-            writer.printMemberDetailsListStartTag();
+             if (holder.equals(classdoc) ||
+-                (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
+-                writer.dd();
+-                writer.printInlineComment(field);
+-                writer.ddEnd();
++                    (! (holder.isPublic() || Util.isLinkable(holder, configuration())))) {
++                writer.addInlineComment(field, fieldDocTree);
+             } else {
+-                String classlink = writer.codeText(
+-                    writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
++                Content link = new RawHtml(
++                        writer.getDocLink(LinkInfoImpl.CONTEXT_FIELD_DOC_COPY,
+                         holder, field,
+                         holder.isIncluded() ?
+                             holder.typeName() : holder.qualifiedTypeName(),
+-                        false));
+-                writer.dd();
+-                writer.strong(configuration().getText(holder.isClass()?
+-                   "doclet.Description_From_Class" :
+-                    "doclet.Description_From_Interface", classlink));
+-                writer.ddEnd();
+-                writer.dd();
+-                writer.printInlineComment(field);
+-                writer.ddEnd();
++                            false));
++                Content codeLink = HtmlTree.CODE(link);
++                Content strong = HtmlTree.STRONG(holder.isClass()?
++                   writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
++                strong.addContent(writer.getSpace());
++                strong.addContent(codeLink);
++                fieldDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
++                writer.addInlineComment(field, fieldDocTree);
+             }
+         }
+     }
+ 
+     /**
+-     * Write the tag output for the given field.
+-     *
+-     * @param field the field being documented.
++     * {@inheritDoc}
+      */
+-    public void writeTags(FieldDoc field) {
+-        writer.printTags(field);
++    public void addTags(FieldDoc field, Content fieldDocTree) {
++        writer.addTagsInfo(field, fieldDocTree);
+     }
+ 
+     /**
+-     * Write the field footer.
++     * {@inheritDoc}
+      */
+-    public void writeFieldFooter() {
+-        printMemberFooter();
++    public Content getFieldDetails(Content fieldDetailsTree) {
++        return getMemberTree(fieldDetailsTree);
+     }
+ 
+     /**
+-     * Write the footer for the field documentation.
+-     *
+-     * @param classDoc the class that the fields belong to.
++     * {@inheritDoc}
+      */
+-    public void writeFooter(ClassDoc classDoc) {
+-        //No footer to write for field documentation
++    public Content getFieldDoc(Content fieldDocTree,
++            boolean isLastContent) {
++        return getMemberTree(fieldDocTree, isLastContent);
+     }
+ 
+     /**
+@@ -237,85 +177,136 @@
+         return VisibleMemberMap.FIELDS;
+     }
+ 
+-    public void printSummaryLabel() {
+-        writer.printText("doclet.Field_Summary");
++    /**
++     * {@inheritDoc}
++     */
++    public void addSummaryLabel(Content memberTree) {
++        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
++                writer.getResource("doclet.Field_Summary"));
++        memberTree.addContent(label);
+     }
+ 
+-    public void printTableSummary() {
+-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++    /**
++     * {@inheritDoc}
++     */
++    public String getTableSummary() {
++        return configuration().getText("doclet.Member_Table_Summary",
+                 configuration().getText("doclet.Field_Summary"),
+-                configuration().getText("doclet.fields")));
++                configuration().getText("doclet.fields"));
+     }
+ 
+-    public void printSummaryTableHeader(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    public String getCaption() {
++        return configuration().getText("doclet.Fields");
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String[] getSummaryTableHeader(ProgramElementDoc member) {
+         String[] header = new String[] {
+             writer.getModifierTypeHeader(),
+             configuration().getText("doclet.0_and_1",
+                     configuration().getText("doclet.Field"),
+                     configuration().getText("doclet.Description"))
+         };
+-        writer.summaryTableHeader(header, "col");
++        return header;
+     }
+ 
+-    public void printSummaryAnchor(ClassDoc cd) {
+-        writer.anchor("field_summary");
++    /**
++     * {@inheritDoc}
++     */
++    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
++        memberTree.addContent(writer.getMarkerAnchor("field_summary"));
+     }
+ 
+-    public void printInheritedSummaryAnchor(ClassDoc cd) {
+-        writer.anchor("fields_inherited_from_class_" + configuration().getClassName(cd));
++    /**
++     * {@inheritDoc}
++     */
++    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
++        inheritedTree.addContent(writer.getMarkerAnchor(
++                "fields_inherited_from_class_" + configuration().getClassName(cd)));
+     }
+ 
+-    public void printInheritedSummaryLabel(ClassDoc cd) {
+-        String classlink = writer.getPreQualifiedClassLink(
+-            LinkInfoImpl.CONTEXT_MEMBER, cd, false);
+-        writer.strong();
+-        String key = cd.isClass()?
+-            "doclet.Fields_Inherited_From_Class" :
+-            "doclet.Fields_Inherited_From_Interface";
+-        writer.printText(key, classlink);
+-        writer.strongEnd();
++    /**
++     * {@inheritDoc}
++     */
++    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
++        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
++                LinkInfoImpl.CONTEXT_MEMBER, cd, false));
++        Content label = new StringContent(cd.isClass() ?
++            configuration().getText("doclet.Fields_Inherited_From_Class") :
++            configuration().getText("doclet.Fields_Inherited_From_Interface"));
++        Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
++                label);
++        labelHeading.addContent(writer.getSpace());
++        labelHeading.addContent(classLink);
++        inheritedTree.addContent(labelHeading);
+     }
+ 
+-    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
+-        writer.strong();
+-        writer.printDocLink(context, cd , (MemberDoc) member, member.name(), false);
+-        writer.strongEnd();
++    /**
++     * {@inheritDoc}
++     */
++    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
++            Content tdSummary) {
++        Content strong = HtmlTree.STRONG(new RawHtml(
++                writer.getDocLink(context, cd , (MemberDoc) member, member.name(), false)));
++        Content code = HtmlTree.CODE(strong);
++        tdSummary.addContent(code);
+     }
+ 
+-    protected void writeInheritedSummaryLink(ClassDoc cd,
+-            ProgramElementDoc member) {
+-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
+-            member.name(), false);
++    /**
++     * {@inheritDoc}
++     */
++    protected void addInheritedSummaryLink(ClassDoc cd,
++            ProgramElementDoc member, Content linksTree) {
++        linksTree.addContent(new RawHtml(
++                writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER, cd, (MemberDoc)member,
++                member.name(), false)));
+     }
+ 
+-    protected void printSummaryType(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
+         FieldDoc field = (FieldDoc)member;
+-        printModifierAndType(field, field.type());
++        addModifierAndType(field, field.type(), tdSummaryType);
+     }
+ 
+-    protected void writeDeprecatedLink(ProgramElementDoc member) {
+-        writer.printDocLink(LinkInfoImpl.CONTEXT_MEMBER,
+-            (MemberDoc) member, ((FieldDoc)member).qualifiedName(), false);
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getDeprecatedLink(ProgramElementDoc member) {
++        return writer.getDocLink(LinkInfoImpl.CONTEXT_MEMBER,
++                (MemberDoc) member, ((FieldDoc)member).qualifiedName());
+     }
+ 
+-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
+         if (link) {
+-            writer.printHyperLink("", (cd == null)?
+-                        "field_summary":
+-                        "fields_inherited_from_class_" +
+-                        configuration().getClassName(cd),
+-                    configuration().getText("doclet.navField"));
++            return writer.getHyperLink("", (cd == null)?
++                "field_summary":
++                "fields_inherited_from_class_" +
++                configuration().getClassName(cd),
++                writer.getResource("doclet.navField"));
+         } else {
+-            writer.printText("doclet.navField");
++            return writer.getResource("doclet.navField");
+         }
+     }
+ 
+-    protected void printNavDetailLink(boolean link) {
++    /**
++     * {@inheritDoc}
++     */
++    protected void addNavDetailLink(boolean link, Content liNav) {
+         if (link) {
+-            writer.printHyperLink("", "field_detail",
+-                configuration().getText("doclet.navField"));
++            liNav.addContent(writer.getHyperLink("", "field_detail",
++                    writer.getResource("doclet.navField")));
+         } else {
+-            writer.printText("doclet.navField");
++            liNav.addContent(writer.getResource("doclet.navField"));
+         }
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/FrameOutputWriter.java
+@@ -25,8 +25,10 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import java.io.*;
++import com.sun.tools.doclets.internal.toolkit.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Generate the documentation in the Html "frame" format in the browser. The
+@@ -47,6 +49,8 @@
+      */
+     int noOfPackages;
+ 
++    private final String SCROLL_YES = "yes";
++
+     /**
+      * Constructor to construct FrameOutputWriter object.
+      *
+@@ -86,82 +90,93 @@
+      * as well as warning if browser is not supporting the Html frames.
+      */
+     protected void generateFrameFile() {
++        Content frameset = getFrameDetails();
+         if (configuration.windowtitle.length() > 0) {
+-            printFramesetHeader(configuration.windowtitle, configuration.notimestamp);
++            printFramesetDocument(configuration.windowtitle, configuration.notimestamp,
++                    frameset);
+         } else {
+-            printFramesetHeader(configuration.getText("doclet.Generated_Docs_Untitled"),
+-                                configuration.notimestamp);
++            printFramesetDocument(configuration.getText("doclet.Generated_Docs_Untitled"),
++                    configuration.notimestamp, frameset);
+         }
+-        printFrameDetails();
+-        printFrameFooter();
+     }
+ 
+     /**
+-     * Generate the code for issueing the warning for a non-frame capable web
++     * Add the code for issueing the warning for a non-frame capable web
+      * client. Also provide links to the non-frame version documentation.
++     *
++     * @param contentTree the content tree to which the non-frames information will be added
+      */
+-    protected void printFrameWarning() {
+-        noFrames();
+-        h2();
+-        printText("doclet.Frame_Alert");
+-        h2End();
+-        p();
+-        printText("doclet.Frame_Warning_Message");
+-        br();
+-        printText("doclet.Link_To");
+-        printHyperLink(configuration.topFile,
+-            configuration.getText("doclet.Non_Frame_Version"));
+-        println("");
+-        noFramesEnd();
++    protected void addFrameWarning(Content contentTree) {
++        Content noframes = new HtmlTree(HtmlTag.NOFRAMES);
++        Content noScript = HtmlTree.NOSCRIPT(
++                HtmlTree.DIV(getResource("doclet.No_Script_Message")));
++        noframes.addContent(noScript);
++        Content noframesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                getResource("doclet.Frame_Alert"));
++        noframes.addContent(noframesHead);
++        Content p = HtmlTree.P(getResource("doclet.Frame_Warning_Message"));
++        noframes.addContent(p);
++        noframes.addContent(new HtmlTree(HtmlTag.BR));
++        noframes.addContent(getResource("doclet.Link_To"));
++        Content link = getHyperLink(configuration.topFile,
++                getResource("doclet.Non_Frame_Version"));
++        noframes.addContent(link);
++        contentTree.addContent(noframes);
+     }
+ 
+     /**
+-     * Print the frame sizes and their contents.
++     * Get the frame sizes and their contents.
++     *
++     * @return a content tree for the frame details
+      */
+-    protected void printFrameDetails() {
+-        // title attribute intentionally made empty so
+-        // 508 tests will not flag it as missing
+-        frameSet("cols=\"20%,80%\" title=\"\" onLoad=\"top.loadFrames()\"");
++    protected Content getFrameDetails() {
++        HtmlTree frameset = HtmlTree.FRAMESET("20%,80%", null, "Documentation frame",
++                "top.loadFrames()");
+         if (noOfPackages <= 1) {
+-            printAllClassesFrameTag();
++            addAllClassesFrameTag(frameset);
+         } else if (noOfPackages > 1) {
+-            frameSet("rows=\"30%,70%\" title=\"\" onLoad=\"top.loadFrames()\"");
+-            printAllPackagesFrameTag();
+-            printAllClassesFrameTag();
+-            frameSetEnd();
++            HtmlTree leftFrameset = HtmlTree.FRAMESET(null, "30%,70%", "Left frames",
++                "top.loadFrames()");
++            addAllPackagesFrameTag(leftFrameset);
++            addAllClassesFrameTag(leftFrameset);
++            frameset.addContent(leftFrameset);
+         }
+-        printClassFrameTag();
+-        printFrameWarning();
+-        frameSetEnd();
++        addClassFrameTag(frameset);
++        addFrameWarning(frameset);
++        return frameset;
+     }
+ 
+     /**
+-     * Print the FRAME tag for the frame that lists all packages
++     * Add the FRAME tag for the frame that lists all packages.
++     *
++     * @param contentTree the content tree to which the information will be added
+      */
+-    private void printAllPackagesFrameTag() {
+-        frame("src=\"overview-frame.html\" name=\"packageListFrame\""
+-            + " title=\"" + configuration.getText("doclet.All_Packages") + "\"");
++    private void addAllPackagesFrameTag(Content contentTree) {
++        HtmlTree frame = HtmlTree.FRAME("overview-frame.html", "packageListFrame",
++                configuration.getText("doclet.All_Packages"));
++        contentTree.addContent(frame);
+     }
+ 
+     /**
+-     * Print the FRAME tag for the frame that lists all classes
++     * Add the FRAME tag for the frame that lists all classes.
++     *
++     * @param contentTree the content tree to which the information will be added
+      */
+-    private void printAllClassesFrameTag() {
+-        frame("src=\"" + "allclasses-frame.html" + "\""
+-            + " name=\"packageFrame\""
+-            + " title=\"" + configuration.getText("doclet.All_classes_and_interfaces")
+-            + "\"");
++    private void addAllClassesFrameTag(Content contentTree) {
++        HtmlTree frame = HtmlTree.FRAME("allclasses-frame.html", "packageFrame",
++                configuration.getText("doclet.All_classes_and_interfaces"));
++        contentTree.addContent(frame);
+     }
+ 
+     /**
+-     * Print the FRAME tag for the frame that describes the class in detail
++     * Add the FRAME tag for the frame that describes the class in detail.
++     *
++     * @param contentTree the content tree to which the information will be added
+      */
+-    private void printClassFrameTag() {
+-        frame("src=\"" + configuration.topFile + "\""
+-            + " name=\"classFrame\""
+-            + " title=\""
+-            + configuration.getText("doclet.Package_class_and_interface_descriptions")
+-            + "\" scrolling=\"yes\"");
++    private void addClassFrameTag(Content contentTree) {
++        HtmlTree frame = HtmlTree.FRAME(configuration.topFile, "classFrame",
++                configuration.getText("doclet.Package_class_and_interface_descriptions"),
++                SCROLL_YES);
++        contentTree.addContent(frame);
+     }
+-
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
+@@ -25,8 +25,10 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import java.io.*;
++import com.sun.tools.doclets.internal.toolkit.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Generate the Help File for the generated API documentation. The help file
+@@ -72,159 +74,242 @@
+      * Generate the help file contents.
+      */
+     protected void generateHelpFile() {
+-        printHtmlHeader(configuration.getText("doclet.Window_Help_title"),
+-            null, true);
+-        printTop();
+-        navLinks(true);  hr();
+-
+-        printHelpFileContents();
+-
+-        navLinks(false);
+-        printBottom();
+-        printBodyHtmlEnd();
++        String title = configuration.getText("doclet.Window_Help_title");
++        Content body = getBody(true, getWindowTitle(title));
++        addTop(body);
++        addNavLinks(true, body);
++        addHelpFileContents(body);
++        addNavLinks(false, body);
++        addBottom(body);
++        printHtmlDocument(null, true, body);
+     }
+ 
+     /**
+-     * Print the help file contents from the resource file. While generating the
++     * Add the help file contents from the resource file to the content tree. While adding the
+      * help file contents it also keeps track of user options. If "-notree"
+-     * is used, then the "overview-tree.html" will not get generated and hence
+-     * help information also will not get generated.
++     * is used, then the "overview-tree.html" will not get added and hence
++     * help information also will not get added.
++     *
++     * @param contentTree the content tree to which the help file contents will be added
+      */
+-    protected void printHelpFileContents() {
+-        center(); h1(); printText("doclet.Help_line_1"); h1End(); centerEnd();
+-        printText("doclet.Help_line_2");
++    protected void addHelpFileContents(Content contentTree) {
++        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, HtmlStyle.title,
++                getResource("doclet.Help_line_1"));
++        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
++        Content line2 = HtmlTree.P(HtmlStyle.subTitle,
++                getResource("doclet.Help_line_2"));
++        div.addContent(line2);
++        contentTree.addContent(div);
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
+         if (configuration.createoverview) {
+-            h3(); printText("doclet.Overview"); h3End();
+-            blockquote(); p();
+-            printText("doclet.Help_line_3",
+-                getHyperLink("overview-summary.html",
+-                configuration.getText("doclet.Overview")));
+-            blockquoteEnd();
++            Content overviewHeading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                getResource("doclet.Overview"));
++            Content liOverview = HtmlTree.LI(HtmlStyle.blockList, overviewHeading);
++            Content line3 = getResource("doclet.Help_line_3",
++                    getHyperLinkString("overview-summary.html",
++                    configuration.getText("doclet.Overview")));
++            Content overviewPara = HtmlTree.P(line3);
++            liOverview.addContent(overviewPara);
++            ul.addContent(liOverview);
+         }
+-        h3(); printText("doclet.Package"); h3End();
+-        blockquote(); p(); printText("doclet.Help_line_4");
+-        ul();
+-        li(); printText("doclet.Interfaces_Italic");
+-        li(); printText("doclet.Classes");
+-        li(); printText("doclet.Enums");
+-        li(); printText("doclet.Exceptions");
+-        li(); printText("doclet.Errors");
+-        li(); printText("doclet.AnnotationTypes");
+-        ulEnd();
+-        blockquoteEnd();
+-        h3(); printText("doclet.Help_line_5"); h3End();
+-        blockquote(); p(); printText("doclet.Help_line_6");
+-        ul();
+-        li(); printText("doclet.Help_line_7");
+-        li(); printText("doclet.Help_line_8");
+-        li(); printText("doclet.Help_line_9");
+-        li(); printText("doclet.Help_line_10");
+-        li(); printText("doclet.Help_line_11");
+-        li(); printText("doclet.Help_line_12");
+-        p();
+-        li(); printText("doclet.Nested_Class_Summary");
+-        li(); printText("doclet.Field_Summary");
+-        li(); printText("doclet.Constructor_Summary");
+-        li(); printText("doclet.Method_Summary");
+-        p();
+-        li(); printText("doclet.Field_Detail");
+-        li(); printText("doclet.Constructor_Detail");
+-        li(); printText("doclet.Method_Detail");
+-        ulEnd();
+-        printText("doclet.Help_line_13");
+-        blockquoteEnd();
+-
++        Content packageHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                getResource("doclet.Package"));
++        Content liPackage = HtmlTree.LI(HtmlStyle.blockList, packageHead);
++        Content line4 = getResource("doclet.Help_line_4");
++        Content packagePara = HtmlTree.P(line4);
++        liPackage.addContent(packagePara);
++        HtmlTree ulPackage = new HtmlTree(HtmlTag.UL);
++        ulPackage.addContent(HtmlTree.LI(
++                getResource("doclet.Interfaces_Italic")));
++        ulPackage.addContent(HtmlTree.LI(
++                getResource("doclet.Classes")));
++        ulPackage.addContent(HtmlTree.LI(
++                getResource("doclet.Enums")));
++        ulPackage.addContent(HtmlTree.LI(
++                getResource("doclet.Exceptions")));
++        ulPackage.addContent(HtmlTree.LI(
++                getResource("doclet.Errors")));
++        ulPackage.addContent(HtmlTree.LI(
++                getResource("doclet.AnnotationTypes")));
++        liPackage.addContent(ulPackage);
++        ul.addContent(liPackage);
++        Content classHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                getResource("doclet.Help_line_5"));
++        Content liClass = HtmlTree.LI(HtmlStyle.blockList, classHead);
++        Content line6 = getResource("doclet.Help_line_6");
++        Content classPara = HtmlTree.P(line6);
++        liClass.addContent(classPara);
++        HtmlTree ul1 = new HtmlTree(HtmlTag.UL);
++        ul1.addContent(HtmlTree.LI(
++                getResource("doclet.Help_line_7")));
++        ul1.addContent(HtmlTree.LI(
++                getResource("doclet.Help_line_8")));
++        ul1.addContent(HtmlTree.LI(
++                getResource("doclet.Help_line_9")));
++        ul1.addContent(HtmlTree.LI(
++                getResource("doclet.Help_line_10")));
++        ul1.addContent(HtmlTree.LI(
++                getResource("doclet.Help_line_11")));
++        ul1.addContent(HtmlTree.LI(
++                getResource("doclet.Help_line_12")));
++        liClass.addContent(ul1);
++        HtmlTree ul2 = new HtmlTree(HtmlTag.UL);
++        ul2.addContent(HtmlTree.LI(
++                getResource("doclet.Nested_Class_Summary")));
++        ul2.addContent(HtmlTree.LI(
++                getResource("doclet.Field_Summary")));
++        ul2.addContent(HtmlTree.LI(
++                getResource("doclet.Constructor_Summary")));
++        ul2.addContent(HtmlTree.LI(
++                getResource("doclet.Method_Summary")));
++        liClass.addContent(ul2);
++        HtmlTree ul3 = new HtmlTree(HtmlTag.UL);
++        ul3.addContent(HtmlTree.LI(
++                getResource("doclet.Field_Detail")));
++        ul3.addContent(HtmlTree.LI(
++                getResource("doclet.Constructor_Detail")));
++        ul3.addContent(HtmlTree.LI(
++                getResource("doclet.Method_Detail")));
++        liClass.addContent(ul3);
++        Content line13 = getResource("doclet.Help_line_13");
++        Content para = HtmlTree.P(line13);
++        liClass.addContent(para);
++        ul.addContent(liClass);
+         //Annotation Types
+-        blockquoteEnd();
+-        h3(); printText("doclet.AnnotationType"); h3End();
+-        blockquote(); p(); printText("doclet.Help_annotation_type_line_1");
+-        ul();
+-        li(); printText("doclet.Help_annotation_type_line_2");
+-        li(); printText("doclet.Help_annotation_type_line_3");
+-        li(); printText("doclet.Annotation_Type_Required_Member_Summary");
+-        li(); printText("doclet.Annotation_Type_Optional_Member_Summary");
+-        li(); printText("doclet.Annotation_Type_Member_Detail");
+-        ulEnd();
+-        blockquoteEnd();
+-
++        Content aHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                getResource("doclet.AnnotationType"));
++        Content liAnnotation = HtmlTree.LI(HtmlStyle.blockList, aHead);
++        Content aline1 = getResource("doclet.Help_annotation_type_line_1");
++        Content aPara = HtmlTree.P(aline1);
++        liAnnotation.addContent(aPara);
++        HtmlTree aul = new HtmlTree(HtmlTag.UL);
++        aul.addContent(HtmlTree.LI(
++                getResource("doclet.Help_annotation_type_line_2")));
++        aul.addContent(HtmlTree.LI(
++                getResource("doclet.Help_annotation_type_line_3")));
++        aul.addContent(HtmlTree.LI(
++                getResource("doclet.Annotation_Type_Required_Member_Summary")));
++        aul.addContent(HtmlTree.LI(
++                getResource("doclet.Annotation_Type_Optional_Member_Summary")));
++        aul.addContent(HtmlTree.LI(
++                getResource("doclet.Annotation_Type_Member_Detail")));
++        liAnnotation.addContent(aul);
++        ul.addContent(liAnnotation);
+         //Enums
+-        blockquoteEnd();
+-        h3(); printText("doclet.Enum"); h3End();
+-        blockquote(); p(); printText("doclet.Help_enum_line_1");
+-        ul();
+-        li(); printText("doclet.Help_enum_line_2");
+-        li(); printText("doclet.Help_enum_line_3");
+-        li(); printText("doclet.Enum_Constant_Summary");
+-        li(); printText("doclet.Enum_Constant_Detail");
+-        ulEnd();
+-        blockquoteEnd();
+-
++        Content enumHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                getResource("doclet.Enum"));
++        Content liEnum = HtmlTree.LI(HtmlStyle.blockList, enumHead);
++        Content eline1 = getResource("doclet.Help_enum_line_1");
++        Content enumPara = HtmlTree.P(eline1);
++        liEnum.addContent(enumPara);
++        HtmlTree eul = new HtmlTree(HtmlTag.UL);
++        eul.addContent(HtmlTree.LI(
++                getResource("doclet.Help_enum_line_2")));
++        eul.addContent(HtmlTree.LI(
++                getResource("doclet.Help_enum_line_3")));
++        eul.addContent(HtmlTree.LI(
++                getResource("doclet.Enum_Constant_Summary")));
++        eul.addContent(HtmlTree.LI(
++                getResource("doclet.Enum_Constant_Detail")));
++        liEnum.addContent(eul);
++        ul.addContent(liEnum);
+         if (configuration.classuse) {
+-            h3(); printText("doclet.Help_line_14"); h3End();
+-            blockquote();
+-            printText("doclet.Help_line_15");
+-            blockquoteEnd();
++            Content useHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                    getResource("doclet.Help_line_14"));
++            Content liUse = HtmlTree.LI(HtmlStyle.blockList, useHead);
++            Content line15 = getResource("doclet.Help_line_15");
++            Content usePara = HtmlTree.P(line15);
++            liUse.addContent(usePara);
++            ul.addContent(liUse);
+         }
+         if (configuration.createtree) {
+-            h3(); printText("doclet.Help_line_16"); h3End();
+-            blockquote();
+-            printText("doclet.Help_line_17_with_tree_link",
+-                 getHyperLink("overview-tree.html",
+-                 configuration.getText("doclet.Class_Hierarchy")));
+-            ul();
+-            li(); printText("doclet.Help_line_18");
+-            li(); printText("doclet.Help_line_19");
+-            ulEnd();
+-            blockquoteEnd();
++            Content treeHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                    getResource("doclet.Help_line_16"));
++            Content liTree = HtmlTree.LI(HtmlStyle.blockList, treeHead);
++            Content line17 = getResource("doclet.Help_line_17_with_tree_link",
++                    getHyperLinkString("overview-tree.html",
++                    configuration.getText("doclet.Class_Hierarchy")));
++            Content treePara = HtmlTree.P(line17);
++            liTree.addContent(treePara);
++            HtmlTree tul = new HtmlTree(HtmlTag.UL);
++            tul.addContent(HtmlTree.LI(
++                    getResource("doclet.Help_line_18")));
++            tul.addContent(HtmlTree.LI(
++                    getResource("doclet.Help_line_19")));
++            liTree.addContent(tul);
++            ul.addContent(liTree);
+         }
+         if (!(configuration.nodeprecatedlist ||
+                   configuration.nodeprecated)) {
+-            h3(); printText("doclet.Deprecated_API"); h3End();
+-            blockquote();
+-            printText("doclet.Help_line_20_with_deprecated_api_link",
+-                getHyperLink("deprecated-list.html",
+-                configuration.getText("doclet.Deprecated_API")));
+-            blockquoteEnd();
++            Content dHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                    getResource("doclet.Deprecated_API"));
++            Content liDeprecated = HtmlTree.LI(HtmlStyle.blockList, dHead);
++            Content line20 = getResource("doclet.Help_line_20_with_deprecated_api_link",
++                    getHyperLinkString("deprecated-list.html",
++                    configuration.getText("doclet.Deprecated_API")));
++            Content dPara = HtmlTree.P(line20);
++            liDeprecated.addContent(dPara);
++            ul.addContent(liDeprecated);
+         }
+         if (configuration.createindex) {
+             String indexlink;
+             if (configuration.splitindex) {
+-                indexlink = getHyperLink("index-files/index-1.html",
+-                    configuration.getText("doclet.Index"));
++                indexlink = getHyperLinkString("index-files/index-1.html",
++                        configuration.getText("doclet.Index"));
+             } else {
+-                indexlink = getHyperLink("index-all.html",
+-                    configuration.getText("doclet.Index"));
++                indexlink = getHyperLinkString("index-all.html",
++                        configuration.getText("doclet.Index"));
+             }
+-            h3(); printText("doclet.Help_line_21"); h3End();
+-            blockquote();
+-            printText("doclet.Help_line_22", indexlink);
+-            blockquoteEnd();
++            Content indexHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                    getResource("doclet.Help_line_21"));
++            Content liIndex = HtmlTree.LI(HtmlStyle.blockList, indexHead);
++            Content line22 = getResource("doclet.Help_line_22", indexlink);
++            Content indexPara = HtmlTree.P(line22);
++            liIndex.addContent(indexPara);
++            ul.addContent(liIndex);
+         }
+-        h3(); printText("doclet.Help_line_23"); h3End();
+-        printText("doclet.Help_line_24");
+-        h3(); printText("doclet.Help_line_25"); h3End();
+-        printText("doclet.Help_line_26"); p();
+-
+-        h3(); printText("doclet.Serialized_Form"); h3End();
+-        printText("doclet.Help_line_27"); p();
+-
+-        h3(); printText("doclet.Constants_Summary"); h3End();
+-        printText("doclet.Help_line_28"); p();
+-
+-        font("-1"); em();
+-        printText("doclet.Help_line_29");
+-        emEnd(); fontEnd(); br();
+-        hr();
++        Content prevHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                getResource("doclet.Help_line_23"));
++        Content liPrev = HtmlTree.LI(HtmlStyle.blockList, prevHead);
++        Content line24 = getResource("doclet.Help_line_24");
++        Content prevPara = HtmlTree.P(line24);
++        liPrev.addContent(prevPara);
++        ul.addContent(liPrev);
++        Content frameHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                getResource("doclet.Help_line_25"));
++        Content liFrame = HtmlTree.LI(HtmlStyle.blockList, frameHead);
++        Content line26 = getResource("doclet.Help_line_26");
++        Content framePara = HtmlTree.P(line26);
++        liFrame.addContent(framePara);
++        ul.addContent(liFrame);
++        Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                getResource("doclet.Serialized_Form"));
++        Content liSerial = HtmlTree.LI(HtmlStyle.blockList, sHead);
++        Content line27 = getResource("doclet.Help_line_27");
++        Content serialPara = HtmlTree.P(line27);
++        liSerial.addContent(serialPara);
++        ul.addContent(liSerial);
++        Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                getResource("doclet.Constants_Summary"));
++        Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead);
++        Content line28 = getResource("doclet.Help_line_28");
++        Content constPara = HtmlTree.P(line28);
++        liConst.addContent(constPara);
++        ul.addContent(liConst);
++        Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul);
++        Content line29 = HtmlTree.EM(getResource("doclet.Help_line_29"));
++        divContent.addContent(line29);
++        contentTree.addContent(divContent);
+     }
+ 
+     /**
+-     * Highlight the word "Help" in the navigation bar as this is the help file.
++     * Get the help label.
++     *
++     * @return a content tree for the help label
+      */
+-    protected void navLinkHelp() {
+-        navCellRevStart();
+-        fontStyle("NavBarFont1Rev");
+-        strongText("doclet.Help");
+-        fontEnd();
+-        navCellEnd();
++    protected Content getNavLinkHelp() {
++        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, helpLabel);
++        return li;
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
+@@ -144,8 +144,11 @@
+             !configuration.nohelp) {
+             HelpWriter.generate(configuration);
+         }
++        // If a stylesheet file is not specified, copy the default stylesheet.
+         if (configuration.stylesheetfile.length() == 0) {
+-            StylesheetWriter.generate(configuration);
++            Util.copyFile(configuration, "stylesheet.css", Util.RESOURCESDIR,
++                    (configdestdir.isEmpty()) ?
++                        System.getProperty("user.dir") : configdestdir, false);
+         }
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+@@ -88,6 +88,11 @@
+     public ConfigurationImpl configuration;
+ 
+     /**
++     * To check whether annotation heading is printed or not.
++     */
++    protected boolean printedAnnotationHeading = false;
++
++    /**
+      * Constructor to construct the HtmlStandardWriter object.
+      *
+      * @param filename File to be generated.
+@@ -169,7 +174,7 @@
+             // Append slash if next character is not a slash
+             if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length()
+                     && htmlstr.charAt(previndex) != '/') {
+-                buf.append(DirectoryManager.URL_FILE_SEPERATOR);
++                buf.append(DirectoryManager.URL_FILE_SEPARATOR);
+             }
+         }
+         return buf.toString();
+@@ -192,17 +197,47 @@
+         println("  <!--");
+         println("  if(window==top) {");
+         println("    document.writeln('"
+-            + getHyperLink(link, where, label, strong, "", "", target) + "');");
++            + getHyperLinkString(link, where, label, strong, "", "", target) + "');");
+         println("  }");
+         println("  //-->");
+         scriptEnd();
+         noScript();
+-        println("  " + getHyperLink(link, where, label, strong, "", "", target));
++        println("  " + getHyperLinkString(link, where, label, strong, "", "", target));
+         noScriptEnd();
+         println(DocletConstants.NL);
+     }
+ 
+-    private void printMethodInfo(MethodDoc method) {
++    /**
++     * Get the script to show or hide the All classes link.
++     *
++     * @param id id of the element to show or hide
++     * @return a content tree for the script
++     */
++    public Content getAllClassesLinkScript(String id) {
++        HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
++        script.addAttr(HtmlAttr.TYPE, "text/javascript");
++        String scriptCode = "<!--\n" +
++                "  allClassesLink = document.getElementById(\"" + id + "\");\n" +
++                "  if(window==top) {\n" +
++                "    allClassesLink.style.display = \"block\";\n" +
++                "  }\n" +
++                "  else {\n" +
++                "    allClassesLink.style.display = \"none\";\n" +
++                "  }\n" +
++                "  //-->\n";
++        Content scriptContent = new RawHtml(scriptCode);
++        script.addContent(scriptContent);
++        Content div = HtmlTree.DIV(script);
++        return div;
++    }
++
++    /**
++     * Add method information.
++     *
++     * @param method the method to be documented
++     * @param dl the content tree to which the method information will be added
++     */
++    private void addMethodInfo(MethodDoc method, Content dl) {
+         ClassDoc[] intfacs = method.containingClass().interfaces();
+         MethodDoc overriddenMethod = method.overriddenMethod();
+         // Check whether there is any implementation or overridden info to be
+@@ -211,44 +246,38 @@
+         if ((intfacs.length > 0 &&
+                 new ImplementedMethods(method, this.configuration).build().length > 0) ||
+                 overriddenMethod != null) {
+-            printMemberDetailsListStartTag();
+-            dd();
+-            printTagsInfoHeader();
+-            MethodWriterImpl.printImplementsInfo(this, method);
++            MethodWriterImpl.addImplementsInfo(this, method, dl);
+             if (overriddenMethod != null) {
+-                MethodWriterImpl.printOverridden(this,
+-                    method.overriddenType(), overriddenMethod);
++                MethodWriterImpl.addOverridden(this,
++                        method.overriddenType(), overriddenMethod, dl);
+             }
+-            printTagsInfoFooter();
+-            ddEnd();
+         }
+     }
+ 
+-    protected void printTags(Doc doc) {
+-        if(configuration.nocomment){
++    /**
++     * Adds the tags information.
++     *
++     * @param doc the doc for which the tags will be generated
++     * @param htmltree the documentation tree to which the tags will be added
++     */
++    protected void addTagsInfo(Doc doc, Content htmltree) {
++        if (configuration.nocomment) {
+             return;
+         }
++        Content dl = new HtmlTree(HtmlTag.DL);
+         if (doc instanceof MethodDoc) {
+-            printMethodInfo((MethodDoc) doc);
++            addMethodInfo((MethodDoc) doc, dl);
+         }
+         TagletOutputImpl output = new TagletOutputImpl("");
+         TagletWriter.genTagOuput(configuration.tagletManager, doc,
+             configuration.tagletManager.getCustomTags(doc),
+                 getTagletWriterInstance(false), output);
+         String outputString = output.toString().trim();
+-        // For RootDoc and ClassDoc, this section is not the definition description
+-        // but the start of definition list.
+         if (!outputString.isEmpty()) {
+-            if (!(doc instanceof RootDoc || doc instanceof ClassDoc)) {
+-                printMemberDetailsListStartTag();
+-                dd();
+-            }
+-            printTagsInfoHeader();
+-            print(outputString);
+-            printTagsInfoFooter();
+-            if (!(doc instanceof RootDoc || doc instanceof ClassDoc))
+-                ddEnd();
++            Content resultString = new RawHtml(outputString);
++            dl.addContent(resultString);
+         }
++        htmltree.addContent(dl);
+     }
+ 
+     /**
+@@ -284,17 +313,16 @@
+     }
+ 
+     /**
+-     * Print Package link, with target frame.
++     * Get Package link, with target frame.
+      *
+-     * @param pd The link will be to the "package-summary.html" page for this
+-     * package.
+-     * @param target Name of the target frame.
+-     * @param label Tag for the link.
++     * @param pd The link will be to the "package-summary.html" page for this package
++     * @param target name of the target frame
++     * @param label tag for the link
++     * @return a content for the target package link
+      */
+-    public void printTargetPackageLink(PackageDoc pd, String target,
+-        String label) {
+-        print(getHyperLink(pathString(pd, "package-summary.html"), "", label,
+-            false, "", "", target));
++    public Content getTargetPackageLink(PackageDoc pd, String target,
++            Content label) {
++        return getHyperLink(pathString(pd, "package-summary.html"), "", label, "", target);
+     }
+ 
+     /**
+@@ -358,6 +386,64 @@
+     }
+ 
+     /**
++     * Generates the HTML document tree and prints it out.
++     *
++     * @param metakeywords Array of String keywords for META tag. Each element
++     *                     of the array is assigned to a separate META tag.
++     *                     Pass in null for no array
++     * @param includeScript true if printing windowtitle script
++     *                      false for files that appear in the left-hand frames
++     * @param body the body htmltree to be included in the document
++     */
++    public void printHtmlDocument(String[] metakeywords, boolean includeScript,
++            Content body) {
++        Content htmlDocType = DocType.Transitional();
++        Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
++        Content head = new HtmlTree(HtmlTag.HEAD);
++        if (!configuration.notimestamp) {
++            Content headComment = new Comment("Generated by javadoc (version " +
++                    ConfigurationImpl.BUILD_DATE + ") on " + today());
++            head.addContent(headComment);
++        }
++        if (configuration.charset.length() > 0) {
++            Content meta = HtmlTree.META("Content-Type", "text/html",
++                    configuration.charset);
++            head.addContent(meta);
++        }
++        head.addContent(getTitle());
++        if (!configuration.notimestamp) {
++            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
++            Content meta = HtmlTree.META("date", dateFormat.format(new Date()));
++            head.addContent(meta);
++        }
++        if (metakeywords != null) {
++            for (int i=0; i < metakeywords.length; i++) {
++                Content meta = HtmlTree.META("keywords", metakeywords[i]);
++                head.addContent(meta);
++            }
++        }
++        head.addContent(getStyleSheetProperties());
++        Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
++                head, body);
++        Content htmlDocument = new HtmlDocument(htmlDocType,
++                htmlComment, htmlTree);
++        print(htmlDocument.toString());
++    }
++
++    /**
++     * Get the window title.
++     *
++     * @param title the title string to construct the complete window title
++     * @return the window title string
++     */
++    public String getWindowTitle(String title) {
++        if (configuration.windowtitle.length() > 0) {
++            title += " (" + configuration.windowtitle  + ")";
++        }
++        return title;
++    }
++
++    /**
+      * Print user specified header and the footer.
+      *
+      * @param header if true print the user provided header else print the
+@@ -378,6 +464,28 @@
+     }
+ 
+     /**
++     * Get user specified header and the footer.
++     *
++     * @param header if true print the user provided header else print the
++     * user provided footer.
++     */
++    public Content getUserHeaderFooter(boolean header) {
++        String content;
++        if (header) {
++            content = replaceDocRootDir(configuration.header);
++        } else {
++            if (configuration.footer.length() != 0) {
++                content = replaceDocRootDir(configuration.footer);
++            } else {
++                content = replaceDocRootDir(configuration.header);
++            }
++        }
++        Content rawContent = new RawHtml(content);
++        Content em = HtmlTree.EM(rawContent);
++        return em;
++    }
++
++    /**
+      * Print the user specified top.
+      */
+     public void printTop() {
+@@ -386,6 +494,16 @@
+     }
+ 
+     /**
++     * Adds the user specified top.
++     *
++     * @param body the content tree to which user specified top will be added
++     */
++    public void addTop(Content body) {
++        Content top = new RawHtml(replaceDocRootDir(configuration.top));
++        body.addContent(top);
++    }
++
++    /**
+      * Print the user specified bottom.
+      */
+     public void printBottom() {
+@@ -394,6 +512,18 @@
+     }
+ 
+     /**
++     * Adds the user specified bottom.
++     *
++     * @param body the content tree to which user specified bottom will be added
++     */
++    public void addBottom(Content body) {
++        Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom));
++        Content small = HtmlTree.SMALL(bottom);
++        Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
++        body.addContent(p);
++    }
++
++    /**
+      * Print the navigation bar for the Html page at the top and and the bottom.
+      *
+      * @param header If true print navigation bar at the top of the page else
+@@ -406,13 +536,13 @@
+                 println(DocletConstants.NL + "<!-- ========= START OF TOP NAVBAR ======= -->");
+                 anchor("navbar_top");
+                 println();
+-                print(getHyperLink("", "skip-navbar_top", "", false, "",
++                print(getHyperLinkString("", "skip-navbar_top", "", false, "",
+                     configuration.getText("doclet.Skip_navigation_links"), ""));
+             } else {
+                 println(DocletConstants.NL + "<!-- ======= START OF BOTTOM NAVBAR ====== -->");
+                 anchor("navbar_bottom");
+                 println();
+-                print(getHyperLink("", "skip-navbar_bottom", "", false, "",
++                print(getHyperLinkString("", "skip-navbar_bottom", "", false, "",
+                     configuration.getText("doclet.Skip_navigation_links"), ""));
+             }
+             table(0, "100%", 1, 0);
+@@ -516,6 +646,97 @@
+     }
+ 
+     /**
++     * Adds the navigation bar for the Html page at the top and and the bottom.
++     *
++     * @param header If true print navigation bar at the top of the page else
++     * @param body the HtmlTree to which the nav links will be added
++     */
++    protected void addNavLinks(boolean header, Content body) {
++        if (!configuration.nonavbar) {
++            String allClassesId = "allclasses_";
++            HtmlTree navDiv = new HtmlTree(HtmlTag.DIV);
++            if (header) {
++                body.addContent(HtmlConstants.START_OF_TOP_NAVBAR);
++                navDiv.addStyle(HtmlStyle.topNav);
++                allClassesId += "navbar_top";
++                Content a = getMarkerAnchor("navbar_top");
++                navDiv.addContent(a);
++                Content skipLinkContent = getHyperLink("",
++                        "skip-navbar_top", HtmlTree.EMPTY, configuration.getText(
++                        "doclet.Skip_navigation_links"), "");
++                navDiv.addContent(skipLinkContent);
++            } else {
++                body.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR);
++                navDiv.addStyle(HtmlStyle.bottomNav);
++                allClassesId += "navbar_bottom";
++                Content a = getMarkerAnchor("navbar_bottom");
++                navDiv.addContent(a);
++                Content skipLinkContent = getHyperLink("",
++                        "skip-navbar_bottom", HtmlTree.EMPTY, configuration.getText(
++                        "doclet.Skip_navigation_links"), "");
++                navDiv.addContent(skipLinkContent);
++            }
++            if (header) {
++                navDiv.addContent(getMarkerAnchor("navbar_top_firstrow"));
++            } else {
++                navDiv.addContent(getMarkerAnchor("navbar_bottom_firstrow"));
++            }
++            HtmlTree navList = new HtmlTree(HtmlTag.UL);
++            navList.addStyle(HtmlStyle.navList);
++            navList.addAttr(HtmlAttr.TITLE, "Navigation");
++            if (configuration.createoverview) {
++                navList.addContent(getNavLinkContents());
++            }
++            if (configuration.packages.length == 1) {
++                navList.addContent(getNavLinkPackage(configuration.packages[0]));
++            } else if (configuration.packages.length > 1) {
++                navList.addContent(getNavLinkPackage());
++            }
++            navList.addContent(getNavLinkClass());
++            if(configuration.classuse) {
++                navList.addContent(getNavLinkClassUse());
++            }
++            if(configuration.createtree) {
++                navList.addContent(getNavLinkTree());
++            }
++            if(!(configuration.nodeprecated ||
++                     configuration.nodeprecatedlist)) {
++                navList.addContent(getNavLinkDeprecated());
++            }
++            if(configuration.createindex) {
++                navList.addContent(getNavLinkIndex());
++            }
++            if (!configuration.nohelp) {
++                navList.addContent(getNavLinkHelp());
++            }
++            navDiv.addContent(navList);
++            Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, getUserHeaderFooter(header));
++            navDiv.addContent(aboutDiv);
++            body.addContent(navDiv);
++            Content ulNav = HtmlTree.UL(HtmlStyle.navList, getNavLinkPrevious());
++            ulNav.addContent(getNavLinkNext());
++            Content subDiv = HtmlTree.DIV(HtmlStyle.subNav, ulNav);
++            Content ulFrames = HtmlTree.UL(HtmlStyle.navList, getNavShowLists());
++            ulFrames.addContent(getNavHideLists(filename));
++            subDiv.addContent(ulFrames);
++            HtmlTree ulAllClasses = HtmlTree.UL(HtmlStyle.navList, getNavLinkClassIndex());
++            ulAllClasses.addAttr(HtmlAttr.ID, allClassesId.toString());
++            subDiv.addContent(ulAllClasses);
++            subDiv.addContent(getAllClassesLinkScript(allClassesId.toString()));
++            addSummaryDetailLinks(subDiv);
++            if (header) {
++                subDiv.addContent(getMarkerAnchor("skip-navbar_top"));
++                body.addContent(subDiv);
++                body.addContent(HtmlConstants.END_OF_TOP_NAVBAR);
++            } else {
++                subDiv.addContent(getMarkerAnchor("skip-navbar_bottom"));
++                body.addContent(subDiv);
++                body.addContent(HtmlConstants.END_OF_BOTTOM_NAVBAR);
++            }
++        }
++    }
++
++    /**
+      * Print the word "NEXT" to indicate that no link is available.  Override
+      * this method to customize next link.
+      */
+@@ -524,6 +745,16 @@
+     }
+ 
+     /**
++     * Get the word "NEXT" to indicate that no link is available.  Override
++     * this method to customize next link.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkNext() {
++        return getNavLinkNext(null);
++    }
++
++    /**
+      * Print the word "PREV" to indicate that no link is available.  Override
+      * this method to customize prev link.
+      */
+@@ -532,12 +763,28 @@
+     }
+ 
+     /**
++     * Get the word "PREV" to indicate that no link is available.  Override
++     * this method to customize prev link.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkPrevious() {
++        return getNavLinkPrevious(null);
++    }
++
++    /**
+      * Do nothing. This is the default method.
+      */
+     protected void printSummaryDetailLinks() {
+     }
+ 
+     /**
++     * Do nothing. This is the default method.
++     */
++    protected void addSummaryDetailLinks(Content navDiv) {
++    }
++
++    /**
+      * Print link to the "overview-summary.html" page.
+      */
+     protected void navLinkContents() {
+@@ -548,6 +795,18 @@
+     }
+ 
+     /**
++     * Get link to the "overview-summary.html" page.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkContents() {
++        Content linkContent = getHyperLink(relativePath +
++                "overview-summary.html", "", overviewLabel, "", "");
++        Content li = HtmlTree.LI(linkContent);
++        return li;
++    }
++
++    /**
+      * Description for a cell in the navigation bar.
+      */
+     protected void navCellStart() {
+@@ -588,6 +847,19 @@
+     }
+ 
+     /**
++     * Get link to the "package-summary.html" page for the package passed.
++     *
++     * @param pkg Package to which link will be generated
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkPackage(PackageDoc pkg) {
++        Content linkContent = getPackageLink(pkg,
++                packageLabel);
++        Content li = HtmlTree.LI(linkContent);
++        return li;
++    }
++
++    /**
+      * Print the word "Package" in the navigation bar cell, to indicate that
+      * link is not available here.
+      */
+@@ -600,6 +872,16 @@
+     }
+ 
+     /**
++     * Get the word "Package" , to indicate that link is not available here.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkPackage() {
++        Content li = HtmlTree.LI(packageLabel);
++        return li;
++    }
++
++    /**
+      * Print the word "Use" in the navigation bar cell, to indicate that link
+      * is not available.
+      */
+@@ -612,6 +894,16 @@
+     }
+ 
+     /**
++     * Get the word "Use", to indicate that link is not available.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkClassUse() {
++        Content li = HtmlTree.LI(useLabel);
++        return li;
++    }
++
++    /**
+      * Print link for previous file.
+      *
+      * @param prev File name for the prev link.
+@@ -626,6 +918,22 @@
+     }
+ 
+     /**
++     * Get link for previous file.
++     *
++     * @param prev File name for the prev link
++     * @return a content tree for the link
++     */
++    public Content getNavLinkPrevious(String prev) {
++        Content li;
++        if (prev != null) {
++            li = HtmlTree.LI(getHyperLink(prev, "", prevLabel, "", ""));
++        }
++        else
++            li = HtmlTree.LI(prevLabel);
++        return li;
++    }
++
++    /**
+      * Print link for next file.  If next is null, just print the label
+      * without linking it anywhere.
+      *
+@@ -641,16 +949,46 @@
+     }
+ 
+     /**
++     * Get link for next file.  If next is null, just print the label
++     * without linking it anywhere.
++     *
++     * @param next File name for the next link
++     * @return a content tree for the link
++     */
++    public Content getNavLinkNext(String next) {
++        Content li;
++        if (next != null) {
++            li = HtmlTree.LI(getHyperLink(next, "", nextLabel, "", ""));
++        }
++        else
++            li = HtmlTree.LI(nextLabel);
++        return li;
++    }
++
++    /**
+      * Print "FRAMES" link, to switch to the frame version of the output.
+      *
+      * @param link File to be linked, "index.html".
+      */
+     protected void navShowLists(String link) {
+-        print(getHyperLink(link + "?" + path + filename, "",
++        print(getHyperLinkString(link + "?" + path + filename, "",
+             configuration.getText("doclet.FRAMES"), true, "", "", "_top"));
+     }
+ 
+     /**
++     * Get "FRAMES" link, to switch to the frame version of the output.
++     *
++     * @param link File to be linked, "index.html"
++     * @return a content tree for the link
++     */
++    protected Content getNavShowLists(String link) {
++        Content framesContent = getHyperLink(link + "?" + path +
++                filename, "", framesLabel, "", "_top");
++        Content li = HtmlTree.LI(framesContent);
++        return li;
++    }
++
++    /**
+      * Print "FRAMES" link, to switch to the frame version of the output.
+      */
+     protected void navShowLists() {
+@@ -658,16 +996,37 @@
+     }
+ 
+     /**
++     * Get "FRAMES" link, to switch to the frame version of the output.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavShowLists() {
++        return getNavShowLists(relativePath + "index.html");
++    }
++
++    /**
+      * Print "NO FRAMES" link, to switch to the non-frame version of the output.
+      *
+      * @param link File to be linked.
+      */
+     protected void navHideLists(String link) {
+-        print(getHyperLink(link, "", configuration.getText("doclet.NO_FRAMES"),
++        print(getHyperLinkString(link, "", configuration.getText("doclet.NO_FRAMES"),
+             true, "", "", "_top"));
+     }
+ 
+     /**
++     * Get "NO FRAMES" link, to switch to the non-frame version of the output.
++     *
++     * @param link File to be linked
++     * @return a content tree for the link
++     */
++    protected Content getNavHideLists(String link) {
++        Content noFramesContent = getHyperLink(link, "", noframesLabel, "", "_top");
++        Content li = HtmlTree.LI(noFramesContent);
++        return li;
++    }
++
++    /**
+      * Print "Tree" link in the navigation bar. If there is only one package
+      * specified on the command line, then the "Tree" link will be to the
+      * only "package-tree.html" file otherwise it will be to the
+@@ -687,10 +1046,39 @@
+     }
+ 
+     /**
+-     * Print "Tree" link to the "overview-tree.html" file.
++     * Get "Tree" link in the navigation bar. If there is only one package
++     * specified on the command line, then the "Tree" link will be to the
++     * only "package-tree.html" file otherwise it will be to the
++     * "overview-tree.html" file.
++     *
++     * @return a content tree for the link
+      */
+-    protected void navLinkMainTree(String label) {
+-        printHyperLink(relativePath + "overview-tree.html", label);
++    protected Content getNavLinkTree() {
++        Content treeLinkContent;
++        PackageDoc[] packages = configuration.root.specifiedPackages();
++        if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) {
++            treeLinkContent = getHyperLink(pathString(packages[0],
++                    "package-tree.html"), "", treeLabel,
++                    "", "");
++        } else {
++            treeLinkContent = getHyperLink(relativePath + "overview-tree.html",
++                    "", treeLabel, "", "");
++        }
++        Content li = HtmlTree.LI(treeLinkContent);
++        return li;
++    }
++
++    /**
++     * Get the overview tree link for the main tree.
++     *
++     * @param label the label for the link
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkMainTree(String label) {
++        Content mainTreeContent = getHyperLink(relativePath + "overview-tree.html",
++                new StringContent(label));
++        Content li = HtmlTree.LI(mainTreeContent);
++        return li;
+     }
+ 
+     /**
+@@ -706,6 +1094,16 @@
+     }
+ 
+     /**
++     * Get the word "Class", to indicate that class link is not available.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkClass() {
++        Content li = HtmlTree.LI(classLabel);
++        return li;
++    }
++
++    /**
+      * Print "Deprecated" API link in the navigation bar.
+      */
+     protected void navLinkDeprecated() {
+@@ -716,6 +1114,18 @@
+     }
+ 
+     /**
++     * Get "Deprecated" API link in the navigation bar.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkDeprecated() {
++        Content linkContent = getHyperLink(relativePath +
++                "deprecated-list.html", "", deprecatedLabel, "", "");
++        Content li = HtmlTree.LI(linkContent);
++        return li;
++    }
++
++    /**
+      * Print link for generated index. If the user has used "-splitindex"
+      * command line option, then link to file "index-files/index-1.html" is
+      * generated otherwise link to file "index-all.html" is generated.
+@@ -725,6 +1135,21 @@
+                 AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES,
+             "", "", configuration.getText("doclet.All_Classes"), true);
+     }
++
++    /**
++     * Get link for generated index. If the user has used "-splitindex"
++     * command line option, then link to file "index-files/index-1.html" is
++     * generated otherwise link to file "index-all.html" is generated.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkClassIndex() {
++        Content allClassesContent = getHyperLink(relativePath +
++                AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "",
++                allclassesLabel, "", "");
++        Content li = HtmlTree.LI(allClassesContent);
++        return li;
++    }
+     /**
+      * Print link for generated class index.
+      */
+@@ -741,6 +1166,20 @@
+     }
+ 
+     /**
++     * Get link for generated class index.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkIndex() {
++        Content linkContent = getHyperLink(relativePath +(configuration.splitindex?
++            DirectoryManager.getPath("index-files") + fileseparator: "") +
++            (configuration.splitindex?"index-1.html" : "index-all.html"), "",
++            indexLabel, "", "");
++        Content li = HtmlTree.LI(linkContent);
++        return li;
++    }
++
++    /**
+      * Print help file link. If user has provided a help file, then generate a
+      * link to the user given file, which is already copied to current or
+      * destination directory.
+@@ -762,6 +1201,29 @@
+     }
+ 
+     /**
++     * Get help file link. If user has provided a help file, then generate a
++     * link to the user given file, which is already copied to current or
++     * destination directory.
++     *
++     * @return a content tree for the link
++     */
++    protected Content getNavLinkHelp() {
++        String helpfilenm = configuration.helpfile;
++        if (helpfilenm.equals("")) {
++            helpfilenm = "help-doc.html";
++        } else {
++            int lastsep;
++            if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) {
++                helpfilenm = helpfilenm.substring(lastsep + 1);
++            }
++        }
++        Content linkContent = getHyperLink(relativePath + helpfilenm, "",
++                helpLabel, "", "");
++        Content li = HtmlTree.LI(linkContent);
++        return li;
++    }
++
++    /**
+      * Print the word "Detail" in the navigation bar. No link is available.
+      */
+     protected void navDetail() {
+@@ -843,6 +1305,96 @@
+     }
+ 
+     /**
++     * Get summary table header.
++     *
++     * @param header the header for the table
++     * @param scope the scope of the headers
++     * @return a content tree for the header
++     */
++    public Content getSummaryTableHeader(String[] header, String scope) {
++        Content tr = new HtmlTree(HtmlTag.TR);
++        int size = header.length;
++        Content tableHeader;
++        if (size == 1) {
++            tableHeader = new StringContent(header[0]);
++            tr.addContent(HtmlTree.TH(HtmlStyle.colOne, scope, tableHeader));
++            return tr;
++        }
++        for (int i = 0; i < size; i++) {
++            tableHeader = new StringContent(header[i]);
++            if(i == 0)
++                tr.addContent(HtmlTree.TH(HtmlStyle.colFirst, scope, tableHeader));
++            else if(i == (size - 1))
++                tr.addContent(HtmlTree.TH(HtmlStyle.colLast, scope, tableHeader));
++            else
++                tr.addContent(HtmlTree.TH(scope, tableHeader));
++        }
++        return tr;
++    }
++
++    /**
++     * Get table caption.
++     *
++     * @param rawText the caption for the table which could be raw Html
++     * @return a content tree for the caption
++     */
++    public Content getTableCaption(String rawText) {
++        Content title = new RawHtml(rawText);
++        Content captionSpan = HtmlTree.SPAN(title);
++        Content space = getSpace();
++        Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space);
++        Content caption = HtmlTree.CAPTION(captionSpan);
++        caption.addContent(tabSpan);
++        return caption;
++    }
++
++    /**
++     * Get the marker anchor which will be added to the documentation tree.
++     *
++     * @param anchorName the anchor name attribute
++     * @return a content tree for the marker anchor
++     */
++    public Content getMarkerAnchor(String anchorName) {
++        return getMarkerAnchor(anchorName, null);
++    }
++
++    /**
++     * Get the marker anchor which will be added to the documentation tree.
++     *
++     * @param anchorName the anchor name attribute
++     * @param anchorContent the content that should be added to the anchor
++     * @return a content tree for the marker anchor
++     */
++    public Content getMarkerAnchor(String anchorName, Content anchorContent) {
++        if (anchorContent == null)
++            anchorContent = new Comment(" ");
++        Content markerAnchor = HtmlTree.A_NAME(anchorName, anchorContent);
++        return markerAnchor;
++    }
++
++    /**
++     * Returns a packagename content.
++     *
++     * @param packageDoc the package to check
++     * @return package name content
++     */
++    public Content getPackageName(PackageDoc packageDoc) {
++        return packageDoc == null || packageDoc.name().length() == 0 ?
++            defaultPackageLabel :
++            getPackageLabel(packageDoc.name());
++    }
++
++    /**
++     * Returns a package name label.
++     *
++     * @param parsedName the package name
++     * @return the package name content
++     */
++    public Content getPackageLabel(String packageName) {
++        return new StringContent(packageName);
++    }
++
++    /**
+      * Prine table header information about color, column span and the font.
+      *
+      * @param color Background color.
+@@ -1026,7 +1578,7 @@
+      * @param isStrong true if the label should be strong.
+      */
+     public void printPackageLink(PackageDoc pkg, String label, boolean isStrong) {
+-        print(getPackageLink(pkg, label, isStrong));
++        print(getPackageLinkString(pkg, label, isStrong));
+     }
+ 
+     /**
+@@ -1039,7 +1591,7 @@
+      */
+     public void printPackageLink(PackageDoc pkg, String label, boolean isStrong,
+             String style) {
+-        print(getPackageLink(pkg, label, isStrong, style));
++        print(getPackageLinkString(pkg, label, isStrong, style));
+     }
+ 
+     /**
+@@ -1050,9 +1602,9 @@
+      * @param isStrong true if the label should be strong.
+      * @return the link to the given package.
+      */
+-    public String getPackageLink(PackageDoc pkg, String label,
++    public String getPackageLinkString(PackageDoc pkg, String label,
+                                  boolean isStrong) {
+-        return getPackageLink(pkg, label, isStrong, "");
++        return getPackageLinkString(pkg, label, isStrong, "");
+     }
+ 
+     /**
+@@ -1064,7 +1616,7 @@
+      * @param style  the font of the package link label.
+      * @return the link to the given package.
+      */
+-    public String getPackageLink(PackageDoc pkg, String label, boolean isStrong,
++    public String getPackageLinkString(PackageDoc pkg, String label, boolean isStrong,
+             String style) {
+         boolean included = pkg != null && pkg.isIncluded();
+         if (! included) {
+@@ -1077,12 +1629,43 @@
+             }
+         }
+         if (included || pkg == null) {
+-            return getHyperLink(pathString(pkg, "package-summary.html"),
++            return getHyperLinkString(pathString(pkg, "package-summary.html"),
+                                 "", label, isStrong, style);
+         } else {
+             String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
+             if (crossPkgLink != null) {
+-                return getHyperLink(crossPkgLink, "", label, isStrong, style);
++                return getHyperLinkString(crossPkgLink, "", label, isStrong, style);
++            } else {
++                return label;
++            }
++        }
++    }
++
++    /**
++     * Return the link to the given package.
++     *
++     * @param pkg the package to link to.
++     * @param label the label for the link.
++     * @return a content tree for the package link.
++     */
++    public Content getPackageLink(PackageDoc pkg, Content label) {
++        boolean included = pkg != null && pkg.isIncluded();
++        if (! included) {
++            PackageDoc[] packages = configuration.packages;
++            for (int i = 0; i < packages.length; i++) {
++                if (packages[i].equals(pkg)) {
++                    included = true;
++                    break;
++                }
++            }
++        }
++        if (included || pkg == null) {
++            return getHyperLink(pathString(pkg, "package-summary.html"),
++                                "", label);
++        } else {
++            String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg));
++            if (crossPkgLink != null) {
++                return getHyperLink(crossPkgLink, "", label);
+             } else {
+                 return label;
+             }
+@@ -1110,6 +1693,29 @@
+     }
+ 
+     /**
++     * Add the link to the content tree.
++     *
++     * @param doc program element doc for which the link will be added
++     * @param label label for the link
++     * @param htmltree the content tree to which the link will be added
++     */
++    public void addSrcLink(ProgramElementDoc doc, Content label, Content htmltree) {
++        if (doc == null) {
++            return;
++        }
++        ClassDoc cd = doc.containingClass();
++        if (cd == null) {
++            //d must be a class doc since in has no containing class.
++            cd = (ClassDoc) doc;
++        }
++        String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME
++                + DirectoryManager.getDirectoryPath(cd.containingPackage())
++                + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(doc);
++        Content linkContent = getHyperLink(href, "", label, "", "");
++        htmltree.addContent(linkContent);
++    }
++
++    /**
+      * Return the link to the given class.
+      *
+      * @param linkInfo the information about the link.
+@@ -1173,7 +1779,7 @@
+                 //the -link option.  There are ways to determine if an external package
+                 //exists, but no way to determine if the external class exists.  We just
+                 //have to assume that it does.
+-                return getHyperLink(
++                return getHyperLinkString(
+                     configuration.extern.getExternalLink(packageName, relativePath,
+                                 className + ".html?is-external=true"),
+                     refMemName == null ? "" : refMemName,
+@@ -1198,17 +1804,27 @@
+             "package-summary.html?is-external=true");
+     }
+ 
+-    public void printQualifiedClassLink(int context, ClassDoc cd) {
+-        printLink(new LinkInfoImpl(context, cd,
+-            configuration.getClassName(cd), ""));
++    /**
++     * Get the class link.
++     *
++     * @param context the id of the context where the link will be added
++     * @param cd the class doc to link to
++     * @return a content tree for the link
++     */
++    public Content getQualifiedClassLink(int context, ClassDoc cd) {
++        return new RawHtml(getLink(new LinkInfoImpl(context, cd,
++                configuration.getClassName(cd), "")));
+     }
+ 
+     /**
+-     * Print Class link, with only class name as the link and prefixing
+-     * plain package name.
++     * Add the class link.
++     *
++     * @param context the id of the context where the link will be added
++     * @param cd the class doc to link to
++     * @param contentTree the content tree to which the link will be added
+      */
+-    public void printPreQualifiedClassLink(int context, ClassDoc cd) {
+-        print(getPreQualifiedClassLink(context, cd, false));
++    public void addPreQualifiedClassLink(int context, ClassDoc cd, Content contentTree) {
++        addPreQualifiedClassLink(context, cd, false, contentTree);
+     }
+ 
+     /**
+@@ -1231,13 +1847,36 @@
+         return classlink;
+     }
+ 
++    /**
++     * Add the class link with the package portion of the label in
++     * plain text. If the qualifier is excluded, it will not be included in the
++     * link label.
++     *
++     * @param context the id of the context where the link will be added
++     * @param cd the class to link to
++     * @param isStrong true if the link should be strong
++     * @param contentTree the content tree to which the link with be added
++     */
++    public void addPreQualifiedClassLink(int context,
++            ClassDoc cd, boolean isStrong, Content contentTree) {
++        PackageDoc pd = cd.containingPackage();
++        if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) {
++            contentTree.addContent(getPkgName(cd));
++        }
++        contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl(
++                context, cd, cd.name(), isStrong))));
++    }
+ 
+     /**
+-     * Print Class link, with only class name as the strong link and prefixing
++     * Add the class link, with only class name as the strong link and prefixing
+      * plain package name.
++     *
++     * @param context the id of the context where the link will be added
++     * @param cd the class to link to
++     * @param contentTree the content tree to which the link with be added
+      */
+-    public void printPreQualifiedStrongClassLink(int context, ClassDoc cd) {
+-        print(getPreQualifiedClassLink(context, cd, true));
++    public void addPreQualifiedStrongClassLink(int context, ClassDoc cd, Content contentTree) {
++        addPreQualifiedClassLink(context, cd, true, contentTree);
+     }
+ 
+     public void printText(String key) {
+@@ -1265,16 +1904,15 @@
+     }
+ 
+     /**
+-     * Print the link for the given member.
++     * Get the link for the given member.
+      *
+-     * @param context the id of the context where the link will be printed.
+-     * @param doc the member being linked to.
+-     * @param label the label for the link.
+-     * @param strong true if the link should be strong.
++     * @param context the id of the context where the link will be added
++     * @param doc the member being linked to
++     * @param label the label for the link
++     * @return a content tree for the doc link
+      */
+-    public void printDocLink(int context, MemberDoc doc, String label,
+-            boolean strong) {
+-        print(getDocLink(context, doc, label, strong));
++    public Content getDocLink(int context, MemberDoc doc, String label) {
++        return getDocLink(context, doc.containingClass(), doc, label);
+     }
+ 
+     /**
+@@ -1336,6 +1974,34 @@
+         }
+     }
+ 
++    /**
++     * Return the link for the given member.
++     *
++     * @param context the id of the context where the link will be added
++     * @param classDoc the classDoc that we should link to.  This is not
++     *                 necessarily equal to doc.containingClass().  We may be
++     *                 inheriting comments
++     * @param doc the member being linked to
++     * @param label the label for the link
++     * @return the link for the given member
++     */
++    public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc,
++        String label) {
++        if (! (doc.isIncluded() ||
++            Util.isLinkable(classDoc, configuration()))) {
++            return new StringContent(label);
++        } else if (doc instanceof ExecutableMemberDoc) {
++            ExecutableMemberDoc emd = (ExecutableMemberDoc)doc;
++            return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
++                getAnchor(emd), label, false)));
++        } else if (doc instanceof MemberDoc) {
++            return new RawHtml(getLink(new LinkInfoImpl(context, classDoc,
++                doc.name(), label, false)));
++        } else {
++            return new StringContent(label);
++        }
++    }
++
+     public void anchor(ExecutableMemberDoc emd) {
+         anchor(getAnchor(emd));
+     }
+@@ -1390,14 +2056,14 @@
+                 //@see is referencing an included package
+                 String packageName = isplaintext ? refPackage.name() :
+                     getCode() + refPackage.name() + getCodeEnd();
+-                result.append(getPackageLink(refPackage,
++                result.append(getPackageLinkString(refPackage,
+                     label.length() == 0 ? packageName : label, false));
+             } else {
+                 //@see is not referencing an included class or package.  Check for cross links.
+                 String classCrossLink, packageCrossLink = getCrossPackageLink(refClassName);
+                 if (packageCrossLink != null) {
+                     //Package cross link found
+-                    result.append(getHyperLink(packageCrossLink, "",
++                    result.append(getHyperLinkString(packageCrossLink, "",
+                         (label.length() == 0)? text : label, false));
+                 } else if ((classCrossLink = getCrossClassLink(refClassName,
+                         refMemName, label, false, "", ! isplaintext)) != null) {
+@@ -1456,18 +2122,61 @@
+         printCommentTags(doc, tag.inlineTags(), false, false);
+     }
+ 
++    /**
++     * Add the inline comment.
++     *
++     * @param doc the doc for which the inline comment will be added
++     * @param tag the inline tag to be added
++     * @param htmltree the content tree to which the comment will be added
++     */
++    public void addInlineComment(Doc doc, Tag tag, Content htmltree) {
++        addCommentTags(doc, tag.inlineTags(), false, false, htmltree);
++    }
++
+     public void printInlineDeprecatedComment(Doc doc, Tag tag) {
+         printCommentTags(doc, tag.inlineTags(), true, false);
+     }
+ 
++    /**
++     * Add the inline deprecated comment.
++     *
++     * @param doc the doc for which the inline deprecated comment will be added
++     * @param tag the inline tag to be added
++     * @param htmltree the content tree to which the comment will be added
++     */
++    public void addInlineDeprecatedComment(Doc doc, Tag tag, Content htmltree) {
++        addCommentTags(doc, tag.inlineTags(), true, false, htmltree);
++    }
++
+     public void printSummaryComment(Doc doc) {
+         printSummaryComment(doc, doc.firstSentenceTags());
+     }
+ 
++    /**
++     * Adds the summary content.
++     *
++     * @param doc the doc for which the summary will be generated
++     * @param htmltree the documentation tree to which the summary will be added
++     */
++    public void addSummaryComment(Doc doc, Content htmltree) {
++        addSummaryComment(doc, doc.firstSentenceTags(), htmltree);
++    }
++
+     public void printSummaryComment(Doc doc, Tag[] firstSentenceTags) {
+         printCommentTags(doc, firstSentenceTags, false, true);
+     }
+ 
++    /**
++     * Adds the summary content.
++     *
++     * @param doc the doc for which the summary will be generated
++     * @param firstSentenceTags the first sentence tags for the doc
++     * @param htmltree the documentation tree to which the summary will be added
++     */
++    public void addSummaryComment(Doc doc, Tag[] firstSentenceTags, Content htmltree) {
++        addCommentTags(doc, firstSentenceTags, false, true, htmltree);
++    }
++
+     public void printSummaryDeprecatedComment(Doc doc) {
+         printCommentTags(doc, doc.firstSentenceTags(), true, true);
+     }
+@@ -1476,11 +2185,25 @@
+         printCommentTags(doc, tag.firstSentenceTags(), true, true);
+     }
+ 
++    public void addSummaryDeprecatedComment(Doc doc, Tag tag, Content htmltree) {
++        addCommentTags(doc, tag.firstSentenceTags(), true, true, htmltree);
++    }
++
+     public void printInlineComment(Doc doc) {
+         printCommentTags(doc, doc.inlineTags(), false, false);
+         p();
+     }
+ 
++    /**
++     * Adds the inline comment.
++     *
++     * @param doc the doc for which the inline comments will be generated
++     * @param htmltree the documentation tree to which the inline comments will be added
++     */
++    public void addInlineComment(Doc doc, Content htmltree) {
++        addCommentTags(doc, doc.inlineTags(), false, false, htmltree);
++    }
++
+     public void printInlineDeprecatedComment(Doc doc) {
+         printCommentTags(doc, doc.inlineTags(), true, false);
+     }
+@@ -1503,6 +2226,36 @@
+     }
+ 
+     /**
++     * Adds the comment tags.
++     *
++     * @param doc the doc for which the comment tags will be generated
++     * @param tags the first sentence tags for the doc
++     * @param depr true if it is deprecated
++     * @param first true if the first sentenge tags should be added
++     * @param htmltree the documentation tree to which the comment tags will be added
++     */
++    private void addCommentTags(Doc doc, Tag[] tags, boolean depr,
++            boolean first, Content htmltree) {
++        if(configuration.nocomment){
++            return;
++        }
++        Content div;
++        Content result = new RawHtml(commentTagsToString(null, doc, tags, first));
++        if (depr) {
++            Content italic = HtmlTree.I(result);
++            div = HtmlTree.DIV(HtmlStyle.block, italic);
++            htmltree.addContent(div);
++        }
++        else {
++            div = HtmlTree.DIV(HtmlStyle.block, result);
++            htmltree.addContent(div);
++        }
++        if (tags.length == 0) {
++            htmltree.addContent(getSpace());
++        }
++    }
++
++    /**
+      * Converts inline tags and text to text strings, expanding the
+      * inline tags along the way.  Called wherever text can contain
+      * an inline tag, such as in comments or in free-form text arguments
+@@ -1612,8 +2365,8 @@
+             return text;
+         }
+ 
+-        if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPERATOR)) {
+-            redirectPathFromRoot += DirectoryManager.URL_FILE_SEPERATOR;
++        if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPARATOR)) {
++            redirectPathFromRoot += DirectoryManager.URL_FILE_SEPARATOR;
+         }
+ 
+         //Redirect all relative links.
+@@ -1739,6 +2492,27 @@
+     }
+ 
+     /**
++     * Returns a link to the stylesheet file.
++     *
++     * @return an HtmlTree for the lINK tag which provides the stylesheet location
++     */
++    public HtmlTree getStyleSheetProperties() {
++        String filename = configuration.stylesheetfile;
++        if (filename.length() > 0) {
++            File stylefile = new File(filename);
++            String parent = stylefile.getParent();
++            filename = (parent == null)?
++                filename:
++                filename.substring(parent.length() + 1);
++        } else {
++            filename = "stylesheet.css";
++        }
++        filename = relativePath + filename;
++        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
++        return link;
++    }
++
++    /**
+      * According to the Java Language Specifications, all the outer classes
+      * and static nested classes are core classes.
+      */
+@@ -1765,6 +2539,16 @@
+     }
+ 
+     /**
++     * Adds the annotatation types for the given doc.
++     *
++     * @param packageDoc the package to write annotations for
++     * @param htmltree the content tree to which the annotation types will be added
++     */
++    public void addAnnotationInfo(ProgramElementDoc doc, Content htmltree) {
++        addAnnotationInfo(doc, doc.annotations(), htmltree);
++    }
++
++    /**
+      * Write the annotatation types for the given doc and parameter.
+      *
+      * @param indent the number of spaced to indent the parameters.
+@@ -1776,6 +2560,30 @@
+     }
+ 
+     /**
++     * Adds the annotatation types for the given packageDoc.
++     *
++     * @param packageDoc the package to write annotations for.
++     * @param htmltree the documentation tree to which the annotation info will be
++     *        added
++     */
++    public void addAnnotationInfo(PackageDoc packageDoc, Content htmltree) {
++        addAnnotationInfo(packageDoc, packageDoc.annotations(), htmltree);
++    }
++
++    /**
++     * Add the annotatation types for the given doc and parameter.
++     *
++     * @param indent the number of spaces to indent the parameters.
++     * @param doc the doc to write annotations for.
++     * @param param the parameter to write annotations for.
++     * @param tree the content tree to which the annotation types will be added
++     */
++    public boolean addAnnotationInfo(int indent, Doc doc, Parameter param,
++            Content tree) {
++        return addAnnotationInfo(indent, doc, param.annotations(), false, tree);
++    }
++
++    /**
+      * Write the annotatation types for the given doc.
+      *
+      * @param doc the doc to write annotations for.
+@@ -1786,6 +2594,19 @@
+     }
+ 
+     /**
++     * Adds the annotatation types for the given doc.
++     *
++     * @param doc the doc to write annotations for.
++     * @param descList the array of {@link AnnotationDesc}.
++     * @param htmltree the documentation tree to which the annotation info will be
++     *        added
++     */
++    private void addAnnotationInfo(Doc doc, AnnotationDesc[] descList,
++            Content htmltree) {
++        addAnnotationInfo(0, doc, descList, true, htmltree);
++    }
++
++    /**
+      * Write the annotatation types for the given doc.
+      *
+      * @param indent the number of extra spaces to indent the annotations.
+@@ -1806,6 +2627,29 @@
+     }
+ 
+     /**
++     * Adds the annotatation types for the given doc.
++     *
++     * @param indent the number of extra spaces to indent the annotations.
++     * @param doc the doc to write annotations for.
++     * @param descList the array of {@link AnnotationDesc}.
++     * @param htmltree the documentation tree to which the annotation info will be
++     *        added
++     */
++    private boolean addAnnotationInfo(int indent, Doc doc,
++            AnnotationDesc[] descList, boolean lineBreak, Content htmltree) {
++        List<String> annotations = getAnnotations(indent, descList, lineBreak);
++        if (annotations.size() == 0) {
++            return false;
++        }
++        Content annotationContent;
++        for (Iterator<String> iter = annotations.iterator(); iter.hasNext();) {
++            annotationContent = new RawHtml(iter.next());
++            htmltree.addContent(annotationContent);
++        }
++        return true;
++    }
++
++   /**
+      * Return the string representations of the annotation types for
+      * the given doc.
+      *
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java
+@@ -31,6 +31,7 @@
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Generate serialized form for serializable fields.
+@@ -46,8 +47,6 @@
+ 
+     private boolean printedOverallAnchor = false;
+ 
+-    private boolean printedFirstMember = false;
+-
+     public HtmlSerialFieldWriter(SubWriterHolderWriter writer,
+                                     ClassDoc classdoc) {
+         super(writer, classdoc);
+@@ -69,109 +68,143 @@
+         }
+     }
+ 
+-    public void writeHeader(String heading) {
+-        if (! printedOverallAnchor) {
+-            writer.anchor("serializedForm");
+-            printedOverallAnchor = true;
+-            writer.printTableHeadingBackground(heading);
+-            writer.println();
+-            if (heading.equals(
+-                   configuration().getText("doclet.Serialized_Form_class"))) {
+-                assert !writer.getMemberDetailsListPrinted();
+-            }
+-        } else {
+-            writer.printTableHeadingBackground(heading);
+-            writer.println();
+-        }
+-    }
+-
+-    public void writeMemberHeader(ClassDoc fieldType, String fieldTypeStr,
+-            String fieldDimensions, String fieldName) {
+-        if (printedFirstMember) {
+-            writer.printMemberHeader();
+-        }
+-        printedFirstMember = true;
+-        writer.h3();
+-        writer.print(fieldName);
+-        writer.h3End();
+-        writer.pre();
+-        if (fieldType == null) {
+-            writer.print(fieldTypeStr);
+-        } else {
+-            writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIAL_MEMBER,
+-                fieldType));
+-        }
+-        print(fieldDimensions + ' ');
+-        strong(fieldName);
+-        writer.preEnd();
+-        assert !writer.getMemberDetailsListPrinted();
++    /**
++     * Return the header for serializable fields section.
++     *
++     * @return a content tree for the header
++     */
++    public Content getSerializableFieldsHeader() {
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
++        return ul;
+     }
+ 
+     /**
+-     * Write the deprecated information for this member.
++     * Return the header for serializable fields content section.
+      *
+-     * @param field the field to document.
++     * @param isLastContent true if the cotent being documented is the last content.
++     * @return a content tree for the header
+      */
+-    public void writeMemberDeprecatedInfo(FieldDoc field) {
+-        printDeprecated(field);
++    public Content getFieldsContentHeader(boolean isLastContent) {
++        HtmlTree li = new HtmlTree(HtmlTag.LI);
++        if (isLastContent)
++            li.addStyle(HtmlStyle.blockListLast);
++        else
++            li.addStyle(HtmlStyle.blockList);
++        return li;
+     }
+ 
+     /**
+-     * Write the description text for this member.
++     * Add serializable fields.
++     *
++     * @param heading the heading for the section
++     * @param serializableFieldsTree the tree to be added to the serializable fileds
++     *        content tree
++     * @return a content tree for the serializable fields content
++     */
++    public Content getSerializableFields(String heading, Content serializableFieldsTree) {
++        HtmlTree li = new HtmlTree(HtmlTag.LI);
++        li.addStyle(HtmlStyle.blockList);
++        if (serializableFieldsTree.isValid()) {
++            if (!printedOverallAnchor) {
++                li.addContent(writer.getMarkerAnchor("serializedForm"));
++                printedOverallAnchor = true;
++            }
++            Content headingContent = new StringContent(heading);
++            Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
++                    headingContent);
++            li.addContent(serialHeading);
++            li.addContent(serializableFieldsTree);
++        }
++        return li;
++    }
++
++    /**
++     * Add the member header.
++     *
++     * @param fieldsType the class document to be listed
++     * @param fieldTypeStr the string for the filed type to be documented
++     * @param fieldDimensions the dimensions of the field string to be added
++     * @param firldName name of the field to be added
++     * @param contentTree the content tree to which the member header will be added
++     */
++    public void addMemberHeader(ClassDoc fieldType, String fieldTypeStr,
++            String fieldDimensions, String fieldName, Content contentTree) {
++        Content nameContent = new RawHtml(fieldName);
++        Content heading = HtmlTree.HEADING(HtmlConstants.MEMBER_HEADING, nameContent);
++        contentTree.addContent(heading);
++        Content pre = new HtmlTree(HtmlTag.PRE);
++        if (fieldType == null) {
++            pre.addContent(fieldTypeStr);
++        } else {
++            Content fieldContent = new RawHtml(writer.getLink(new LinkInfoImpl(
++                    LinkInfoImpl.CONTEXT_SERIAL_MEMBER, fieldType)));
++            pre.addContent(fieldContent);
++        }
++        pre.addContent(fieldDimensions + " ");
++        pre.addContent(fieldName);
++        contentTree.addContent(pre);
++    }
++
++    /**
++     * Add the deprecated information for this member.
+      *
+      * @param field the field to document.
++     * @param contentTree the tree to which the deprecated info will be added
+      */
+-    public void writeMemberDescription(FieldDoc field) {
++    public void addMemberDeprecatedInfo(FieldDoc field, Content contentTree) {
++        addDeprecatedInfo(field, contentTree);
++    }
++
++    /**
++     * Add the description text for this member.
++     *
++     * @param field the field to document.
++     * @param contentTree the tree to which the deprecated info will be added
++     */
++    public void addMemberDescription(FieldDoc field, Content contentTree) {
+         if (field.inlineTags().length > 0) {
+-            writer.printMemberDetailsListStartTag();
+-            writer.dd();
+-            writer.printInlineComment(field);
+-            writer.ddEnd();
++            writer.addInlineComment(field, contentTree);
+         }
+         Tag[] tags = field.tags("serial");
+         if (tags.length > 0) {
+-            writer.printMemberDetailsListStartTag();
+-            writer.dd();
+-            writer.printInlineComment(field, tags[0]);
+-            writer.ddEnd();
++            writer.addInlineComment(field, tags[0], contentTree);
+         }
+     }
+ 
+     /**
+-     * Write the description text for this member represented by the tag.
++     * Add the description text for this member represented by the tag.
+      *
+-     * @param serialFieldTag the field to document (represented by tag).
++     * @param serialFieldTag the field to document (represented by tag)
++     * @param contentTree the tree to which the deprecated info will be added
+      */
+-    public void writeMemberDescription(SerialFieldTag serialFieldTag) {
++    public void addMemberDescription(SerialFieldTag serialFieldTag, Content contentTree) {
+         String serialFieldTagDesc = serialFieldTag.description().trim();
+         if (!serialFieldTagDesc.isEmpty()) {
+-            writer.dl();
+-            writer.dd();
+-            writer.print(serialFieldTagDesc);
+-            writer.ddEnd();
+-            writer.dlEnd();
++            Content serialFieldContent = new RawHtml(serialFieldTagDesc);
++            Content div = HtmlTree.DIV(HtmlStyle.block, serialFieldContent);
++            contentTree.addContent(div);
+         }
+     }
+ 
+     /**
+-     * Write the tag information for this member.
++     * Add the tag information for this member.
+      *
+      * @param field the field to document.
++     * @param contentTree the tree to which the member tags info will be added
+      */
+-    public void writeMemberTags(FieldDoc field) {
++    public void addMemberTags(FieldDoc field, Content contentTree) {
+         TagletOutputImpl output = new TagletOutputImpl("");
+         TagletWriter.genTagOuput(configuration().tagletManager, field,
+-            configuration().tagletManager.getCustomTags(field),
++                configuration().tagletManager.getCustomTags(field),
+                 writer.getTagletWriterInstance(false), output);
+         String outputString = output.toString().trim();
++        Content dlTags = new HtmlTree(HtmlTag.DL);
+         if (!outputString.isEmpty()) {
+-            writer.printMemberDetailsListStartTag();
+-            writer.dd();
+-            writer.dl();
+-            print(outputString);
+-            writer.dlEnd();
+-            writer.ddEnd();
++            Content tagContent = new RawHtml(outputString);
++            dlTags.addContent(tagContent);
+         }
++        contentTree.addContent(dlTags);
+     }
+ 
+     /**
+@@ -192,24 +225,4 @@
+             return true;
+         return false;
+     }
+-
+-    public void writeMemberFooter() {
+-        printMemberFooter();
+-    }
+-
+-    /**
+-     * Write the footer information. If the serilization overview section was
+-     * printed, check for definition list and close list tag.
+-     *
+-     * @param heading the heading that was written.
+-     */
+-    public void writeFooter(String heading) {
+-        if (printedOverallAnchor) {
+-            if (heading.equals(
+-                   configuration().getText("doclet.Serialized_Form_class"))) {
+-                writer.printMemberDetailsListEndTag();
+-                assert !writer.getMemberDetailsListPrinted();
+-            }
+-        }
+-    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialMethodWriter.java
+@@ -28,57 +28,119 @@
+ import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.taglets.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Generate serialized form for Serializable/Externalizable methods.
+  * Documentation denoted by the <code>serialData</code> tag is processed.
+  *
+  * @author Joe Fialli
++ * @author Bhavesh Patel (Modified)
+  */
+ public class HtmlSerialMethodWriter extends MethodWriterImpl implements
+         SerializedFormWriter.SerialMethodWriter{
+ 
+-    private boolean printedFirstMember = false;
+-
+     public HtmlSerialMethodWriter(SubWriterHolderWriter writer,
+             ClassDoc classdoc) {
+         super(writer, classdoc);
+     }
+ 
+-    public void writeHeader(String heading) {
+-        writer.anchor("serialized_methods");
+-        writer.printTableHeadingBackground(heading);
+-        writer.p();
++    /**
++     * Return the header for serializable methods section.
++     *
++     * @return a content tree for the header
++     */
++    public Content getSerializableMethodsHeader() {
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
++        return ul;
+     }
+ 
+-    public void writeNoCustomizationMsg(String msg) {
+-        writer.print(msg);
+-        writer.p();
++    /**
++     * Return the header for serializable methods content section.
++     *
++     * @param isLastContent true if the cotent being documented is the last content.
++     * @return a content tree for the header
++     */
++    public Content getMethodsContentHeader(boolean isLastContent) {
++        HtmlTree li = new HtmlTree(HtmlTag.LI);
++        if (isLastContent)
++            li.addStyle(HtmlStyle.blockListLast);
++        else
++            li.addStyle(HtmlStyle.blockList);
++        return li;
+     }
+ 
+-    public void writeMemberHeader(MethodDoc member) {
+-        if (printedFirstMember) {
+-            writer.printMemberHeader();
+-        }
+-        printedFirstMember = true;
+-        writer.anchor(member);
+-        printHead(member);
+-        writeSignature(member);
++    /**
++     * Add serializable methods.
++     *
++     * @param heading the heading for the section
++     * @param serializableMethodContent the tree to be added to the serializable methods
++     *        content tree
++     * @return a content tree for the serializable methods content
++     */
++    public Content getSerializableMethods(String heading, Content serializableMethodContent) {
++        Content li = HtmlTree.LI(HtmlStyle.blockList, writer.getMarkerAnchor(
++                "serialized_methods"));
++        Content headingContent = new StringContent(heading);
++        Content serialHeading = HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
++                headingContent);
++        li.addContent(serialHeading);
++        li.addContent(serializableMethodContent);
++        return li;
+     }
+ 
+-    public void writeMemberFooter() {
+-        printMemberFooter();
++    /**
++     * Return the no customization message.
++     *
++     * @param msg the message to be displayed
++     * @return no customization message content
++     */
++    public Content getNoCustomizationMsg(String msg) {
++        Content noCustomizationMsg = new StringContent(msg);
++        return noCustomizationMsg;
+     }
+ 
+-    public void writeDeprecatedMemberInfo(MethodDoc member) {
+-        printDeprecated(member);
++    /**
++     * Add the member header.
++     *
++     * @param member the method document to be listed
++     * @param methodsContentTree the content tree to which the member header will be added
++     */
++    public void addMemberHeader(MethodDoc member, Content methodsContentTree) {
++        methodsContentTree.addContent(writer.getMarkerAnchor(
++                writer.getAnchor(member)));
++        methodsContentTree.addContent(getHead(member));
++        methodsContentTree.addContent(getSignature(member));
+     }
+ 
+-    public void writeMemberDescription(MethodDoc member) {
+-        printComment(member);
++    /**
++     * Add the deprecated information for this member.
++     *
++     * @param member the method to document.
++     * @param methodsContentTree the tree to which the deprecated info will be added
++     */
++    public void addDeprecatedMemberInfo(MethodDoc member, Content methodsContentTree) {
++        addDeprecatedInfo(member, methodsContentTree);
+     }
+ 
+-    public void writeMemberTags(MethodDoc member) {
++    /**
++     * Add the description text for this member.
++     *
++     * @param member the method to document.
++     * @param methodsContentTree the tree to which the deprecated info will be added
++     */
++    public void addMemberDescription(MethodDoc member, Content methodsContentTree) {
++        addComment(member, methodsContentTree);
++    }
++
++    /**
++     * Add the tag information for this member.
++     *
++     * @param member the method to document.
++     * @param methodsContentTree the tree to which the member tags info will be added
++     */
++    public void addMemberTags(MethodDoc member, Content methodsContentTree) {
+         TagletOutputImpl output = new TagletOutputImpl("");
+         TagletManager tagletManager =
+             ConfigurationImpl.getInstance().tagletManager;
+@@ -86,14 +148,12 @@
+             tagletManager.getSerializedFormTags(),
+             writer.getTagletWriterInstance(false), output);
+         String outputString = output.toString().trim();
++        Content dlTags = new HtmlTree(HtmlTag.DL);
+         if (!outputString.isEmpty()) {
+-            writer.printMemberDetailsListStartTag();
+-            writer.dd();
+-            writer.dl();
+-            print(outputString);
+-            writer.dlEnd();
+-            writer.ddEnd();
++            Content tagContent = new RawHtml(outputString);
++            dlTags.addContent(tagContent);
+         }
++        methodsContentTree.addContent(dlTags);
+         MethodDoc method = (MethodDoc)member;
+         if (method.name().compareTo("writeExternal") == 0
+                 && method.tags("serialData").length == 0) {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/LinkFactoryImpl.java
+@@ -79,7 +79,7 @@
+                 String filename = pathString(classLinkInfo);
+                 if (linkInfo.linkToSelf ||
+                                 !(linkInfo.classDoc.name() + ".html").equals(m_writer.filename)) {
+-                        linkOutput.append(m_writer.getHyperLink(filename,
++                        linkOutput.append(m_writer.getHyperLinkString(filename,
+                             classLinkInfo.where, label.toString(),
+                             classLinkInfo.isStrong, classLinkInfo.styleName,
+                             title, classLinkInfo.target));
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/MethodWriterImpl.java
+@@ -28,9 +28,9 @@
+ import java.io.*;
+ 
+ import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.tools.doclets.internal.toolkit.taglets.*;
+ 
+ /**
+  * Writes method documentation in HTML format.
+@@ -43,8 +43,6 @@
+ public class MethodWriterImpl extends AbstractExecutableMemberWriter
+         implements MethodWriter, MemberSummaryWriter {
+ 
+-    private boolean printedSummaryHeader = false;
+-
+     /**
+      * Construct a new MethodWriterImpl.
+      *
+@@ -65,184 +63,127 @@
+     }
+ 
+     /**
+-     * Write the methods summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
++     * {@inheritDoc}
+      */
+-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
+-        printedSummaryHeader = true;
+-        writer.println();
+-        writer.println("<!-- ========== METHOD SUMMARY =========== -->");
+-        writer.println();
+-        writer.printSummaryHeader(this, classDoc);
+-    }
+-
+-    /**
+-     * Write the methods summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
+-        writer.printSummaryFooter(this, classDoc);
+-    }
+-
+-    /**
+-     * Write the inherited methods summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
+-        if(! printedSummaryHeader){
+-            //We don't want inherited summary to not be under heading.
+-            writeMemberSummaryHeader(classDoc);
+-            writeMemberSummaryFooter(classDoc);
+-            printedSummaryHeader = true;
+-        }
+-        writer.printInheritedSummaryHeader(this, classDoc);
++    public Content getMemberSummaryHeader(ClassDoc classDoc,
++            Content memberSummaryTree) {
++        memberSummaryTree.addContent(HtmlConstants.START_OF_METHOD_SUMMARY);
++        Content memberTree = writer.getMemberTreeHeader();
++        writer.addSummaryHeader(this, classDoc, memberTree);
++        return memberTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummary(ClassDoc classDoc,
+-        ProgramElementDoc method, boolean isFirst, boolean isLast) {
+-        writer.printInheritedSummaryMember(this, classDoc, method, isFirst);
++    public Content getMethodDetailsTreeHeader(ClassDoc classDoc,
++            Content memberDetailsTree) {
++        memberDetailsTree.addContent(HtmlConstants.START_OF_METHOD_DETAILS);
++        Content methodDetailsTree = writer.getMemberTreeHeader();
++        methodDetailsTree.addContent(writer.getMarkerAnchor("method_detail"));
++        Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING,
++                writer.methodDetailsLabel);
++        methodDetailsTree.addContent(heading);
++        return methodDetailsTree;
+     }
+ 
+     /**
+-     * Write the inherited methods summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
++     * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
+-        writer.printInheritedSummaryFooter(this, classDoc);        ;
++    public Content getMethodDocTreeHeader(MethodDoc method,
++            Content methodDetailsTree) {
++        String erasureAnchor;
++        if ((erasureAnchor = getErasureAnchor(method)) != null) {
++            methodDetailsTree.addContent(writer.getMarkerAnchor((erasureAnchor)));
++        }
++        methodDetailsTree.addContent(
++                writer.getMarkerAnchor(writer.getAnchor(method)));
++        Content methodDocTree = writer.getMemberTreeHeader();
++        Content heading = new HtmlTree(HtmlConstants.MEMBER_HEADING);
++        heading.addContent(method.name());
++        methodDocTree.addContent(heading);
++        return methodDocTree;
+     }
+ 
+     /**
+-     * Write the header for the method documentation.
++     * Get the signature for the given method.
+      *
+-     * @param classDoc the class that the methods belong to.
++     * @param method the method being documented.
++     * @return a content object for the signature
+      */
+-    public void writeHeader(ClassDoc classDoc, String header) {
+-        writer.println();
+-        writer.println("<!-- ============ METHOD DETAIL ========== -->");
+-        writer.println();
+-        writer.anchor("method_detail");
+-        writer.printTableHeadingBackground(header);
++    public Content getSignature(MethodDoc method) {
++        writer.displayLength = 0;
++        Content pre = new HtmlTree(HtmlTag.PRE);
++        writer.addAnnotationInfo(method, pre);
++        addModifiers(method, pre);
++        addTypeParameters(method, pre);
++        addReturnType(method, pre);
++        if (configuration().linksource) {
++            Content methodName = new StringContent(method.name());
++            writer.addSrcLink(method, methodName, pre);
++        } else {
++            addName(method.name(), pre);
++        }
++        addParameters(method, pre);
++        addExceptions(method, pre);
++        return pre;
+     }
+ 
+     /**
+-     * Write the method header for the given method.
+-     *
+-     * @param method the method being documented.
+-     * @param isFirst the flag to indicate whether or not the method is the
+-     *        first to be documented.
++     * {@inheritDoc}
+      */
+-    public void writeMethodHeader(MethodDoc method, boolean isFirst) {
+-        if (! isFirst) {
+-            writer.printMemberHeader();
+-        }
+-        writer.println();
+-        String erasureAnchor;
+-        if ((erasureAnchor = getErasureAnchor(method)) != null) {
+-            writer.anchor(erasureAnchor);
+-        }
+-        writer.anchor(method);
+-        writer.h3();
+-        writer.print(method.name());
+-        writer.h3End();
++    public void addDeprecated(MethodDoc method, Content methodDocTree) {
++        addDeprecatedInfo(method, methodDocTree);
+     }
+ 
+     /**
+-     * Write the signature for the given method.
+-     *
+-     * @param method the method being documented.
++     * {@inheritDoc}
+      */
+-    public void writeSignature(MethodDoc method) {
+-        writer.displayLength = 0;
+-        writer.pre();
+-        writer.writeAnnotationInfo(method);
+-        printModifiers(method);
+-        writeTypeParameters(method);
+-        printReturnType(method);
+-        if (configuration().linksource) {
+-            writer.printSrcLink(method, method.name());
+-        } else {
+-            strong(method.name());
+-        }
+-        writeParameters(method);
+-        writeExceptions(method);
+-        writer.preEnd();
+-        assert !writer.getMemberDetailsListPrinted();
+-    }
+-
+-    /**
+-     * Write the deprecated output for the given method.
+-     *
+-     * @param method the method being documented.
+-     */
+-    public void writeDeprecated(MethodDoc method) {
+-        printDeprecated(method);
+-    }
+-
+-    /**
+-     * Write the comments for the given method.
+-     *
+-     * @param method the method being documented.
+-     */
+-    public void writeComments(Type holder, MethodDoc method) {
++    public void addComments(Type holder, MethodDoc method, Content methodDocTree) {
+         ClassDoc holderClassDoc = holder.asClassDoc();
+         if (method.inlineTags().length > 0) {
+-            writer.printMemberDetailsListStartTag();
+             if (holder.asClassDoc().equals(classdoc) ||
+-                (! (holderClassDoc.isPublic() ||
++                    (! (holderClassDoc.isPublic() ||
+                     Util.isLinkable(holderClassDoc, configuration())))) {
+-                writer.dd();
+-                writer.printInlineComment(method);
+-                writer.ddEnd();
++                writer.addInlineComment(method, methodDocTree);
+             } else {
+-                String classlink = writer.codeText(
+-                    writer.getDocLink(LinkInfoImpl.CONTEXT_METHOD_DOC_COPY,
++                Content link = new RawHtml(
++                        writer.getDocLink(LinkInfoImpl.CONTEXT_METHOD_DOC_COPY,
+                         holder.asClassDoc(), method,
+                         holder.asClassDoc().isIncluded() ?
+                             holder.typeName() : holder.qualifiedTypeName(),
+-                        false));
+-                writer.dd();
+-                writer.strongText(holder.asClassDoc().isClass()?
+-                        "doclet.Description_From_Class":
+-                        "doclet.Description_From_Interface",
+-                    classlink);
+-                writer.ddEnd();
+-                writer.dd();
+-                writer.printInlineComment(method);
+-                writer.ddEnd();
++                            false));
++                Content codelLink = HtmlTree.CODE(link);
++                Content strong = HtmlTree.STRONG(holder.asClassDoc().isClass()?
++                    writer.descfrmClassLabel : writer.descfrmInterfaceLabel);
++                strong.addContent(writer.getSpace());
++                strong.addContent(codelLink);
++                methodDocTree.addContent(HtmlTree.DIV(HtmlStyle.block, strong));
++                writer.addInlineComment(method, methodDocTree);
+             }
+         }
+     }
+ 
+     /**
+-     * Write the tag output for the given method.
+-     *
+-     * @param method the method being documented.
++     * {@inheritDoc}
+      */
+-    public void writeTags(MethodDoc method) {
+-        writer.printTags(method);
++    public void addTags(MethodDoc method, Content methodDocTree) {
++        writer.addTagsInfo(method, methodDocTree);
+     }
+ 
+     /**
+-     * Write the method footer.
++     * {@inheritDoc}
+      */
+-    public void writeMethodFooter() {
+-        printMemberFooter();
++    public Content getMethodDetails(Content methodDetailsTree) {
++        return getMemberTree(methodDetailsTree);
+     }
+ 
+     /**
+-     * Write the footer for the method documentation.
+-     *
+-     * @param classDoc the class that the methods belong to.
++     * {@inheritDoc}
+      */
+-    public void writeFooter(ClassDoc classDoc) {
+-        //No footer to write for method documentation
++    public Content getMethodDoc(Content methodDocTree,
++            boolean isLastContent) {
++        return getMemberTree(methodDocTree, isLastContent);
+     }
+ 
+     /**
+@@ -256,53 +197,89 @@
+         return VisibleMemberMap.METHODS;
+     }
+ 
+-    public void printSummaryLabel() {
+-        writer.printText("doclet.Method_Summary");
++    /**
++     * {@inheritDoc}
++     */
++    public void addSummaryLabel(Content memberTree) {
++        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
++                writer.getResource("doclet.Method_Summary"));
++        memberTree.addContent(label);
+     }
+ 
+-    public void printTableSummary() {
+-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++    /**
++     * {@inheritDoc}
++     */
++    public String getTableSummary() {
++        return configuration().getText("doclet.Member_Table_Summary",
+                 configuration().getText("doclet.Method_Summary"),
+-                configuration().getText("doclet.methods")));
++                configuration().getText("doclet.methods"));
+     }
+ 
+-    public void printSummaryTableHeader(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    public String getCaption() {
++        return configuration().getText("doclet.Methods");
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String[] getSummaryTableHeader(ProgramElementDoc member) {
+         String[] header = new String[] {
+             writer.getModifierTypeHeader(),
+             configuration().getText("doclet.0_and_1",
+                     configuration().getText("doclet.Method"),
+                     configuration().getText("doclet.Description"))
+         };
+-        writer.summaryTableHeader(header, "col");
++        return header;
+     }
+ 
+-    public void printSummaryAnchor(ClassDoc cd) {
+-        writer.anchor("method_summary");
++    /**
++     * {@inheritDoc}
++     */
++    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
++        memberTree.addContent(writer.getMarkerAnchor("method_summary"));
+     }
+ 
+-    public void printInheritedSummaryAnchor(ClassDoc cd) {
+-        writer.anchor("methods_inherited_from_class_" +
+-            ConfigurationImpl.getInstance().getClassName(cd));
++    /**
++     * {@inheritDoc}
++     */
++    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
++        inheritedTree.addContent(writer.getMarkerAnchor(
++                "methods_inherited_from_class_" +
++                configuration().getClassName(cd)));
+     }
+ 
+-    public void printInheritedSummaryLabel(ClassDoc cd) {
+-        String classlink = writer.getPreQualifiedClassLink(
+-            LinkInfoImpl.CONTEXT_MEMBER, cd, false);
+-        writer.strong();
+-        String key = cd.isClass()?
+-            "doclet.Methods_Inherited_From_Class" :
+-            "doclet.Methods_Inherited_From_Interface";
+-        writer.printText(key, classlink);
+-        writer.strongEnd();
++    /**
++     * {@inheritDoc}
++     */
++    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
++        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
++                LinkInfoImpl.CONTEXT_MEMBER, cd, false));
++        Content label = new StringContent(cd.isClass() ?
++            configuration().getText("doclet.Methods_Inherited_From_Class") :
++            configuration().getText("doclet.Methods_Inherited_From_Interface"));
++        Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
++                label);
++        labelHeading.addContent(writer.getSpace());
++        labelHeading.addContent(classLink);
++        inheritedTree.addContent(labelHeading);
+     }
+ 
+-    protected void printSummaryType(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    protected void addSummaryType(ProgramElementDoc member, Content tdSummaryType) {
+         MethodDoc meth = (MethodDoc)member;
+-        printModifierAndType(meth, meth.returnType());
++        addModifierAndType(meth, meth.returnType(), tdSummaryType);
+     }
+ 
+-    protected static void printOverridden(HtmlDocletWriter writer,
+-            Type overriddenType, MethodDoc method) {
++    /**
++     * {@inheritDoc}
++     */
++    protected static void addOverridden(HtmlDocletWriter writer,
++            Type overriddenType, MethodDoc method, Content dl) {
+         if(writer.configuration.nocomment){
+             return;
+         }
+@@ -317,31 +294,33 @@
+             //is not visible so don't document this.
+             return;
+         }
+-        String label = "doclet.Overrides";
++        Content label = writer.overridesLabel;
+         int context = LinkInfoImpl.CONTEXT_METHOD_OVERRIDES;
+ 
+         if (method != null) {
+             if(overriddenType.asClassDoc().isAbstract() && method.isAbstract()){
+                 //Abstract method is implemented from abstract class,
+                 //not overridden
+-                label = "doclet.Specified_By";
++                label = writer.specifiedByLabel;
+                 context = LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY;
+             }
+-            String overriddenTypeLink = writer.codeText(
+-                writer.getLink(new LinkInfoImpl(context, overriddenType)));
++            Content dt = HtmlTree.DT(HtmlTree.STRONG(label));
++            dl.addContent(dt);
++            Content overriddenTypeLink = new RawHtml(
++                    writer.getLink(new LinkInfoImpl(context, overriddenType)));
++            Content codeOverridenTypeLink = HtmlTree.CODE(overriddenTypeLink);
+             String name = method.name();
+-            writer.dt();
+-            writer.strongText(label);
+-            writer.dtEnd();
+-            writer.dd();
+-            String methLink = writer.codeText(
+-                writer.getLink(
++            Content methlink = new RawHtml(writer.getLink(
+                     new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+-                        overriddenType.asClassDoc(),
+-                        writer.getAnchor(method), name, false)
+-                ));
+-            writer.printText("doclet.in_class", methLink, overriddenTypeLink);
+-            writer.ddEnd();
++                    overriddenType.asClassDoc(),
++                    writer.getAnchor(method), name, false)));
++            Content codeMethLink = HtmlTree.CODE(methlink);
++            Content dd = HtmlTree.DD(codeMethLink);
++            dd.addContent(writer.getSpace());
++            dd.addContent(writer.getResource("doclet.in_class"));
++            dd.addContent(writer.getSpace());
++            dd.addContent(codeOverridenTypeLink);
++            dl.addContent(dd);
+         }
+     }
+ 
+@@ -363,61 +342,78 @@
+         }
+     }
+ 
+-    protected static void printImplementsInfo(HtmlDocletWriter writer,
+-            MethodDoc method) {
++    /**
++     * {@inheritDoc}
++     */
++    protected static void addImplementsInfo(HtmlDocletWriter writer,
++            MethodDoc method, Content dl) {
+         if(writer.configuration.nocomment){
+             return;
+         }
+         ImplementedMethods implementedMethodsFinder =
+-            new ImplementedMethods(method, writer.configuration);
++                new ImplementedMethods(method, writer.configuration);
+         MethodDoc[] implementedMethods = implementedMethodsFinder.build();
+         for (int i = 0; i < implementedMethods.length; i++) {
+             MethodDoc implementedMeth = implementedMethods[i];
+             Type intfac = implementedMethodsFinder.getMethodHolder(implementedMeth);
+-            String methlink = "";
+-            String intfaclink = writer.codeText(
+-                writer.getLink(new LinkInfoImpl(
++            Content intfaclink = new RawHtml(writer.getLink(new LinkInfoImpl(
+                     LinkInfoImpl.CONTEXT_METHOD_SPECIFIED_BY, intfac)));
+-            writer.dt();
+-            writer.strongText("doclet.Specified_By");
+-            writer.dtEnd();
+-            writer.dd();
+-            methlink = writer.codeText(writer.getDocLink(
+-                LinkInfoImpl.CONTEXT_MEMBER, implementedMeth,
+-                implementedMeth.name(), false));
+-            writer.printText("doclet.in_interface", methlink, intfaclink);
+-            writer.ddEnd();
+-        }
+-
+-    }
+-
+-    protected void printReturnType(MethodDoc method) {
+-        Type type = method.returnType();
+-        if (type != null) {
+-            writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_RETURN_TYPE,
+-                type));
+-            print(' ');
++            Content codeIntfacLink = HtmlTree.CODE(intfaclink);
++            Content dt = HtmlTree.DT(HtmlTree.STRONG(writer.specifiedByLabel));
++            dl.addContent(dt);
++            Content methlink = new RawHtml(writer.getDocLink(
++                    LinkInfoImpl.CONTEXT_MEMBER, implementedMeth,
++                    implementedMeth.name(), false));
++            Content codeMethLink = HtmlTree.CODE(methlink);
++            Content dd = HtmlTree.DD(codeMethLink);
++            dd.addContent(writer.getSpace());
++            dd.addContent(writer.getResource("doclet.in_interface"));
++            dd.addContent(writer.getSpace());
++            dd.addContent(codeIntfacLink);
++            dl.addContent(dd);
+         }
+     }
+ 
+-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
+-        if (link) {
+-            writer.printHyperLink("", (cd == null)?
+-                "method_summary":
+-                "methods_inherited_from_class_" +
+-                ConfigurationImpl.getInstance().getClassName(cd),
+-                ConfigurationImpl.getInstance().getText("doclet.navMethod"));
+-        } else {
+-            writer.printText("doclet.navMethod");
++    /**
++     * Add the return type.
++     *
++     * @param method the method being documented.
++     * @param htmltree the content tree to which the return type will be added
++     */
++    protected void addReturnType(MethodDoc method, Content htmltree) {
++        Type type = method.returnType();
++        if (type != null) {
++            Content linkContent = new RawHtml(writer.getLink(
++                    new LinkInfoImpl(LinkInfoImpl.CONTEXT_RETURN_TYPE, type)));
++            htmltree.addContent(linkContent);
++            htmltree.addContent(writer.getSpace());
+         }
+     }
+ 
+-    protected void printNavDetailLink(boolean link) {
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
+         if (link) {
+-            writer.printHyperLink("", "method_detail",
+-                ConfigurationImpl.getInstance().getText("doclet.navMethod"));
++            return writer.getHyperLink("", (cd == null)?
++                "method_summary":
++                "methods_inherited_from_class_" +
++                configuration().getClassName(cd),
++                writer.getResource("doclet.navMethod"));
+         } else {
+-            writer.printText("doclet.navMethod");
++            return writer.getResource("doclet.navMethod");
++        }
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    protected void addNavDetailLink(boolean link, Content liNav) {
++        if (link) {
++            liNav.addContent(writer.getHyperLink("", "method_detail",
++                    writer.getResource("doclet.navMethod")));
++        } else {
++            liNav.addContent(writer.getResource("doclet.navMethod"));
+         }
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/NestedClassWriterImpl.java
+@@ -26,8 +26,10 @@
+ package com.sun.tools.doclets.formats.html;
+ 
+ import java.io.*;
++import java.util.*;
+ 
+ import com.sun.javadoc.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ 
+@@ -42,8 +44,6 @@
+ public class NestedClassWriterImpl extends AbstractMemberWriter
+     implements MemberSummaryWriter {
+ 
+-    private boolean printedSummaryHeader = false;
+-
+     public NestedClassWriterImpl(SubWriterHolderWriter writer,
+             ClassDoc classdoc) {
+         super(writer, classdoc);
+@@ -54,90 +54,17 @@
+     }
+ 
+     /**
+-     * Write the classes summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeMemberSummaryHeader(ClassDoc classDoc) {
+-        printedSummaryHeader = true;
+-        writer.println("<!-- ======== NESTED CLASS SUMMARY ======== -->");
+-        writer.println();
+-        writer.printSummaryHeader(this, classDoc);
+-    }
+-
+-    /**
+-     * Write the classes summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeMemberSummaryFooter(ClassDoc classDoc) {
+-        writer.printSummaryFooter(this, classDoc);
+-    }
+-
+-    /**
+-     * Write the inherited classes summary header for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc) {
+-        if(! printedSummaryHeader){
+-            //We don't want inherited summary to not be under heading.
+-            writeMemberSummaryHeader(classDoc);
+-            writeMemberSummaryFooter(classDoc);
+-            printedSummaryHeader = true;
+-        }
+-        writer.printInheritedSummaryHeader(this, classDoc);
+-    }
+-
+-    /**
+      * {@inheritDoc}
+      */
+-    public void writeInheritedMemberSummary(ClassDoc classDoc,
+-            ProgramElementDoc nestedClass, boolean isFirst, boolean isLast) {
+-        writer.printInheritedSummaryMember(this, classDoc, nestedClass, isFirst);
++    public Content getMemberSummaryHeader(ClassDoc classDoc,
++            Content memberSummaryTree) {
++        memberSummaryTree.addContent(HtmlConstants.START_OF_NESTED_CLASS_SUMMARY);
++        Content memberTree = writer.getMemberTreeHeader();
++        writer.addSummaryHeader(this, classDoc, memberTree);
++        return memberTree;
+     }
+ 
+     /**
+-     * Write the inherited classes summary footer for the given class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     */
+-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc) {
+-        writer.printInheritedSummaryFooter(this, classDoc);
+-        writer.println();
+-    }
+-
+-    /**
+-     * Write the header for the nested class documentation.
+-     *
+-     * @param classDoc the class that the classes belong to.
+-     */
+-    public void writeHeader(ClassDoc classDoc, String header) {
+-        writer.anchor("nested class_detail");
+-        writer.printTableHeadingBackground(header);
+-    }
+-
+-    /**
+-     * Write the nested class header for the given nested class.
+-     *
+-     * @param nestedClass the nested class being documented.
+-     * @param isFirst the flag to indicate whether or not the nested class is the
+-     *        first to be documented.
+-     */
+-    public void writeClassHeader(ClassDoc nestedClass, boolean isFirst) {
+-        if (! isFirst) {
+-            writer.printMemberHeader();
+-            writer.println("");
+-        }
+-        writer.anchor(nestedClass.name());
+-        writer.h3();
+-        writer.print(nestedClass.name());
+-        writer.h3End();
+-    }
+-
+-
+-
+-    /**
+      * Close the writer.
+      */
+     public void close() throws IOException {
+@@ -148,17 +75,35 @@
+         return VisibleMemberMap.INNERCLASSES;
+     }
+ 
+-    public void printSummaryLabel() {
+-        writer.printText("doclet.Nested_Class_Summary");
++    /**
++     * {@inheritDoc}
++     */
++    public void addSummaryLabel(Content memberTree) {
++        Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING,
++                writer.getResource("doclet.Nested_Class_Summary"));
++        memberTree.addContent(label);
+     }
+ 
+-    public void printTableSummary() {
+-        writer.tableIndexSummary(configuration().getText("doclet.Member_Table_Summary",
++    /**
++     * {@inheritDoc}
++     */
++    public String getTableSummary() {
++        return configuration().getText("doclet.Member_Table_Summary",
+                 configuration().getText("doclet.Nested_Class_Summary"),
+-                configuration().getText("doclet.nested_classes")));
++                configuration().getText("doclet.nested_classes"));
+     }
+ 
+-    public void printSummaryTableHeader(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    public String getCaption() {
++        return configuration().getText("doclet.Nested_Classes");
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String[] getSummaryTableHeader(ProgramElementDoc member) {
+         String[] header;
+         if (member.isInterface()) {
+             header = new String[] {
+@@ -176,92 +121,95 @@
+                         configuration().getText("doclet.Description"))
+             };
+         }
+-        writer.summaryTableHeader(header, "col");
++        return header;
+     }
+ 
+-    public void printSummaryAnchor(ClassDoc cd) {
+-        writer.anchor("nested_class_summary");
++    /**
++     * {@inheritDoc}
++     */
++    public void addSummaryAnchor(ClassDoc cd, Content memberTree) {
++        memberTree.addContent(writer.getMarkerAnchor("nested_class_summary"));
+     }
+ 
+-    public void printInheritedSummaryAnchor(ClassDoc cd) {
+-        writer.anchor("nested_classes_inherited_from_class_" +
+-                       cd.qualifiedName());
++    /**
++     * {@inheritDoc}
++     */
++    public void addInheritedSummaryAnchor(ClassDoc cd, Content inheritedTree) {
++        inheritedTree.addContent(writer.getMarkerAnchor(
++                "nested_classes_inherited_from_class_" + cd.qualifiedName()));
+     }
+ 
+-    public void printInheritedSummaryLabel(ClassDoc cd) {
+-        String clslink = writer.getPreQualifiedClassLink(
+-            LinkInfoImpl.CONTEXT_MEMBER, cd, false);
+-        writer.strong();
+-        writer.printText(cd.isInterface() ?
+-            "doclet.Nested_Classes_Interface_Inherited_From_Interface" :
+-            "doclet.Nested_Classes_Interfaces_Inherited_From_Class",
+-            clslink);
+-        writer.strongEnd();
++    /**
++     * {@inheritDoc}
++     */
++    public void addInheritedSummaryLabel(ClassDoc cd, Content inheritedTree) {
++        Content classLink = new RawHtml(writer.getPreQualifiedClassLink(
++                LinkInfoImpl.CONTEXT_MEMBER, cd, false));
++        Content label = new StringContent(cd.isInterface() ?
++            configuration().getText("doclet.Nested_Classes_Interface_Inherited_From_Interface") :
++            configuration().getText("doclet.Nested_Classes_Interfaces_Inherited_From_Class"));
++        Content labelHeading = HtmlTree.HEADING(HtmlConstants.INHERITED_SUMMARY_HEADING,
++                label);
++        labelHeading.addContent(writer.getSpace());
++        labelHeading.addContent(classLink);
++        inheritedTree.addContent(labelHeading);
+     }
+ 
+-    protected void writeSummaryLink(int context, ClassDoc cd, ProgramElementDoc member) {
+-        writer.strong();
+-        writer.printLink(new LinkInfoImpl(context, (ClassDoc)member, false));
+-        writer.strongEnd();
++    /**
++     * {@inheritDoc}
++     */
++    protected void addSummaryLink(int context, ClassDoc cd, ProgramElementDoc member,
++            Content tdSummary) {
++        Content strong = HtmlTree.STRONG(new RawHtml(
++                writer.getLink(new LinkInfoImpl(context, (ClassDoc)member, false))));
++        Content code = HtmlTree.CODE(strong);
++        tdSummary.addContent(code);
+     }
+ 
+-    protected void writeInheritedSummaryLink(ClassDoc cd,
+-            ProgramElementDoc member) {
+-        writer.printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
+-            (ClassDoc)member, false));
++    /**
++     * {@inheritDoc}
++     */
++    protected void addInheritedSummaryLink(ClassDoc cd,
++            ProgramElementDoc member, Content linksTree) {
++        linksTree.addContent(new RawHtml(
++                writer.getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER,
++                (ClassDoc)member, false))));
+     }
+ 
+-    protected void printSummaryType(ProgramElementDoc member) {
++    /**
++     * {@inheritDoc}
++     */
++    protected void addSummaryType(ProgramElementDoc member,
++            Content tdSummaryType) {
+         ClassDoc cd = (ClassDoc)member;
+-        printModifierAndType(cd, null);
++        addModifierAndType(cd, null, tdSummaryType);
+     }
+ 
+-    protected void printHeader(ClassDoc cd) {
+-        // N.A.
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getDeprecatedLink(ProgramElementDoc member) {
++        return writer.getQualifiedClassLink(LinkInfoImpl.CONTEXT_MEMBER,
++                (ClassDoc)member);
+     }
+ 
+-    protected void printBodyHtmlEnd(ClassDoc cd) {
+-        // N.A.
+-    }
+-
+-    protected void printMember(ProgramElementDoc member) {
+-        // N.A.
+-    }
+-
+-    protected void writeDeprecatedLink(ProgramElementDoc member) {
+-        writer.printQualifiedClassLink(LinkInfoImpl.CONTEXT_MEMBER,
+-            (ClassDoc)member);
+-    }
+-
+-    protected void printNavSummaryLink(ClassDoc cd, boolean link) {
++    /**
++     * {@inheritDoc}
++     */
++    protected Content getNavSummaryLink(ClassDoc cd, boolean link) {
+         if (link) {
+-            writer.printHyperLink("", (cd == null) ? "nested_class_summary":
+-                    "nested_classes_inherited_from_class_" +
++            return writer.getHyperLink("", (cd == null) ? "nested_class_summary":
++                "nested_classes_inherited_from_class_" +
+                 cd.qualifiedName(),
+-                ConfigurationImpl.getInstance().getText("doclet.navNested"));
++                writer.getResource("doclet.navNested"));
+         } else {
+-            writer.printText("doclet.navNested");
++            return writer.getResource("doclet.navNested");
+         }
+     }
+ 
+-    protected void printNavDetailLink(boolean link) {
+-    }
+-
+-    protected void printMemberLink(ProgramElementDoc member) {
+-    }
+-
+-    protected void printMembersSummaryLink(ClassDoc cd, ClassDoc icd,
+-                                           boolean link) {
+-        if (link) {
+-            writer.printHyperLink(cd.name() + ".html",
+-                (cd == icd)?
+-                    "nested_class_summary":
+-                    "nested_classes_inherited_from_class_" +
+-                    icd.qualifiedName(),
+-                    ConfigurationImpl.getInstance().getText(
+-                        "doclet.Nested_Class_Summary"));
+-        } else {
+-            writer.printText("doclet.Nested_Class_Summary");
+-        }
++    /**
++     * {@inheritDoc}
++     */
++    protected void addNavDetailLink(boolean link, Content liNav) {
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageFrameWriter.java
+@@ -25,18 +25,20 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++import java.util.*;
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+-import com.sun.javadoc.*;
+-import java.io.*;
+-import java.util.*;
+ /**
+  * Class to generate file for each package contents in the left-hand bottom
+  * frame. This will list all the Class Kinds in the package. A click on any
+  * class-kind will update the right-hand frame with the clicked class-kind page.
+  *
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class PackageFrameWriter extends HtmlDocletWriter {
+ 
+@@ -85,132 +87,107 @@
+      * @param packageDoc The package for which "pacakge-frame.html" is to be generated.
+      */
+     public static void generate(ConfigurationImpl configuration,
+-                                PackageDoc packageDoc) {
++            PackageDoc packageDoc) {
+         PackageFrameWriter packgen;
+         try {
+             packgen = new PackageFrameWriter(configuration, packageDoc);
+             String pkgName = Util.getPackageName(packageDoc);
+-            packgen.printHtmlHeader(pkgName, configuration.metakeywords.getMetaKeywords(packageDoc), false);
+-            packgen.printPackageHeader(pkgName);
+-            packgen.generateClassListing();
+-            packgen.printBodyHtmlEnd();
++            Content body = packgen.getBody(false, packgen.getWindowTitle(pkgName));
++            Content pkgNameContent = new StringContent(pkgName);
++            Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar,
++                    packgen.getTargetPackageLink(packageDoc, "classFrame", pkgNameContent));
++            body.addContent(heading);
++            HtmlTree div = new HtmlTree(HtmlTag.DIV);
++            div.addStyle(HtmlStyle.indexContainer);
++            packgen.addClassListing(div);
++            body.addContent(div);
++            packgen.printHtmlDocument(
++                    configuration.metakeywords.getMetaKeywords(packageDoc), false, body);
+             packgen.close();
+         } catch (IOException exc) {
+             configuration.standardmessage.error(
+-                        "doclet.exception_encountered",
+-                        exc.toString(), OUTPUT_FILE_NAME);
++                    "doclet.exception_encountered",
++                    exc.toString(), OUTPUT_FILE_NAME);
+             throw new DocletAbortException();
+         }
+     }
+ 
+     /**
+-     * Generate class listing for all the classes in this package. Divide class
++     * Add class listing for all the classes in this package. Divide class
+      * listing as per the class kind and generate separate listing for
+      * Classes, Interfaces, Exceptions and Errors.
++     *
++     * @param contentTree the content tree to which the listing will be added
+      */
+-    protected void generateClassListing() {
++    protected void addClassListing(Content contentTree) {
+         Configuration config = configuration();
+         if (packageDoc.isIncluded()) {
+-            generateClassKindListing(packageDoc.interfaces(),
+-                configuration.getText("doclet.Interfaces"));
+-            generateClassKindListing(packageDoc.ordinaryClasses(),
+-                configuration.getText("doclet.Classes"));
+-            generateClassKindListing(packageDoc.enums(),
+-                configuration.getText("doclet.Enums"));
+-            generateClassKindListing(packageDoc.exceptions(),
+-                configuration.getText("doclet.Exceptions"));
+-            generateClassKindListing(packageDoc.errors(),
+-                configuration.getText("doclet.Errors"));
+-            generateClassKindListing(packageDoc.annotationTypes(),
+-                configuration.getText("doclet.AnnotationTypes"));
++            addClassKindListing(packageDoc.interfaces(),
++                getResource("doclet.Interfaces"), contentTree);
++            addClassKindListing(packageDoc.ordinaryClasses(),
++                getResource("doclet.Classes"), contentTree);
++            addClassKindListing(packageDoc.enums(),
++                getResource("doclet.Enums"), contentTree);
++            addClassKindListing(packageDoc.exceptions(),
++                getResource("doclet.Exceptions"), contentTree);
++            addClassKindListing(packageDoc.errors(),
++                getResource("doclet.Errors"), contentTree);
++            addClassKindListing(packageDoc.annotationTypes(),
++                getResource("doclet.AnnotationTypes"), contentTree);
+         } else {
+             String name = Util.getPackageName(packageDoc);
+-            generateClassKindListing(config.classDocCatalog.interfaces(name),
+-                configuration.getText("doclet.Interfaces"));
+-            generateClassKindListing(config.classDocCatalog.ordinaryClasses(name),
+-                configuration.getText("doclet.Classes"));
+-            generateClassKindListing(config.classDocCatalog.enums(name),
+-                configuration.getText("doclet.Enums"));
+-            generateClassKindListing(config.classDocCatalog.exceptions(name),
+-                configuration.getText("doclet.Exceptions"));
+-            generateClassKindListing(config.classDocCatalog.errors(name),
+-                configuration.getText("doclet.Errors"));
+-            generateClassKindListing(config.classDocCatalog.annotationTypes(name),
+-                configuration.getText("doclet.AnnotationTypes"));
++            addClassKindListing(config.classDocCatalog.interfaces(name),
++                getResource("doclet.Interfaces"), contentTree);
++            addClassKindListing(config.classDocCatalog.ordinaryClasses(name),
++                getResource("doclet.Classes"), contentTree);
++            addClassKindListing(config.classDocCatalog.enums(name),
++                getResource("doclet.Enums"), contentTree);
++            addClassKindListing(config.classDocCatalog.exceptions(name),
++                getResource("doclet.Exceptions"), contentTree);
++            addClassKindListing(config.classDocCatalog.errors(name),
++                getResource("doclet.Errors"), contentTree);
++            addClassKindListing(config.classDocCatalog.annotationTypes(name),
++                getResource("doclet.AnnotationTypes"), contentTree);
+         }
+     }
+ 
+     /**
+-     * Generate specific class kind listing. Also add label to the listing.
++     * Add specific class kind listing. Also add label to the listing.
+      *
+-     * @param arr Array of specific class kinds, namely Class or Interface or
+-     * Exception or Error.
+-     * @param label Label for the listing
++     * @param arr Array of specific class kinds, namely Class or Interface or Exception or Error
++     * @param labelContent content tree of the label to be added
++     * @param contentTree the content tree to which the class kind listing will be added
+      */
+-    protected void generateClassKindListing(ClassDoc[] arr, String label) {
++    protected void addClassKindListing(ClassDoc[] arr, Content labelContent,
++            Content contentTree) {
+         if(arr.length > 0) {
+             Arrays.sort(arr);
+-            printPackageTableHeader();
+-            fontSizeStyle("+1", "FrameHeadingFont");
+             boolean printedHeader = false;
++            HtmlTree ul = new HtmlTree(HtmlTag.UL);
++            ul.addAttr(HtmlAttr.TITLE, labelContent.toString());
+             for (int i = 0; i < arr.length; i++) {
+                 if (documentedClasses != null &&
+-                    !documentedClasses.contains(arr[i])) {
++                        !documentedClasses.contains(arr[i])) {
+                     continue;
+                 }
+                 if (!Util.isCoreClass(arr[i]) || !
+-                    configuration.isGeneratedDoc(arr[i])) {
++                        configuration.isGeneratedDoc(arr[i])) {
+                     continue;
+                 }
+                 if (!printedHeader) {
+-                    print(label);
+-                    fontEnd();
+-                    println("&nbsp;");
+-                    fontStyle("FrameItemFont");
++                    Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
++                            true, labelContent);
++                    contentTree.addContent(heading);
+                     printedHeader = true;
+                 }
+-                br();
+-                printLink(new LinkInfoImpl(
+-                    LinkInfoImpl.PACKAGE_FRAME,
+-                    arr[i],
+-                    (arr[i].isInterface() ?
+-                        italicsText(arr[i].name()) :
+-                        arr[i].name()),"classFrame")
+-                );
++                Content link = new RawHtml (getLink(new LinkInfoImpl(
++                        LinkInfoImpl.PACKAGE_FRAME, arr[i],
++                        (arr[i].isInterface() ? italicsText(arr[i].name()) :
++                            arr[i].name()),"classFrame")));
++                Content li = HtmlTree.LI(link);
++                ul.addContent(li);
+             }
+-            fontEnd();
+-            printPackageTableFooter();
+-            println();
++            contentTree.addContent(ul);
+         }
+     }
+-
+-    /**
+-     * Print the package link at the top of the class kind listing. Clicking
+-     * this link, package-summary page will appear in the right hand frame.
+-     *
+-     * @param heading Top Heading to be used for the class kind listing.
+-     */
+-    protected void printPackageHeader(String heading) {
+-        fontSizeStyle("+1", "FrameTitleFont");
+-        printTargetPackageLink(packageDoc, "classFrame", heading);
+-        fontEnd();
+-    }
+-
+-    /**
+-     * The table for the class kind listing.
+-     */
+-    protected void printPackageTableHeader() {
+-        table();
+-        tr();
+-        tdNowrap();
+-    }
+-
+-    /**
+-     * Closing Html tags for table of class kind listing.
+-     */
+-    protected void printPackageTableFooter() {
+-        tdEnd();
+-        trEnd();
+-        tableEnd();
+-    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexFrameWriter.java
+@@ -25,10 +25,11 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++import com.sun.javadoc.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-
+-import com.sun.javadoc.*;
+-import java.io.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Generate the package index for the left-hand frame in the generated output.
+@@ -58,7 +59,7 @@
+         String filename = "overview-frame.html";
+         try {
+             packgen = new PackageIndexFrameWriter(configuration, filename);
+-            packgen.generatePackageIndexFile("doclet.Window_Overview", false);
++            packgen.buildPackageIndexFile("doclet.Window_Overview", false);
+             packgen.close();
+         } catch (IOException exc) {
+             configuration.standardmessage.error(
+@@ -69,114 +70,86 @@
+     }
+ 
+     /**
+-     * Print each package name on separate rows.
+-     *
+-     * @param pd PackageDoc
++     * {@inheritDoc}
+      */
+-    protected void printIndexRow(PackageDoc pd) {
+-        fontStyle("FrameItemFont");
+-        if (pd.name().length() > 0) {
+-            print(getHyperLink(pathString(pd, "package-frame.html"), "",
+-                pd.name(), false, "", "", "packageFrame"));
+-        } else {
+-            print(getHyperLink("package-frame.html", "", "&lt;unnamed package>",
+-                false, "", "", "packageFrame"));
++    protected void addPackagesList(PackageDoc[] packages, String text,
++            String tableSummary, Content body) {
++        Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
++                packagesLabel);
++        Content div = HtmlTree.DIV(HtmlStyle.indexContainer, heading);
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addAttr(HtmlAttr.TITLE, packagesLabel.toString());
++        for(int i = 0; i < packages.length; i++) {
++            if (packages[i] != null) {
++                ul.addContent(getPackage(packages[i]));
++            }
+         }
+-        fontEnd();
+-        br();
++        div.addContent(ul);
++        body.addContent(div);
+     }
+ 
+     /**
+-     * Print the "-packagesheader" string in strong format, at top of the page,
+-     * if it is not the empty string.  Otherwise print the "-header" string.
+-     * Despite the name, there is actually no navigation bar for this page.
++     * Gets each package name as a separate link.
++     *
++     * @param pd PackageDoc
++     * @return content for the package link
+      */
+-    protected void printNavigationBarHeader() {
+-        printTableHeader(true);
+-        fontSizeStyle("+1", "FrameTitleFont");
++    protected Content getPackage(PackageDoc pd) {
++        Content packageLinkContent;
++        Content packageLabel;
++        if (pd.name().length() > 0) {
++            packageLabel = getPackageLabel(pd.name());
++            packageLinkContent = getHyperLink(pathString(pd,
++                    "package-frame.html"), "", packageLabel, "",
++                    "packageFrame");
++        } else {
++            packageLabel = new RawHtml("&lt;unnamed package&gt;");
++            packageLinkContent = getHyperLink("package-frame.html",
++                    "", packageLabel, "", "packageFrame");
++        }
++        Content li = HtmlTree.LI(packageLinkContent);
++        return li;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    protected void addNavigationBarHeader(Content body) {
++        Content headerContent;
+         if (configuration.packagesheader.length() > 0) {
+-            strong(replaceDocRootDir(configuration.packagesheader));
++            headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader));
+         } else {
+-            strong(replaceDocRootDir(configuration.header));
++            headerContent = new RawHtml(replaceDocRootDir(configuration.header));
+         }
+-        fontEnd();
+-        printTableFooter(true);
++        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
++                HtmlStyle.bar, headerContent);
++        body.addContent(heading);
+     }
+ 
+     /**
+      * Do nothing as there is no overview information in this page.
+      */
+-    protected void printOverviewHeader() {
++    protected void addOverviewHeader(Content body) {
+     }
+ 
+     /**
+-     * Print Html "table" tag for the package index format.
++     * Adds "All Classes" link for the top of the left-hand frame page to the
++     * documentation tree.
+      *
+-     * @param text Text string will not be used in this method.
++     * @param body the Content object to which the all classes link should be added
+      */
+-    protected void printIndexHeader(String text, String tableSummary) {
+-        printTableHeader(false);
++    protected void addAllClassesLink(Content body) {
++        Content linkContent = getHyperLink("allclasses-frame.html", "",
++                allclassesLabel, "", "packageFrame");
++        Content div = HtmlTree.DIV(HtmlStyle.indexHeader, linkContent);
++        body.addContent(div);
+     }
+ 
+     /**
+-     * Print Html closing "table" tag at the end of the package index.
++     * {@inheritDoc}
+      */
+-    protected void printIndexFooter() {
+-        printTableFooter(false);
+-    }
+-
+-    /**
+-     * Print "All Classes" link at the top of the left-hand frame page.
+-     */
+-    protected void printAllClassesPackagesLink() {
+-        fontStyle("FrameItemFont");
+-        print(getHyperLink("allclasses-frame.html", "",
+-            configuration.getText("doclet.All_Classes"), false, "", "",
+-            "packageFrame"));
+-        fontEnd();
+-        p();
+-        fontSizeStyle("+1", "FrameHeadingFont");
+-        printText("doclet.Packages");
+-        fontEnd();
+-        br();
+-    }
+-
+-    /**
+-     * Just print some space, since there is no navigation bar for this page.
+-     */
+-    protected void printNavigationBarFooter() {
+-        p();
+-        space();
+-    }
+-
+-    /**
+-     * Print Html closing tags for the table for package index.
+-     *
+-     * @param isHeading true if this is a table for a heading.
+-     */
+-    private void printTableFooter(boolean isHeading) {
+-        if (isHeading) {
+-            thEnd();
+-        } else {
+-            tdEnd();
+-        }
+-        trEnd();
+-        tableEnd();
+-    }
+-
+-    /**
+-     * Print Html tags for the table for package index.
+-     *
+-     * @param isHeading true if this is a table for a heading.
+-     */
+-    private void printTableHeader(boolean isHeading) {
+-        table();
+-        tr();
+-        if (isHeading) {
+-            thAlignNowrap("left");
+-        } else {
+-            tdNowrap();
+-        }
+-
++    protected void addNavigationBarFooter(Content body) {
++        Content p = HtmlTree.P(getSpace());
++        body.addContent(p);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
+@@ -25,10 +25,12 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
+-import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+ import java.io.*;
+ import java.util.*;
++import com.sun.javadoc.*;
++import com.sun.tools.doclets.internal.toolkit.*;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Generate the package index page "overview-summary.html" for the right-hand
+@@ -83,7 +85,7 @@
+         String filename = "overview-summary.html";
+         try {
+             packgen = new PackageIndexWriter(configuration, filename);
+-            packgen.generatePackageIndexFile("doclet.Window_Overview_Summary", true);
++            packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
+             packgen.close();
+         } catch (IOException exc) {
+             configuration.standardmessage.error(
+@@ -94,125 +96,139 @@
+     }
+ 
+     /**
+-     * Print each package in separate rows in the index table. Generate link
+-     * to each package.
++     * Depending upon the grouping information and their titles, add
++     * separate table indices for each package group.
+      *
+-     * @param pkg Package to which link is to be generated.
++     * @param body the documentation tree to which the index will be added
+      */
+-    protected void printIndexRow(PackageDoc pkg) {
+-        if(pkg != null && pkg.name().length() > 0) {
+-            trBgcolorStyle("white", "TableRowColor");
+-            summaryRow(20);
+-            strong();
+-            printPackageLink(pkg, Util.getPackageName(pkg), false);
+-            strongEnd();
+-            summaryRowEnd();
+-            summaryRow(0);
+-            printSummaryComment(pkg);
+-            summaryRowEnd();
+-            trEnd();
+-       }
+-    }
+-
+-    /**
+-     * Depending upon the grouping information and their titles, generate
+-     * separate table indices for each package group.
+-     */
+-    protected void generateIndex() {
++    protected void addIndex(Content body) {
+         for (int i = 0; i < groupList.size(); i++) {
+         String groupname = (String)groupList.get(i);
+         List list = (List)groupPackageMap.get(groupname);
+             if (list != null && list.size() > 0) {
+-                printIndexContents((PackageDoc[])list.
+-                                       toArray(new PackageDoc[list.size()]),
+-                        groupname,
+-                        configuration.getText("doclet.Member_Table_Summary",
+-                        groupname,
+-                        configuration.getText("doclet.packages")));
++                addIndexContents(list.toArray(new PackageDoc[list.size()]),
++                        groupname, configuration.getText("doclet.Member_Table_Summary",
++                        groupname, configuration.getText("doclet.packages")), body);
+             }
+         }
+     }
+ 
+     /**
+-     * Print the overview summary comment for this documentation. Print one line
+-     * summary at the top of the page and generate a link to the description,
+-     * which is generated at the end of this page.
++     * {@inheritDoc}
+      */
+-    protected void printOverviewHeader() {
+-        if (root.inlineTags().length > 0) {
+-            printSummaryComment(root);
+-            p();
+-            strong(configuration.getText("doclet.See"));
+-            br();
+-            printNbsps();
+-            printHyperLink("", "overview_description",
+-                configuration.getText("doclet.Description"), true);
+-            p();
++    protected void addPackagesList(PackageDoc[] packages, String text,
++            String tableSummary, Content body) {
++        Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary,
++                getTableCaption(text));
++        table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
++        Content tbody = new HtmlTree(HtmlTag.TBODY);
++        addPackagesList(packages, tbody);
++        table.addContent(tbody);
++        Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
++        body.addContent(div);
++    }
++
++    /**
++     * Adds list of packages in the index table. Generate link to each package.
++     *
++     * @param packages Packages to which link is to be generated
++     * @param tbody the documentation tree to which the list will be added
++     */
++    protected void addPackagesList(PackageDoc[] packages, Content tbody) {
++        for (int i = 0; i < packages.length; i++) {
++            if (packages[i] != null && packages[i].name().length() > 0) {
++                Content packageLinkContent = getPackageLink(packages[i],
++                        getPackageName(packages[i]));
++                Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
++                HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
++                tdSummary.addStyle(HtmlStyle.colLast);
++                addSummaryComment(packages[i], tdSummary);
++                HtmlTree tr = HtmlTree.TR(tdPackage);
++                tr.addContent(tdSummary);
++                if (i%2 == 0)
++                    tr.addStyle(HtmlStyle.altColor);
++                else
++                    tr.addStyle(HtmlStyle.rowColor);
++                tbody.addContent(tr);
++            }
+         }
+     }
+ 
+     /**
+-     * Print Html tags for the table for this package index.
++     * Adds the overview summary comment for this documentation. Add one line
++     * summary at the top of the page and generate a link to the description,
++     * which is added at the end of this page.
++     *
++     * @param body the documentation tree to which the overview header will be added
+      */
+-    protected void printIndexHeader(String text, String tableSummary) {
+-        tableIndexSummary(tableSummary);
+-        tableCaptionStart();
+-        print(text);
+-        tableCaptionEnd();
+-        summaryTableHeader(packageTableHeader, "col");
+-    }
+-
+-    /**
+-     * Print Html closing tags for the table for this package index.
+-     */
+-    protected void printIndexFooter() {
+-        tableEnd();
+-        p();
+-        space();
+-    }
+-
+-    /**
+-     * Print the overview comment as provided in the file specified by the
+-     * "-overview" option on the command line.
+-     */
+-    protected void printOverviewComment() {
++    protected void addOverviewHeader(Content body) {
+         if (root.inlineTags().length > 0) {
+-            anchor("overview_description");
+-            p();
+-            printInlineComment(root);
+-            p();
++            HtmlTree p = new HtmlTree(HtmlTag.P);
++            p.addStyle(HtmlStyle.subTitle);
++            addSummaryComment(root, p);
++            Content div = HtmlTree.DIV(HtmlStyle.header, p);
++            Content see = seeLabel;
++            see.addContent(" ");
++            Content descPara = HtmlTree.P(see);
++            Content descLink = getHyperLink("", "overview_description",
++                descriptionLabel, "", "");
++            descPara.addContent(descLink);
++            div.addContent(descPara);
++            body.addContent(div);
+         }
+     }
+ 
+     /**
+-     * Call {@link #printOverviewComment()} and then genrate the tag information
+-     * as provided in the file specified by the "-overview" option on the
+-     * command line.
++     * Adds the overview comment as provided in the file specified by the
++     * "-overview" option on the command line.
++     *
++     * @param htmltree the documentation tree to which the overview comment will
++     *                 be added
+      */
+-    protected void printOverview() throws IOException {
+-        printOverviewComment();
+-        printTags(root);
++    protected void addOverviewComment(Content htmltree) {
++        if (root.inlineTags().length > 0) {
++            htmltree.addContent(getMarkerAnchor("overview_description"));
++            HtmlTree p = new HtmlTree(HtmlTag.P);
++            p.addStyle(HtmlStyle.subTitle);
++            addInlineComment(root, p);
++            htmltree.addContent(p);
++        }
+     }
+ 
+     /**
+-     * Print the top text (from the -top option), the upper
+-     * navigation bar, and then the title (from the"-title"
+-     * option), at the top of page.
++     * Adds the tag information as provided in the file specified by the
++     * "-overview" option on the command line.
++     *
++     * @param body the documentation tree to which the overview will be added
+      */
+-    protected void printNavigationBarHeader() {
+-        printTop();
+-        navLinks(true);
+-        hr();
+-        printConfigurationTitle();
++    protected void addOverview(Content body) throws IOException {
++        HtmlTree div = new HtmlTree(HtmlTag.DIV);
++        div.addStyle(HtmlStyle.footer);
++        addOverviewComment(div);
++        addTagsInfo(root, div);
++        body.addContent(div);
+     }
+ 
+     /**
+-     * Print the lower navigation bar and the bottom text
++     * Adds the top text (from the -top option), the upper
++     * navigation bar, and then the title (from the"-title"
++     * option), at the top of page.
++     *
++     * @body the documentation tree to which the navigation bar header will be added
++     */
++    protected void addNavigationBarHeader(Content body) {
++        addTop(body);
++        addNavLinks(true, body);
++        addConfigurationTitle(body);
++    }
++
++    /**
++     * Adds the lower navigation bar and the bottom text
+      * (from the -bottom option) at the bottom of page.
+-     */
+-    protected void printNavigationBarFooter() {
+-        hr();
+-        navLinks(false);
+-        printBottom();
++     *
++     * @param the documentation tree to which the navigation bar footer will be a     */
++    protected void addNavigationBarFooter(Content body) {
++        addNavLinks(false, body);
++        addBottom(body);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageTreeWriter.java
+@@ -29,12 +29,15 @@
+ 
+ import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+  * Class to generate Tree page for a package. The name of the file generated is
+  * "package-tree.html" and it is generated in the respective package directory.
+  *
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class PackageTreeWriter extends AbstractTreeWriter {
+ 
+@@ -107,94 +110,96 @@
+      * Generate a separate tree file for each package.
+      */
+     protected void generatePackageTreeFile() throws IOException {
+-        printHtmlHeader(packagedoc.name() + " "
+-            + configuration.getText("doclet.Window_Class_Hierarchy"), null, true);
+-
+-        printPackageTreeHeader();
+-
++        Content body = getPackageTreeHeader();
++        Content headContent = getResource("doclet.Hierarchy_For_Package",
++                Util.getPackageName(packagedoc));
++        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
++                HtmlStyle.title, headContent);
++        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
+         if (configuration.packages.length > 1) {
+-            printLinkToMainTree();
++            addLinkToMainTree(div);
+         }
+-
+-        generateTree(classtree.baseclasses(), "doclet.Class_Hierarchy");
+-        generateTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy");
+-        generateTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy");
+-        generateTree(classtree.baseEnums(), "doclet.Enum_Hierarchy");
+-
+-        printPackageTreeFooter();
+-        printBottom();
+-        printBodyHtmlEnd();
++        body.addContent(div);
++        HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
++        divTree.addStyle(HtmlStyle.contentContainer);
++        addTree(classtree.baseclasses(), "doclet.Class_Hierarchy", divTree);
++        addTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy", divTree);
++        addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
++        addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree);
++        body.addContent(divTree);
++        addNavLinks(false, body);
++        addBottom(body);
++        printHtmlDocument(null, true, body);
+     }
+ 
+     /**
+-     * Print the navigation bar header for the package tree file.
++     * Get the package tree header.
++     *
++     * @return a content tree for the header
+      */
+-    protected void printPackageTreeHeader() {
+-        printTop();
+-        navLinks(true);
+-        hr();
+-        center();
+-        h2(configuration.getText("doclet.Hierarchy_For_Package",
+-            Util.getPackageName(packagedoc)));
+-        centerEnd();
++    protected Content getPackageTreeHeader() {
++        String title = packagedoc.name() + " " +
++                configuration.getText("doclet.Window_Class_Hierarchy");
++        Content bodyTree = getBody(true, getWindowTitle(title));
++        addTop(bodyTree);
++        addNavLinks(true, bodyTree);
++        return bodyTree;
+     }
+ 
+     /**
+-     * Generate a link to the tree for all the packages.
++     * Add a link to the tree for all the packages.
++     *
++     * @param div the content tree to which the link will be added
+      */
+-    protected void printLinkToMainTree() {
+-        dl();
+-        dt();
+-        strongText("doclet.Package_Hierarchies");
+-        dtEnd();
+-        dd();
+-        navLinkMainTree(configuration.getText("doclet.All_Packages"));
+-        ddEnd();
+-        dlEnd();
+-        hr();
++    protected void addLinkToMainTree(Content div) {
++        Content span = HtmlTree.SPAN(HtmlStyle.strong,
++                getResource("doclet.Package_Hierarchies"));
++        div.addContent(span);
++        HtmlTree ul = new HtmlTree (HtmlTag.UL);
++        ul.addStyle(HtmlStyle.horizontal);
++        ul.addContent(getNavLinkMainTree(configuration.getText("doclet.All_Packages")));
++        div.addContent(ul);
+     }
+ 
+     /**
+-     * Print the navigation bar footer for the package tree file.
++     * Get link for the previous package tree file.
++     *
++     * @return a content tree for the link
+      */
+-    protected void printPackageTreeFooter() {
+-        hr();
+-        navLinks(false);
+-    }
+-
+-    /**
+-     * Link for the previous package tree file.
+-     */
+-    protected void navLinkPrevious() {
++    protected Content getNavLinkPrevious() {
+         if (prev == null) {
+-            navLinkPrevious(null);
++            return getNavLinkPrevious(null);
+         } else {
+             String path = DirectoryManager.getRelativePath(packagedoc.name(),
+-                                                           prev.name());
+-            navLinkPrevious(path + "package-tree.html");
++                    prev.name());
++            return getNavLinkPrevious(path + "package-tree.html");
+         }
+     }
+ 
+     /**
+-     * Link for the next package tree file.
++     * Get link for the next package tree file.
++     *
++     * @return a content tree for the link
+      */
+-    protected void navLinkNext() {
++    protected Content getNavLinkNext() {
+         if (next == null) {
+-            navLinkNext(null);
++            return getNavLinkNext(null);
+         } else {
+             String path = DirectoryManager.getRelativePath(packagedoc.name(),
+-                                                           next.name());
+-            navLinkNext(path + "package-tree.html");
++                    next.name());
++            return getNavLinkNext(path + "package-tree.html");
+         }
+     }
+ 
+     /**
+-     * Link to the package summary page for the package of this tree.
++     * Get link to the package summary page for the package of this tree.
++     *
++     * @return a content tree for the package link
+      */
+-    protected void navLinkPackage() {
+-        navCellStart();
+-        printHyperLink("package-summary.html", "", configuration.getText("doclet.Package"),
+-                        true, "NavBarFont1");
+-        navCellEnd();
++    protected Content getNavLinkPackage() {
++        Content linkContent = getHyperLink("package-summary.html", "",
++                packageLabel);
++        Content li = HtmlTree.LI(linkContent);
++        return li;
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+@@ -25,10 +25,12 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
+-import com.sun.tools.doclets.internal.toolkit.util.*;
+-import com.sun.javadoc.*;
+ import java.io.*;
+ import java.util.*;
++import com.sun.javadoc.*;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+  * Generate package usage information.
+@@ -106,49 +108,74 @@
+ 
+ 
+     /**
+-     * Print the class use list.
++     * Generate the package use list.
+      */
+     protected void generatePackageUseFile() throws IOException {
+-        printPackageUseHeader();
+-
++        Content body = getPackageUseHeader();
++        HtmlTree div = new HtmlTree(HtmlTag.DIV);
++        div.addStyle(HtmlStyle.contentContainer);
+         if (usingPackageToUsedClasses.isEmpty()) {
+-            printText("doclet.ClassUse_No.usage.of.0", pkgdoc.name());
+-            p();
++            div.addContent(getResource(
++                    "doclet.ClassUse_No.usage.of.0", pkgdoc.name()));
+         } else {
+-            generatePackageUse();
++            addPackageUse(div);
+         }
+-
+-        printPackageUseFooter();
++        body.addContent(div);
++        addNavLinks(false, body);
++        addBottom(body);
++        printHtmlDocument(null, true, body);
+     }
+ 
+     /**
+-     * Print the class use list.
++     * Add the package use information.
++     *
++     * @param contentTree the content tree to which the package use information will be added
+      */
+-    protected void generatePackageUse() throws IOException {
++    protected void addPackageUse(Content contentTree) throws IOException {
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
+         if (configuration.packages.length > 1) {
+-            generatePackageList();
++            addPackageList(ul);
+         }
+-        generateClassList();
++        addClassList(ul);
++        contentTree.addContent(ul);
+     }
+ 
+-    protected void generatePackageList() throws IOException {
+-        tableIndexSummary(useTableSummary);
+-        tableCaptionStart();
+-        printText("doclet.ClassUse_Packages.that.use.0",
+-            getPackageLink(pkgdoc, Util.getPackageName(pkgdoc), false));
+-        tableCaptionEnd();
+-        summaryTableHeader(packageTableHeader, "col");
++    /**
++     * Add the list of packages that use the given package.
++     *
++     * @param contentTree the content tree to which the package list will be added
++     */
++    protected void addPackageList(Content contentTree) throws IOException {
++        Content table = HtmlTree.TABLE(0, 3, 0, useTableSummary,
++                getTableCaption(configuration().getText(
++                "doclet.ClassUse_Packages.that.use.0",
++                getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false))));
++        table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
++        Content tbody = new HtmlTree(HtmlTag.TBODY);
+         Iterator it = usingPackageToUsedClasses.keySet().iterator();
+-        while (it.hasNext()) {
++        for (int i = 0; it.hasNext(); i++) {
+             PackageDoc pkg = configuration.root.packageNamed((String)it.next());
+-            generatePackageUse(pkg);
++            HtmlTree tr = new HtmlTree(HtmlTag.TR);
++            if (i % 2 == 0) {
++                tr.addStyle(HtmlStyle.altColor);
++            } else {
++                tr.addStyle(HtmlStyle.rowColor);
++            }
++            addPackageUse(pkg, tr);
++            tbody.addContent(tr);
+         }
+-        tableEnd();
+-        space();
+-        p();
++        table.addContent(tbody);
++        Content li = HtmlTree.LI(HtmlStyle.blockList, table);
++        contentTree.addContent(li);
+     }
+ 
+-    protected void generateClassList() throws IOException {
++    /**
++     * Add the list of classes that use the given package.
++     *
++     * @param contentTree the content tree to which the class list will be added
++     */
++    protected void addClassList(Content contentTree) throws IOException {
+         String[] classTableHeader = new String[] {
+             configuration.getText("doclet.0_and_1",
+                     configuration.getText("doclet.Class"),
+@@ -158,118 +185,127 @@
+         while (itp.hasNext()) {
+             String packageName = (String)itp.next();
+             PackageDoc usingPackage = configuration.root.packageNamed(packageName);
++            HtmlTree li = new HtmlTree(HtmlTag.LI);
++            li.addStyle(HtmlStyle.blockList);
+             if (usingPackage != null) {
+-                anchor(usingPackage.name());
++                li.addContent(getMarkerAnchor(usingPackage.name()));
+             }
+-            tableIndexSummary(configuration.getText("doclet.Use_Table_Summary",
+-                    configuration.getText("doclet.classes")));
+-            tableCaptionStart();
+-            printText("doclet.ClassUse_Classes.in.0.used.by.1",
+-                getPackageLink(pkgdoc, Util.getPackageName(pkgdoc), false),
+-                getPackageLink(usingPackage,Util.getPackageName(usingPackage), false));
+-            tableCaptionEnd();
+-            summaryTableHeader(classTableHeader, "col");
++            String tableSummary = configuration.getText("doclet.Use_Table_Summary",
++                    configuration.getText("doclet.classes"));
++            Content table = HtmlTree.TABLE(0, 3, 0, tableSummary,
++                    getTableCaption(configuration().getText(
++                    "doclet.ClassUse_Classes.in.0.used.by.1",
++                    getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false),
++                    getPackageLinkString(usingPackage,Util.getPackageName(usingPackage), false))));
++            table.addContent(getSummaryTableHeader(classTableHeader, "col"));
++            Content tbody = new HtmlTree(HtmlTag.TBODY);
+             Iterator itc =
+                 ((Collection)usingPackageToUsedClasses.get(packageName))
+                 .iterator();
+-            while (itc.hasNext()) {
+-                printClassRow((ClassDoc)itc.next(), packageName);
++            for (int i = 0; itc.hasNext(); i++) {
++                HtmlTree tr = new HtmlTree(HtmlTag.TR);
++                if (i % 2 == 0) {
++                    tr.addStyle(HtmlStyle.altColor);
++                } else {
++                    tr.addStyle(HtmlStyle.rowColor);
++                }
++                addClassRow(itc.next(), packageName, tr);
++                tbody.addContent(tr);
+             }
+-            tableEnd();
+-            space();
+-            p();
++            table.addContent(tbody);
++            li.addContent(table);
++            contentTree.addContent(li);
+         }
+     }
+ 
+-    protected void printClassRow(ClassDoc usedClass, String packageName) {
++    /**
++     * Add a row for the class that uses the given package.
++     *
++     * @param usedClass the class that uses the given package
++     * @param packageName the name of the package to which the class belongs
++     * @param contentTree the content tree to which the row will be added
++     */
++    protected void addClassRow(ClassDoc usedClass, String packageName,
++            Content contentTree) {
+         String path = pathString(usedClass,
+-                                 "class-use/" + usedClass.name() + ".html");
+-
+-        trBgcolorStyle("white", "TableRowColor");
+-        summaryRow(0);
+-        strong();
+-        printHyperLink(path, packageName, usedClass.name(), true);
+-        strongEnd();
+-        println(); br();
+-        printNbsps();
+-        printIndexComment(usedClass);
+-        summaryRowEnd();
+-        trEnd();
++                "class-use/" + usedClass.name() + ".html");
++        Content td = HtmlTree.TD(HtmlStyle.colOne,
++                getHyperLink(path, packageName, new StringContent(usedClass.name())));
++        addIndexComment(usedClass, td);
++        contentTree.addContent(td);
+     }
+ 
+     /**
+-     * Print the package use list.
++     * Add the package use information.
++     *
++     * @param pkg the package that used the given package
++     * @param contentTree the content tree to which the information will be added
+      */
+-    protected void generatePackageUse(PackageDoc pkg) throws IOException {
+-        trBgcolorStyle("white", "TableRowColor");
+-        summaryRow(0);
+-        //Just want an anchor here.
+-        printHyperLink("", pkg.name(), Util.getPackageName(pkg), true);
+-        summaryRowEnd();
+-        summaryRow(0);
+-        if (pkg != null) {
+-            printSummaryComment(pkg);
+-        }
+-        space();
+-        summaryRowEnd();
+-        trEnd();
++    protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException {
++        Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst,
++                getHyperLink("", pkg.name(), new StringContent(Util.getPackageName(pkg))));
++        contentTree.addContent(tdFirst);
++        HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
++        tdLast.addStyle(HtmlStyle.colLast);
++        if (pkg != null)
++            addSummaryComment(pkg, tdLast);
++        else
++            tdLast.addContent(getSpace());
++        contentTree.addContent(tdLast);
+     }
+ 
+     /**
+-     * Print the header for the class use Listing.
++     * Get the header for the package use listing.
++     *
++     * @return a content tree representing the package use header
+      */
+-    protected void printPackageUseHeader() {
+-        String packageLabel = configuration.getText("doclet.Package");
++    protected Content getPackageUseHeader() {
++        String packageText = configuration.getText("doclet.Package");
+         String name = pkgdoc.name();
+-        printHtmlHeader(configuration.getText("doclet.Window_ClassUse_Header",
+-            packageLabel, name), null, true);
+-        printTop();
+-        navLinks(true);
+-        hr();
+-        center();
+-        h2();
+-        strongText("doclet.ClassUse_Title", packageLabel, name);
+-        h2End();
+-        centerEnd();
++        String title = configuration.getText("doclet.Window_ClassUse_Header",
++                packageText, name);
++        Content bodyTree = getBody(true, getWindowTitle(title));
++        addTop(bodyTree);
++        addNavLinks(true, bodyTree);
++        Content headContent = getResource("doclet.ClassUse_Title", packageText, name);
++        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
++                HtmlStyle.title, headContent);
++        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
++        bodyTree.addContent(div);
++        return bodyTree;
+     }
+ 
+     /**
+-     * Print the footer for the class use Listing.
++     * Get this package link.
++     *
++     * @return a content tree for the package link
+      */
+-    protected void printPackageUseFooter() {
+-        hr();
+-        navLinks(false);
+-        printBottom();
+-        printBodyHtmlEnd();
+-    }
+-
+-
+-    /**
+-     * Print this package link
+-     */
+-    protected void navLinkPackage() {
+-        navCellStart();
+-        printHyperLink("package-summary.html", "", configuration.getText("doclet.Package"),
+-                       true, "NavBarFont1");
+-        navCellEnd();
++    protected Content getNavLinkPackage() {
++        Content linkContent = getHyperLink("package-summary.html", "",
++                packageLabel);
++        Content li = HtmlTree.LI(linkContent);
++        return li;
+     }
+ 
+     /**
+-     * Print class use link
++     * Get the use link.
++     *
++     * @return a content tree for the use link
+      */
+-    protected void navLinkClassUse() {
+-        navCellRevStart();
+-        fontStyle("NavBarFont1Rev");
+-        strongText("doclet.navClassUse");
+-        fontEnd();
+-        navCellEnd();
++    protected Content getNavLinkClassUse() {
++        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, useLabel);
++        return li;
+     }
+ 
+-    protected void navLinkTree() {
+-        navCellStart();
+-        printHyperLink("package-tree.html", "", configuration.getText("doclet.Tree"),
+-                       true, "NavBarFont1");
+-        navCellEnd();
++    /**
++     * Get the tree link.
++     *
++     * @return a content tree for the tree link
++     */
++    protected Content getNavLinkTree() {
++        Content linkContent = getHyperLink("package-tree.html", "",
++                treeLabel);
++        Content li = HtmlTree.LI(linkContent);
++        return li;
+     }
+-
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageWriterImpl.java
+@@ -25,12 +25,12 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
++import java.util.*;
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-
+-import com.sun.javadoc.*;
+-import java.io.*;
+-import java.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Class to generate file for each package contents in the right-hand
+@@ -98,189 +98,206 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void writeSummaryHeader() {}
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+-    public void writeSummaryFooter() {}
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+-    public void writeClassesSummary(ClassDoc[] classes, String label, String tableSummary, String[] tableHeader) {
+-        if(classes.length > 0) {
+-            Arrays.sort(classes);
+-            tableIndexSummary(tableSummary);
+-            boolean printedHeading = false;
+-            for (int i = 0; i < classes.length; i++) {
+-                if (!printedHeading) {
+-                    printTableCaption(label);
+-                    printFirstRow(tableHeader);
+-                    printedHeading = true;
+-                }
+-                if (!Util.isCoreClass(classes[i]) ||
+-                    !configuration.isGeneratedDoc(classes[i])) {
+-                    continue;
+-                }
+-                trBgcolorStyle("white", "TableRowColor");
+-                summaryRow(15);
+-                strong();
+-                printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_PACKAGE,
+-                    classes[i], false));
+-                strongEnd();
+-                summaryRowEnd();
+-                summaryRow(0);
+-                if (Util.isDeprecated(classes[i])) {
+-                    strongText("doclet.Deprecated");
+-                    if (classes[i].tags("deprecated").length > 0) {
+-                        space();
+-                        printSummaryDeprecatedComment(classes[i],
+-                            classes[i].tags("deprecated")[0]);
+-                    }
+-                } else {
+-                    printSummaryComment(classes[i]);
+-                }
+-                summaryRowEnd();
+-                trEnd();
+-            }
+-            tableEnd();
+-            println("&nbsp;");
+-            p();
++    public Content getPackageHeader(String heading) {
++        String pkgName = packageDoc.name();
++        Content bodyTree = getBody(true, getWindowTitle(pkgName));
++        addTop(bodyTree);
++        addNavLinks(true, bodyTree);
++        HtmlTree div = new HtmlTree(HtmlTag.DIV);
++        div.addStyle(HtmlStyle.header);
++        Content annotationContent = new HtmlTree(HtmlTag.P);
++        addAnnotationInfo(packageDoc, annotationContent);
++        div.addContent(annotationContent);
++        Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
++                HtmlStyle.title, packageLabel);
++        tHeading.addContent(getSpace());
++        Content packageHead = new RawHtml(heading);
++        tHeading.addContent(packageHead);
++        div.addContent(tHeading);
++        if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) {
++            HtmlTree p = new HtmlTree(HtmlTag.P);
++            p.addStyle(HtmlStyle.subTitle);
++            addSummaryComment(packageDoc, p);
++            div.addContent(p);
++            Content space = getSpace();
++            Content descLink = getHyperLink("", "package_description",
++                    descriptionLabel, "", "");
++            Content descPara = new HtmlTree(HtmlTag.P, seeLabel, space, descLink);
++            div.addContent(descPara);
+         }
+-    }
+-
+-    /**
+-     * Print the table caption for the class-listing.
+-     *
+-     * @param label label for the Class kind listing.
+-     */
+-    protected void printTableCaption(String label) {
+-        tableCaptionStart();
+-        print(label);
+-        tableCaptionEnd();
+-    }
+-
+-    /**
+-     * Print the table heading for the class-listing.
+-     *
+-     * @param tableHeader table header string for the Class listing.
+-     */
+-    protected void printFirstRow(String[] tableHeader) {
+-        summaryTableHeader(tableHeader, "col");
++        bodyTree.addContent(div);
++        return bodyTree;
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writePackageDescription() {
+-        if (packageDoc.inlineTags().length > 0) {
+-            anchor("package_description");
+-            h2(configuration.getText("doclet.Package_Description", packageDoc.name()));
+-            p();
+-            printInlineComment(packageDoc);
+-            p();
++    public Content getContentHeader() {
++        HtmlTree div = new HtmlTree(HtmlTag.DIV);
++        div.addStyle(HtmlStyle.contentContainer);
++        return div;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public Content getSummaryHeader() {
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
++        return ul;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void addClassesSummary(ClassDoc[] classes, String label,
++            String tableSummary, String[] tableHeader, Content summaryContentTree) {
++        if(classes.length > 0) {
++            Arrays.sort(classes);
++            Content caption = getTableCaption(label);
++            Content table = HtmlTree.TABLE(HtmlStyle.packageSummary, 0, 3, 0,
++                    tableSummary, caption);
++            table.addContent(getSummaryTableHeader(tableHeader, "col"));
++            Content tbody = new HtmlTree(HtmlTag.TBODY);
++            for (int i = 0; i < classes.length; i++) {
++                if (!Util.isCoreClass(classes[i]) ||
++                    !configuration.isGeneratedDoc(classes[i])) {
++                    continue;
++                }
++                Content classContent = new RawHtml(getLink(new LinkInfoImpl(
++                        LinkInfoImpl.CONTEXT_PACKAGE, classes[i], false)));
++                Content tdClass = HtmlTree.TD(HtmlStyle.colFirst, classContent);
++                HtmlTree tr = HtmlTree.TR(tdClass);
++                if (i%2 == 0)
++                    tr.addStyle(HtmlStyle.altColor);
++                else
++                    tr.addStyle(HtmlStyle.rowColor);
++                HtmlTree tdClassDescription = new HtmlTree(HtmlTag.TD);
++                tdClassDescription.addStyle(HtmlStyle.colLast);
++                if (Util.isDeprecated(classes[i])) {
++                    tdClassDescription.addContent(deprecatedLabel);
++                    if (classes[i].tags("deprecated").length > 0) {
++                        addSummaryDeprecatedComment(classes[i],
++                            classes[i].tags("deprecated")[0], tdClassDescription);
++                    }
++                }
++                else
++                    addSummaryComment(classes[i], tdClassDescription);
++                tr.addContent(tdClassDescription);
++                tbody.addContent(tr);
++            }
++            table.addContent(tbody);
++            Content li = HtmlTree.LI(HtmlStyle.blockList, table);
++            summaryContentTree.addContent(li);
+         }
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writePackageTags() {
+-        printTags(packageDoc);
+-    }
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+-    public void writePackageHeader(String heading) {
+-        String pkgName = packageDoc.name();
+-        printHtmlHeader(pkgName,
+-            configuration.metakeywords.getMetaKeywords(packageDoc), true);
+-        printTop();
+-        navLinks(true);
+-        hr();
+-        writeAnnotationInfo(packageDoc);
+-        h2(configuration.getText("doclet.Package") + " " + heading);
+-        if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) {
+-            printSummaryComment(packageDoc);
+-            p();
+-            strong(configuration.getText("doclet.See"));
+-            br();
+-            printNbsps();
+-            printHyperLink("", "package_description",
+-                configuration.getText("doclet.Description"), true);
+-            p();
++    public void addPackageDescription(Content packageContentTree) {
++        if (packageDoc.inlineTags().length > 0) {
++            packageContentTree.addContent(getMarkerAnchor("package_description"));
++            Content h2Content = new StringContent(
++                    configuration.getText("doclet.Package_Description",
++                    packageDoc.name()));
++            packageContentTree.addContent(HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING,
++                    true, h2Content));
++            addInlineComment(packageDoc, packageContentTree);
+         }
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+-    public void writePackageFooter() {
+-        hr();
+-        navLinks(false);
+-        printBottom();
+-        printBodyHtmlEnd();
++    public void addPackageTags(Content packageContentTree) {
++        addTagsInfo(packageDoc, packageContentTree);
+     }
+ 
+     /**
+-     * Print "Use" link for this pacakge in the navigation bar.
++     * {@inheritDoc}
+      */
+-    protected void navLinkClassUse() {
+-        navCellStart();
+-        printHyperLink("package-use.html", "", configuration.getText("doclet.navClassUse"),
+-                       true, "NavBarFont1");
+-        navCellEnd();
++    public void addPackageFooter(Content contentTree) {
++        addNavLinks(false, contentTree);
++        addBottom(contentTree);
+     }
+ 
+     /**
+-     * Print "PREV PACKAGE" link in the navigation bar.
++     * {@inheritDoc}
+      */
+-    protected void navLinkPrevious() {
++    public void printDocument(Content contentTree) {
++        printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageDoc),
++                true, contentTree);
++    }
++
++    /**
++     * Get "Use" link for this pacakge in the navigation bar.
++     *
++     * @return a content tree for the class use link
++     */
++    protected Content getNavLinkClassUse() {
++        Content useLink = getHyperLink("package-use.html", "",
++                useLabel, "", "");
++        Content li = HtmlTree.LI(useLink);
++        return li;
++    }
++
++    /**
++     * Get "PREV PACKAGE" link in the navigation bar.
++     *
++     * @return a content tree for the previous link
++     */
++    public Content getNavLinkPrevious() {
++        Content li;
+         if (prev == null) {
+-            printText("doclet.Prev_Package");
++            li = HtmlTree.LI(prevpackageLabel);
+         } else {
+             String path = DirectoryManager.getRelativePath(packageDoc.name(),
+                                                            prev.name());
+-            printHyperLink(path + "package-summary.html", "",
+-                configuration.getText("doclet.Prev_Package"), true);
++            li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "",
++                prevpackageLabel, "", ""));
+         }
++        return li;
+     }
+ 
+     /**
+-     * Print "NEXT PACKAGE" link in the navigation bar.
++     * Get "NEXT PACKAGE" link in the navigation bar.
++     *
++     * @return a content tree for the next link
+      */
+-    protected void navLinkNext() {
++    public Content getNavLinkNext() {
++        Content li;
+         if (next == null) {
+-            printText("doclet.Next_Package");
++            li = HtmlTree.LI(nextpackageLabel);
+         } else {
+             String path = DirectoryManager.getRelativePath(packageDoc.name(),
+                                                            next.name());
+-            printHyperLink(path + "package-summary.html", "",
+-                configuration.getText("doclet.Next_Package"), true);
++            li = HtmlTree.LI(getHyperLink(path + "package-summary.html", "",
++                nextpackageLabel, "", ""));
+         }
++        return li;
+     }
+ 
+     /**
+-     * Print "Tree" link in the navigation bar. This will be link to the package
++     * Get "Tree" link in the navigation bar. This will be link to the package
+      * tree file.
++     *
++     * @return a content tree for the tree link
+      */
+-    protected void navLinkTree() {
+-        navCellStart();
+-        printHyperLink("package-tree.html", "", configuration.getText("doclet.Tree"),
+-                       true, "NavBarFont1");
+-        navCellEnd();
++    protected Content getNavLinkTree() {
++        Content useLink = getHyperLink("package-tree.html", "",
++                treeLabel, "", "");
++        Content li = HtmlTree.LI(useLink);
++        return li;
+     }
+ 
+     /**
+      * Highlight "Package" in the navigation bar, as this is the package page.
++     *
++     * @return a content tree for the package link
+      */
+-    protected void navLinkPackage() {
+-        navCellRevStart();
+-        fontStyle("NavBarFont1Rev");
+-        strongText("doclet.Package");
+-        fontEnd();
+-        navCellEnd();
++    protected Content getNavLinkPackage() {
++        Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, packageLabel);
++        return li;
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SerializedFormWriterImpl.java
+@@ -25,8 +25,10 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
+ import com.sun.javadoc.*;
+-import java.io.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+  * Generate the Serialized Form Information Page.
+@@ -64,76 +66,167 @@
+     }
+ 
+     /**
+-     * Write the given package header.
++     * Get the given header.
+      *
+-     * @param packageName the package header to write.
++     * @param header the header to write
++     * @return the body content tree
+      */
+-    public void writePackageHeader(String packageName) {
+-        hr(4, "noshade");
+-        tableHeader();
+-        thAlign("center");
+-        font("+2");
+-        strongText("doclet.Package");
+-        print(' ');
+-        strong(packageName);
+-        tableFooter();
++    public Content getHeader(String header) {
++        Content bodyTree = getBody(true, getWindowTitle(header));
++        addTop(bodyTree);
++        addNavLinks(true, bodyTree);
++        Content h1Content = new StringContent(header);
++        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true,
++                HtmlStyle.title, h1Content);
++        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
++        bodyTree.addContent(div);
++        return bodyTree;
+     }
+ 
+     /**
+-     * Write the serial UID info.
++     * Get the serialized form summaries header.
+      *
+-     * @param header the header that will show up before the UID.
+-     * @param serialUID the serial UID to print.
++     * @return the serialized form summary header tree
+      */
+-    public void writeSerialUIDInfo(String header, String serialUID) {
+-        strong(header + "&nbsp;");
+-        println(serialUID);
+-        p();
++    public Content getSerializedSummariesHeader() {
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
++        return ul;
+     }
+ 
+     /**
+-     * Write the footer.
++     * Get the package serialized form header.
++     *
++     * @return the package serialized form header tree
+      */
+-    public void writeFooter() {
+-        p();
+-        hr();
+-        navLinks(false);
+-        printBottom();
+-        printBodyHtmlEnd();
++    public Content getPackageSerializedHeader() {
++        HtmlTree li = new HtmlTree(HtmlTag.LI);
++        li.addStyle(HtmlStyle.blockList);
++        return li;
+     }
+ 
++    /**
++     * Get the given package header.
++     *
++     * @param packageName the package header to write
++     * @return a content tree for the package header
++     */
++    public Content getPackageHeader(String packageName) {
++        Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
++                packageLabel);
++        heading.addContent(getSpace());
++        heading.addContent(packageName);
++        return heading;
++    }
+ 
+     /**
+-     * Write the serializable class heading.
++     * Get the serialized class header.
+      *
+-     * @param classDoc the class being processed.
++     * @return a content tree for the serialized class header
+      */
+-    public void writeClassHeader(ClassDoc classDoc) {
++    public Content getClassSerializedHeader() {
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
++        return ul;
++    }
++
++    /**
++     * Get the serializable class heading.
++     *
++     * @param classDoc the class being processed
++     * @return a content tree for the class header
++     */
++    public Content getClassHeader(ClassDoc classDoc) {
+         String classLink = (classDoc.isPublic() || classDoc.isProtected())?
+             getLink(new LinkInfoImpl(classDoc,
+-                configuration.getClassName(classDoc))):
++            configuration.getClassName(classDoc))):
+             classDoc.qualifiedName();
+-        p();
+-        anchor(classDoc.qualifiedName());
++        Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(
++                classDoc.qualifiedName()));
+         String superClassLink =
+             classDoc.superclassType() != null ?
+                 getLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_SERIALIZED_FORM,
+-                    classDoc.superclassType())) :
++                classDoc.superclassType())) :
+                 null;
+ 
+         //Print the heading.
+         String className = superClassLink == null ?
+             configuration.getText(
+-                "doclet.Class_0_implements_serializable", classLink) :
++            "doclet.Class_0_implements_serializable", classLink) :
+             configuration.getText(
+-                "doclet.Class_0_extends_implements_serializable", classLink,
+-                    superClassLink);
+-        tableHeader();
+-        thAlignColspan("left", 2);
+-        font("+2");
+-        strong(className);
+-        tableFooter();
+-        p();
++            "doclet.Class_0_extends_implements_serializable", classLink,
++            superClassLink);
++        Content classNameContent = new RawHtml(className);
++        li.addContent(HtmlTree.HEADING(HtmlConstants.SERIALIZED_MEMBER_HEADING,
++                classNameContent));
++        return li;
++    }
++
++    /**
++     * Get the serial UID info header.
++     *
++     * @return a content tree for the serial uid info header
++     */
++    public Content getSerialUIDInfoHeader() {
++        HtmlTree dl = new HtmlTree(HtmlTag.DL);
++        dl.addStyle(HtmlStyle.nameValue);
++        return dl;
++    }
++
++    /**
++     * Adds the serial UID info.
++     *
++     * @param header the header that will show up before the UID.
++     * @param serialUID the serial UID to print.
++     * @param serialUidTree the serial UID content tree to which the serial UID
++     *                      content will be added
++     */
++    public void addSerialUIDInfo(String header, String serialUID,
++            Content serialUidTree) {
++        Content headerContent = new StringContent(header);
++        serialUidTree.addContent(HtmlTree.DT(headerContent));
++        Content serialContent = new StringContent(serialUID);
++        serialUidTree.addContent(HtmlTree.DD(serialContent));
++    }
++
++    /**
++     * Get the class serialize content header.
++     *
++     * @return a content tree for the class serialize content header
++     */
++    public Content getClassContentHeader() {
++        HtmlTree ul = new HtmlTree(HtmlTag.UL);
++        ul.addStyle(HtmlStyle.blockList);
++        return ul;
++    }
++
++    /**
++     * Get the serialized content tree section.
++     *
++     * @param serializedTreeContent the serialized content tree to be added
++     * @return a div content tree
++     */
++    public Content getSerializedContent(Content serializedTreeContent) {
++        Content divContent = HtmlTree.DIV(HtmlStyle.serializedFormContainer,
++                serializedTreeContent);
++        return divContent;
++    }
++
++    /**
++     * Add the footer.
++     *
++     * @param serializedTree the serialized tree to be added
++     */
++    public void addFooter(Content serializedTree) {
++        addNavLinks(false, serializedTree);
++        addBottom(serializedTree);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void printDocument(Content serializedTree) {
++        printHtmlDocument(null, true, serializedTree);
+     }
+ 
+     private void tableHeader() {
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java
+@@ -25,9 +25,10 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-
+-import java.io.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+  * Generate only one index file for all the Member Names with Indexing in
+@@ -36,6 +37,7 @@
+  *
+  * @see java.lang.Character
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class SingleIndexWriter extends AbstractIndexWriter {
+ 
+@@ -82,34 +84,35 @@
+      * Member Field, Method and Constructor Description.
+      */
+     protected void generateIndexFile() throws IOException {
+-        printHtmlHeader(configuration.getText("doclet.Window_Single_Index"),
+-            null, true);
+-        printTop();
+-        navLinks(true);
+-        printLinksForIndexes();
+-
+-        hr();
+-
++        String title = configuration.getText("doclet.Window_Single_Index");
++        Content body = getBody(true, getWindowTitle(title));
++        addTop(body);
++        addNavLinks(true, body);
++        HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
++        divTree.addStyle(HtmlStyle.contentContainer);
++        addLinksForIndexes(divTree);
+         for (int i = 0; i < indexbuilder.elements().length; i++) {
+             Character unicode = (Character)((indexbuilder.elements())[i]);
+-            generateContents(unicode, indexbuilder.getMemberList(unicode));
++            addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
+         }
+-
+-        printLinksForIndexes();
+-        navLinks(false);
+-
+-        printBottom();
+-        printBodyHtmlEnd();
++        addLinksForIndexes(divTree);
++        body.addContent(divTree);
++        addNavLinks(false, body);
++        addBottom(body);
++        printHtmlDocument(null, true, body);
+     }
+ 
+     /**
+-     * Print Links for all the Index Files per unicode character.
++     * Add links for all the Index Files per unicode character.
++     *
++     * @param contentTree the content tree to which the links for indexes will be added
+      */
+-    protected void printLinksForIndexes() {
++    protected void addLinksForIndexes(Content contentTree) {
+         for (int i = 0; i < indexbuilder.elements().length; i++) {
+             String unicode = (indexbuilder.elements())[i].toString();
+-            printHyperLink("#_" + unicode + "_", unicode);
+-            print(' ');
++            contentTree.addContent(
++                    getHyperLink("#_" + unicode + "_", new StringContent(unicode)));
++            contentTree.addContent(getSpace());
+         }
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
+rename from src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java
+rename to src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/SourceToHTMLConverter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java
+@@ -23,14 +23,14 @@
+  * questions.
+  */
+ 
+-package com.sun.tools.doclets.internal.toolkit.util;
++package com.sun.tools.doclets.formats.html;
+ 
+ import java.io.*;
+-import java.util.*;
+ import javax.tools.FileObject;
+-
+ import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * Converts Java Source Code to HTML.
+@@ -40,27 +40,28 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.4
+  */
+ public class SourceToHTMLConverter {
+ 
+     /**
+-     * The background color.
+-     */
+-    protected static final String BGCOLOR = "white";
+-
+-    /**
+-     * The line number color.
+-     */
+-    protected static final String LINE_NO_COLOR = "green";
+-
+-    /**
+      * The number of trailing blank lines at the end of the page.
+      * This is inserted so that anchors at the bottom of small pages
+      * can be reached.
+      */
+-    protected static final int NUM_BLANK_LINES = 60;
++    private static final int NUM_BLANK_LINES = 60;
+ 
++    /**
++     * New line to be added to the documentation.
++     */
++    private static final Content NEW_LINE = new RawHtml(DocletConstants.NL);
++
++    /**
++     * Relative path from the documentation root to the file that is being
++     * generated.
++     */
++    private static String relativePath = "";
+ 
+     /**
+      * Source is converted to HTML using static methods below.
+@@ -69,11 +70,13 @@
+ 
+     /**
+      * Convert the Classes in the given RootDoc to an HTML.
++     *
+      * @param configuration the configuration.
+      * @param rd the RootDoc to convert.
+      * @param outputdir the name of the directory to output to.
+      */
+-    public static void convertRoot(Configuration configuration, RootDoc rd, String outputdir) {
++    public static void convertRoot(ConfigurationImpl configuration, RootDoc rd,
++            String outputdir) {
+         if (rd == null || outputdir == null) {
+             return;
+         }
+@@ -84,17 +87,19 @@
+         ClassDoc[] cds = rd.specifiedClasses();
+         for (int i = 0; i < cds.length; i++) {
+             convertClass(configuration, cds[i],
+-                getPackageOutputDir(outputdir, cds[i].containingPackage()));
++                    getPackageOutputDir(outputdir, cds[i].containingPackage()));
+         }
+     }
+ 
+     /**
+      * Convert the Classes in the given Package to an HTML.
++     *
+      * @param configuration the configuration.
+      * @param pd the Package to convert.
+      * @param outputdir the name of the directory to output to.
+      */
+-    public static void convertPackage(Configuration configuration, PackageDoc pd, String outputdir) {
++    public static void convertPackage(ConfigurationImpl configuration, PackageDoc pd,
++            String outputdir) {
+         if (pd == null || outputdir == null) {
+             return;
+         }
+@@ -107,8 +112,10 @@
+ 
+     /**
+      * Return the directory write output to for the given package.
++     *
+      * @param outputDir the directory to output to.
+      * @param pd the Package to generate output for.
++     * @return the package output directory as a String.
+      */
+     private static String getPackageOutputDir(String outputDir, PackageDoc pd) {
+         return outputDir + File.separator +
+@@ -117,11 +124,13 @@
+ 
+     /**
+      * Convert the given Class to an HTML.
++     *
+      * @param configuration the configuration.
+      * @param cd the class to convert.
+      * @param outputdir the name of the directory to output to.
+      */
+-    public static void convertClass(Configuration configuration, ClassDoc cd, String outputdir) {
++    public static void convertClass(ConfigurationImpl configuration, ClassDoc cd,
++            String outputdir) {
+         if (cd == null || outputdir == null) {
+             return;
+         }
+@@ -145,19 +154,23 @@
+             LineNumberReader reader = new LineNumberReader(r);
+             int lineno = 1;
+             String line;
+-            StringBuffer output = new StringBuffer();
++            relativePath = DirectoryManager.getRelativePath(DocletConstants.SOURCE_OUTPUT_DIR_NAME) +
++                    DirectoryManager.getRelativePath(cd.containingPackage());
++            Content body = getHeader();
++            Content pre = new HtmlTree(HtmlTag.PRE);
+             try {
+                 while ((line = reader.readLine()) != null) {
+-                    output.append(formatLine(line, configuration.sourcetab, lineno));
++                    addLineNo(pre, lineno);
++                    addLine(pre, line, configuration.sourcetab, lineno);
+                     lineno++;
+                 }
+             } finally {
+                 reader.close();
+             }
+-            output = addLineNumbers(output.toString());
+-            output.insert(0, getHeader(configuration));
+-            output.append(getFooter());
+-            writeToFile(output.toString(), outputdir, cd.name(), configuration);
++            addBlankLines(pre);
++            Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
++            body.addContent(div);
++            writeToFile(body, outputdir, cd.name(), configuration);
+         } catch (Exception e){
+             e.printStackTrace();
+         }
+@@ -165,135 +178,117 @@
+ 
+     /**
+      * Write the output to the file.
+-     * @param output the string to output.
++     *
++     * @param body the documentation content to be written to the file.
+      * @param outputDir the directory to output to.
+      * @param className the name of the class that I am converting to HTML.
+      * @param configuration the Doclet configuration to pass notices to.
+      */
+-    private static void writeToFile(String output, String outputDir, String className, Configuration configuration) throws IOException {
++    private static void writeToFile(Content body, String outputDir,
++            String className, ConfigurationImpl configuration) throws IOException {
++        Content htmlDocType = DocType.Transitional();
++        Content head = new HtmlTree(HtmlTag.HEAD);
++        head.addContent(HtmlTree.TITLE(new StringContent(
++                configuration.getText("doclet.Window_Source_title"))));
++        head.addContent(getStyleSheetProperties(configuration));
++        Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
++                head, body);
++        Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree);
+         File dir = new File(outputDir);
+         dir.mkdirs();
+         File newFile = new File(dir, className + ".html");
+         configuration.message.notice("doclet.Generating_0", newFile.getPath());
+         FileOutputStream fout = new FileOutputStream(newFile);
+         BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fout));
+-        bw.write(output);
++        bw.write(htmlDocument.toString());
+         bw.close();
+         fout.close();
+     }
+ 
+     /**
+-     * Given a <code>String</code>, add line numbers.
+-     * @param s the text to add line numbers to.
++     * Returns a link to the stylesheet file.
+      *
+-     * @return the string buffer with the line numbering for each line.
++     * @param configuration the doclet configuration for the current run of javadoc
++     * @return an HtmlTree for the lINK tag which provides the stylesheet location
+      */
+-    private static StringBuffer addLineNumbers(String s) {
+-        StringBuffer sb = new StringBuffer();
+-        StringTokenizer st = new StringTokenizer(s, "\n", true);
+-        int lineno = 1;
+-        String current;
+-        while(st.hasMoreTokens()){
+-            current = st.nextToken();
+-            sb.append(current.equals("\n") ?
+-                    getHTMLLineNo(lineno) + current :
+-                    getHTMLLineNo(lineno) + current + st.nextToken());
+-            lineno++;
++    public static HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
++        String filename = configuration.stylesheetfile;
++        if (filename.length() > 0) {
++            File stylefile = new File(filename);
++            String parent = stylefile.getParent();
++            filename = (parent == null)?
++                filename:
++                filename.substring(parent.length() + 1);
++        } else {
++            filename = "stylesheet.css";
+         }
+-        return sb;
++        filename = relativePath + filename;
++        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style");
++        return link;
+     }
+ 
+     /**
+      * Get the header.
+-     * @param configuration the Doclet configuration
+-     * @return the header to the output file
++     *
++     * @return the header content for the HTML file
+      */
+-    protected static String getHeader(Configuration configuration) {
+-        StringBuffer result = new StringBuffer("<HTML lang=\"" + configuration.getLocale().getLanguage() + "\">" + DocletConstants.NL);
+-        result.append("<BODY BGCOLOR=\""+ BGCOLOR + "\">" + DocletConstants.NL);
+-        result.append("<PRE>" + DocletConstants.NL);
+-        return result.toString();
++    private static Content getHeader() {
++        return new HtmlTree(HtmlTag.BODY);
+     }
+ 
+     /**
+-     * Get the footer
+-     * @return the footer to the output file
++     * Add the line numbers for the source code.
++     *
++     * @param pre the content tree to which the line number will be added
++     * @param lineno The line number
+      */
+-    protected static String getFooter() {
+-        StringBuffer footer = new StringBuffer();
+-        for (int i = 0; i < NUM_BLANK_LINES; i++) {
+-            footer.append(DocletConstants.NL);
++    private static void addLineNo(Content pre, int lineno) {
++        HtmlTree span = new HtmlTree(HtmlTag.SPAN);
++        span.addStyle(HtmlStyle.sourceLineNo);
++        if (lineno < 10) {
++            span.addContent("00" + Integer.toString(lineno));
++        } else if (lineno < 100) {
++            span.addContent("0" + Integer.toString(lineno));
++        } else {
++            span.addContent(Integer.toString(lineno));
+         }
+-        footer.append("</PRE>" + DocletConstants.NL + "</BODY>" +
+-            DocletConstants.NL + "</HTML>" + DocletConstants.NL);
+-        return footer.toString();
++        pre.addContent(span);
+     }
+ 
+     /**
+-     * Get the HTML for the lines.
+-     * @param lineno The line number
+-     * @return the HTML code for the line
+-     */
+-    protected static String getHTMLLineNo(int lineno) {
+-        StringBuffer result = new StringBuffer("<FONT color=\"" + LINE_NO_COLOR
+-            + "\">");
+-        if (lineno < 10) {
+-            result.append("00" + ((new Integer(lineno)).toString()));
+-        } else if (lineno < 100) {
+-            result.append("0" + ((new Integer(lineno)).toString()));
+-        } else {
+-            result.append((new Integer(lineno)).toString());
+-        }
+-        result.append("</FONT>    ");
+-        return result.toString();
+-    }
+-
+-    /**
+-     * Format a given line of source. <br>
+-     * Note:  In the future, we will add special colors for constructs in the
+-     * language.
++     * Add a line from source to the HTML file that is generated.
++     *
++     * @param pre the content tree to which the line will be added.
+      * @param line the string to format.
+      * @param tabLength the number of spaces for each tab.
+      * @param currentLineNo the current number.
+      */
+-    protected static String formatLine(String line, int tabLength, int currentLineNo) {
+-        if (line == null) {
+-            return null;
+-        }
+-        StringBuffer lineBuffer = new StringBuffer(Util.escapeHtmlChars(line));
+-        //Insert an anchor for the line
+-        lineBuffer.append("<a name=\"line." + Integer.toString(currentLineNo) + "\"></a>");
+-        lineBuffer.append(DocletConstants.NL);
+-        Util.replaceTabs(tabLength, lineBuffer);
+-        return lineBuffer.toString();
+-    }
+-
+-    /**
+-     * Given an array of <code>Doc</code>s, add to the given <code>HashMap</code> the
+-     * line numbers and anchors that should be inserted in the output at those lines.
+-     * @param docs the array of <code>Doc</code>s to add anchors for.
+-     * @param hash the <code>HashMap</code> to add to.
+-     */
+-    protected static void addToHash(Doc[] docs, HashMap<Integer,String> hash) {
+-        if(docs == null) {
+-            return;
+-        }
+-        for(int i = 0; i < docs.length; i++) {
+-            hash.put(docs[i].position().line(), getAnchor(docs[i]));
++    private static void addLine(Content pre, String line, int tabLength,
++            int currentLineNo) {
++        if (line != null) {
++            StringBuffer lineBuffer = new StringBuffer(Util.escapeHtmlChars(line));
++            Util.replaceTabs(tabLength, lineBuffer);
++            pre.addContent(new RawHtml(lineBuffer.toString()));
++            Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo));
++            pre.addContent(anchor);
++            pre.addContent(NEW_LINE);
+         }
+     }
+ 
+     /**
+-     * Given a <code>Doc</code>, return an anchor for it.
+-     * @param d the <code>Doc</code> to check.
+-     * @return an anchor of the form &lt;a name="my_name">&lt;/a>
++     * Add trailing blank lines at the end of the page.
++     *
++     * @param pre the content tree to which the blank lines will be added.
+      */
+-    protected static String getAnchor(Doc d) {
+-        return "    <a name=\"" + getAnchorName(d) + "\"></a>";
++    private static void addBlankLines(Content pre) {
++        for (int i = 0; i < NUM_BLANK_LINES; i++) {
++            pre.addContent(NEW_LINE);
++        }
+     }
+ 
+     /**
+      * Given a <code>Doc</code>, return an anchor name for it.
++     *
+      * @param d the <code>Doc</code> to check.
+      * @return the name of the anchor.
+      */
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SplitIndexWriter.java
+@@ -25,9 +25,10 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-
+-import java.io.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+  * Generate Separate Index Files for all the member names with Indexing in
+@@ -36,6 +37,7 @@
+  *
+  * @see java.lang.Character
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class SplitIndexWriter extends AbstractIndexWriter {
+ 
+@@ -109,56 +111,68 @@
+      * index.
+      */
+     protected void generateIndexFile(Character unicode) throws IOException {
+-        printHtmlHeader(configuration.getText("doclet.Window_Split_Index",
+-            unicode.toString()), null, true);
+-        printTop();
+-        navLinks(true);
+-        printLinksForIndexes();
+-
+-        hr();
+-
+-        generateContents(unicode, indexbuilder.getMemberList(unicode));
+-
+-        navLinks(false);
+-        printLinksForIndexes();
+-
+-        printBottom();
+-        printBodyHtmlEnd();
++        String title = configuration.getText("doclet.Window_Split_Index",
++                unicode.toString());
++        Content body = getBody(true, getWindowTitle(title));
++        addTop(body);
++        addNavLinks(true, body);
++        HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
++        divTree.addStyle(HtmlStyle.contentContainer);
++        addLinksForIndexes(divTree);
++        addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
++        addLinksForIndexes(divTree);
++        body.addContent(divTree);
++        addNavLinks(false, body);
++        addBottom(body);
++        printHtmlDocument(null, true, body);
+     }
+ 
+     /**
+-     * Print Links for all the Index Files per unicode character.
++     * Add links for all the Index Files per unicode character.
++     *
++     * @param contentTree the content tree to which the links for indexes will be added
+      */
+-    protected void printLinksForIndexes() {
+-        for (int i = 0; i < indexbuilder.elements().length; i++) {
++    protected void addLinksForIndexes(Content contentTree) {
++        Object[] unicodeChars = indexbuilder.elements();
++        for (int i = 0; i < unicodeChars.length; i++) {
+             int j = i + 1;
+-            printHyperLink("index-" + j + ".html",
+-                           indexbuilder.elements()[i].toString());
+-            print(' ');
++            contentTree.addContent(getHyperLink("index-" + j + ".html",
++                    new StringContent(unicodeChars[i].toString())));
++            contentTree.addContent(getSpace());
+         }
+     }
+ 
+     /**
+-     * Print the previous unicode character index link.
++     * Get link to the previous unicode character.
++     *
++     * @return a content tree for the link
+      */
+-    protected void navLinkPrevious() {
++    public Content getNavLinkPrevious() {
++        Content prevletterLabel = getResource("doclet.Prev_Letter");
+         if (prev == -1) {
+-            printText("doclet.Prev_Letter");
+-        } else {
+-            printHyperLink("index-" + prev + ".html", "",
+-                configuration.getText("doclet.Prev_Letter"), true);
++            return HtmlTree.LI(prevletterLabel);
++        }
++        else {
++            Content prevLink = getHyperLink("index-" + prev + ".html", "",
++                    prevletterLabel);
++            return HtmlTree.LI(prevLink);
+         }
+     }
+ 
+     /**
+-     * Print the next unicode character index link.
++     * Get link to the next unicode character.
++     *
++     * @return a content tree for the link
+      */
+-    protected void navLinkNext() {
++    public Content getNavLinkNext() {
++        Content nextletterLabel = getResource("doclet.Next_Letter");
+         if (next == -1) {
+-            printText("doclet.Next_Letter");
+-        } else {
+-            printHyperLink("index-" + next + ".html","",
+-                configuration.getText("doclet.Next_Letter"), true);
++            return HtmlTree.LI(nextletterLabel);
++        }
++        else {
++            Content nextLink = getHyperLink("index-" + next + ".html","",
++                    nextletterLabel);
++            return HtmlTree.LI(nextLink);
+         }
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/StylesheetWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/StylesheetWriter.java
+deleted file mode 100644
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/StylesheetWriter.java
++++ /dev/null
+@@ -1,130 +0,0 @@
+-/*
+- * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+- */
+-
+-package com.sun.tools.doclets.formats.html;
+-
+-import com.sun.tools.doclets.internal.toolkit.util.*;
+-
+-import java.io.*;
+-
+-/**
+- * Writes the style sheet for the doclet output.
+- *
+- * @author Atul M Dambalkar
+- * @author Bhavesh Patel (Modified)
+- */
+-public class StylesheetWriter extends HtmlDocletWriter {
+-
+-    /**
+-     * Constructor.
+-     */
+-    public StylesheetWriter(ConfigurationImpl configuration,
+-                            String filename) throws IOException {
+-        super(configuration, filename);
+-    }
+-
+-    /**
+-     * Generate the style file contents.
+-     * @throws DocletAbortException
+-     */
+-    public static void generate(ConfigurationImpl configuration) {
+-        StylesheetWriter stylegen;
+-        String filename = "";
+-        try {
+-            filename = "stylesheet.css";
+-            stylegen = new StylesheetWriter(configuration, filename);
+-            stylegen.generateStyleFile();
+-            stylegen.close();
+-        } catch (IOException exc) {
+-            configuration.standardmessage.error(
+-                        "doclet.exception_encountered",
+-                        exc.toString(), filename);
+-            throw new DocletAbortException();
+-        }
+-    }
+-
+-    /**
+-     * Generate the style file contents.
+-     */
+-    protected void generateStyleFile() {
+-        print("/* "); printText("doclet.Style_line_1"); println(" */");
+-        println("");
+-
+-        print("/* "); printText("doclet.Style_line_2"); println(" */");
+-        println("");
+-
+-        print("/* "); printText("doclet.Style_line_3"); println(" */");
+-        println("body { background-color: #FFFFFF; color:#000000 }");
+-        println("");
+-
+-        print("/* "); printText("doclet.Style_Headings"); println(" */");
+-        println("h1 { font-size: 145% }");
+-        println("");
+-
+-        print("/* "); printText("doclet.Style_line_4"); println(" */");
+-        print(".TableHeadingColor     { background: #CCCCFF; color:#000000 }");
+-        print(" /* "); printText("doclet.Style_line_5"); println(" */");
+-        print(".TableSubHeadingColor  { background: #EEEEFF; color:#000000 }");
+-        print(" /* "); printText("doclet.Style_line_6"); println(" */");
+-        print(".TableRowColor         { background: #FFFFFF; color:#000000 }");
+-        print(" /* "); printText("doclet.Style_line_7"); println(" */");
+-        println("");
+-
+-        print("/* "); printText("doclet.Style_line_8"); println(" */");
+-        println(".FrameTitleFont   { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 }");
+-        println(".FrameHeadingFont { font-size:  90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }");
+-        println(".FrameItemFont    { font-size:  90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }");
+-        println("");
+-
+-       // Removed doclet.Style_line_9 as no longer needed
+-
+-        print("/* "); printText("doclet.Style_line_10"); println(" */");
+-        print(".NavBarCell1    { background-color:#EEEEFF; color:#000000}");
+-        print(" /* "); printText("doclet.Style_line_6"); println(" */");
+-        print(".NavBarCell1Rev { background-color:#00008B; color:#FFFFFF}");
+-        print(" /* "); printText("doclet.Style_line_11"); println(" */");
+-
+-        print(".NavBarFont1    { font-family: Arial, Helvetica, sans-serif; color:#000000;");
+-        println("color:#000000;}");
+-        print(".NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;");
+-        println("color:#FFFFFF;}");
+-        println("");
+-
+-        print(".NavBarCell2    { font-family: Arial, Helvetica, sans-serif; ");
+-        println("background-color:#FFFFFF; color:#000000}");
+-        print(".NavBarCell3    { font-family: Arial, Helvetica, sans-serif; ");
+-        println("background-color:#FFFFFF; color:#000000}");
+-
+-        print("/* "); printText("doclet.Style_line_12"); println(" */");
+-        print(".TableCaption     { background: #CCCCFF; color:#000000; text-align: left; font-size: 150%; font-weight: bold; border-left: 2px ridge; border-right: 2px ridge; border-top: 2px ridge; padding-left: 5px; }");
+-        print(" /* "); printText("doclet.Style_line_5"); println(" */");
+-        print(".TableSubCaption  { background: #EEEEFF; color:#000000; text-align: left; font-weight: bold; border-left: 2px ridge; border-right: 2px ridge; border-top: 2px ridge; padding-left: 5px; }");
+-        print(" /* "); printText("doclet.Style_line_6"); println(" */");
+-        print(".TableHeader     { text-align: center; font-size: 80%; font-weight: bold; }");
+-        println("");
+-
+-    }
+-
+-}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SubWriterHolderWriter.java
+@@ -25,10 +25,11 @@
+ 
+ package com.sun.tools.doclets.formats.html;
+ 
++import java.io.*;
+ import com.sun.javadoc.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-
+-import java.io.*;
++import com.sun.tools.doclets.formats.html.markup.*;
+ 
+ /**
+  * This abstract class exists to provide functionality needed in the
+@@ -71,13 +72,31 @@
+         tdEnd();
+     }
+ 
+-    public void printSummaryHeader(AbstractMemberWriter mw, ClassDoc cd) {
+-        mw.printSummaryAnchor(cd);
+-        mw.printTableSummary();
+-        tableCaptionStart();
+-        mw.printSummaryLabel();
+-        tableCaptionEnd();
+-        mw.printSummaryTableHeader(cd);
++    /**
++     * Add the summary header.
++     *
++     * @param mw the writer for the member being documented
++     * @param cd the classdoc to be documented
++     * @param memberTree the content tree to which the summary header will be added
++     */
++    public void addSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
++            Content memberTree) {
++        mw.addSummaryAnchor(cd, memberTree);
++        mw.addSummaryLabel(memberTree);
++    }
++
++    /**
++     * Get the summary table.
++     *
++     * @param mw the writer for the member being documented
++     * @param cd the classdoc to be documented
++     * @return the content tree for the summary table
++     */
++    public Content getSummaryTableTree(AbstractMemberWriter mw, ClassDoc cd) {
++        Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0,
++                mw.getTableSummary(), getTableCaption(mw.getCaption()));
++        table.addContent(getSummaryTableHeader(mw.getSummaryTableHeader(cd), "col"));
++        return table;
+     }
+ 
+     public void printTableHeadingBackground(String str) {
+@@ -88,15 +107,17 @@
+         tableEnd();
+     }
+ 
+-    public void printInheritedSummaryHeader(AbstractMemberWriter mw, ClassDoc cd) {
+-        mw.printInheritedSummaryAnchor(cd);
+-        tableIndexSummary();
+-        tableInheritedHeaderStart("#EEEEFF");
+-        mw.printInheritedSummaryLabel(cd);
+-        tableInheritedHeaderEnd();
+-        trBgcolorStyle("white", "TableRowColor");
+-        summaryRow(0);
+-        code();
++    /**
++     * Add the inherited summary header.
++     *
++     * @param mw the writer for the member being documented
++     * @param cd the classdoc to be documented
++     * @param inheritedTree the content tree to which the inherited summary header will be added
++     */
++    public void addInheritedSummaryHeader(AbstractMemberWriter mw, ClassDoc cd,
++            Content inheritedTree) {
++        mw.addInheritedSummaryAnchor(cd, inheritedTree);
++        mw.addInheritedSummaryLabel(cd, inheritedTree);
+     }
+ 
+     public void printSummaryFooter(AbstractMemberWriter mw, ClassDoc cd) {
+@@ -112,8 +133,14 @@
+         space();
+     }
+ 
+-    protected void printIndexComment(Doc member) {
+-        printIndexComment(member, member.firstSentenceTags());
++    /**
++     * Add the index comment.
++     *
++     * @param member the member being documented
++     * @param contentTree the content tree to which the comment will be added
++     */
++    protected void addIndexComment(Doc member, Content contentTree) {
++        addIndexComment(member, member.firstSentenceTags(), contentTree);
+     }
+ 
+     protected void printIndexComment(Doc member, Tag[] firstSentenceTags) {
+@@ -134,17 +161,60 @@
+         printSummaryComment(member, firstSentenceTags);
+     }
+ 
+-    public void printSummaryLinkType(AbstractMemberWriter mw,
+-                                     ProgramElementDoc member) {
+-        trBgcolorStyle("white", "TableRowColor");
+-        mw.printSummaryType(member);
+-        summaryRow(0);
+-        code();
++    /**
++     * Add the index comment.
++     *
++     * @param member the member being documented
++     * @param firstSentenceTags the first sentence tags for the member to be documented
++     * @param tdSummary the content tree to which the comment will be added
++     */
++    protected void addIndexComment(Doc member, Tag[] firstSentenceTags,
++            Content tdSummary) {
++        Tag[] deprs = member.tags("deprecated");
++        Content div;
++        if (Util.isDeprecated((ProgramElementDoc) member)) {
++            Content strong = HtmlTree.STRONG(deprecatedPhrase);
++            div = HtmlTree.DIV(HtmlStyle.block, strong);
++            div.addContent(getSpace());
++            if (deprs.length > 0) {
++                addInlineDeprecatedComment(member, deprs[0], div);
++            }
++            tdSummary.addContent(div);
++            return;
++        } else {
++            ClassDoc cd = ((ProgramElementDoc)member).containingClass();
++            if (cd != null && Util.isDeprecated(cd)) {
++                Content strong = HtmlTree.STRONG(deprecatedPhrase);
++                div = HtmlTree.DIV(HtmlStyle.block, strong);
++                div.addContent(getSpace());
++                tdSummary.addContent(div);
++            }
++        }
++        addSummaryComment(member, firstSentenceTags, tdSummary);
+     }
+ 
+-    public void printSummaryLinkComment(AbstractMemberWriter mw,
+-                                        ProgramElementDoc member) {
+-        printSummaryLinkComment(mw, member, member.firstSentenceTags());
++    /**
++     * Add the summary type for the member.
++     *
++     * @param mw the writer for the member being documented
++     * @param member the member to be documented
++     * @param tdSummaryType the content tree to which the type will be added
++     */
++    public void addSummaryType(AbstractMemberWriter mw, ProgramElementDoc member,
++            Content tdSummaryType) {
++        mw.addSummaryType(member, tdSummaryType);
++    }
++
++    /**
++     * Add the summary link for the member.
++     *
++     * @param mw the writer for the member being documented
++     * @param member the member to be documented
++     * @param contentTree the content tree to which the link will be added
++     */
++    public void addSummaryLinkComment(AbstractMemberWriter mw,
++            ProgramElementDoc member, Content contentTree) {
++        addSummaryLinkComment(mw, member, member.firstSentenceTags(), contentTree);
+     }
+ 
+     public void printSummaryLinkComment(AbstractMemberWriter mw,
+@@ -159,12 +229,34 @@
+         trEnd();
+     }
+ 
+-    public void printInheritedSummaryMember(AbstractMemberWriter mw, ClassDoc cd,
+-            ProgramElementDoc member, boolean isFirst) {
++    /**
++     * Add the summary link comment.
++     *
++     * @param mw the writer for the member being documented
++     * @param member the member being documented
++     * @param firstSentenceTags the first sentence tags for the member to be documented
++     * @param tdSummary the content tree to which the comment will be added
++     */
++    public void addSummaryLinkComment(AbstractMemberWriter mw,
++            ProgramElementDoc member, Tag[] firstSentenceTags, Content tdSummary) {
++        addIndexComment(member, firstSentenceTags, tdSummary);
++    }
++
++    /**
++     * Add the inherited member summary.
++     *
++     * @param mw the writer for the member being documented
++     * @param cd the class being documented
++     * @param member the member being documented
++     * @param isFirst true if its the first link being documented
++     * @param linksTree the content tree to which the summary will be added
++     */
++    public void addInheritedMemberSummary(AbstractMemberWriter mw, ClassDoc cd,
++            ProgramElementDoc member, boolean isFirst, Content linksTree) {
+         if (! isFirst) {
+-            mw.print(", ");
++            linksTree.addContent(", ");
+         }
+-        mw.writeInheritedSummaryLink(cd, member);
++        mw.addInheritedSummaryLink(cd, member, linksTree);
+     }
+ 
+     public void printMemberHeader() {
+@@ -174,4 +266,67 @@
+     public void printMemberFooter() {
+     }
+ 
++    /**
++     * Get the document content header tree
++     *
++     * @return a content tree the document content header
++     */
++    public Content getContentHeader() {
++        HtmlTree div = new HtmlTree(HtmlTag.DIV);
++        div.addStyle(HtmlStyle.contentContainer);
++        return div;
++    }
++
++    /**
++     * Get the member header tree
++     *
++     * @return a content tree the member header
++     */
++    public Content getMemberTreeHeader() {
++        HtmlTree li = new HtmlTree(HtmlTag.LI);
++        li.addStyle(HtmlStyle.blockList);
++        return li;
++    }
++
++    /**
++     * Get the member tree
++     *
++     * @param contentTree the tree used to generate the complete member tree
++     * @return a content tree for the member
++     */
++    public Content getMemberTree(Content contentTree) {
++        Content ul = HtmlTree.UL(HtmlStyle.blockList, contentTree);
++        return ul;
++    }
++
++    /**
++     * Get the member summary tree
++     *
++     * @param contentTree the tree used to generate the member summary tree
++     * @return a content tree for the member summary
++     */
++    public Content getMemberSummaryTree(Content contentTree) {
++        return getMemberTree(HtmlStyle.summary, contentTree);
++    }
++
++    /**
++     * Get the member details tree
++     *
++     * @param contentTree the tree used to generate the member details tree
++     * @return a content tree for the member details
++     */
++    public Content getMemberDetailsTree(Content contentTree) {
++        return getMemberTree(HtmlStyle.details, contentTree);
++    }
++
++    /**
++     * Get the member tree
++     *
++     * @param style the style class to be added to the content tree
++     * @param contentTree the tree used to generate the complete member tree
++     */
++    public Content getMemberTree(HtmlStyle style, Content contentTree) {
++        Content div = HtmlTree.DIV(style, getMemberTree(contentTree));
++        return div;
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TagletWriterImpl.java
+@@ -70,9 +70,9 @@
+         Tag[] deprs = doc.tags("deprecated");
+         if (doc instanceof ClassDoc) {
+             if (Util.isDeprecated((ProgramElementDoc) doc)) {
+-                output.append("<STRONG>" +
++                output.append("<span class=\"strong\">" +
+                     ConfigurationImpl.getInstance().
+-                        getText("doclet.Deprecated") + "</STRONG>&nbsp;");
++                        getText("doclet.Deprecated") + "</span>&nbsp;");
+                 if (deprs.length > 0) {
+                     Tag[] commentTags = deprs[0].inlineTags();
+                     if (commentTags.length > 0) {
+@@ -82,30 +82,24 @@
+                         );
+                     }
+                 }
+-                output.append("<p>");
+             }
+         } else {
+             MemberDoc member = (MemberDoc) doc;
+             if (Util.isDeprecated((ProgramElementDoc) doc)) {
+-                output.append("<DD><STRONG>" +
++                output.append("<span class=\"strong\">" +
+                     ConfigurationImpl.getInstance().
+-                            getText("doclet.Deprecated") + "</STRONG>&nbsp;");
++                            getText("doclet.Deprecated") + "</span>&nbsp;");
+                 if (deprs.length > 0) {
+-                    output.append("<I>");
++                    output.append("<i>");
+                     output.append(commentTagsToOutput(null, doc,
+                         deprs[0].inlineTags(), false).toString());
+-                    output.append("</I>");
++                    output.append("</i>");
+                 }
+-                if (member instanceof ExecutableMemberDoc) {
+-                    output.append(DocletConstants.NL + "<P>" +
+-                        DocletConstants.NL);
+-                }
+-                output.append("</DD>");
+             } else {
+                 if (Util.isDeprecated(member.containingClass())) {
+-                    output.append("<DD><STRONG>" +
++                    output.append("<span class=\"strong\">" +
+                     ConfigurationImpl.getInstance().
+-                            getText("doclet.Deprecated") + "</STRONG>&nbsp;</DD>");
++                            getText("doclet.Deprecated") + "</span>&nbsp;");
+                 }
+             }
+         }
+@@ -124,8 +118,8 @@
+      */
+     public TagletOutput getParamHeader(String header) {
+         StringBuffer result = new StringBuffer();
+-        result.append("<DT>");
+-        result.append("<STRONG>" +  header + "</STRONG></DT>");
++        result.append("<dt>");
++        result.append("<span class=\"strong\">" +  header + "</span></dt>");
+         return new TagletOutputImpl(result.toString());
+     }
+ 
+@@ -133,8 +127,8 @@
+      * {@inheritDoc}
+      */
+     public TagletOutput paramTagOutput(ParamTag paramTag, String paramName) {
+-        TagletOutput result = new TagletOutputImpl("<DD><CODE>" + paramName + "</CODE>"
+-         + " - " + htmlWriter.commentTagsToString(paramTag, null, paramTag.inlineTags(), false) + "</DD>");
++        TagletOutput result = new TagletOutputImpl("<dd><code>" + paramName + "</code>"
++         + " - " + htmlWriter.commentTagsToString(paramTag, null, paramTag.inlineTags(), false) + "</dd>");
+         return result;
+     }
+ 
+@@ -142,11 +136,11 @@
+      * {@inheritDoc}
+      */
+     public TagletOutput returnTagOutput(Tag returnTag) {
+-        TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "<DT>" +
+-            "<STRONG>" + htmlWriter.configuration.getText("doclet.Returns") +
+-            "</STRONG>" + "</DT>" + "<DD>" +
++        TagletOutput result = new TagletOutputImpl(DocletConstants.NL + "<dt>" +
++            "<span class=\"strong\">" + htmlWriter.configuration.getText("doclet.Returns") +
++            "</span>" + "</dt>" + "<dd>" +
+             htmlWriter.commentTagsToString(returnTag, null, returnTag.inlineTags(),
+-            false) + "</DD>");
++            false) + "</dd>");
+         return result;
+     }
+ 
+@@ -168,7 +162,7 @@
+                 htmlWriter instanceof ClassWriterImpl) {
+             //Automatically add link to constant values page for constant fields.
+             result = addSeeHeader(result);
+-            result += htmlWriter.getHyperLink(htmlWriter.relativePath +
++            result += htmlWriter.getHyperLinkString(htmlWriter.relativePath +
+                 ConfigurationImpl.CONSTANTS_FILE_NAME
+                 + "#" + ((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName()
+                 + "." + ((FieldDoc) holder).name(),
+@@ -179,18 +173,19 @@
+             if ((SerializedFormBuilder.serialInclude(holder) &&
+                       SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) {
+                 result = addSeeHeader(result);
+-                result += htmlWriter.getHyperLink(htmlWriter.relativePath + "serialized-form.html",
++                result += htmlWriter.getHyperLinkString(htmlWriter.relativePath + "serialized-form.html",
+                         ((ClassDoc)holder).qualifiedName(), htmlWriter.configuration.getText("doclet.Serialized_Form"), false);
+             }
+         }
+-        return result.equals("") ? null : new TagletOutputImpl(result + "</DD>");
++        return result.equals("") ? null : new TagletOutputImpl(result + "</dd>");
+     }
+ 
+     private String addSeeHeader(String result) {
+         if (result != null && result.length() > 0) {
+             return result + ", " + DocletConstants.NL;
+         } else {
+-            return "<DT><STRONG>" + htmlWriter.configuration().getText("doclet.See_Also") + "</STRONG></DT><DD>";
++            return "<dt><span class=\"strong\">" +
++                    htmlWriter.configuration().getText("doclet.See_Also") + "</span></dt><dd>";
+         }
+      }
+ 
+@@ -198,15 +193,15 @@
+      * {@inheritDoc}
+      */
+     public TagletOutput simpleTagOutput(Tag[] simpleTags, String header) {
+-        String result = "<DT><STRONG>" + header + "</STRONG></DT>" + DocletConstants.NL +
+-            "  <DD>";
++        String result = "<dt><span class=\"strong\">" + header + "</span></dt>" + DocletConstants.NL +
++            "  <dd>";
+         for (int i = 0; i < simpleTags.length; i++) {
+             if (i > 0) {
+                 result += ", ";
+             }
+             result += htmlWriter.commentTagsToString(simpleTags[i], null, simpleTags[i].inlineTags(), false);
+         }
+-        result += "</DD>" + DocletConstants.NL;
++        result += "</dd>" + DocletConstants.NL;
+         return new TagletOutputImpl(result);
+     }
+ 
+@@ -214,24 +209,24 @@
+      * {@inheritDoc}
+      */
+     public TagletOutput simpleTagOutput(Tag simpleTag, String header) {
+-        return new TagletOutputImpl("<DT><STRONG>" + header + "</STRONG></DT>" + "  <DD>"
++        return new TagletOutputImpl("<dt><span class=\"strong\">" + header + "</span></dt>" + "  <dd>"
+             + htmlWriter.commentTagsToString(simpleTag, null, simpleTag.inlineTags(), false)
+-            + "</DD>" + DocletConstants.NL);
++            + "</dd>" + DocletConstants.NL);
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+     public TagletOutput getThrowsHeader() {
+-        return new TagletOutputImpl(DocletConstants.NL + "<DT>" + "<STRONG>" +
+-            htmlWriter.configuration().getText("doclet.Throws") + "</STRONG></DT>");
++        return new TagletOutputImpl(DocletConstants.NL + "<dt>" + "<span class=\"strong\">" +
++            htmlWriter.configuration().getText("doclet.Throws") + "</span></dt>");
+     }
+ 
+     /**
+      * {@inheritDoc}
+      */
+     public TagletOutput throwsTagOutput(ThrowsTag throwsTag) {
+-        String result = DocletConstants.NL + "<DD>";
++        String result = DocletConstants.NL + "<dd>";
+         result += throwsTag.exceptionType() == null ?
+             htmlWriter.codeText(throwsTag.exceptionName()) :
+             htmlWriter.codeText(
+@@ -243,7 +238,7 @@
+         if (text != null && text.toString().length() > 0) {
+             result += " - " + text;
+         }
+-        result += "</DD>";
++        result += "</dd>";
+         return new TagletOutputImpl(result);
+     }
+ 
+@@ -251,9 +246,9 @@
+      * {@inheritDoc}
+      */
+     public TagletOutput throwsTagOutput(Type throwsType) {
+-        return new TagletOutputImpl(DocletConstants.NL + "<DD>" +
++        return new TagletOutputImpl(DocletConstants.NL + "<dd>" +
+             htmlWriter.codeText(htmlWriter.getLink(
+-                new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "</DD>");
++                new LinkInfoImpl(LinkInfoImpl.CONTEXT_MEMBER, throwsType))) + "</dd>");
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/TreeWriter.java
+@@ -29,6 +29,8 @@
+ 
+ import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++import com.sun.tools.doclets.internal.toolkit.*;
+ 
+ /**
+  * Generate Class Hierarchy page for all the Classes in this run.  Use
+@@ -37,6 +39,7 @@
+  * current or the destination directory.
+  *
+  * @author Atul M Dambalkar
++ * @author Bhavesh Patel (Modified)
+  */
+ public class TreeWriter extends AbstractTreeWriter {
+ 
+@@ -90,86 +93,70 @@
+     }
+ 
+     /**
+-     * Print the interface hierarchy and class hierarchy in the file.
++     * Generate the interface hierarchy and class hierarchy.
+      */
+     public void generateTreeFile() throws IOException {
+-        printHtmlHeader(configuration.getText("doclet.Window_Class_Hierarchy"),
+-            null, true);
+-
+-        printTreeHeader();
+-
+-        printPageHeading();
+-
+-        printPackageTreeLinks();
+-
+-        generateTree(classtree.baseclasses(), "doclet.Class_Hierarchy");
+-        generateTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy");
+-        generateTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy");
+-        generateTree(classtree.baseEnums(), "doclet.Enum_Hierarchy");
+-
+-        printTreeFooter();
++        Content body = getTreeHeader();
++        Content headContent = getResource("doclet.Hierarchy_For_All_Packages");
++        Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false,
++                HtmlStyle.title, headContent);
++        Content div = HtmlTree.DIV(HtmlStyle.header, heading);
++        addPackageTreeLinks(div);
++        body.addContent(div);
++        HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
++        divTree.addStyle(HtmlStyle.contentContainer);
++        addTree(classtree.baseclasses(), "doclet.Class_Hierarchy", divTree);
++        addTree(classtree.baseinterfaces(), "doclet.Interface_Hierarchy", divTree);
++        addTree(classtree.baseAnnotationTypes(), "doclet.Annotation_Type_Hierarchy", divTree);
++        addTree(classtree.baseEnums(), "doclet.Enum_Hierarchy", divTree);
++        body.addContent(divTree);
++        addNavLinks(false, body);
++        addBottom(body);
++        printHtmlDocument(null, true, body);
+     }
+ 
+     /**
+-     * Generate the links to all the package tree files.
++     * Add the links to all the package tree files.
++     *
++     * @param contentTree the content tree to which the links will be added
+      */
+-    protected void printPackageTreeLinks() {
++    protected void addPackageTreeLinks(Content contentTree) {
+         //Do nothing if only unnamed package is used
+         if (packages.length == 1 && packages[0].name().length() == 0) {
+             return;
+         }
+         if (!classesonly) {
+-            dl();
+-            dt();
+-            strongText("doclet.Package_Hierarchies");
+-            dtEnd();
+-            dd();
++            Content span = HtmlTree.SPAN(HtmlStyle.strong,
++                    getResource("doclet.Package_Hierarchies"));
++            contentTree.addContent(span);
++            HtmlTree ul = new HtmlTree(HtmlTag.UL);
++            ul.addStyle(HtmlStyle.horizontal);
+             for (int i = 0; i < packages.length; i++) {
+                 if (packages[i].name().length() == 0) {
+                     continue;
+                 }
+-                String filename = pathString(packages[i], "package-tree.html");
+-                printHyperLink(filename, "", packages[i].name());
++                String link = pathString(packages[i], "package-tree.html");
++                Content li = HtmlTree.LI(getHyperLink(
++                        link, "", new StringContent(packages[i].name())));
+                 if (i < packages.length - 1) {
+-                    print(", ");
++                    li.addContent(", ");
+                 }
++                ul.addContent(li);
+             }
+-            ddEnd();
+-            dlEnd();
+-            hr();
++            contentTree.addContent(ul);
+         }
+     }
+ 
+     /**
+-     * Print the top text (from the -top option) and
+-     * navigation bar at the top of page.
++     * Get the tree header.
++     *
++     * @return a content tree for the tree header
+      */
+-    protected void printTreeHeader() {
+-        printTop();
+-        navLinks(true);
+-        hr();
+-    }
+-
+-    /**
+-     * Print the navigation bar and bottom text (from the -bottom option)
+-     * at the bottom of page.
+-     */
+-    protected void printTreeFooter() {
+-        hr();
+-        navLinks(false);
+-        printBottom();
+-        printBodyHtmlEnd();
+-    }
+-
+-    /**
+-     * Print the page title "Hierarchy For All Packages" at the top of the tree
+-     * page.
+-     */
+-    protected void printPageHeading() {
+-        center();
+-        h2();
+-        printText("doclet.Hierarchy_For_All_Packages");
+-        h2End();
+-        centerEnd();
++    protected Content getTreeHeader() {
++        String title = configuration.getText("doclet.Window_Class_Hierarchy");
++        Content bodyTree = getBody(true, getWindowTitle(title));
++        addTop(bodyTree);
++        addNavLinks(true, bodyTree);
++        return bodyTree;
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java
+@@ -0,0 +1,90 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.formats.html.markup;
++
++import com.sun.tools.doclets.internal.toolkit.Content;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++
++/**
++ * Class for generating a comment for HTML pages of javadoc output.
++ *
++ * @author Bhavesh Patel
++ */
++public class Comment extends Content{
++
++    private String commentText;
++
++    /**
++     * Constructor to construct a Comment object.
++     *
++     * @param comment comment text for the comment
++     */
++    public Comment(String comment) {
++        commentText = nullCheck(comment);
++    }
++
++    /**
++     * This method is not supported by the class.
++     *
++     * @param content content that needs to be added
++     * @throws DocletAbortException this method will always throw a
++     *                              DocletAbortException because it
++     *                              is not supported.
++     */
++    public void addContent(Content content) {
++        throw new DocletAbortException();
++    }
++
++    /**
++     * This method is not supported by the class.
++     *
++     * @param stringContent string content that needs to be added
++     * @throws DocletAbortException this method will always throw a
++     *                              DocletAbortException because it
++     *                              is not supported.
++     */
++    public void addContent(String stringContent) {
++        throw new DocletAbortException();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public boolean isEmpty() {
++        return commentText.isEmpty();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void write(StringBuilder contentBuilder) {
++        if (!endsWithNewLine(contentBuilder))
++            contentBuilder.append("\n");
++        contentBuilder.append("<!-- ");
++        contentBuilder.append(commentText);
++        contentBuilder.append(" -->\n");
++    }
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
+@@ -0,0 +1,113 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.formats.html.markup;
++
++import com.sun.tools.doclets.internal.toolkit.Content;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++
++/**
++ * Class for generating document type for HTML pages of javadoc output.
++ *
++ * @author Bhavesh Patel
++ */
++public class DocType extends Content{
++
++    private String docType;
++
++    private static DocType transitional;
++
++    private static DocType frameset;
++
++    /**
++     * Constructor to construct a DocType object.
++     *
++     * @param type the doctype to be added
++     */
++    private DocType(String type, String dtd) {
++        docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " + type +
++                "//EN\" \"" + dtd + "\">\n";
++    }
++
++     /**
++     * Construct and return a HTML 4.01 transitional DocType content
++     *
++     * @return a content tree for transitional DocType
++     */
++    public static DocType Transitional() {
++        if (transitional == null)
++            transitional = new DocType("Transitional", "http://www.w3.org/TR/html4/loose.dtd");
++        return transitional;
++    }
++
++    /**
++     * Construct and return a HTML 4.01 frameset DocType content
++     *
++     * @return a content tree for frameset DocType
++     */
++    public static DocType Frameset() {
++        if (frameset == null)
++            frameset = new DocType("Frameset", "http://www.w3.org/TR/html4/frameset.dtd");
++        return frameset;
++    }
++
++    /**
++     * This method is not supported by the class.
++     *
++     * @param content content that needs to be added
++     * @throws DocletAbortException this method will always throw a
++     *                              DocletAbortException because it
++     *                              is not supported.
++     */
++    public void addContent(Content content) {
++        throw new DocletAbortException();
++    }
++
++    /**
++     * This method is not supported by the class.
++     *
++     * @param stringContent string content that needs to be added
++     * @throws DocletAbortException this method will always throw a
++     *                              DocletAbortException because it
++     *                              is not supported.
++     */
++    public void addContent(String stringContent) {
++        throw new DocletAbortException();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public boolean isEmpty() {
++        return (docType.length() == 0);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void write(StringBuilder contentBuilder) {
++        contentBuilder.append(docType);
++    }
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlAttr.java
+@@ -0,0 +1,73 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.formats.html.markup;
++
++/**
++ * Enum representing HTML tag attributes.
++ *
++ * @author Bhavesh Patel
++ */
++public enum HtmlAttr {
++    ALT,
++    BORDER,
++    CELLPADDING,
++    CELLSPACING,
++    CHARSET,
++    CLASS,
++    CLEAR,
++    COLS,
++    CONTENT,
++    HREF,
++    HTTP_EQUIV("http-equiv"),
++    ID,
++    LANG,
++    NAME,
++    ONLOAD,
++    REL,
++    ROWS,
++    SCOPE,
++    SCROLLING,
++    SRC,
++    SUMMARY,
++    TARGET,
++    TITLE,
++    TYPE,
++    WIDTH;
++
++    private final String value;
++
++    HtmlAttr() {
++        this.value = name().toLowerCase();
++    }
++
++    HtmlAttr(String name) {
++        this.value = name;
++    }
++
++    public String toString() {
++        return value;
++    }
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlConstants.java
+@@ -0,0 +1,189 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.formats.html.markup;
++
++import com.sun.tools.doclets.internal.toolkit.Content;
++
++/**
++ * Stores constants for Html Doclet.
++ *
++ * @author Bhavesh Patel
++ */
++public class HtmlConstants {
++
++    /**
++     * Marker to identify start of top navigation bar.
++     */
++    public static final Content START_OF_TOP_NAVBAR =
++            new Comment("========= START OF TOP NAVBAR =======");
++
++    /**
++     * Marker to identify start of bottom navigation bar.
++     */
++    public static final Content START_OF_BOTTOM_NAVBAR =
++            new Comment("======= START OF BOTTOM NAVBAR ======");
++
++    /**
++     * Marker to identify end of top navigation bar.
++     */
++    public static final Content END_OF_TOP_NAVBAR =
++            new Comment("========= END OF TOP NAVBAR =========");
++
++    /**
++     * Marker to identify end of bottom navigation bar.
++     */
++    public static final Content END_OF_BOTTOM_NAVBAR =
++            new Comment("======== END OF BOTTOM NAVBAR =======");
++
++    /**
++     * Marker to identify start of class data.
++     */
++    public static final Content START_OF_CLASS_DATA =
++            new Comment("======== START OF CLASS DATA ========");
++
++    /**
++     * Marker to identify end of class data.
++     */
++    public static final Content END_OF_CLASS_DATA =
++            new Comment("========= END OF CLASS DATA =========");
++
++    /**
++     * Marker to identify start of nested class summary.
++     */
++    public static final Content START_OF_NESTED_CLASS_SUMMARY =
++            new Comment("======== NESTED CLASS SUMMARY ========");
++
++    /**
++     * Marker to identify start of annotation type optional member summary.
++     */
++    public static final Content START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY =
++            new Comment("=========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY ===========");
++
++    /**
++     * Marker to identify start of annotation type required member summary.
++     */
++    public static final Content START_OF_ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY =
++            new Comment("=========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY ===========");
++
++    /**
++     * Marker to identify start of constructor summary.
++     */
++    public static final Content START_OF_CONSTRUCTOR_SUMMARY =
++            new Comment("======== CONSTRUCTOR SUMMARY ========");
++
++    /**
++     * Marker to identify start of enum constants summary.
++     */
++    public static final Content START_OF_ENUM_CONSTANT_SUMMARY =
++            new Comment("=========== ENUM CONSTANT SUMMARY ===========");
++
++    /**
++     * Marker to identify start of field summary.
++     */
++    public static final Content START_OF_FIELD_SUMMARY =
++            new Comment("=========== FIELD SUMMARY ===========");
++
++    /**
++     * Marker to identify start of method summary.
++     */
++    public static final Content START_OF_METHOD_SUMMARY =
++            new Comment("========== METHOD SUMMARY ===========");
++
++    /**
++     * Marker to identify start of annotation type details.
++     */
++    public static final Content START_OF_ANNOTATION_TYPE_DETAILS =
++            new Comment("============ ANNOTATION TYPE MEMBER DETAIL ===========");
++
++    /**
++     * Marker to identify start of method details.
++     */
++    public static final Content START_OF_METHOD_DETAILS =
++            new Comment("============ METHOD DETAIL ==========");
++
++    /**
++     * Marker to identify start of field details.
++     */
++    public static final Content START_OF_FIELD_DETAILS =
++            new Comment("============ FIELD DETAIL ===========");
++
++    /**
++     * Marker to identify start of constructor details.
++     */
++    public static final Content START_OF_CONSTRUCTOR_DETAILS =
++            new Comment("========= CONSTRUCTOR DETAIL ========");
++
++    /**
++     * Marker to identify start of enum constants details.
++     */
++    public static final Content START_OF_ENUM_CONSTANT_DETAILS =
++            new Comment("============ ENUM CONSTANT DETAIL ===========");
++
++    /**
++     * Html tag for the page title heading.
++     */
++    public static final HtmlTag TITLE_HEADING = HtmlTag.H1;
++
++    /**
++     * Html tag for the class page title heading.
++     */
++    public static final HtmlTag CLASS_PAGE_HEADING = HtmlTag.H2;
++
++    /**
++     * Html tag for the content heading.
++     */
++    public static final HtmlTag CONTENT_HEADING = HtmlTag.H2;
++
++    /**
++     * Html tag for the package name heading.
++     */
++    public static final HtmlTag PACKAGE_HEADING = HtmlTag.H2;
++
++    /**
++     * Html tag for the member summary heading.
++     */
++    public static final HtmlTag SUMMARY_HEADING = HtmlTag.H3;
++
++    /**
++     * Html tag for the inherited member summary heading.
++     */
++    public static final HtmlTag INHERITED_SUMMARY_HEADING = HtmlTag.H3;
++
++    /**
++     * Html tag for the member details heading.
++     */
++    public static final HtmlTag DETAILS_HEADING = HtmlTag.H3;
++
++    /**
++     * Html tag for the serialized member heading.
++     */
++    public static final HtmlTag SERIALIZED_MEMBER_HEADING = HtmlTag.H3;
++
++    /**
++     * Html tag for the member heading.
++     */
++    public static final HtmlTag MEMBER_HEADING = HtmlTag.H4;
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocWriter.java
+@@ -87,7 +87,7 @@
+      */
+     public void printHyperLink(String link, String where,
+                                String label, boolean strong) {
+-        print(getHyperLink(link, where, label, strong, "", "", ""));
++        print(getHyperLinkString(link, where, label, strong, "", "", ""));
+     }
+ 
+     /**
+@@ -115,7 +115,7 @@
+     public void printHyperLink(String link, String where,
+                                String label, boolean strong,
+                                String stylename) {
+-        print(getHyperLink(link, where, label, strong, stylename, "", ""));
++        print(getHyperLinkString(link, where, label, strong, stylename, "", ""));
+     }
+ 
+     /**
+@@ -128,9 +128,9 @@
+      * @param strong       Boolean that sets label to strong.
+      * @return String    Hyper Link.
+      */
+-    public String getHyperLink(String link, String where,
++    public String getHyperLinkString(String link, String where,
+                                String label, boolean strong) {
+-        return getHyperLink(link, where, label, strong, "", "", "");
++        return getHyperLinkString(link, where, label, strong, "", "", "");
+     }
+ 
+     /**
+@@ -144,10 +144,24 @@
+      * @param stylename  String style of text defined in style sheet.
+      * @return String    Hyper Link.
+      */
+-    public String getHyperLink(String link, String where,
++    public String getHyperLinkString(String link, String where,
+                                String label, boolean strong,
+                                String stylename) {
+-        return getHyperLink(link, where, label, strong, stylename, "", "");
++        return getHyperLinkString(link, where, label, strong, stylename, "", "");
++    }
++
++    /**
++     * Get Html Hyper Link string.
++     *
++     * @param link       String name of the file.
++     * @param where      Position of the link in the file. Character '#' is not
++     *                   needed.
++     * @param label      Tag for the link.
++     * @return a content tree for the hyper link
++     */
++    public Content getHyperLink(String link, String where,
++                               Content label) {
++        return getHyperLink(link, where, label, "", "");
+     }
+ 
+     /**
+@@ -163,11 +177,11 @@
+      * @param target     Target frame.
+      * @return String    Hyper Link.
+      */
+-    public String getHyperLink(String link, String where,
++    public String getHyperLinkString(String link, String where,
+                                String label, boolean strong,
+                                String stylename, String title, String target) {
+         StringBuffer retlink = new StringBuffer();
+-        retlink.append("<A HREF=\"");
++        retlink.append("<a href=\"");
+         retlink.append(link);
+         if (where != null && where.length() != 0) {
+             retlink.append("#");
+@@ -187,27 +201,54 @@
+             retlink.append("\">");
+         }
+         if (strong) {
+-            retlink.append("<STRONG>");
++            retlink.append("<span class=\"strong\">");
+         }
+         retlink.append(label);
+         if (strong) {
+-            retlink.append("</STRONG>");
++            retlink.append("</span>");
+         }
+         if (stylename != null && stylename.length() != 0) {
+             retlink.append("</FONT>");
+         }
+-        retlink.append("</A>");
++        retlink.append("</a>");
+         return retlink.toString();
+     }
+ 
+     /**
+-     * Print link without positioning in the file.
++     * Get Html Hyper Link.
+      *
+      * @param link       String name of the file.
++     * @param where      Position of the link in the file. Character '#' is not
++     *                   needed.
+      * @param label      Tag for the link.
++     * @param title      String that describes the link's content for accessibility.
++     * @param target     Target frame.
++     * @return a content tree for the hyper link.
+      */
+-    public void printHyperLink(String link, String label) {
+-        print(getHyperLink(link, "", label, false));
++    public Content getHyperLink(String link, String where,
++            Content label, String title, String target) {
++        if (where != null && where.length() != 0) {
++            link += "#" + where;
++        }
++        HtmlTree anchor = HtmlTree.A(link, label);
++        if (title != null && title.length() != 0) {
++            anchor.addAttr(HtmlAttr.TITLE, title);
++        }
++        if (target != null && target.length() != 0) {
++            anchor.addAttr(HtmlAttr.TARGET, target);
++        }
++        return anchor;
++    }
++
++    /**
++     * Get a hyperlink to a file.
++     *
++     * @param link String name of the file
++     * @param label Label for the link
++     * @return a content for the hyperlink to the file
++     */
++    public Content getHyperLink(String link, Content label) {
++        return getHyperLink(link, "", label);
+     }
+ 
+     /**
+@@ -217,8 +258,8 @@
+      * @param label      Tag for the link.
+      * @return Strign    Hyper link.
+      */
+-    public String getHyperLink(String link, String label) {
+-        return getHyperLink(link, "", label, false);
++    public String getHyperLinkString(String link, String label) {
++        return getHyperLinkString(link, "", label, false);
+     }
+ 
+     /**
+@@ -273,54 +314,32 @@
+      * Print the frameset version of the Html file header.
+      * Called only when generating an HTML frameset file.
+      *
+-     * @param title    Title of this HTML document.
++     * @param title Title of this HTML document
++     * @param noTimeStamp If true, don't print time stamp in header
++     * @param frameset the frameset to be added to the HTML document
+      */
+-    public void printFramesetHeader(String title) {
+-        printFramesetHeader(title, false);
+-    }
+-
+-    /**
+-     * Print the frameset version of the Html file header.
+-     * Called only when generating an HTML frameset file.
+-     *
+-     * @param title        Title of this HTML document.
+-     * @param noTimeStamp  If true, don't print time stamp in header.
+-     */
+-    public void printFramesetHeader(String title, boolean noTimeStamp) {
+-        println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " +
+-                    "Frameset//EN\" " +
+-                    "\"http://www.w3.org/TR/html4/frameset.dtd\">");
+-        println("<!--NewPage-->");
+-        html();
+-        head();
++    public void printFramesetDocument(String title, boolean noTimeStamp,
++            Content frameset) {
++        Content htmlDocType = DocType.Frameset();
++        Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
++        Content head = new HtmlTree(HtmlTag.HEAD);
+         if (! noTimeStamp) {
+-            print("<!-- Generated by javadoc on ");
+-            print(today());
+-            println("-->");
++            Content headComment = new Comment("Generated by javadoc on " + today());
++            head.addContent(headComment);
+         }
+         if (configuration.charset.length() > 0) {
+-            println("<META http-equiv=\"Content-Type\" content=\"text/html; "
+-                        + "charset=" + configuration.charset + "\">");
++            Content meta = HtmlTree.META("Content-Type", "text/html",
++                    configuration.charset);
++            head.addContent(meta);
+         }
+-        title();
+-        println(title);
+-        titleEnd();
+-        //Script to set the classFrame if necessary.
+-        script();
+-        println("    targetPage = \"\" + window.location.search;");
+-        println("    if (targetPage != \"\" && targetPage != \"undefined\")");
+-        println("        targetPage = targetPage.substring(1);");
+-        println("    if (targetPage.indexOf(\":\") != -1)");
+-        println("        targetPage = \"undefined\";");
+-
+-        println("    function loadFrames() {");
+-        println("        if (targetPage != \"\" && targetPage != \"undefined\")");
+-        println("             top.classFrame.location = top.targetPage;");
+-        println("    }");
+-        scriptEnd();
+-        noScript();
+-        noScriptEnd();
+-        headEnd();
++        Content windowTitle = HtmlTree.TITLE(new StringContent(title));
++        head.addContent(windowTitle);
++        head.addContent(getFramesetJavaScript());
++        Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
++                head, frameset);
++        Content htmlDocument = new HtmlDocument(htmlDocType,
++                htmlComment, htmlTree);
++        print(htmlDocument.toString());
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocument.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocument.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlDocument.java
+@@ -0,0 +1,103 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.formats.html.markup;
++
++import java.util.*;
++import com.sun.tools.doclets.internal.toolkit.Content;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++
++/**
++ * Class for generating an HTML document for javadoc output.
++ *
++ * @author Bhavesh Patel
++ */
++public class HtmlDocument extends Content {
++
++    private List<Content> docContent = Collections.<Content>emptyList();
++
++    /**
++     * Constructor to construct an HTML document.
++     *
++     * @param docType document type for the HTML document
++     * @param docComment comment for the document
++     * @param htmlTree HTML tree of the document
++     */
++    public HtmlDocument(Content docType, Content docComment, Content htmlTree) {
++        docContent = new ArrayList<Content>();
++        addContent(nullCheck(docType));
++        addContent(nullCheck(docComment));
++        addContent(nullCheck(htmlTree));
++    }
++
++    /**
++     * Constructor to construct an HTML document.
++     *
++     * @param docType document type for the HTML document
++     * @param htmlTree HTML tree of the document
++     */
++    public HtmlDocument(Content docType, Content htmlTree) {
++        docContent = new ArrayList<Content>();
++        addContent(nullCheck(docType));
++        addContent(nullCheck(htmlTree));
++    }
++
++    /**
++     * Adds content for the HTML document.
++     *
++     * @param htmlContent html content to be added
++     */
++    public void addContent(Content htmlContent) {
++        if (htmlContent.isValid())
++            docContent.add(htmlContent);
++    }
++
++    /**
++     * This method is not supported by the class.
++     *
++     * @param stringContent string content that needs to be added
++     * @throws DocletAbortException this method will always throw a
++     *                              DocletAbortException because it
++     *                              is not supported.
++     */
++    public void addContent(String stringContent) {
++        throw new DocletAbortException();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public boolean isEmpty() {
++        return (docContent.isEmpty());
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void write(StringBuilder contentBuilder) {
++        for (Content c : docContent)
++            c.write(contentBuilder);
++    }
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlStyle.java
+@@ -0,0 +1,73 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.formats.html.markup;
++
++/**
++ * Enum representing HTML styles. The name map to values in the CSS file.
++ *
++ * @author Bhavesh Patel
++ */
++public enum HtmlStyle {
++    aboutLanguage,
++    altColor,
++    bar,
++    block,
++    blockList,
++    blockListLast,
++    bottomNav,
++    classUseContainer,
++    colFirst,
++    colLast,
++    colOne,
++    constantValuesContainer,
++    contentContainer,
++    description,
++    details,
++    header,
++    horizontal,
++    footer,
++    indexContainer,
++    indexHeader,
++    inheritance,
++    legalCopy,
++    nameValue,
++    navBarCell1Rev,
++    navList,
++    overviewSummary,
++    packageSummary,
++    rowColor,
++    serializedFormContainer,
++    sourceContainer,
++    sourceLineNo,
++    strong,
++    subNav,
++    subNavList,
++    subTitle,
++    summary,
++    tabEnd,
++    title,
++    topNav;
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTag.java
+@@ -0,0 +1,126 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.formats.html.markup;
++
++/**
++ * Enum representing HTML tags.
++ *
++ * @author Bhavesh Patel
++ */
++public enum HtmlTag {
++    A(BlockType.INLINE, EndTag.END),
++    BLOCKQUOTE,
++    BODY(BlockType.OTHER, EndTag.END),
++    BR(BlockType.INLINE, EndTag.NOEND),
++    CAPTION,
++    CENTER,
++    CODE(BlockType.INLINE, EndTag.END),
++    DD,
++    DIV,
++    DL,
++    DT,
++    EM(BlockType.INLINE, EndTag.END),
++    FONT(BlockType.INLINE, EndTag.END),
++    FRAME(BlockType.OTHER, EndTag.NOEND),
++    FRAMESET(BlockType.OTHER, EndTag.END),
++    H1,
++    H2,
++    H3,
++    H4,
++    H5,
++    H6,
++    HEAD(BlockType.OTHER, EndTag.END),
++    HR(BlockType.BLOCK, EndTag.NOEND),
++    HTML(BlockType.OTHER, EndTag.END),
++    I(BlockType.INLINE, EndTag.END),
++    IMG(BlockType.INLINE, EndTag.NOEND),
++    LI,
++    LINK(BlockType.OTHER, EndTag.NOEND),
++    MENU,
++    META(BlockType.OTHER, EndTag.NOEND),
++    NOFRAMES(BlockType.OTHER, EndTag.END),
++    NOSCRIPT(BlockType.OTHER, EndTag.END),
++    OL,
++    P,
++    PRE,
++    SCRIPT(BlockType.OTHER, EndTag.END),
++    SMALL(BlockType.INLINE, EndTag.END),
++    SPAN(BlockType.INLINE, EndTag.END),
++    STRONG(BlockType.INLINE, EndTag.END),
++    TABLE,
++    TBODY,
++    TD,
++    TH,
++    TITLE(BlockType.OTHER, EndTag.END),
++    TR,
++    TT(BlockType.INLINE, EndTag.END),
++    UL;
++
++    protected final BlockType blockType;
++    protected final EndTag endTag;
++    private final String value;
++
++    /**
++     * Enum representing the type of HTML element.
++     */
++    protected static enum BlockType {
++        BLOCK,
++        INLINE,
++        OTHER;
++    }
++
++    /**
++     * Enum representing HTML end tag requirement.
++     */
++    protected static enum EndTag {
++        END,
++        NOEND;
++    }
++
++    HtmlTag() {
++        this(BlockType.BLOCK, EndTag.END);
++    }
++
++    HtmlTag(BlockType blockType, EndTag endTag ) {
++        this.blockType = blockType;
++        this.endTag = endTag;
++        this.value = name().toLowerCase();
++    }
++
++    /**
++     * Returns true if the end tag is required. This is specific to the standard
++     * doclet and does not exactly resemble the W3C specifications.
++     *
++     * @return true if end tag needs to be displayed else return false
++     */
++    public boolean endTagRequired() {
++        return (endTag == EndTag.END);
++    }
++
++    public String toString() {
++        return value;
++    }
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
+@@ -0,0 +1,777 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.formats.html.markup;
++
++import java.util.*;
++import com.sun.tools.doclets.internal.toolkit.Content;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++
++/**
++ * Class for generating HTML tree for javadoc output.
++ *
++ * @author Bhavesh Patel
++ */
++public class HtmlTree extends Content {
++
++    private HtmlTag htmlTag;
++    private Map<HtmlAttr,String> attrs = Collections.<HtmlAttr,String>emptyMap();
++    private List<Content> content = Collections.<Content>emptyList();
++    public static final Content EMPTY = new StringContent("");
++
++    /**
++     * Constructor to construct HtmlTree object.
++     *
++     * @param tag HTML tag for the HtmlTree object
++     */
++    public HtmlTree(HtmlTag tag) {
++        htmlTag = nullCheck(tag);
++    }
++
++    /**
++     * Constructor to construct HtmlTree object.
++     *
++     * @param tag HTML tag for the HtmlTree object
++     * @param contents contents to be added to the tree
++     */
++    public HtmlTree(HtmlTag tag, Content... contents) {
++        this(tag);
++        for (Content content: contents)
++            addContent(content);
++    }
++
++    /**
++     * Adds an attribute for the HTML tag.
++     *
++     * @param attrName name of the attribute
++     * @param attrValue value of the attribute
++     */
++    public void addAttr(HtmlAttr attrName, String attrValue) {
++        if (attrs.isEmpty())
++            attrs = new LinkedHashMap<HtmlAttr,String>();
++        attrs.put(nullCheck(attrName), nullCheck(attrValue));
++    }
++
++    /**
++     * Adds a style for the HTML tag.
++     *
++     * @param style style to be added
++     */
++    public void addStyle(HtmlStyle style) {
++        addAttr(HtmlAttr.CLASS, style.toString());
++    }
++
++    /**
++     * Adds content for the HTML tag.
++     *
++     * @param tagContent tag content to be added
++     */
++    public void addContent(Content tagContent) {
++        if (tagContent == HtmlTree.EMPTY || tagContent.isValid()) {
++            if (content.isEmpty())
++                content = new ArrayList<Content>();
++            content.add(tagContent);
++        }
++    }
++
++    /**
++     * This method adds a string content to the htmltree. If the last content member
++     * added is a StringContent, append the string to that StringContent or else
++     * create a new StringContent and add it to the html tree.
++     *
++     * @param stringContent string content that needs to be added
++     */
++    public void addContent(String stringContent) {
++        if (!content.isEmpty()) {
++            Content lastContent = content.get(content.size() - 1);
++            if (lastContent instanceof StringContent)
++                lastContent.addContent(stringContent);
++            else
++                addContent(new StringContent(stringContent));
++        }
++        else
++            addContent(new StringContent(stringContent));
++    }
++
++    /**
++     * Generates an HTML anchor tag.
++     *
++     * @param ref reference url for the anchor tag
++     * @param body content for the anchor tag
++     * @return an HtmlTree object
++     */
++    public static HtmlTree A(String ref, Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.A, nullCheck(body));
++        htmltree.addAttr(HtmlAttr.HREF, nullCheck(ref));
++        return htmltree;
++    }
++
++    /**
++     * Generates an HTML anchor tag with name attribute and content.
++     *
++     * @param name name for the anchor tag
++     * @param body content for the anchor tag
++     * @return an HtmlTree object
++     */
++    public static HtmlTree A_NAME(String name, Content body) {
++        HtmlTree htmltree = HtmlTree.A_NAME(name);
++        htmltree.addContent(nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates an HTML anchor tag with name attribute.
++     *
++     * @param name name for the anchor tag
++     * @return an HtmlTree object
++     */
++    public static HtmlTree A_NAME(String name) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.A);
++        htmltree.addAttr(HtmlAttr.NAME, nullCheck(name));
++        return htmltree;
++    }
++
++    /**
++     * Generates a CAPTION tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the CAPTION tag
++     */
++    public static HtmlTree CAPTION(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.CAPTION, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a CODE tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the CODE tag
++     */
++    public static HtmlTree CODE(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.CODE, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a DD tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the DD tag
++     */
++    public static HtmlTree DD(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.DD, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a DL tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the DL tag
++     */
++    public static HtmlTree DL(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.DL, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a DIV tag with the style class attributes. It also encloses
++     * a content.
++     *
++     * @param styleClass stylesheet class for the tag
++     * @param body content for the tag
++     * @return an HtmlTree object for the DIV tag
++     */
++    public static HtmlTree DIV(HtmlStyle styleClass, Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.DIV, nullCheck(body));
++        if (styleClass != null)
++            htmltree.addStyle(styleClass);
++        return htmltree;
++    }
++
++    /**
++     * Generates a DIV tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the DIV tag
++     */
++    public static HtmlTree DIV(Content body) {
++        return DIV(null, body);
++    }
++
++    /**
++     * Generates a DT tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the DT tag
++     */
++    public static HtmlTree DT(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.DT, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a EM tag with some content.
++     *
++     * @param body content to be added to the tag
++     * @return an HtmlTree object for the EM tag
++     */
++    public static HtmlTree EM(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.EM, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a FRAME tag.
++     *
++     * @param src the url of the document to be shown in the frame
++     * @param name specifies the name of the frame
++     * @param title the title for the frame
++     * @param scrolling specifies whether to display scrollbars in the frame
++     * @return an HtmlTree object for the FRAME tag
++     */
++    public static HtmlTree FRAME(String src, String name, String title, String scrolling) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.FRAME);
++        htmltree.addAttr(HtmlAttr.SRC, nullCheck(src));
++        htmltree.addAttr(HtmlAttr.NAME, nullCheck(name));
++        htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
++        if (scrolling != null)
++            htmltree.addAttr(HtmlAttr.SCROLLING, scrolling);
++        return htmltree;
++    }
++
++    /**
++     * Generates a Frame tag.
++     *
++     * @param src the url of the document to be shown in the frame
++     * @param name specifies the name of the frame
++     * @param title the title for the frame
++     * @return an HtmlTree object for the SPAN tag
++     */
++    public static HtmlTree FRAME(String src, String name, String title) {
++        return FRAME(src, name, title, null);
++    }
++
++    /**
++     * Generates a FRAMESET tag.
++     *
++     * @param cols the size of columns in the frameset
++     * @param rows the size of rows in the frameset
++     * @param title the title for the frameset
++     * @param onload the script to run when the document loads
++     * @return an HtmlTree object for the FRAMESET tag
++     */
++    public static HtmlTree FRAMESET(String cols, String rows, String title, String onload) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.FRAMESET);
++        if (cols != null)
++            htmltree.addAttr(HtmlAttr.COLS, cols);
++        if (rows != null)
++            htmltree.addAttr(HtmlAttr.ROWS, rows);
++        htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
++        htmltree.addAttr(HtmlAttr.ONLOAD, nullCheck(onload));
++        return htmltree;
++    }
++
++    /**
++     * Generates a heading tag (h1 to h6) with the title and style class attributes. It also encloses
++     * a content.
++     *
++     * @param headingTag the heading tag to be generated
++     * @param printTitle true if title for the tag needs to be printed else false
++     * @param styleClass stylesheet class for the tag
++     * @param body content for the tag
++     * @return an HtmlTree object for the tag
++     */
++    public static HtmlTree HEADING(HtmlTag headingTag, boolean printTitle,
++            HtmlStyle styleClass, Content body) {
++        HtmlTree htmltree = new HtmlTree(headingTag, nullCheck(body));
++        if (printTitle)
++            htmltree.addAttr(HtmlAttr.TITLE, Util.stripHtml(body.toString()));
++        if (styleClass != null)
++            htmltree.addStyle(styleClass);
++        return htmltree;
++    }
++
++    /**
++     * Generates a heading tag (h1 to h6) with style class attribute. It also encloses
++     * a content.
++     *
++     * @param headingTag the heading tag to be generated
++     * @param styleClass stylesheet class for the tag
++     * @param body content for the tag
++     * @return an HtmlTree object for the tag
++     */
++    public static HtmlTree HEADING(HtmlTag headingTag, HtmlStyle styleClass, Content body) {
++        return HEADING(headingTag, false, styleClass, body);
++    }
++
++    /**
++     * Generates a heading tag (h1 to h6) with the title attribute. It also encloses
++     * a content.
++     *
++     * @param headingTag the heading tag to be generated
++     * @param printTitle true if the title for the tag needs to be printed else false
++     * @param body content for the tag
++     * @return an HtmlTree object for the tag
++     */
++    public static HtmlTree HEADING(HtmlTag headingTag, boolean printTitle, Content body) {
++        return HEADING(headingTag, printTitle, null, body);
++    }
++
++    /**
++     * Generates a heading tag (h1 to h6)  with some content.
++     *
++     * @param headingTag the heading tag to be generated
++     * @param body content for the tag
++     * @return an HtmlTree object for the tag
++     */
++    public static HtmlTree HEADING(HtmlTag headingTag, Content body) {
++        return HEADING(headingTag, false, null, body);
++    }
++
++    /**
++     * Generates an HTML tag with lang attribute. It also adds head and body
++     * content to the HTML tree.
++     *
++     * @param lang language for the HTML document
++     * @param head head for the HTML tag
++     * @param body body for the HTML tag
++     * @return an HtmlTree object for the HTML tag
++     */
++    public static HtmlTree HTML(String lang, Content head, Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.HTML, nullCheck(head), nullCheck(body));
++        htmltree.addAttr(HtmlAttr.LANG, nullCheck(lang));
++        return htmltree;
++    }
++
++    /**
++     * Generates a I tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the I tag
++     */
++    public static HtmlTree I(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.I, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a LI tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the LI tag
++     */
++    public static HtmlTree LI(Content body) {
++        return LI(null, body);
++    }
++
++    /**
++     * Generates a LI tag with some content.
++     *
++     * @param styleClass style for the tag
++     * @param body content for the tag
++     * @return an HtmlTree object for the LI tag
++     */
++    public static HtmlTree LI(HtmlStyle styleClass, Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.LI, nullCheck(body));
++        if (styleClass != null)
++            htmltree.addStyle(styleClass);
++        return htmltree;
++    }
++
++    /**
++     * Generates a LINK tag with the rel, type, href and title attributes.
++     *
++     * @param rel relevance of the link
++     * @param type type of link
++     * @param href the path for the link
++     * @param title title for the link
++     * @return an HtmlTree object for the LINK tag
++     */
++    public static HtmlTree LINK(String rel, String type, String href, String title) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.LINK);
++        htmltree.addAttr(HtmlAttr.REL, nullCheck(rel));
++        htmltree.addAttr(HtmlAttr.TYPE, nullCheck(type));
++        htmltree.addAttr(HtmlAttr.HREF, nullCheck(href));
++        htmltree.addAttr(HtmlAttr.TITLE, nullCheck(title));
++        return htmltree;
++    }
++
++    /**
++     * Generates a META tag with the http-equiv, content and charset attributes.
++     *
++     * @param http-equiv http equiv attribute for the META tag
++     * @param content type of content
++     * @param charset character set used
++     * @return an HtmlTree object for the META tag
++     */
++    public static HtmlTree META(String httpEquiv, String content, String charSet) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.META);
++        htmltree.addAttr(HtmlAttr.HTTP_EQUIV, nullCheck(httpEquiv));
++        htmltree.addAttr(HtmlAttr.CONTENT, nullCheck(content));
++        htmltree.addAttr(HtmlAttr.CHARSET, nullCheck(charSet));
++        return htmltree;
++    }
++
++    /**
++     * Generates a META tag with the name and content attributes.
++     *
++     * @param name name attribute
++     * @param content type of content
++     * @return an HtmlTree object for the META tag
++     */
++    public static HtmlTree META(String name, String content) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.META);
++        htmltree.addAttr(HtmlAttr.NAME, nullCheck(name));
++        htmltree.addAttr(HtmlAttr.CONTENT, nullCheck(content));
++        return htmltree;
++    }
++
++    /**
++     * Generates a NOSCRIPT tag with some content.
++     *
++     * @param body content of the noscript tag
++     * @return an HtmlTree object for the NOSCRIPT tag
++     */
++    public static HtmlTree NOSCRIPT(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.NOSCRIPT, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a P tag with some content.
++     *
++     * @param body content of the Paragraph tag
++     * @return an HtmlTree object for the P tag
++     */
++    public static HtmlTree P(Content body) {
++        return P(null, body);
++    }
++
++    /**
++     * Generates a P tag with some content.
++     *
++     * @param styleClass style of the Paragraph tag
++     * @param body content of the Paragraph tag
++     * @return an HtmlTree object for the P tag
++     */
++    public static HtmlTree P(HtmlStyle styleClass, Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.P, nullCheck(body));
++        if (styleClass != null)
++            htmltree.addStyle(styleClass);
++        return htmltree;
++    }
++
++    /**
++     * Generates a SMALL tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the SMALL tag
++     */
++    public static HtmlTree SMALL(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.SMALL, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a STRONG tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the STRONG tag
++     */
++    public static HtmlTree STRONG(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.STRONG, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a SPAN tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the SPAN tag
++     */
++    public static HtmlTree SPAN(Content body) {
++        return SPAN(null, body);
++    }
++
++    /**
++     * Generates a SPAN tag with style class attribute and some content.
++     *
++     * @param styleClass style class for the tag
++     * @param body content for the tag
++     * @return an HtmlTree object for the SPAN tag
++     */
++    public static HtmlTree SPAN(HtmlStyle styleClass, Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.SPAN, nullCheck(body));
++        if (styleClass != null)
++            htmltree.addStyle(styleClass);
++        return htmltree;
++    }
++
++    /**
++     * Generates a Table tag with border, width and summary attributes and
++     * some content.
++     *
++     * @param border border for the table
++     * @param width width of the table
++     * @param summary summary for the table
++     * @param body content for the table
++     * @return an HtmlTree object for the TABLE tag
++     */
++    public static HtmlTree TABLE(int border, int width, String summary,
++            Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.TABLE, nullCheck(body));
++        htmltree.addAttr(HtmlAttr.BORDER, Integer.toString(border));
++        htmltree.addAttr(HtmlAttr.WIDTH, Integer.toString(width));
++        htmltree.addAttr(HtmlAttr.SUMMARY, nullCheck(summary));
++        return htmltree;
++    }
++
++    /**
++     * Generates a Table tag with style class, border, cell padding,
++     * cellspacing and summary attributes and some content.
++     *
++     * @param styleClass style of the table
++     * @param border border for the table
++     * @param cellPadding cell padding for the table
++     * @param cellSpacing cell spacing for the table
++     * @param summary summary for the table
++     * @param body content for the table
++     * @return an HtmlTree object for the TABLE tag
++     */
++    public static HtmlTree TABLE(HtmlStyle styleClass, int border, int cellPadding,
++            int cellSpacing, String summary, Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.TABLE, nullCheck(body));
++        if (styleClass != null)
++            htmltree.addStyle(styleClass);
++        htmltree.addAttr(HtmlAttr.BORDER, Integer.toString(border));
++        htmltree.addAttr(HtmlAttr.CELLPADDING, Integer.toString(cellPadding));
++        htmltree.addAttr(HtmlAttr.CELLSPACING, Integer.toString(cellSpacing));
++        htmltree.addAttr(HtmlAttr.SUMMARY, nullCheck(summary));
++        return htmltree;
++    }
++
++    /**
++     * Generates a Table tag with border, cell padding,
++     * cellspacing and summary attributes and some content.
++     *
++     * @param border border for the table
++     * @param cellPadding cell padding for the table
++     * @param cellSpacing cell spacing for the table
++     * @param summary summary for the table
++     * @param body content for the table
++     * @return an HtmlTree object for the TABLE tag
++     */
++    public static HtmlTree TABLE(int border, int cellPadding,
++            int cellSpacing, String summary, Content body) {
++        return TABLE(null, border, cellPadding, cellSpacing, summary, body);
++    }
++
++    /**
++     * Generates a TD tag with style class attribute and some content.
++     *
++     * @param styleClass style for the tag
++     * @param body content for the tag
++     * @return an HtmlTree object for the TD tag
++     */
++    public static HtmlTree TD(HtmlStyle styleClass, Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.TD, nullCheck(body));
++        if (styleClass != null)
++            htmltree.addStyle(styleClass);
++        return htmltree;
++    }
++
++    /**
++     * Generates a TD tag for an HTML table with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the TD tag
++     */
++    public static HtmlTree TD(Content body) {
++        return TD(null, body);
++    }
++
++    /**
++     * Generates a TH tag with style class and scope attributes and some content.
++     *
++     * @param styleClass style for the tag
++     * @param scope scope of the tag
++     * @param body content for the tag
++     * @return an HtmlTree object for the TH tag
++     */
++    public static HtmlTree TH(HtmlStyle styleClass, String scope, Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.TH, nullCheck(body));
++        if (styleClass != null)
++            htmltree.addStyle(styleClass);
++        htmltree.addAttr(HtmlAttr.SCOPE, nullCheck(scope));
++        return htmltree;
++    }
++
++    /**
++     * Generates a TH tag with scope attribute and some content.
++     *
++     * @param scope scope of the tag
++     * @param body content for the tag
++     * @return an HtmlTree object for the TH tag
++     */
++    public static HtmlTree TH(String scope, Content body) {
++        return TH(null, scope, body);
++    }
++
++    /**
++     * Generates a TITLE tag with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the TITLE tag
++     */
++    public static HtmlTree TITLE(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.TITLE, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a TR tag for an HTML table with some content.
++     *
++     * @param body content for the tag
++     * @return an HtmlTree object for the TR tag
++     */
++    public static HtmlTree TR(Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.TR, nullCheck(body));
++        return htmltree;
++    }
++
++    /**
++     * Generates a UL tag with the style class attribute and some content.
++     *
++     * @param styleClass style for the tag
++     * @param body content for the tag
++     * @return an HtmlTree object for the UL tag
++     */
++    public static HtmlTree UL(HtmlStyle styleClass, Content body) {
++        HtmlTree htmltree = new HtmlTree(HtmlTag.UL, nullCheck(body));
++        htmltree.addStyle(nullCheck(styleClass));
++        return htmltree;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public boolean isEmpty() {
++        return (!hasContent() && !hasAttrs());
++    }
++
++    /**
++     * Returns true if the HTML tree has content.
++     *
++     * @return true if the HTML tree has content else return false
++     */
++    public boolean hasContent() {
++        return (!content.isEmpty());
++    }
++
++    /**
++     * Returns true if the HTML tree has attributes.
++     *
++     * @return true if the HTML tree has attributes else return false
++     */
++    public boolean hasAttrs() {
++        return (!attrs.isEmpty());
++    }
++
++    /**
++     * Returns true if the HTML tree has a specific attribute.
++     *
++     * @param attrName name of the attribute to check within the HTML tree
++     * @return true if the HTML tree has the specified attribute else return false
++     */
++    public boolean hasAttr(HtmlAttr attrName) {
++        return (attrs.containsKey(attrName));
++    }
++
++    /**
++     * Returns true if the HTML tree is valid. This check is more specific to
++     * standard doclet and not exactly similar to W3C specifications. But it
++     * ensures HTML validation.
++     *
++     * @return true if the HTML tree is valid
++     */
++    public boolean isValid() {
++        switch (htmlTag) {
++            case A :
++                return (hasAttr(HtmlAttr.NAME) || (hasAttr(HtmlAttr.HREF) && hasContent()));
++            case BR :
++                return (!hasContent() && (!hasAttrs() || hasAttr(HtmlAttr.CLEAR)));
++            case FRAME :
++                return (hasAttr(HtmlAttr.SRC) && !hasContent());
++            case HR :
++                return (!hasContent());
++            case IMG :
++                return (hasAttr(HtmlAttr.SRC) && hasAttr(HtmlAttr.ALT) && !hasContent());
++            case LINK :
++                return (hasAttr(HtmlAttr.HREF) && !hasContent());
++            case META :
++                return (hasAttr(HtmlAttr.CONTENT) && !hasContent());
++            default :
++                return hasContent();
++        }
++    }
++
++    /**
++     * Returns true if the element is an inline element.
++     *
++     * @return true if the HTML tag is an inline element
++     */
++    public boolean isInline() {
++        return (htmlTag.blockType == HtmlTag.BlockType.INLINE);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void write(StringBuilder contentBuilder) {
++        if (!isInline() && !endsWithNewLine(contentBuilder))
++            contentBuilder.append("\n");
++        String tagString = htmlTag.toString();
++        contentBuilder.append("<" + tagString);
++        Iterator<HtmlAttr> iterator = attrs.keySet().iterator();
++        HtmlAttr key;
++        String value = "";
++        while (iterator.hasNext()) {
++            key = iterator.next();
++            value = attrs.get(key);
++            contentBuilder.append(" " + key.toString());
++            if (!value.isEmpty())
++                contentBuilder.append("=\"" + value + "\"");
++        }
++        contentBuilder.append(">");
++        for (Content c : content)
++            c.write(contentBuilder);
++        if (htmlTag.endTagRequired())
++            contentBuilder.append("</" + tagString + ">");
++        if (!isInline())
++            contentBuilder.append("\n");
++    }
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+@@ -55,7 +55,7 @@
+      * URL file separator string("/").
+      */
+     public static final String fileseparator =
+-         DirectoryManager.URL_FILE_SEPERATOR;
++         DirectoryManager.URL_FILE_SEPARATOR;
+ 
+     /**
+      * The configuration
+@@ -82,6 +82,72 @@
+      */
+     protected final String modifierTypeHeader;
+ 
++    public final Content overviewLabel;
++
++    public final Content defaultPackageLabel;
++
++    public final Content packageLabel;
++
++    public final Content useLabel;
++
++    public final Content prevLabel;
++
++    public final Content nextLabel;
++
++    public final Content prevclassLabel;
++
++    public final Content nextclassLabel;
++
++    public final Content summaryLabel;
++
++    public final Content detailLabel;
++
++    public final Content framesLabel;
++
++    public final Content noframesLabel;
++
++    public final Content treeLabel;
++
++    public final Content classLabel;
++
++    public final Content deprecatedLabel;
++
++    public final Content deprecatedPhrase;
++
++    public final Content allclassesLabel;
++
++    public final Content indexLabel;
++
++    public final Content helpLabel;
++
++    public final Content seeLabel;
++
++    public final Content descriptionLabel;
++
++    public final Content prevpackageLabel;
++
++    public final Content nextpackageLabel;
++
++    public final Content packagesLabel;
++
++    public final Content methodDetailsLabel;
++
++    public final Content annotationTypeDetailsLabel;
++
++    public final Content fieldDetailsLabel;
++
++    public final Content constructorDetailsLabel;
++
++    public final Content enumConstantsDetailsLabel;
++
++    public final Content specifiedByLabel;
++
++    public final Content overridesLabel;
++
++    public final Content descfrmClassLabel;
++
++    public final Content descfrmInterfaceLabel;
++
+     /**
+      * Constructor.
+      *
+@@ -111,6 +177,73 @@
+         modifierTypeHeader = configuration.getText("doclet.0_and_1",
+                 configuration.getText("doclet.Modifier"),
+                 configuration.getText("doclet.Type"));
++        overviewLabel = getResource("doclet.Overview");
++        defaultPackageLabel = new RawHtml(
++                DocletConstants.DEFAULT_PACKAGE_NAME);
++        packageLabel = getResource("doclet.Package");
++        useLabel = getResource("doclet.navClassUse");
++        prevLabel = getResource("doclet.Prev");
++        nextLabel = getResource("doclet.Next");
++        prevclassLabel = getResource("doclet.Prev_Class");
++        nextclassLabel = getResource("doclet.Next_Class");
++        summaryLabel = getResource("doclet.Summary");
++        detailLabel = getResource("doclet.Detail");
++        framesLabel = getResource("doclet.FRAMES");
++        noframesLabel = getResource("doclet.NO_FRAMES");
++        treeLabel = getResource("doclet.Tree");
++        classLabel = getResource("doclet.Class");
++        deprecatedLabel = getResource("doclet.navDeprecated");
++        deprecatedPhrase = getResource("doclet.Deprecated");
++        allclassesLabel = getResource("doclet.All_Classes");
++        indexLabel = getResource("doclet.Index");
++        helpLabel = getResource("doclet.Help");
++        seeLabel = getResource("doclet.See");
++        descriptionLabel = getResource("doclet.Description");
++        prevpackageLabel = getResource("doclet.Prev_Package");
++        nextpackageLabel = getResource("doclet.Next_Package");
++        packagesLabel = getResource("doclet.Packages");
++        methodDetailsLabel = getResource("doclet.Method_Detail");
++        annotationTypeDetailsLabel = getResource("doclet.Annotation_Type_Member_Detail");
++        fieldDetailsLabel = getResource("doclet.Field_Detail");
++        constructorDetailsLabel = getResource("doclet.Constructor_Detail");
++        enumConstantsDetailsLabel = getResource("doclet.Enum_Constant_Detail");
++        specifiedByLabel = getResource("doclet.Specified_By");
++        overridesLabel = getResource("doclet.Overrides");
++        descfrmClassLabel = getResource("doclet.Description_From_Class");
++        descfrmInterfaceLabel = getResource("doclet.Description_From_Interface");
++    }
++
++    /**
++     * Get the configuration string as a content.
++     *
++     * @param key the key to look for in the configuration file
++     * @return a content tree for the text
++     */
++    public Content getResource(String key) {
++        return new StringContent(configuration.getText(key));
++    }
++
++    /**
++     * Get the configuration string as a content.
++     *
++     * @param key the key to look for in the configuration file
++     * @param a1 string argument added to configuration text
++     * @return a content tree for the text
++     */
++    public Content getResource(String key, String a1) {
++        return new RawHtml(configuration.getText(key, a1));
++    }
++
++    /**
++     * Get the configuration string as a content.
++     *
++     * @param key the key to look for in the configuration file
++     * @param a1 string argument added to configuration text
++     * @param a2 string argument added to configuration text
++     * @return a content tree for the text
++     */
++    public Content getResource(String key, String a1, String a2) {
++        return new RawHtml(configuration.getText(key, a1, a2));
+     }
+ 
+     /**
+@@ -146,6 +279,48 @@
+     }
+ 
+     /**
++     * Returns an HtmlTree for the SCRIPT tag.
++     *
++     * @return an HtmlTree for the SCRIPT tag
++     */
++    protected HtmlTree getWinTitleScript(){
++        HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
++        if(winTitle != null && winTitle.length() > 0) {
++            script.addAttr(HtmlAttr.TYPE, "text/javascript");
++            String scriptCode = "<!--\n" +
++                    "    if (location.href.indexOf('is-external=true') == -1) {\n" +
++                    "        parent.document.title=\"" + winTitle + "\";\n" +
++                    "    }\n" +
++                    "//-->\n";
++            RawHtml scriptContent = new RawHtml(scriptCode);
++            script.addContent(scriptContent);
++        }
++        return script;
++    }
++
++    /**
++     * Returns a content tree for the SCRIPT tag for the main page(index.html).
++     *
++     * @return a content for the SCRIPT tag
++     */
++    protected Content getFramesetJavaScript(){
++        HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
++        script.addAttr(HtmlAttr.TYPE, "text/javascript");
++        String scriptCode = "\n    targetPage = \"\" + window.location.search;\n" +
++                "    if (targetPage != \"\" && targetPage != \"undefined\")\n" +
++                "        targetPage = targetPage.substring(1);\n" +
++                "    if (targetPage.indexOf(\":\") != -1)\n" +
++                "        targetPage = \"undefined\";\n" +
++                "    function loadFrames() {\n" +
++                "        if (targetPage != \"\" && targetPage != \"undefined\")\n" +
++                "             top.classFrame.location = top.targetPage;\n" +
++                "    }\n";
++        RawHtml scriptContent = new RawHtml(scriptCode);
++        script.addContent(scriptContent);
++        return script;
++    }
++
++    /**
+      * Print the Javascript &lt;SCRIPT&gt; start tag with its type
+      * attribute.
+      */
+@@ -204,6 +379,28 @@
+     }
+ 
+     /**
++     * Returns an HtmlTree for the BODY tag.
++     *
++     * @param includeScript  set true if printing windowtitle script
++     * @param title title for the window
++     * @return an HtmlTree for the BODY tag
++     */
++    public HtmlTree getBody(boolean includeScript, String title) {
++        HtmlTree body = new HtmlTree(HtmlTag.BODY);
++        // Set window title string which is later printed
++        this.winTitle = title;
++        // Don't print windowtitle script for overview-frame, allclasses-frame
++        // and package-frame
++        if (includeScript) {
++            body.addContent(getWinTitleScript());
++            Content noScript = HtmlTree.NOSCRIPT(
++                    HtmlTree.DIV(getResource("doclet.No_Script_Message")));
++            body.addContent(noScript);
++        }
++        return body;
++    }
++
++    /**
+      * Print &lt;/BODY&gt; tag. Add a newline character at the end.
+      */
+     public void bodyEnd() {
+@@ -228,6 +425,15 @@
+         title();
+     }
+ 
++    /**
++     * Returns an HtmlTree for the TITLE tag.
++     *
++     * @return an HtmlTree for the TITLE tag
++     */
++    public HtmlTree getTitle() {
++        HtmlTree title = HtmlTree.TITLE(new StringContent(winTitle));
++        return title;
++    }
+ 
+     /**
+      * Print &lt;/TITLE&gt; tag. Add a newline character at the end.
+@@ -519,17 +725,17 @@
+     }
+ 
+     /**
+-     * Return, text passed, with Italics &lt;I&gt; and &lt;/I&gt; tags, surrounding it.
+-     * So if the text passed is "Hi", then string returned will be "&lt;I&gt;Hi&lt;/I&gt;".
++     * Return, text passed, with Italics &lt;i&gt; and &lt;/i&gt; tags, surrounding it.
++     * So if the text passed is "Hi", then string returned will be "&lt;i&gt;Hi&lt;/i&gt;".
+      *
+      * @param text String to be printed in between &lt;I&gt; and &lt;/I&gt; tags.
+      */
+     public String italicsText(String text) {
+-        return "<I>" + text + "</I>";
++        return "<i>" + text + "</i>";
+     }
+ 
+     public String codeText(String text) {
+-        return "<CODE>" + text + "</CODE>";
++        return "<code>" + text + "</code>";
+     }
+ 
+     /**
+@@ -540,6 +746,13 @@
+     }
+ 
+     /**
++     * Return "&#38;nbsp;", non-breaking space.
++     */
++    public Content getSpace() {
++        return RawHtml.nbsp;
++    }
++
++    /**
+      * Print &lt;DL&gt; tag. Add a newline character at the end.
+      */
+     public void dl() {
+@@ -1182,21 +1395,21 @@
+     }
+ 
+     /**
+-     * Get the "&lt;CODE&gt;" string.
++     * Get the "&lt;code&gt;" string.
+      *
+-     * @return String Return String "&lt;CODE>";
++     * @return String Return String "&lt;code&gt;";
+      */
+     public String getCode() {
+-        return "<CODE>";
++        return "<code>";
+     }
+ 
+     /**
+-     * Get the "&lt;/CODE&gt;" string.
++     * Get the "&lt;/code&gt;" string.
+      *
+-     * @return String Return String "&lt;/CODE&gt;";
++     * @return String Return String "&lt;/code&gt;";
+      */
+     public String getCodeEnd() {
+-        return "</CODE>";
++        return "</code>";
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/RawHtml.java
+@@ -0,0 +1,88 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.formats.html.markup;
++
++import com.sun.tools.doclets.internal.toolkit.Content;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++
++/**
++ * Class for generating raw HTML content to be added to HTML pages of javadoc output.
++ *
++ * @author Bhavesh Patel
++ */
++public class RawHtml extends Content{
++
++    private String rawHtmlContent;
++
++    public static final Content nbsp = new RawHtml("&nbsp;");
++
++    /**
++     * Constructor to construct a RawHtml object.
++     *
++     * @param rawHtml raw HTML text to be added
++     */
++    public RawHtml(String rawHtml) {
++        rawHtmlContent = nullCheck(rawHtml);
++    }
++
++    /**
++     * This method is not supported by the class.
++     *
++     * @param content content that needs to be added
++     * @throws DocletAbortException this method will always throw a
++     *                              DocletAbortException because it
++     *                              is not supported.
++     */
++    public void addContent(Content content) {
++        throw new DocletAbortException();
++    }
++
++    /**
++     * This method is not supported by the class.
++     *
++     * @param stringContent string content that needs to be added
++     * @throws DocletAbortException this method will always throw a
++     *                              DocletAbortException because it
++     *                              is not supported.
++     */
++    public void addContent(String stringContent) {
++        throw new DocletAbortException();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public boolean isEmpty() {
++        return rawHtmlContent.isEmpty();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void write(StringBuilder contentBuilder) {
++        contentBuilder.append(rawHtmlContent);
++    }
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/StringContent.java
+@@ -0,0 +1,99 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.formats.html.markup;
++
++import com.sun.tools.doclets.internal.toolkit.Content;
++import com.sun.tools.doclets.internal.toolkit.util.*;
++
++/**
++ * Class for generating string content for HTML tags of javadoc output.
++ *
++ * @author Bhavesh Patel
++ */
++public class StringContent extends Content{
++
++    private StringBuilder stringContent;
++
++    /**
++     * Constructor to construct StringContent object.
++     */
++    public StringContent() {
++        stringContent = new StringBuilder();
++    }
++
++    /**
++     * Constructor to construct StringContent object with some initial content.
++     *
++     * @param initialContent initial content for the object
++     */
++    public StringContent(String initialContent) {
++        stringContent = new StringBuilder(
++                Util.escapeHtmlChars(nullCheck(initialContent)));
++    }
++
++    /**
++     * This method is not supported by the class.
++     *
++     * @param content content that needs to be added
++     * @throws DocletAbortException this method will always throw a
++     *                              DocletAbortException because it
++     *                              is not supported.
++     */
++    public void addContent(Content content) {
++        throw new DocletAbortException();
++    }
++
++    /**
++     * Adds content for the StringContent object.  The method escapes
++     * HTML characters for the string content that is added.
++     *
++     * @param strContent string content to be added
++     */
++    public void addContent(String strContent) {
++        stringContent.append(Util.escapeHtmlChars(nullCheck(strContent)));
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public boolean isEmpty() {
++        return (stringContent.length() == 0);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String toString() {
++        return stringContent.toString();
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public void write(StringBuilder contentBuilder) {
++        contentBuilder.append(stringContent);
++    }
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
+@@ -43,6 +43,7 @@
+ doclet.Window_Split_Index={0}-Index
+ doclet.Help=Help
+ doclet.Skip_navigation_links=Skip navigation links
++doclet.New_Page=NewPage
+ doclet.None=None
+ doclet.CLASSES=CLASSES
+ doclet.MEMBERS=MEMBERS
+@@ -53,7 +54,7 @@
+ doclet.Window_Deprecated_List=Deprecated List
+ doclet.Note_0_is_deprecated=Note: {0} is deprecated.
+ doclet.Overrides=Overrides:
+-doclet.in_class={0} in class {1}
++doclet.in_class=in class
+ doclet.0_Fields_and_Methods=&quot;{0}&quot; Fields and Methods
+ doclet.Index_of_Fields_and_Methods=Index of Fields and Methods
+ doclet.Static_variable_in=Static variable in {0}
+@@ -102,7 +103,7 @@
+ doclet.Package_Description=Package {0} Description
+ doclet.Description=Description
+ doclet.Specified_By=Specified by:
+-doclet.in_interface={0} in interface {1}
++doclet.in_interface=in interface
+ doclet.Subclasses=Direct Known Subclasses:
+ doclet.Subinterfaces=All Known Subinterfaces:
+ doclet.Implementing_Classes=All Known Implementing Classes:
+@@ -120,18 +121,20 @@
+ doclet.Frame_Alert=Frame Alert
+ doclet.Overview-Member-Frame=Overview Member Frame
+ doclet.Frame_Warning_Message=This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
++doclet.No_Script_Message=JavaScript is disabled on your browser.
+ doclet.Non_Frame_Version=Non-frame version.
+ doclet.Frame_Version=Frame version
+ doclet.Link_To=Link to
+ doclet.Following_From_Class=Following copied from class: {0}
+ doclet.Following_From_Interface=Following copied from interface: {0}
+-doclet.Description_From_Interface=Description copied from interface: {0}
+-doclet.Description_From_Class=Description copied from class: {0}
++doclet.Description_From_Interface=Description copied from interface:
++doclet.Description_From_Class=Description copied from class:
+ doclet.Standard_doclet_invoked=Standard doclet invoked...
+ doclet.No_Non_Deprecated_Classes_To_Document=No non-deprecated classes found to document.
+ doclet.Interfaces_Italic=Interfaces (italic)
+ doclet.Enclosing_Class=Enclosing class:
+ doclet.Enclosing_Interface=Enclosing interface:
++doclet.Window_Source_title=Source code
+ doclet.Help_title=API Help
+ doclet.Window_Help_title=API Help
+ doclet.Help_line_1=How This API Document Is Organized
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeOptionalMemberWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeOptionalMemberWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeOptionalMemberWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeOptionalMemberWriter.java
+@@ -35,14 +35,18 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface AnnotationTypeOptionalMemberWriter extends
+-    AnnotationTypeRequiredMemberWriter {
++        AnnotationTypeRequiredMemberWriter {
+ 
+     /**
+-     * Write the default value documentation.
++     * Add the the default value documentation.
++     *
++     * @param member the member being documented
++     * @param annotationDocTree content tree to which the default value will be added
+      */
+-    public void writeDefaultValueInfo(MemberDoc member);
++    public void addDefaultValueInfo(MemberDoc member, Content annotationDocTree);
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeRequiredMemberWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeRequiredMemberWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeRequiredMemberWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeRequiredMemberWriter.java
+@@ -36,67 +36,79 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface AnnotationTypeRequiredMemberWriter {
+ 
+     /**
+-     * Write the header for the member documentation.
++     * Add the annotation type details tree header.
+      *
+-     * @param classDoc the annotation type that the members belong to.
+-     * @param header the header to write.
++     * @param classDoc the annotation type being documented
++     * @param memberDetailsTree the content tree representing member details
+      */
+-    public void writeHeader(ClassDoc classDoc, String header);
++    public void addAnnotationDetailsTreeHeader(ClassDoc classDoc,
++            Content memberDetailsTree);
+ 
+     /**
+-     * Write the member header for the given member.
++     * Get the annotation type documentation tree header.
+      *
+-     * @param member the member being documented.
+-     * @param isFirst the flag to indicate whether or not the member is
+-     *                the first to be documented.
++     * @param member the annotation type being documented
++     * @param annotationDetailsTree the content tree representing annotation type details
++     * @return content tree for the annotation type documentation header
+      */
+-    public void writeMemberHeader(MemberDoc member, boolean isFirst);
++    public Content getAnnotationDocTreeHeader(MemberDoc member,
++            Content annotationDetailsTree);
+ 
+     /**
+-     * Write the signature for the given member.
++     * Get the annotation type details tree.
+      *
+-     * @param member the member being documented.
++     * @param annotationDetailsTree the content tree representing annotation type details
++     * @return content tree for the annotation type details
+      */
+-    public void writeSignature(MemberDoc member);
++    public Content getAnnotationDetails(Content annotationDetailsTree);
+ 
+     /**
+-     * Write the deprecated output for the given member.
++     * Get the annotation type documentation.
+      *
+-     * @param member the member being documented.
++     * @param annotationDocTree the content tree representing annotation type documentation
++     * @param isLastContent true if the content to be added is the last content
++     * @return content tree for the annotation type documentation
+      */
+-    public void writeDeprecated(MemberDoc member);
++    public Content getAnnotationDoc(Content annotationDocTree, boolean isLastContent);
+ 
+     /**
+-     * Write the comments for the given member.
++     * Get the signature for the given member.
+      *
+-     * @param member the member being documented.
++     * @param member the member being documented
++     * @return content tree for the annotation type signature
+      */
+-    public void writeComments(MemberDoc member);
++    public Content getSignature(MemberDoc member);
+ 
+     /**
+-     * Write the tag output for the given member.
++     * Add the deprecated output for the given member.
+      *
+-     * @param member the member being documented.
++     * @param member the member being documented
++     * @param annotationDocTree content tree to which the deprecated information will be added
+      */
+-    public void writeTags(MemberDoc member);
++    public void addDeprecated(MemberDoc member, Content annotationDocTree);
+ 
+     /**
+-     * Write the member footer.
++     * Add the comments for the given member.
++     *
++     * @param member the member being documented
++     * @param annotationDocTree the content tree to which the comments will be added
+      */
+-    public void writeMemberFooter();
++    public void addComments(MemberDoc member, Content annotationDocTree);
+ 
+     /**
+-     * Write the footer for the member documentation.
++     * Add the tags for the given member.
+      *
+-     * @param classDoc the class that the member belong to.
++     * @param member the member being documented
++     * @param annotationDocTree the content tree to which the tags will be added
+      */
+-    public void writeFooter(ClassDoc classDoc);
++    public void addTags(MemberDoc member, Content annotationDocTree);
+ 
+     /**
+      * Close the writer.
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/AnnotationTypeWriter.java
+@@ -37,43 +37,122 @@
+  * Do not use it as an API.
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface AnnotationTypeWriter {
+ 
+     /**
+-     * Write the header of the page.
+-     * @param header the header to write.
++     * Get the header of the page.
++     *
++     * @param header the header string to write
++     * @return a content tree for the header documentation
+      */
+-    public void writeHeader(String header);
++    public Content getHeader(String header);
+ 
+     /**
+-     * Write the signature of the current annotation type.
++     * Get the annotation content header.
+      *
+-     * @param modifiers the modifiers for the signature.
++     * @return annotation content header that needs to be added to the documentation
+      */
+-    public void writeAnnotationTypeSignature(String modifiers);
++    public Content getAnnotationContentHeader();
++
++    /**
++     * Get the annotation information tree header.
++     *
++     * @return annotation information tree header that needs to be added to the documentation
++     */
++    public Content getAnnotationInfoTreeHeader();
++
++    /**
++     * Get the annotation information.
++     *
++     * @param annotationInfoTree content tree containing the annotation information
++     * @return a content tree for the annotation
++     */
++    public Content getAnnotationInfo(Content annotationInfoTree);
++
++    /**
++     * Add the signature of the current annotation type.
++     *
++     * @param modifiers the modifiers for the signature
++     * @param annotationInfoTree the annotation content tree to which the signature will be added
++     */
++    public void addAnnotationTypeSignature(String modifiers, Content annotationInfoTree);
+ 
+     /**
+      * Build the annotation type description.
++     *
++     * @param annotationInfoTree content tree to which the description will be added
+      */
+-    public void writeAnnotationTypeDescription();
++    public void addAnnotationTypeDescription(Content annotationInfoTree);
+ 
+     /**
+-     * Write the tag information for the current annotation type.
++     * Add the tag information for the current annotation type.
++     *
++     * @param annotationInfoTree content tree to which the tag information will be added
+      */
+-    public void writeAnnotationTypeTagInfo();
++    public void addAnnotationTypeTagInfo(Content annotationInfoTree);
+ 
+     /**
+-     * If this annotation type is deprecated, write the appropriate information.
++     * If this annotation is deprecated, add the appropriate information.
++     *
++     * @param annotationInfoTree content tree to which the deprecated information will be added
+      */
+-    public void writeAnnotationTypeDeprecationInfo();
++    public void addAnnotationTypeDeprecationInfo (Content annotationInfoTree);
+ 
+     /**
+-     * Write the footer of the page.
++     * Add the annotation type details marker.
++     *
++     * @param memberDetails the content tree representing member details marker
+      */
+-    public void writeFooter();
++    public void addAnnotationDetailsMarker(Content memberDetails);
++
++    /**
++     * Get the member tree header for the annotation type.
++     *
++     * @return a content tree for the member tree header
++     */
++    public Content getMemberTreeHeader();
++
++    /**
++     * Get the member tree.
++     *
++     * @param memberTree the content tree that will be modified and returned
++     * @return a content tree for the member
++     */
++    public Content getMemberTree(Content memberTree);
++
++    /**
++     * Get the member summary tree.
++     *
++     * @param memberTree the content tree that will be used to build the summary tree
++     * @return a content tree for the member summary
++     */
++    public Content getMemberSummaryTree(Content memberTree);
++
++    /**
++     * Get the member details tree.
++     *
++     * @param memberTree the content tree that will be used to build the details tree
++     * @return a content tree for the member details
++     */
++    public Content getMemberDetailsTree(Content memberTree);
++
++    /**
++     * Add the footer of the page.
++     *
++     * @param contentTree content tree to which the footer will be added
++     */
++    public void addFooter(Content contentTree);
++
++    /**
++     * Print the document.
++     *
++     * @param contentTree content tree that will be printed as a document
++     */
++    public void printDocument(Content contentTree);
+ 
+     /**
+      * Close the writer.
+@@ -86,10 +165,4 @@
+      * @return the AnnotationTypeDoc being documented.
+      */
+     public AnnotationTypeDoc getAnnotationTypeDoc();
+-
+-    /**
+-     * Perform any operations that are necessary when the member summary
+-     * finished building.
+-     */
+-    public void completeMemberSummaryBuild();
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ClassWriter.java
+@@ -37,85 +37,149 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface ClassWriter {
+ 
+     /**
+-     * Write the header of the page.
+-     * @param header the header to write.
++     * Get the header of the page.
++     *
++     * @param header the header string to write
++     * @return header content that needs to be added to the documentation
+      */
+-    public void writeHeader(String header);
++    public Content getHeader(String header);
+ 
+     /**
+-     * Write the class tree documentation.
++     * Get the class content header.
++     *
++     * @return class content header that needs to be added to the documentation
+      */
+-    public void writeClassTree();
++    public Content getClassContentHeader();
+ 
+     /**
+-     * Write all implemented interfaces if this is a class.
++     * Add the class tree documentation.
++     *
++     * @param classContentTree class content tree to which the documentation will be added
+      */
+-    public void writeImplementedInterfacesInfo();
++    public void addClassTree(Content classContentTree);
+ 
+     /**
+-     * Write all super interfaces if this is an interface.
++     * Get the class information tree header.
++     *
++     * @return class informaion tree header that needs to be added to the documentation
+      */
+-    public void writeSuperInterfacesInfo();
++    public Content getClassInfoTreeHeader();
+ 
+     /**
+-     * Write the type parameter information.
++     * Add the type parameter information.
++     *
++     * @param classInfoTree content tree to which the documentation will be added
+      */
+-    public void writeTypeParamInfo();
++    public void addTypeParamInfo(Content classInfoTree);
+ 
+     /**
+-     * Write all the classes that extend this one.
++     * Add all super interfaces if this is an interface.
++     *
++     * @param classInfoTree content tree to which the documentation will be added
+      */
+-    public void writeSubClassInfo();
++    public void addSuperInterfacesInfo(Content classInfoTree);
+ 
+     /**
+-     * Write all the interfaces that extend this one.
++     * Add all implemented interfaces if this is a class.
++     *
++     * @param classInfoTree content tree to which the documentation will be added
+      */
+-    public void writeSubInterfacesInfo();
++    public void addImplementedInterfacesInfo(Content classInfoTree);
+ 
+     /**
+-     * If this is an interface, write all classes that implement this
+-     * interface.
++     * Add all the classes that extend this one.
++     *
++     * @param classInfoTree content tree to which the documentation will be added
+      */
+-    public void writeInterfaceUsageInfo ();
++    public void addSubClassInfo(Content classInfoTree);
+ 
+     /**
+-     * If this is an inner class or interface, write the enclosing class or
+-     * interface.
++     * Add all the interfaces that extend this one.
++     *
++     * @param classInfoTree content tree to which the documentation will be added
+      */
+-    public void writeNestedClassInfo ();
++    public void addSubInterfacesInfo(Content classInfoTree);
+ 
+     /**
+-     * If this class is deprecated, write the appropriate information.
++     * If this is an interface, add all classes that implement this
++     * interface.
++     *
++     * @param classInfoTree content tree to which the documentation will be added
+      */
+-    public void writeClassDeprecationInfo ();
++    public void addInterfaceUsageInfo(Content classInfoTree);
+ 
+     /**
+-     * Write the signature of the current class.
++     * If this is an inner class or interface, add the enclosing class or
++     * interface.
+      *
+-     * @param modifiers the modifiers for the signature.
++     * @param classInfoTree content tree to which the documentation will be added
+      */
+-    public void writeClassSignature(String modifiers);
++    public void addNestedClassInfo (Content classInfoTree);
++
++    /**
++     * Get the class information.
++     *
++     * @param classInfoTree content tree conatining the class information
++     * @return a content tree for the class
++     */
++    public Content getClassInfo(Content classInfoTree);
++
++    /**
++     * If this class is deprecated, add the appropriate information.
++     *
++     * @param classInfoTree content tree to which the documentation will be added
++     */
++    public void addClassDeprecationInfo (Content classInfoTree);
++
++    /**
++     * Add the signature of the current class content tree.
++     *
++     * @param modifiers the modifiers for the signature
++     * @param classInfoTree the class content tree to which the signature will be added
++     */
++    public void addClassSignature(String modifiers, Content classInfoTree);
+ 
+     /**
+      * Build the class description.
++     *
++     * @param classInfoTree content tree to which the documentation will be added
+      */
+-    public void writeClassDescription();
++    public void addClassDescription(Content classInfoTree);
+ 
+     /**
+-     * Write the tag information for the current class.
++     * Add the tag information for the current class.
++     *
++     * @param classInfoTree content tree to which the tag information will be added
+      */
+-    public void writeClassTagInfo();
++    public void addClassTagInfo(Content classInfoTree);
+ 
+     /**
+-     * Write the footer of the page.
++     * Get the member tree header for the class.
++     *
++     * @return a content tree for the member tree header
+      */
+-    public void writeFooter();
++    public Content getMemberTreeHeader();
++
++    /**
++     * Add the footer of the page.
++     *
++     * @param contentTree content tree to which the footer will be added
++     */
++    public void addFooter(Content contentTree);
++
++    /**
++     * Print the document.
++     *
++     * @param contentTree content tree that will be printed as a document
++     */
++    public void printDocument(Content contentTree);
+ 
+     /**
+      * Close the writer.
+@@ -130,8 +194,18 @@
+     public ClassDoc getClassDoc();
+ 
+     /**
+-     * Perform any operations that are necessary when the member summary
+-     * finished building.
++     * Get the member summary tree.
++     *
++     * @param memberTree the content tree used to build the summary tree
++     * @return a content tree for the member summary
+      */
+-    public void completeMemberSummaryBuild();
++    public Content getMemberSummaryTree(Content memberTree);
++
++    /**
++     * Get the member details tree.
++     *
++     * @param memberTree the content tree used to build the details tree
++     * @return a content tree for the member details
++     */
++    public Content getMemberDetailsTree(Content memberTree);
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstantsSummaryWriter.java
+@@ -25,9 +25,9 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit;
+ 
+-import com.sun.javadoc.*;
+ import java.util.*;
+ import java.io.*;
++import com.sun.javadoc.*;
+ 
+ /**
+  * The interface for writing constants summary output.
+@@ -37,38 +37,34 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface ConstantsSummaryWriter {
+ 
+     /**
+-     * Write the header for the summary.
+-     */
+-    public abstract void writeHeader();
+-
+-    /**
+-     * Write the footer for the summary.
+-     */
+-    public abstract void writeFooter();
+-
+-    /**
+      * Close the writer.
+      */
+     public abstract void close() throws IOException;
+ 
+     /**
+-     * Write the header for the index.
++     * Get the header for the constant summary documentation.
++     *
++     * @return header that needs to be added to the documentation
+      */
+-    public abstract void writeContentsHeader();
++    public abstract Content getHeader();
+ 
+     /**
+-     * Write the footer for the index.
++     * Get the header for the constant content list.
++     *
++     * @return content header that needs to be added to the documentation
+      */
+-    public abstract void writeContentsFooter();
++    public abstract Content getContentsHeader();
+ 
+     /**
+-     * Add the given package name to the index.
++     * Adds the given package name link to the constant content list tree.
++     *
+      * @param pkg                    the {@link PackageDoc} to index.
+      * @param parsedPackageName      the parsed package name.  We only Write the
+      *                               first 2 directory levels of the package
+@@ -77,38 +73,70 @@
+      * @param WriteedPackageHeaders the set of package headers that have already
+      *                              been indexed.  We don't want to index
+      *                              something more than once.
++     * @param contentListTree the content tree to which the link will be added
+      */
+-    public abstract void writeLinkToPackageContent(PackageDoc pkg, String parsedPackageName,
+-        Set WriteedPackageHeaders);
++    public abstract void addLinkToPackageContent(PackageDoc pkg, String parsedPackageName,
++        Set<String> WriteedPackageHeaders, Content contentListTree);
+ 
+     /**
+-     * Write the given package name.
+-     * @param pkg                    the {@link PackageDoc} to index.
+-     * @param parsedPackageName      the parsed package name.  We only Write the
+-     *                               first 2 directory levels of the package
+-     *                               name. For example, java.lang.ref would be
+-     *                               indexed as java.lang.*.
++     * Get the content list to be added to the documentation tree.
++     *
++     * @param contentListTree the content that will be added to the list
++     * @return content list that will be added to the documentation tree
+      */
+-    public abstract void writePackageName(PackageDoc pkg,
+-        String parsedPackageName);
++    public abstract Content getContentsList(Content contentListTree);
+ 
+     /**
+-     * Write the heading for the current table of constants for a given class.
+-     * @param cd the class whose constants are being documented.
++     * Get the constant summaries for the document.
++     *
++     * @return constant summaries header to be added to the documentation tree
+      */
+-    public abstract void writeConstantMembersHeader(ClassDoc cd);
++    public abstract Content getConstantSummaries();
+ 
+     /**
+-     * Document the given constants.
++     * Adds the given package name.
++     *
++     * @param pkg the {@link PackageDoc} to index.
++     * @param parsedPackageName the parsed package name.  We only Write the
++     *                          first 2 directory levels of the package
++     *                          name. For example, java.lang.ref would be
++     *                          indexed as java.lang.*.
++     * @param summariesTree the documentation tree to which the package name will
++     *                    be written
++     */
++    public abstract void addPackageName(PackageDoc pkg,
++        String parsedPackageName, Content summariesTree);
++
++    /**
++     * Get the class summary header for the constants summary.
++     *
++     * @return the header content for the class constants summary
++     */
++    public abstract Content getClassConstantHeader();
++
++    /**
++     * Adds the constant member table to the documentation tree.
++     *
+      * @param cd the class whose constants are being documented.
+      * @param fields the constants being documented.
++     * @param classConstantTree the documentation tree to which theconstant member
++     *                    table content will be added
+      */
+-    public abstract void writeConstantMembers(ClassDoc cd, List fields);
++    public abstract void addConstantMembers(ClassDoc cd, List<FieldDoc> fields,
++            Content classConstantTree);
+ 
+     /**
+-     * Document the given constants.
+-     * @param cd the class whose constants are being documented.
++     * Adds the footer for the summary documentation.
++     *
++     * @param contentTree content tree to which the footer will be added
+      */
+-    public abstract void writeConstantMembersFooter(ClassDoc cd);
++    public abstract void addFooter(Content contentTree);
++
++    /**
++     * Print the constants summary document.
++     *
++     * @param contentTree content tree which should be printed
++     */
++    public abstract void printDocument(Content contentTree);
+ 
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstructorWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstructorWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstructorWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/ConstructorWriter.java
+@@ -36,67 +36,80 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface ConstructorWriter {
+ 
+     /**
+-     * Write the header for the constructor documentation.
++     * Get the constructor details tree header.
+      *
+-     * @param classDoc the class that the constructors belong to.
+-     * @param header the header to write.
++     * @param classDoc the class being documented
++     * @param memberDetailsTree the content tree representing member details
++     * @return content tree for the constructor details header
+      */
+-    public void writeHeader(ClassDoc classDoc, String header);
++    public Content getConstructorDetailsTreeHeader(ClassDoc classDoc,
++            Content memberDetailsTree);
+ 
+     /**
+-     * Write the constructor header for the given constructor.
++     * Get the constructor documentation tree header.
+      *
+-     * @param constructor the constructor being documented.
+-     * @param isFirst the flag to indicate whether or not the constructor is the
+-     *        first to be documented.
++     * @param constructor the constructor being documented
++     * @param constructorDetailsTree the content tree representing constructor details
++     * @return content tree for the constructor documentation header
+      */
+-    public void writeConstructorHeader(ConstructorDoc constructor, boolean isFirst);
++    public Content getConstructorDocTreeHeader(ConstructorDoc constructor,
++            Content constructorDetailsTree);
+ 
+     /**
+-     * Write the signature for the given constructor.
++     * Get the signature for the given constructor.
+      *
+-     * @param constructor the constructor being documented.
++     * @param constructor the constructor being documented
++     * @return content tree for the constructor signature
+      */
+-    public void writeSignature(ConstructorDoc constructor);
++    public Content getSignature(ConstructorDoc constructor);
+ 
+     /**
+-     * Write the deprecated output for the given constructor.
++     * Add the deprecated output for the given constructor.
+      *
+-     * @param constructor the constructor being documented.
++     * @param constructor the constructor being documented
++     * @param constructorDocTree content tree to which the deprecated information will be added
+      */
+-    public void writeDeprecated(ConstructorDoc constructor);
++    public void addDeprecated(ConstructorDoc constructor, Content constructorDocTree);
+ 
+     /**
+-     * Write the comments for the given constructor.
++     * Add the comments for the given constructor.
+      *
+-     * @param constructor the constructor being documented.
++     * @param constructor the constructor being documented
++     * @param constructorDocTree the content tree to which the comments will be added
+      */
+-    public void writeComments(ConstructorDoc constructor);
++    public void addComments(ConstructorDoc constructor, Content constructorDocTree);
+ 
+     /**
+-     * Write the tag output for the given constructor.
++     * Add the tags for the given constructor.
+      *
+-     * @param constructor the constructor being documented.
++     * @param constructor the constructor being documented
++     * @param constructorDocTree the content tree to which the tags will be added
+      */
+-    public void writeTags(ConstructorDoc constructor);
++    public void addTags(ConstructorDoc constructor, Content constructorDocTree);
+ 
+     /**
+-     * Write the constructor footer.
++     * Get the constructor details tree.
++     *
++     * @param memberDetailsTree the content tree representing member details
++     * @return content tree for the constructor details
+      */
+-    public void writeConstructorFooter();
++    public Content getConstructorDetails(Content memberDetailsTree);
+ 
+     /**
+-     * Write the footer for the constructor documentation.
++     * Get the constructor documentation.
+      *
+-     * @param classDoc the class that the constructors belong to.
++     * @param constructorDocTree the content tree representing constructor documentation
++     * @param isLastContent true if the content to be added is the last content
++     * @return content tree for the constructor documentation
+      */
+-    public void writeFooter(ClassDoc classDoc);
++    public Content getConstructorDoc(Content constructorDocTree, boolean isLastContent);
+ 
+     /**
+      * Let the writer know whether a non public constructor was found.
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java
+@@ -0,0 +1,106 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.internal.toolkit;
++
++import com.sun.tools.doclets.internal.toolkit.util.*;
++
++/**
++ * A class to create content for javadoc output pages.
++ *
++ * @author Bhavesh Patel
++ */
++public abstract class Content {
++
++    /**
++     * Returns a string representation of the content.
++     *
++     * @return string representation of the content
++     */
++    public String toString() {
++        StringBuilder contentBuilder = new StringBuilder();
++        write(contentBuilder);
++        return contentBuilder.toString();
++    }
++
++    /**
++     * Adds content to the existing content.
++     *
++     * @param content content that needs to be added
++     */
++    public abstract void addContent(Content content);
++
++    /**
++     * Adds a string content to the existing content.
++     *
++     * @param stringContent the string content to be added
++     */
++    public abstract void addContent(String stringContent);
++
++    /**
++     * Writes content to a StringBuilder.
++     *
++     */
++    public abstract void write(StringBuilder contentBuilder);
++
++    /**
++     * Returns true if the content is empty.
++     *
++     * @return true if no content to be displayed else return false
++     */
++    public abstract boolean isEmpty();
++
++    /**
++     * Returns true if the content is valid.
++     *
++     * @return true if the content is valid else return false
++     */
++    public boolean isValid() {
++        return !isEmpty();
++    }
++
++    /**
++     * Checks for null values.
++     *
++     * @param t reference type to check for null values
++     * @return the reference type if not null or else throws a null pointer exception
++     */
++    protected static <T> T nullCheck(T t) {
++        t.getClass();
++        return t;
++    }
++
++    /**
++     * Returns true if the content ends with a newline character. Empty content
++     * is considered as ending with new line.
++     *
++     * @param contentBuilder content to test for newline character at the end
++     * @return true if the content ends with newline.
++     */
++    public boolean endsWithNewLine(StringBuilder contentBuilder) {
++        return ((contentBuilder.length() == 0) ||
++                (contentBuilder.substring(contentBuilder.length() - 1).equals("\n")));
++    }
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/EnumConstantWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/EnumConstantWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/EnumConstantWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/EnumConstantWriter.java
+@@ -36,67 +36,80 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface EnumConstantWriter {
+ 
+     /**
+-     * Write the header for the enum constant documentation.
++     * Get the enum constants details tree header.
+      *
+-     * @param classDoc the class that the enum constants belong to.
+-     * @param header the header to write.
++     * @param classDoc the class being documented
++     * @param memberDetailsTree the content tree representing member details
++     * @return content tree for the enum constants details header
+      */
+-    public void writeHeader(ClassDoc classDoc, String header);
++    public Content getEnumConstantsDetailsTreeHeader(ClassDoc classDoc,
++            Content memberDetailsTree);
+ 
+     /**
+-     * Write the enum constant header for the given enum constant.
++     * Get the enum constants documentation tree header.
+      *
+-     * @param enumConstant the enum constant being documented.
+-     * @param isFirst the flag to indicate whether or not the enum constant is
+-     *                the first to be documented.
++     * @param enumConstant the enum constant being documented
++     * @param enumConstantDetailsTree the content tree representing enum constant details
++     * @return content tree for the enum constant documentation header
+      */
+-    public void writeEnumConstantHeader(FieldDoc enumConstant, boolean isFirst);
++    public Content getEnumConstantsTreeHeader(FieldDoc enumConstant,
++            Content enumConstantsDetailsTree);
+ 
+     /**
+-     * Write the signature for the given enum constant.
++     * Get the signature for the given enum constant.
+      *
+-     * @param enumConstant the enum constant being documented.
++     * @param enumConstant the enum constant being documented
++     * @return content tree for the enum constant signature
+      */
+-    public void writeSignature(FieldDoc enumConstant);
++    public Content getSignature(FieldDoc enumConstant);
+ 
+     /**
+-     * Write the deprecated output for the given enum constant.
++     * Add the deprecated output for the given enum constant.
+      *
+-     * @param enumConstant the enum constant being documented.
++     * @param enumConstant the enum constant being documented
++     * @param enumConstantsTree content tree to which the deprecated information will be added
+      */
+-    public void writeDeprecated(FieldDoc enumConstant);
++    public void addDeprecated(FieldDoc enumConstant, Content enumConstantsTree);
+ 
+     /**
+-     * Write the comments for the given enum constant.
++     * Add the comments for the given enum constant.
+      *
+-     * @param enumConstant the enum constant being documented.
++     * @param enumConstant the enum constant being documented
++     * @param enumConstantsTree the content tree to which the comments will be added
+      */
+-    public void writeComments(FieldDoc enumConstant);
++    public void addComments(FieldDoc enumConstant, Content enumConstantsTree);
+ 
+     /**
+-     * Write the tag output for the given enum constant.
++     * Add the tags for the given enum constant.
+      *
+-     * @param enumConstant the enum constant being documented.
++     * @param enumConstant the enum constant being documented
++     * @param enumConstantsTree the content tree to which the tags will be added
+      */
+-    public void writeTags(FieldDoc enumConstant);
++    public void addTags(FieldDoc enumConstant, Content enumConstantsTree);
+ 
+     /**
+-     * Write the enum constant footer.
++     * Get the enum constants details tree.
++     *
++     * @param memberDetailsTree the content tree representing member details
++     * @return content tree for the enum constant details
+      */
+-    public void writeEnumConstantFooter();
++    public Content getEnumConstantsDetails(Content memberDetailsTree);
+ 
+     /**
+-     * Write the footer for the enum constant documentation.
++     * Get the enum constants documentation.
+      *
+-     * @param classDoc the class that the enum constant belong to.
++     * @param enumConstantsTree the content tree representing enum constants documentation
++     * @param isLastContent true if the content to be added is the last content
++     * @return content tree for the enum constants documentation
+      */
+-    public void writeFooter(ClassDoc classDoc);
++    public Content getEnumConstants(Content enumConstantsTree, boolean isLastContent);
+ 
+     /**
+      * Close the writer.
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/FieldWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/FieldWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/FieldWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/FieldWriter.java
+@@ -36,67 +36,80 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface FieldWriter {
+ 
+     /**
+-     * Write the header for the field documentation.
++     * Get the field details tree header.
+      *
+-     * @param classDoc the class that the fields belong to.
+-     * @param header the header to write.
++     * @param classDoc the class being documented
++     * @param memberDetailsTree the content tree representing member details
++     * @return content tree for the field details header
+      */
+-    public void writeHeader(ClassDoc classDoc, String header);
++    public Content getFieldDetailsTreeHeader(ClassDoc classDoc,
++            Content memberDetailsTree);
+ 
+     /**
+-     * Write the field header for the given field.
++     * Get the field documentation tree header.
+      *
+-     * @param field the field being documented.
+-     * @param isFirst the flag to indicate whether or not the field is the
+-     *        first to be documented.
++     * @param field the constructor being documented
++     * @param fieldDetailsTree the content tree representing field details
++     * @return content tree for the field documentation header
+      */
+-    public void writeFieldHeader(FieldDoc field, boolean isFirst);
++    public Content getFieldDocTreeHeader(FieldDoc field,
++            Content fieldDetailsTree);
+ 
+     /**
+-     * Write the signature for the given field.
++     * Get the signature for the given field.
+      *
+-     * @param field the field being documented.
++     * @param field the field being documented
++     * @return content tree for the field signature
+      */
+-    public void writeSignature(FieldDoc field);
++    public Content getSignature(FieldDoc field);
+ 
+     /**
+-     * Write the deprecated output for the given field.
++     * Add the deprecated output for the given field.
+      *
+-     * @param field the field being documented.
++     * @param field the field being documented
++     * @param fieldDocTree content tree to which the deprecated information will be added
+      */
+-    public void writeDeprecated(FieldDoc field);
++    public void addDeprecated(FieldDoc field, Content fieldDocTree);
+ 
+     /**
+-     * Write the comments for the given field.
++     * Add the comments for the given field.
+      *
+-     * @param field the field being documented.
++     * @param field the field being documented
++     * @param fieldDocTree the content tree to which the comments will be added
+      */
+-    public void writeComments(FieldDoc field);
++    public void addComments(FieldDoc field, Content fieldDocTree);
+ 
+     /**
+-     * Write the tag output for the given field.
++     * Add the tags for the given field.
+      *
+-     * @param field the field being documented.
++     * @param field the field being documented
++     * @param fieldDocTree the content tree to which the tags will be added
+      */
+-    public void writeTags(FieldDoc field);
++    public void addTags(FieldDoc field, Content fieldDocTree);
+ 
+     /**
+-     * Write the field footer.
++     * Get the field details tree.
++     *
++     * @param memberDetailsTree the content tree representing member details
++     * @return content tree for the field details
+      */
+-    public void writeFieldFooter();
++    public Content getFieldDetails(Content memberDetailsTree);
+ 
+     /**
+-     * Write the footer for the field documentation.
++     * Get the field documentation.
+      *
+-     * @param classDoc the class that the fields belong to.
++     * @param fieldDocTree the content tree representing field documentation
++     * @param isLastContent true if the content to be added is the last content
++     * @return content tree for the field documentation
+      */
+-    public void writeFooter(ClassDoc classDoc);
++    public Content getFieldDoc(Content fieldDocTree, boolean isLastContent);
+ 
+     /**
+      * Close the writer.
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MemberSummaryWriter.java
+@@ -26,6 +26,7 @@
+ package com.sun.tools.doclets.internal.toolkit;
+ 
+ import java.io.*;
++import java.util.*;
+ import com.sun.javadoc.*;
+ 
+ /**
+@@ -36,61 +37,77 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface MemberSummaryWriter {
+ 
+     /**
+-     * Write the member summary header for the given class.
++     * Get the member summary header for the given class.
+      *
+-     * @param classDoc the class the summary belongs to.
++     * @param classDoc the class the summary belongs to
++     * @param memberSummaryTree the content tree to which the member summary will be added
++     * @return a content tree for the member summary header
+      */
+-    public void writeMemberSummaryHeader(ClassDoc classDoc);
++    public Content getMemberSummaryHeader(ClassDoc classDoc,
++            Content memberSummaryTree);
+ 
+     /**
+-     * Write the member summary for the given class and member.
++     * Get the summary table for the given class.
+      *
+-     * @param classDoc the class the summary belongs to.
+-     * @param member the member that I am summarizing.
+-     * @param firstSentenceTags the tags for the sentence being documented.
+-     * @param isFirst true if this is the first member in the list.
+-     * @param isLast true if this the last member being documented.
++     * @param classDoc the class the summary table belongs to
++     * @return a content tree for the member summary table
+      */
+-    public void writeMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
+-        Tag[] firstSentenceTags, boolean isFirst, boolean isLast);
++    public Content getSummaryTableTree(ClassDoc classDoc);
+ 
+     /**
+-     * Write the member summary footer for the given class.
++     * Add the member summary for the given class and member.
+      *
+-     * @param classDoc the class the summary belongs to.
++     * @param classDoc the class the summary belongs to
++     * @param member the member that is documented
++     * @param firstSentenceTags the tags for the sentence being documented
++     * @param tableTree the content treeto which the information will be added
++     * @param counter the counter for determing style for the table row
+      */
+-    public void writeMemberSummaryFooter(ClassDoc classDoc);
++    public void addMemberSummary(ClassDoc classDoc, ProgramElementDoc member,
++        Tag[] firstSentenceTags, Content tableTree, int counter);
+ 
+     /**
+-     * Write the inherited member summary header for the given class.
++     * Get the inherited member summary header for the given class.
+      *
+-     * @param classDoc the class the summary belongs to.
++     * @param classDoc the class the summary belongs to
++     * @return a content tree containing the inherited summary header
+      */
+-    public void writeInheritedMemberSummaryHeader(ClassDoc classDoc);
++    public Content getInheritedSummaryHeader(ClassDoc classDoc);
+ 
+     /**
+-     * Write the inherited member summary for the given class and member.
++     * Add the inherited member summary for the given class and member.
+      *
+-     * @param classDoc the class the inherited member belongs to.
+-     * @param member   the inherited member that I am summarizing.
+-     * @param isFirst  true if this is the first member in the list.
+-     * @param isLast   true if this is the last member in the list.
++     * @param classDoc the class the inherited member belongs to
++     * @param member the inherited member that is being documented
++     * @param isFirst true if this is the first member in the list
++     * @param isLast true if this is the last member in the list
++     * @param linksTree the content tree to which the links will be added
+      */
+-    public void writeInheritedMemberSummary(ClassDoc classDoc,
+-        ProgramElementDoc member, boolean isFirst, boolean isLast);
++    public void addInheritedMemberSummary(ClassDoc classDoc,
++        ProgramElementDoc member, boolean isFirst, boolean isLast,
++        Content linksTree);
+ 
+     /**
+-     * Write the inherited member summary footer for the given class.
++     * Get inherited summary links.
+      *
+-     * @param classDoc the class the summary belongs to.
++     * @return a content tree conatining the inherited summary links
+      */
+-    public void writeInheritedMemberSummaryFooter(ClassDoc classDoc);
++    public Content getInheritedSummaryLinksTree();
++
++    /**
++     * Get the member tree.
++     *
++     * @param memberTree the content tree representating the member
++     * @return a content tree for the member
++     */
++    public Content getMemberTree(Content memberTree);
+ 
+     /**
+      * Close the writer.
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/MethodWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/MethodWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MethodWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/MethodWriter.java
+@@ -36,68 +36,81 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface MethodWriter {
+ 
+     /**
+-     * Write the header for the method documentation.
++     * Get the method details tree header.
+      *
+-     * @param classDoc the class that the methods belong to.
+-     * @param header the header to write.
++     * @param classDoc the class being documented
++     * @param memberDetailsTree the content tree representing member details
++     * @return content tree for the method details header
+      */
+-    public void writeHeader(ClassDoc classDoc, String header);
++    public Content getMethodDetailsTreeHeader(ClassDoc classDoc,
++            Content memberDetailsTree);
+ 
+     /**
+-     * Write the method header for the given method.
++     * Get the method documentation tree header.
+      *
+-     * @param method the method being documented.
+-     * @param isFirst the flag to indicate whether or not the method is the
+-     *        first to be documented.
++     * @param method the method being documented
++     * @param methodDetailsTree the content tree representing method details
++     * @return content tree for the method documentation header
+      */
+-    public void writeMethodHeader(MethodDoc method, boolean isFirst);
++    public Content getMethodDocTreeHeader(MethodDoc method,
++            Content methodDetailsTree);
+ 
+     /**
+-     * Write the signature for the given method.
++     * Get the signature for the given method.
+      *
+-     * @param method the method being documented.
++     * @param method the method being documented
++     * @return content tree for the method signature
+      */
+-    public void writeSignature(MethodDoc method);
++    public Content getSignature(MethodDoc method);
+ 
+     /**
+-     * Write the deprecated output for the given method.
++     * Add the deprecated output for the given method.
+      *
+-     * @param method the method being documented.
++     * @param method the method being documented
++     * @param methodDocTree content tree to which the deprecated information will be added
+      */
+-    public void writeDeprecated(MethodDoc method);
++    public void addDeprecated(MethodDoc method, Content methodDocTree);
+ 
+     /**
+-     * Write the comments for the given method.
++     * Add the comments for the given method.
+      *
+-     * @param holder the holder type (not erasure) of the method.
+-     * @param method the method being documented.
++     * @param holder the holder type (not erasure) of the method
++     * @param method the method being documented
++     * @param methodDocTree the content tree to which the comments will be added
+      */
+-    public void writeComments(Type holder, MethodDoc method);
++    public void addComments(Type holder, MethodDoc method, Content methodDocTree);
+ 
+     /**
+-     * Write the tag output for the given method.
++     * Add the tags for the given method.
+      *
+-     * @param method the method being documented.
++     * @param method the method being documented
++     * @param methodDocTree the content tree to which the tags will be added
+      */
+-    public void writeTags(MethodDoc method);
++    public void addTags(MethodDoc method, Content methodDocTree);
+ 
+     /**
+-     * Write the method footer.
++     * Get the method details tree.
++     *
++     * @param methodDetailsTree the content tree representing method details
++     * @return content tree for the method details
+      */
+-    public void writeMethodFooter();
++    public Content getMethodDetails(Content methodDetailsTree);
+ 
+     /**
+-     * Write the footer for the method documentation.
++     * Get the method documentation.
+      *
+-     * @param classDoc the class that the methods belong to.
++     * @param methodDocTree the content tree representing method documentation
++     * @param isLastContent true if the content to be added is the last content
++     * @return content tree for the method documentation
+      */
+-    public void writeFooter(ClassDoc classDoc);
++    public Content getMethodDoc(Content methodDocTree, boolean isLastContent);
+ 
+     /**
+      * Close the writer.
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/NestedClassWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/NestedClassWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/NestedClassWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/NestedClassWriter.java
+@@ -26,7 +26,6 @@
+ package com.sun.tools.doclets.internal.toolkit;
+ 
+ import java.io.*;
+-import com.sun.javadoc.*;
+ 
+ /**
+  * The interface for writing class output.
+@@ -36,59 +35,13 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+ public interface NestedClassWriter {
+ 
+     /**
+-     * Write the classes summary header for the given class.
+-     *
+-     * @param nestedClass the class the summary belongs to.
+-     */
+-    public void writeNestedClassSummaryHeader(ClassDoc nestedClass);
+-
+-    /**
+-     * Write the class summary for the given class and class.
+-     *
+-     * @param classDoc the class the summary belongs to.
+-     * @param nestedClass the nested class that I am summarizing.
+-     */
+-    public void writeNestedClassSummary(ClassDoc classDoc, ClassDoc nestedClass);
+-
+-    /**
+-     * Write the classes summary footer for the given class.
+-     *
+-     * @param nestedClass the class the summary belongs to.
+-     */
+-    public void writeNestedClassSummaryFooter(ClassDoc nestedClass);
+-
+-    /**
+-     * Write the inherited classes summary header for the given class.
+-     *
+-     * @param nestedClass the class the summary belongs to.
+-     */
+-    public void writeInheritedNestedClassSummaryHeader(ClassDoc nestedClass);
+-
+-    /**
+-     * Write the inherited nested class summary for the given class and nested
+-     * class.
+-     *
+-     * @param classDoc the class the inherited nested class belongs to.
+-     * @param nestedClass the inherited nested class that I am summarizing.
+-     * @param isFirst true if this is the first member in the list.
+-     */
+-    public void writeInheritedNestedClassSummary(ClassDoc classDoc,
+-            ClassDoc nestedClass, boolean isFirst);
+-
+-    /**
+-     * Write the inherited classes summary footer for the given class.
+-     *
+-     * @param nestedClass the class the summary belongs to.
+-     */
+-    public void writeInheritedNestedClassSummaryFooter(ClassDoc nestedClass);
+-
+-    /**
+      * Close the writer.
+      */
+     public void close() throws IOException;
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/PackageSummaryWriter.java
+@@ -36,6 +36,7 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ 
+@@ -49,45 +50,70 @@
+     public abstract String getOutputFileName();
+ 
+     /**
+-     * Write the header for the package summary.
++     * Get the header for the summary.
++     *
++     * @param heading Package name.
++     * @return the header to be added to the content tree
+      */
+-    public abstract void writeSummaryHeader();
++    public abstract Content getPackageHeader(String heading);
+ 
+     /**
+-     * Write the footer for the package summary.
++     * Get the header for the package content.
++     *
++     * @return a content tree for the package content header
+      */
+-    public abstract void writeSummaryFooter();
++    public abstract Content getContentHeader();
+ 
+     /**
+-     * Write the table of classes in this package.
++     * Get the header for the package summary.
++     *
++     * @return a content tree with the package summary header
++     */
++    public abstract Content getSummaryHeader();
++
++    /**
++     * Adds the table of classes to the documentation tree.
+      *
+      * @param classes the array of classes to document.
+      * @param label the label for this table.
++     * @param tableSummary the summary string for the table
++     * @param tableHeader array of table headers
++     * @param summaryContentTree the content tree to which the summaries will be added
+      */
+-    public abstract void writeClassesSummary(ClassDoc[] classes, String label, String tableSummary, String[] tableHeader);
++    public abstract void addClassesSummary(ClassDoc[] classes, String label,
++            String tableSummary, String[] tableHeader, Content summaryContentTree);
+ 
+     /**
+-     * Write the header for the summary.
++     * Adds the package description from the "packages.html" file to the documentation
++     * tree.
+      *
+-     * @param heading Package name.
++     * @param packageContentTree the content tree to which the package description
++     *                           will be added
+      */
+-    public abstract void writePackageHeader(String heading);
++    public abstract void addPackageDescription(Content packageContentTree);
+ 
+     /**
+-     * Print the package description from the "packages.html" file.
++     * Adds the tag information from the "packages.html" file to the documentation
++     * tree.
++     *
++     * @param packageContentTree the content tree to which the package tags will
++     *                           be added
+      */
+-    public abstract void writePackageDescription();
++    public abstract void addPackageTags(Content packageContentTree);
+ 
+     /**
+-     * Print the tag information from the "packages.html" file.
++     * Adds the footer to the documentation tree.
++     *
++     * @param contentTree the tree to which the footer will be added
+      */
+-    public abstract void writePackageTags();
++    public abstract void addPackageFooter(Content contentTree);
+ 
+     /**
+-     * Write the footer for the summary.
++     * Print the package summary document.
+      *
++     * @param contentTree the content tree that will be printed
+      */
+-    public abstract void writePackageFooter();
++    public abstract void printDocument(Content contentTree);
+ 
+     /**
+      * Close the writer.
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/SerializedFormWriter.java
+@@ -43,33 +43,73 @@
+ public interface SerializedFormWriter {
+ 
+     /**
+-     * Write the given header.
++     * Get the header.
+      *
+      * @param header the header to write.
++     * @return the header content tree
+      */
+-    public void writeHeader(String header);
++    public Content getHeader(String header);
+ 
+     /**
+-     * Write the given package header.
++     * Get the serialized form summaries header.
+      *
+-     * @param packageName the package header to write.
++     * @return the serialized form summary header tree
+      */
+-    public void writePackageHeader(String packageName);
++    public Content getSerializedSummariesHeader();
+ 
+     /**
+-     * Write the heading for the serializable class.
++     * Get the package serialized form header.
+      *
+-     * @param classDoc the class being processed.
++     * @return the package serialized form header tree
+      */
+-    public void writeClassHeader(ClassDoc classDoc);
++    public Content getPackageSerializedHeader();
+ 
+     /**
+-     * Write the serial UID info.
++     * Get the given package header.
++     *
++     * @param packageName the package header to write
++     * @return a content tree for the package header
++     */
++    public Content getPackageHeader(String packageName);
++
++    /**
++     * Get the serialized class header.
++     *
++     * @return a content tree for the serialized class header
++     */
++    public Content getClassSerializedHeader();
++
++    /**
++     * Get the heading for the serializable class.
++     *
++     * @param classDoc the class being processed
++     * @return a content tree for the class heading
++     */
++    public Content getClassHeader(ClassDoc classDoc);
++
++    /**
++     * Get the serial UID info header.
++     *
++     * @return a content tree for the serial uid info header
++     */
++    public Content getSerialUIDInfoHeader();
++
++    /**
++     * Adds the serial UID info.
+      *
+      * @param header the header that will show up before the UID.
+      * @param serialUID the serial UID to print.
++     * @param serialUidTree the serial UID tree to which the content will be added.
+      */
+-    public void writeSerialUIDInfo(String header, String serialUID);
++    public void addSerialUIDInfo(String header, String serialUID,
++            Content serialUidTree);
++
++    /**
++     * Get the class serialize content header.
++     *
++     * @return a content tree for the class serialize content header
++     */
++    public Content getClassContentHeader();
+ 
+     /**
+      * Return an instance of a SerialFieldWriter.
+@@ -91,9 +131,26 @@
+     public abstract void close() throws IOException;
+ 
+     /**
+-     * Write the footer.
++     * Get the serialized content.
++     *
++     * @param serializedTreeContent content for serialized data
++     * @return a content tree for serialized information
+      */
+-    public void writeFooter();
++    public Content getSerializedContent(Content serializedTreeContent);
++
++    /**
++     * Add the footer.
++     *
++     * @param serializedTree the serialized tree to be added
++     */
++    public void addFooter(Content serializedTree);
++
++    /**
++     * Print the serialized form document.
++     *
++     * @param serializedTree the content tree that will be printed
++     */
++    public abstract void printDocument(Content serializedTree);
+ 
+     /**
+      * Write the serialized form for a given field.
+@@ -101,56 +158,73 @@
+     public interface SerialFieldWriter {
+ 
+         /**
+-         * Write the given heading.
++         * Get the serializable field header.
++         *
++         * @return serialized fields header content tree
++         */
++        public Content getSerializableFieldsHeader();
++
++        /**
++         * Get the field content header.
++         *
++         * @param isLastContent true if this is the last content to be documented
++         * @return fields header content tree
++         */
++        public Content getFieldsContentHeader(boolean isLastContent);
++
++        /**
++         * Get the fields content.
+          *
+          * @param heading the heading to write.
++         * @param contentTree content tree to which the heading will be added
++         * @return serializable fields content tree
+          */
+-        public void writeHeader(String heading);
++        public Content getSerializableFields(String heading, Content contentTree);
+ 
+         /**
+-         * Write the deprecated information for this member.
++         * Adds the deprecated information for this member.
+          *
+          * @param field the field to document.
++         * @param contentTree content tree to which the deprecated information will be added
+          */
+-        public void writeMemberDeprecatedInfo(FieldDoc field);
++        public void addMemberDeprecatedInfo(FieldDoc field, Content contentTree);
+ 
+         /**
+-         * Write the description text for this member.
++         * Adds the description text for this member.
+          *
+          * @param field the field to document.
++         * @param contentTree content tree to which the member description will be added
+          */
+-        public void writeMemberDescription(FieldDoc field);
++        public void addMemberDescription(FieldDoc field, Content contentTree);
+ 
+         /**
+-         * Write the description text for this member represented by the tag.
++         * Adds the description text for this member represented by the tag.
+          *
+          * @param serialFieldTag the field to document (represented by tag).
++         * @param contentTree content tree to which the member description will be added
+          */
+-        public void writeMemberDescription(SerialFieldTag serialFieldTag);
++        public void addMemberDescription(SerialFieldTag serialFieldTag, Content contentTree);
+ 
+         /**
+-         * Write the tag information for this member.
++         * Adds the tag information for this member.
+          *
+          * @param field the field to document.
++         * @param contentTree content tree to which the member tags will be added
+          */
+-        public void writeMemberTags(FieldDoc field);
++        public void addMemberTags(FieldDoc field, Content contentTree);
+ 
+         /**
+-         * Write the member header.
++         * Adds the member header.
+          *
+          * @param fieldType the type of the field.
+          * @param fieldTypeStr the type of the field in string format.  We will
+          * print this out if we can't link to the type.
+          * @param fieldDimensions the dimensions of the field.
+          * @param fieldName the name of the field.
++         * @param contentTree content tree to which the member header will be added
+          */
+-        public void writeMemberHeader(ClassDoc fieldType, String fieldTypeStr,
+-            String fieldDimensions, String fieldName);
+-
+-        /**
+-         * Write the member footer.
+-         */
+-        public void writeMemberFooter();
++        public void addMemberHeader(ClassDoc fieldType, String fieldTypeStr,
++            String fieldDimensions, String fieldName, Content contentTree);
+ 
+         /**
+          * Check to see if overview details should be printed. If
+@@ -162,13 +236,6 @@
+          * @return true if overview details need to be printed
+          */
+         public boolean shouldPrintOverview(FieldDoc field);
+-
+-        /**
+-         * Write the footer.
+-         *
+-         * @param heading the heading that was written.
+-         */
+-        public void writeFooter (String heading);
+     }
+ 
+     /**
+@@ -177,44 +244,70 @@
+     public interface SerialMethodWriter {
+ 
+         /**
++         * Get the serializable method header.
++         *
++         * @return serializable methods content tree
++         */
++        public Content getSerializableMethodsHeader();
++
++        /**
++         * Get the method content header.
++         *
++         * @param isLastContent true if this is the last content to be documented
++         * @return methods content tree
++         */
++        public Content getMethodsContentHeader(boolean isLastContent);
++
++        /**
+          * Write the given heading.
+          *
+-         * @param heading the heading to write.
++         * @param heading the heading to write
++         * @param serializableMethodTree content tree which will be added
++         * @return serializable methods content tree
+          */
+-        public void writeHeader(String heading);
++        public Content getSerializableMethods(String heading, Content serializableMethodTree);
+ 
+         /**
+          * Write a warning that no serializable methods exist.
+          *
+-         * @param msg the warning to print.
++         * @param msg the warning to print
++         * @return no customization message tree
+          */
+-        public void writeNoCustomizationMsg(String msg);
++        public Content getNoCustomizationMsg(String msg);
+ 
+         /**
+-         * Write the header.
++         * Adds the header.
+          *
+-         * @param member the member to write the header for.
++         * @param member the member to write the header for
++         * @param methodsContentTree content tree to which the header will be added
+          */
+-        public void writeMemberHeader(MethodDoc member);
++        public void addMemberHeader(MethodDoc member, Content methodsContentTree);
+ 
+         /**
+-         * Write the footer.
++         * Adds the deprecated information for this member.
++         *
++         * @param member the member to write the deprecated information for
++         * @param methodsContentTree content tree to which the deprecated
++         * information will be added
+          */
+-        public void writeMemberFooter();
++        public void addDeprecatedMemberInfo(MethodDoc member, Content methodsContentTree);
+ 
+         /**
+-         * Write the deprecated information for this member.
++         * Adds the description for this member.
++         *
++         * @param member the member to write the information for
++         * @param methodsContentTree content tree to which the member
++         * information will be added
+          */
+-        public void writeDeprecatedMemberInfo(MethodDoc member);
++        public void addMemberDescription(MethodDoc member, Content methodsContentTree);
+ 
+         /**
+-         * Write the description for this member.
++         * Adds the tag information for this member.
++         *
++         * @param member the member to write the tags information for
++         * @param methodsContentTree content tree to which the tags
++         * information will be added
+          */
+-        public void writeMemberDescription(MethodDoc member);
+-
+-        /**
+-         * Write the tag information for this member.
+-         */
+-        public void writeMemberTags(MethodDoc member);
++        public void addMemberTags(MethodDoc member, Content methodsContentTree);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
+@@ -95,13 +95,14 @@
+      * Build the documentation, as specified by the given XML element.
+      *
+      * @param node the XML element that specifies which component to document.
++     * @param contentTree content tree to which the documentation will be added
+      */
+     protected void build(XMLNode node) {
+         String component = node.name;
+         try {
+             invokeMethod("build" + component,
+-                    new Class<?>[] { XMLNode.class },
+-                    new Object[] { node });
++                    new Class<?>[]{XMLNode.class, Content.class},
++                    new Object[]{node, contentTree});
+         } catch (NoSuchMethodException e) {
+             e.printStackTrace();
+             configuration.root.printError("Unknown element: " + component);
+@@ -111,8 +112,8 @@
+         } catch (Exception e) {
+             e.printStackTrace();
+             configuration.root.printError("Exception " +
+-                e.getClass().getName() +
+-                " thrown while processing element: " + component);
++                    e.getClass().getName() +
++                    " thrown while processing element: " + component);
+             throw new DocletAbortException();
+         }
+     }
+@@ -121,10 +122,11 @@
+      * Build the documentation, as specified by the children of the given XML element.
+      *
+      * @param node the XML element that specifies which components to document.
++     * @param contentTree content tree to which the documentation will be added
+      */
+-    protected void buildChildren(XMLNode node) {
+-        for (XMLNode child: node.children)
+-            build(child);
++    protected void buildChildren(XMLNode node, Content contentTree) {
++        for (XMLNode child : node.children)
++            build(child, contentTree);
+     }
+ 
+     /**
+@@ -140,8 +142,7 @@
+              Object[] params)
+     throws Exception {
+         if (DEBUG) {
+-            configuration.root.printError("DEBUG: " + this.getClass().getName()
+-                + "." + methodName);
++            configuration.root.printError("DEBUG: " + this.getClass().getName() + "." + methodName);
+         }
+         Method method = this.getClass().getMethod(methodName, paramClasses);
+         method.invoke(this, params);
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
+@@ -27,6 +27,7 @@
+ 
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
++import java.util.*;
+ 
+ /**
+  * The superclass for all member builders.  Member builders are only executed
+@@ -66,12 +67,13 @@
+     /**
+      * Build the sub component if there is anything to document.
+      *
+-     * @param elements {@inheritDoc}
++     * @param node the XML element that specifies which components to document.
++     * @param contentTree content tree to which the documentation will be added
+      */
+     @Override
+-    public void build(XMLNode node) {
++    public void build(XMLNode node, Content contentTree) {
+         if (hasMembersToDocument()) {
+-            super.build(node);
++            super.build(node, contentTree);
+         }
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,11 +25,11 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
++import java.io.*;
++import java.util.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+-import java.io.*;
+-import java.util.*;
+ 
+ /**
+  * Builds the summary for a given annotation type.
+@@ -39,6 +39,7 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class AnnotationTypeBuilder extends AbstractBuilder {
+@@ -59,6 +60,11 @@
+     private AnnotationTypeWriter writer;
+ 
+     /**
++     * The content tree for the annotation documentation.
++     */
++    private Content contentTree;
++
++    /**
+      * Construct a new ClassBuilder.
+      *
+      * @param configuration the current configuration of the
+@@ -83,7 +89,7 @@
+         builder.annotationTypeDoc = annotationTypeDoc;
+         builder.writer = writer;
+         if(containingPackagesSeen == null) {
+-            containingPackagesSeen = new HashSet();
++            containingPackagesSeen = new HashSet<String>();
+         }
+         return builder;
+     }
+@@ -92,7 +98,7 @@
+      * {@inheritDoc}
+      */
+     public void build() throws IOException {
+-        build(LayoutParser.getInstance(configuration).parseXML(ROOT));
++        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+     }
+ 
+     /**
+@@ -102,18 +108,24 @@
+         return ROOT;
+     }
+ 
+-     /**
+-      * Handles the &lt;AnnotationTypeDoc> tag.
++    /**
++      * Build the annotation type documentation.
+       *
+-      * @param elements the XML elements that specify how to document a class.
++      * @param node the XML element that specifies which components to document
++      * @param contentTree the content tree to which the documentation will be added
+       */
+-     public void buildAnnotationTypeDoc(XMLNode node) throws Exception {
+-        buildChildren(node);
+-        writer.close();
+-        copyDocFiles();
++     public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws Exception {
++        contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") +
++                " " + annotationTypeDoc.name());
++        Content annotationContentTree = writer.getAnnotationContentHeader();
++         buildChildren(node, annotationContentTree);
++         contentTree.addContent(annotationContentTree);
++         writer.addFooter(contentTree);
++         writer.printDocument(contentTree);
++         writer.close();
++         copyDocFiles();
+      }
+ 
+-
+      /**
+       * Copy the doc files for the current ClassDoc if necessary.
+       */
+@@ -137,86 +149,112 @@
+      }
+ 
+     /**
+-     * Build the header of the page.
++     * Build the annotation information tree documentation.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationContentTree the content tree to which the documentation will be added
+      */
+-    public void buildAnnotationTypeHeader(XMLNode node) {
+-        writer.writeHeader(configuration.getText("doclet.AnnotationType") +
+-            " " + annotationTypeDoc.name());
++    public void buildAnnotationTypeInfo(XMLNode node, Content annotationContentTree) {
++        Content annotationInfoTree = writer.getAnnotationInfoTreeHeader();
++        buildChildren(node, annotationInfoTree);
++        annotationContentTree.addContent(writer.getAnnotationInfo(annotationInfoTree));
+     }
+ 
+     /**
+-     * If this class is deprecated, print the appropriate information.
++     * If this annotation is deprecated, build the appropriate information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationInfoTree the content tree to which the documentation will be added
+      */
+-    public void buildDeprecationInfo (XMLNode node) {
+-        writer.writeAnnotationTypeDeprecationInfo();
++    public void buildDeprecationInfo (XMLNode node, Content annotationInfoTree) {
++        writer.addAnnotationTypeDeprecationInfo(annotationInfoTree);
+     }
+ 
+     /**
+      * Build the signature of the current annotation type.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationInfoTree the content tree to which the documentation will be added
+      */
+-    public void buildAnnotationTypeSignature(XMLNode node) {
++    public void buildAnnotationTypeSignature(XMLNode node, Content annotationInfoTree) {
+         StringBuffer modifiers = new StringBuffer(
+-            annotationTypeDoc.modifiers() + " ");
+-        writer.writeAnnotationTypeSignature(
+-            Util.replaceText(
+-                modifiers.toString(), "interface", "@interface"));
++                annotationTypeDoc.modifiers() + " ");
++        writer.addAnnotationTypeSignature(Util.replaceText(
++                modifiers.toString(), "interface", "@interface"), annotationInfoTree);
+     }
+ 
+     /**
+-     * Build the class description.
++     * Build the annotation type description.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationInfoTree the content tree to which the documentation will be added
+      */
+-    public void buildAnnotationTypeDescription(XMLNode node) {
+-       writer.writeAnnotationTypeDescription();
++    public void buildAnnotationTypeDescription(XMLNode node, Content annotationInfoTree) {
++        writer.addAnnotationTypeDescription(annotationInfoTree);
+     }
+ 
+     /**
+-     * Build the tag information for the current class.
++     * Build the tag information for the current annotation type.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationInfoTree the content tree to which the documentation will be added
+      */
+-    public void buildAnnotationTypeTagInfo(XMLNode node) {
+-       writer.writeAnnotationTypeTagInfo();
++    public void buildAnnotationTypeTagInfo(XMLNode node, Content annotationInfoTree) {
++        writer.addAnnotationTypeTagInfo(annotationInfoTree);
+     }
+ 
+     /**
+-     * Build the contents of the page.
++     * Build the member summary contents of the page.
+      *
+-     * @param elements the XML elements that specify how a member summary is
+-     *                 documented.
++     * @param node the XML element that specifies which components to document
++     * @param annotationContentTree the content tree to which the documentation will be added
+      */
+-    public void buildMemberSummary(XMLNode node) throws Exception {
++    public void buildMemberSummary(XMLNode node, Content annotationContentTree)
++            throws Exception {
++        Content memberSummaryTree = writer.getMemberTreeHeader();
+         configuration.getBuilderFactory().
+-            getMemberSummaryBuilder(writer).buildChildren(node);
+-        writer.completeMemberSummaryBuild();
++                getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree);
++        annotationContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree));
++    }
++
++    /**
++     * Build the member details contents of the page.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationContentTree the content tree to which the documentation will be added
++     */
++    public void buildAnnotationTypeMemberDetails(XMLNode node, Content annotationContentTree) {
++        Content memberDetailsTree = writer.getMemberTreeHeader();
++        buildChildren(node, memberDetailsTree);
++        if (memberDetailsTree.isValid()) {
++            Content memberDetails = writer.getMemberTreeHeader();
++            writer.addAnnotationDetailsMarker(memberDetails);
++            memberDetails.addContent(writer.getMemberTree(memberDetailsTree));
++            annotationContentTree.addContent(writer.getMemberDetailsTree(memberDetails));
++        }
+     }
+ 
+     /**
+      * Build the annotation type optional member documentation.
+      *
+-     * @param elements the XML elements that specify how a annotation type
+-     *                 members are documented.
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
+      */
+-    public void buildAnnotationTypeOptionalMemberDetails(XMLNode node)
+-    throws Exception {
++    public void buildAnnotationTypeOptionalMemberDetails(XMLNode node, Content memberDetailsTree)
++            throws Exception {
+         configuration.getBuilderFactory().
+-            getAnnotationTypeOptionalMemberBuilder(writer).buildChildren(node);
++                getAnnotationTypeOptionalMemberBuilder(writer).buildChildren(node, memberDetailsTree);
+     }
+ 
+     /**
+      * Build the annotation type required member documentation.
+      *
+-     * @param elements the XML elements that specify how a annotation type
+-     *                 members are documented.
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
+      */
+-    public void buildAnnotationTypeRequiredMemberDetails(XMLNode node)
+-    throws Exception {
++    public void buildAnnotationTypeRequiredMemberDetails(XMLNode node, Content memberDetailsTree)
++            throws Exception {
+         configuration.getBuilderFactory().
+-            getAnnotationTypeRequiredMemberBuilder(writer).buildChildren(node);
+-    }
+-
+-
+-    /**
+-     * Build the footer of the page.
+-     */
+-    public void buildAnnotationTypeFooter(XMLNode node) {
+-        writer.writeFooter();
++                getAnnotationTypeRequiredMemberBuilder(writer).buildChildren(node, memberDetailsTree);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
+@@ -25,11 +25,10 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
+-
++import java.util.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+-import java.util.*;
+ 
+ /**
+  * Builds documentation for optional annotation type members.
+@@ -39,6 +38,7 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class AnnotationTypeOptionalMemberBuilder extends
+@@ -90,27 +90,25 @@
+     }
+ 
+     /**
+-     * Build the member documentation.
++     * Build the annotation type optional member documentation.
+      *
+-     * @param elements the XML elements that specify how to construct this
+-     *                documentation.
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
+      */
+-    public void buildAnnotationTypeOptionalMember(XMLNode node) {
+-        if (writer == null) {
+-            return;
+-        }
+-        for (currentMemberIndex = 0; currentMemberIndex < members.size();
+-            currentMemberIndex++) {
+-            buildChildren(node);
+-        }
++    public void buildAnnotationTypeOptionalMember(XMLNode node, Content memberDetailsTree) {
++        buildAnnotationTypeMember(node, memberDetailsTree);
+     }
+ 
+     /**
+-     * Document the default value for this optional member.
++     * Build the default value for this optional member.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationDocTree the content tree to which the documentation will be added
+      */
+-    public void buildDefaultValueInfo(XMLNode node) {
+-        ((AnnotationTypeOptionalMemberWriter) writer).writeDefaultValueInfo(
+-            (MemberDoc) members.get(currentMemberIndex));
++    public void buildDefaultValueInfo(XMLNode node, Content annotationDocTree) {
++        ((AnnotationTypeOptionalMemberWriter) writer).addDefaultValueInfo(
++                (MemberDoc) members.get(currentMemberIndex),
++                annotationDocTree);
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
+@@ -25,11 +25,10 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
+-
++import java.util.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+-import java.util.*;
+ 
+ /**
+  * Builds documentation for required annotation type members.
+@@ -39,6 +38,7 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder {
+@@ -141,81 +141,86 @@
+     }
+ 
+     /**
++     * Build the annotation type required member documentation.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
++     */
++    public void buildAnnotationTypeRequiredMember(XMLNode node, Content memberDetailsTree) {
++        buildAnnotationTypeMember(node, memberDetailsTree);
++    }
++
++    /**
+      * Build the member documentation.
+      *
+-     * @param elements the XML elements that specify how to construct this
+-     *                documentation.
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
+      */
+-    public void buildAnnotationTypeRequiredMember(XMLNode node) {
++    public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree) {
+         if (writer == null) {
+             return;
+         }
+-        for (currentMemberIndex = 0; currentMemberIndex < members.size();
++        int size = members.size();
++        if (size > 0) {
++            writer.addAnnotationDetailsTreeHeader(
++                    classDoc, memberDetailsTree);
++            for (currentMemberIndex = 0; currentMemberIndex < size;
+             currentMemberIndex++) {
+-            buildChildren(node);
+-        }
+-    }
+-
+-    /**
+-     * Build the overall header.
+-     */
+-    public void buildHeader(XMLNode node) {
+-        writer.writeHeader(classDoc,
+-            configuration.getText("doclet.Annotation_Type_Member_Detail"));
+-    }
+-
+-    /**
+-     * Build the header for the individual members.
+-     */
+-    public void buildMemberHeader(XMLNode node) {
+-        writer.writeMemberHeader((MemberDoc) members.get(
+-                currentMemberIndex),
+-            currentMemberIndex == 0);
++                Content annotationDocTree = writer.getAnnotationDocTreeHeader(
++                        (MemberDoc) members.get(currentMemberIndex),
++                        memberDetailsTree);
++                buildChildren(node, annotationDocTree);
++                memberDetailsTree.addContent(writer.getAnnotationDoc(
++                        annotationDocTree, (currentMemberIndex == size - 1)));
++            } 
++       }
+     }
+ 
+     /**
+      * Build the signature.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationDocTree the content tree to which the documentation will be added
+      */
+-    public void buildSignature(XMLNode node) {
+-        writer.writeSignature((MemberDoc) members.get(currentMemberIndex));
++    public void buildSignature(XMLNode node, Content annotationDocTree) {
++        annotationDocTree.addContent(
++                writer.getSignature((MemberDoc) members.get(currentMemberIndex)));
+     }
+ 
+     /**
+      * Build the deprecation information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationDocTree the content tree to which the documentation will be added
+      */
+-    public void buildDeprecationInfo(XMLNode node) {
+-        writer.writeDeprecated((MemberDoc) members.get(currentMemberIndex));
++    public void buildDeprecationInfo(XMLNode node, Content annotationDocTree) {
++        writer.addDeprecated((MemberDoc) members.get(currentMemberIndex),
++                annotationDocTree);
+     }
+ 
+     /**
+      * Build the comments for the member.  Do nothing if
+      * {@link Configuration#nocomment} is set to true.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationDocTree the content tree to which the documentation will be added
+      */
+-    public void buildMemberComments(XMLNode node) {
++    public void buildMemberComments(XMLNode node, Content annotationDocTree) {
+         if(! configuration.nocomment){
+-            writer.writeComments((MemberDoc) members.get(currentMemberIndex));
++            writer.addComments((MemberDoc) members.get(currentMemberIndex),
++                    annotationDocTree);
+         }
+     }
+ 
+     /**
+      * Build the tag information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param annotationDocTree the content tree to which the documentation will be added
+      */
+-    public void buildTagInfo(XMLNode node) {
+-        writer.writeTags((MemberDoc) members.get(currentMemberIndex));
+-    }
+-
+-    /**
+-     * Build the footer for the individual member.
+-     */
+-    public void buildMemberFooter(XMLNode node) {
+-        writer.writeMemberFooter();
+-    }
+-
+-    /**
+-     * Build the overall footer.
+-     */
+-    public void buildFooter(XMLNode node) {
+-        writer.writeFooter(classDoc);
++    public void buildTagInfo(XMLNode node, Content annotationDocTree) {
++        writer.addTags((MemberDoc) members.get(currentMemberIndex),
++                annotationDocTree);
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
+@@ -25,11 +25,11 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
++import java.io.*;
++import java.util.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+-import java.io.*;
+-import java.util.*;
+ 
+ /**
+  * Builds the summary for a given class.
+@@ -39,6 +39,7 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class ClassBuilder extends AbstractBuilder {
+@@ -69,6 +70,11 @@
+     private boolean isEnum = false;
+ 
+     /**
++     * The content tree for the class documentation.
++     */
++    private Content contentTree;
++
++    /**
+      * Construct a new ClassBuilder.
+      *
+      * @param configuration the current configuration of the
+@@ -108,7 +114,7 @@
+      * {@inheritDoc}
+      */
+     public void build() throws IOException {
+-        build(LayoutParser.getInstance(configuration).parseXML(ROOT));
++        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+     }
+ 
+     /**
+@@ -121,121 +127,159 @@
+      /**
+       * Handles the &lt;ClassDoc> tag.
+       *
+-      * @param elements the XML elements that specify how to document a class.
++      * @param node the XML element that specifies which components to document
++      * @param contentTree the content tree to which the documentation will be added
+       */
+-     public void buildClassDoc(XMLNode node) throws Exception {
+-        buildChildren(node);
+-        writer.close();
+-        copyDocFiles();
++     public void buildClassDoc(XMLNode node, Content contentTree) throws Exception {
++         String key;
++         if (isInterface) {
++             key =  "doclet.Interface";
++         } else if (isEnum) {
++             key = "doclet.Enum";
++         } else {
++             key =  "doclet.Class";
++         }
++         contentTree = writer.getHeader(configuration.getText(key) + " " +
++                 classDoc.name());
++         Content classContentTree = writer.getClassContentHeader();
++         buildChildren(node, classContentTree);
++         contentTree.addContent(classContentTree);
++         writer.addFooter(contentTree);
++         writer.printDocument(contentTree);
++         writer.close();
++         copyDocFiles();
+      }
+ 
++     /**
++      * Build the class tree documentation.
++      *
++      * @param node the XML element that specifies which components to document
++      * @param classContentTree the content tree to which the documentation will be added
++      */
++    public void buildClassTree(XMLNode node, Content classContentTree) {
++        writer.addClassTree(classContentTree);
++    }
+ 
+-     /**
+-      * Copy the doc files for the current ClassDoc if necessary.
+-      */
++    /**
++     * Build the class information tree documentation.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classContentTree the content tree to which the documentation will be added
++     */
++    public void buildClassInfo(XMLNode node, Content classContentTree) {
++        Content classInfoTree = writer.getClassInfoTreeHeader();
++        buildChildren(node, classInfoTree);
++        classContentTree.addContent(writer.getClassInfo(classInfoTree));
++    }
++
++    /**
++     * Build the typeparameters of this class.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
++     */
++    public void buildTypeParamInfo(XMLNode node, Content classInfoTree) {
++        writer.addTypeParamInfo(classInfoTree);
++    }
++
++    /**
++     * If this is an interface, list all super interfaces.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
++     */
++    public void buildSuperInterfacesInfo(XMLNode node, Content classInfoTree) {
++        writer.addSuperInterfacesInfo(classInfoTree);
++    }
++
++    /**
++     * If this is a class, list all interfaces implemented by this class.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
++     */
++    public void buildImplementedInterfacesInfo(XMLNode node, Content classInfoTree) {
++        writer.addImplementedInterfacesInfo(classInfoTree);
++    }
++
++    /**
++     * List all the classes extend this one.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
++     */
++    public void buildSubClassInfo(XMLNode node, Content classInfoTree) {
++        writer.addSubClassInfo(classInfoTree);
++    }
++
++    /**
++     * List all the interfaces that extend this one.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
++     */
++    public void buildSubInterfacesInfo(XMLNode node, Content classInfoTree) {
++        writer.addSubInterfacesInfo(classInfoTree);
++    }
++
++    /**
++     * If this is an interface, list all classes that implement this interface.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
++     */
++    public void buildInterfaceUsageInfo(XMLNode node, Content classInfoTree) {
++        writer.addInterfaceUsageInfo(classInfoTree);
++    }
++
++    /**
++     * If this class is deprecated, build the appropriate information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
++     */
++    public void buildDeprecationInfo (XMLNode node, Content classInfoTree) {
++        writer.addClassDeprecationInfo(classInfoTree);
++    }
++
++    /**
++     * If this is an inner class or interface, list the enclosing class or interface.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
++     */
++    public void buildNestedClassInfo (XMLNode node, Content classInfoTree) {
++        writer.addNestedClassInfo(classInfoTree);
++    }
++
++    /**
++     * Copy the doc files for the current ClassDoc if necessary.
++     */
+      private void copyDocFiles() {
+         PackageDoc containingPackage = classDoc.containingPackage();
+         if((configuration.packages == null ||
+                 Arrays.binarySearch(configuration.packages,
+-                                    containingPackage) < 0) &&
+-           ! containingPackagesSeen.contains(containingPackage.name())){
++                containingPackage) < 0) &&
++                ! containingPackagesSeen.contains(containingPackage.name())){
+             //Only copy doc files dir if the containing package is not
+             //documented AND if we have not documented a class from the same
+             //package already. Otherwise, we are making duplicate copies.
+             Util.copyDocFiles(configuration,
+-                Util.getPackageSourcePath(configuration,
++                    Util.getPackageSourcePath(configuration,
+                     classDoc.containingPackage()) +
+-                DirectoryManager.getDirectoryPath(classDoc.containingPackage())
++                    DirectoryManager.getDirectoryPath(classDoc.containingPackage())
+                     + File.separator, DocletConstants.DOC_FILES_DIR_NAME, true);
+             containingPackagesSeen.add(containingPackage.name());
+         }
+      }
+ 
+     /**
+-     * Build the header of the page.
++     * Build the signature of the current class.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
+      */
+-    public void buildClassHeader(XMLNode node) {
+-        String key;
+-        if (isInterface) {
+-            key =  "doclet.Interface";
+-        } else if (isEnum) {
+-            key = "doclet.Enum";
+-        } else {
+-            key =  "doclet.Class";
+-        }
+-
+-        writer.writeHeader(configuration.getText(key) + " " + classDoc.name());
+-    }
+-
+-    /**
+-     * Build the class tree documentation.
+-     */
+-    public void buildClassTree(XMLNode node) {
+-        writer.writeClassTree();
+-    }
+-
+-    /**
+-     * If this is a class, list all interfaces
+-     * implemented by this class.
+-     */
+-    public void buildImplementedInterfacesInfo(XMLNode node) {
+-        writer.writeImplementedInterfacesInfo();
+-    }
+-
+-    /**
+-     * If this is an interface, list all super interfaces.
+-     */
+-    public void buildSuperInterfacesInfo(XMLNode node) {
+-        writer.writeSuperInterfacesInfo();
+-    }
+-
+-    /**
+-     * List the parameters of this class.
+-     */
+-    public void buildTypeParamInfo(XMLNode node) {
+-        writer.writeTypeParamInfo();
+-    }
+-
+-    /**
+-     * List all the classes extend this one.
+-     */
+-    public void buildSubClassInfo(XMLNode node) {
+-        writer.writeSubClassInfo();
+-    }
+-
+-    /**
+-     * List all the interfaces that extend this one.
+-     */
+-    public void buildSubInterfacesInfo(XMLNode node) {
+-        writer.writeSubInterfacesInfo();
+-    }
+-
+-    /**
+-     * If this is an interface, list all classes that implement this interface.
+-     */
+-    public void buildInterfaceUsageInfo (XMLNode node) {
+-        writer.writeInterfaceUsageInfo();
+-    }
+-
+-    /**
+-     * If this is an inner class or interface, list the enclosing class or
+-     * interface.
+-     */
+-    public void buildNestedClassInfo (XMLNode node) {
+-        writer.writeNestedClassInfo();
+-    }
+-
+-    /**
+-     * If this class is deprecated, print the appropriate information.
+-     */
+-    public void buildDeprecationInfo (XMLNode node) {
+-        writer.writeClassDeprecationInfo();
+-    }
+-
+-    /**
+-     * Build the signature of the current class.
+-     */
+-    public void buildClassSignature(XMLNode node) {
++    public void buildClassSignature(XMLNode node, Content classInfoTree) {
+         StringBuffer modifiers = new StringBuffer(classDoc.modifiers() + " ");
+         if (isEnum) {
+             modifiers.append("enum ");
+@@ -243,93 +287,111 @@
+             if ((index = modifiers.indexOf("abstract")) >= 0) {
+                 modifiers.delete(index, index + (new String("abstract")).length());
+                 modifiers = new StringBuffer(
+-                    Util.replaceText(modifiers.toString(), "  ", " "));
++                        Util.replaceText(modifiers.toString(), "  ", " "));
+             }
+             if ((index = modifiers.indexOf("final")) >= 0) {
+                 modifiers.delete(index, index + (new String("final")).length());
+                 modifiers = new StringBuffer(
+-                    Util.replaceText(modifiers.toString(), "  ", " "));
++                        Util.replaceText(modifiers.toString(), "  ", " "));
+             }
+         //} else if (classDoc.isAnnotationType()) {
+             //modifiers.append("@interface ");
+         } else if (! isInterface) {
+             modifiers.append("class ");
+         }
+-        writer.writeClassSignature(modifiers.toString());
++        writer.addClassSignature(modifiers.toString(), classInfoTree);
+     }
+ 
+     /**
+      * Build the class description.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
+      */
+-    public void buildClassDescription(XMLNode node) {
+-       writer.writeClassDescription();
++    public void buildClassDescription(XMLNode node, Content classInfoTree) {
++       writer.addClassDescription(classInfoTree);
+     }
+ 
+     /**
+      * Build the tag information for the current class.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classInfoTree the content tree to which the documentation will be added
+      */
+-    public void buildClassTagInfo(XMLNode node) {
+-       writer.writeClassTagInfo();
++    public void buildClassTagInfo(XMLNode node, Content classInfoTree) {
++       writer.addClassTagInfo(classInfoTree);
+     }
+ 
+     /**
+-     * Build the contents of the page.
++     * Build the member summary contents of the page.
+      *
+-     * @param elements the XML elements that specify how a member summary is
+-     *                 documented.
++     * @param node the XML element that specifies which components to document
++     * @param classContentTree the content tree to which the documentation will be added
+      */
+-    public void buildMemberSummary(List elements) throws Exception {
++    public void buildMemberSummary(XMLNode node, Content classContentTree) throws Exception {
++        Content memberSummaryTree = writer.getMemberTreeHeader();
+         configuration.getBuilderFactory().
+-            getMemberSummaryBuilder(writer).buildChildren(node);
+-        writer.completeMemberSummaryBuild();
++                getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree);
++        classContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree));
++    }
++
++    /**
++     * Build the member details contents of the page.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classContentTree the content tree to which the documentation will be added
++     */
++    public void buildMemberDetails(XMLNode node, Content classContentTree) {
++        Content memberDetailsTree = writer.getMemberTreeHeader();
++        buildChildren(node, memberDetailsTree);
++        classContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree));
+     }
+ 
+     /**
+      * Build the enum constants documentation.
+      *
+-     * @param elements the XML elements that specify how a enum constants are
+-     *                 documented.
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
+      */
+-    public void buildEnumConstantsDetails(XMLNode node) throws Exception {
++    public void buildEnumConstantsDetails(XMLNode node,
++            Content memberDetailsTree) throws Exception {
+         configuration.getBuilderFactory().
+-            getEnumConstantsBuilder(writer).buildChildren(node);
++                getEnumConstantsBuilder(writer).buildChildren(node, memberDetailsTree);
+     }
+ 
+     /**
+      * Build the field documentation.
+      *
+-     * @param elements the XML elements that specify how a field is documented.
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
+      */
+-    public void buildFieldDetails(XMLNode node) throws Exception {
++    public void buildFieldDetails(XMLNode node,
++            Content memberDetailsTree) throws Exception {
+         configuration.getBuilderFactory().
+-            getFieldBuilder(writer).buildChildren(node);
++                getFieldBuilder(writer).buildChildren(node, memberDetailsTree);
+     }
+ 
+     /**
+      * Build the constructor documentation.
+      *
+-     * @param elements the XML elements that specify how to document a
+-     * constructor.
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
+      */
+-    public void buildConstructorDetails(XMLNode node) throws Exception {
++    public void buildConstructorDetails(XMLNode node,
++            Content memberDetailsTree) throws Exception {
+         configuration.getBuilderFactory().
+-            getConstructorBuilder(writer).buildChildren(node);
++                getConstructorBuilder(writer).buildChildren(node, memberDetailsTree);
+     }
+ 
+     /**
+      * Build the method documentation.
+      *
+-     * @param elements the XML elements that specify how a method is documented.
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
+      */
+-    public void buildMethodDetails(XMLNode node) throws Exception {
++    public void buildMethodDetails(XMLNode node,
++            Content memberDetailsTree) throws Exception {
+         configuration.getBuilderFactory().
+-                getMethodBuilder(writer).buildChildren(node);
+-    }
+-
+-    /**
+-     * Build the footer of the page.
+-     */
+-    public void buildClassFooter(XMLNode node) {
+-        writer.writeFooter();
++                getMethodBuilder(writer).buildChildren(node, memberDetailsTree);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
+@@ -25,11 +25,11 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
++import java.io.*;
++import java.util.*;
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+-import com.sun.javadoc.*;
+-import java.io.*;
+-import java.util.*;
+ 
+ /**
+  * Builds the Constants Summary Page.
+@@ -39,6 +39,7 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class ConstantsSummaryBuilder extends AbstractBuilder {
+@@ -80,6 +81,11 @@
+     private ClassDoc currentClass;
+ 
+     /**
++     * The content tree for the constant summary documentation.
++     */
++    private Content contentTree;
++
++    /**
+      * Construct a new ConstantsSummaryBuilder.
+      *
+      * @param configuration the current configuration of the
+@@ -113,7 +119,7 @@
+             //Doclet does not support this output.
+             return;
+         }
+-        build(LayoutParser.getInstance(configuration).parseXML(ROOT));
++        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
+     }
+ 
+     /**
+@@ -126,85 +132,85 @@
+     /**
+      * Build the constant summary.
+      *
+-     * @param elements the list of elements describing constant summary
+-     *                 documentation.
++     * @param node the XML element that specifies which components to document
++     * @param contentTree the content tree to which the documentation will be added
+      */
+-    public void buildConstantSummary(XMLNode node) throws Exception {
+-        buildChildren(node);
++    public void buildConstantSummary(XMLNode node, Content contentTree) throws Exception {
++        contentTree = writer.getHeader();
++        buildChildren(node, contentTree);
++        writer.addFooter(contentTree);
++        writer.printDocument(contentTree);
+         writer.close();
+     }
+ 
+     /**
+-     * Build the header.
++     * Build the list of packages.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param contentTree the content tree to which the content list will be added
+      */
+-    public void buildHeader(XMLNode node) {
+-        writer.writeHeader();
+-    }
+-
+-    /**
+-     * Build the footer.
+-     */
+-    public void buildFooter(XMLNode node) {
+-        writer.writeFooter();
+-    }
+-
+-    /**
+-     * Build the table of contents.
+-     */
+-    public void buildContents(XMLNode node) {
+-        writer.writeContentsHeader();
++    public void buildContents(XMLNode node, Content contentTree) {
++        Content contentListTree = writer.getContentsHeader();
+         PackageDoc[] packages = configuration.packages;
+         printedPackageHeaders = new HashSet();
+         for (int i = 0; i < packages.length; i++) {
+             if (hasConstantField(packages[i]) && ! hasPrintedPackageIndex(packages[i].name())) {
+-                writer.writeLinkToPackageContent(packages[i],
++                writer.addLinkToPackageContent(packages[i],
+                     parsePackageName(packages[i].name()),
+-                    printedPackageHeaders);
++                    printedPackageHeaders, contentListTree);
+             }
+         }
+-        writer.writeContentsFooter();
++        contentTree.addContent(writer.getContentsList(contentListTree));
+     }
+ 
+     /**
+      * Build the summary for each documented package.
+      *
+-     * @param elements the XML elements that represent the components
+-     *                 of documentation for each package.
++     * @param node the XML element that specifies which components to document
++     * @param contentTree the tree to which the summaries will be added
+      */
+-    public void buildConstantSummaries(XMLNode node) {
++    public void buildConstantSummaries(XMLNode node, Content contentTree) {
+         PackageDoc[] packages = configuration.packages;
+         printedPackageHeaders = new HashSet();
++        Content summariesTree = writer.getConstantSummaries();
+         for (int i = 0; i < packages.length; i++) {
+             if (hasConstantField(packages[i])) {
+                 currentPackage = packages[i];
+                 //Build the documentation for the current package.
+-                buildChildren(node);
++                buildChildren(node, summariesTree);
+             }
+         }
++        contentTree.addContent(summariesTree);
+     }
+ 
+     /**
+-     * Build the summary for the current package.
++     * Build the header for the given package.
+      *
+-     * @param elements the list of XML elements that make up package
+-     *                 documentation.
++     * @param node the XML element that specifies which components to document
++     * @param summariesTree the tree to which the package header will be added
+      */
+-    public void buildPackageConstantSummary(XMLNode node) {
+-        buildChildren(node);
++    public void buildPackageHeader(XMLNode node, Content summariesTree) {
++        String parsedPackageName = parsePackageName(currentPackage.name());
++        if (! printedPackageHeaders.contains(parsedPackageName)) {
++            writer.addPackageName(currentPackage,
++                parsePackageName(currentPackage.name()), summariesTree);
++            printedPackageHeaders.add(parsedPackageName);
++        }
+     }
+ 
+     /**
+      * Build the summary for the current class.
+      *
+-     * @param elements the list of XML elements that make up the class
+-     *                 constant summary.
++     * @param node the XML element that specifies which components to document
++     * @param summariesTree the tree to which the class constant summary will be added
+      */
+-    public void buildClassConstantSummary(XMLNode node) {
++    public void buildClassConstantSummary(XMLNode node, Content summariesTree) {
+         ClassDoc[] classes = currentPackage.name().length() > 0 ?
+             currentPackage.allClasses() :
+             configuration.classDocCatalog.allClasses(
+                 DocletConstants.DEFAULT_PACKAGE_NAME);
+         Arrays.sort(classes);
++        Content classConstantTree = writer.getClassConstantHeader();
+         for (int i = 0; i < classes.length; i++) {
+             if (! classDocsWithConstFields.contains(classes[i]) ||
+                 ! classes[i].isIncluded()) {
+@@ -212,42 +218,20 @@
+             }
+             currentClass = classes[i];
+             //Build the documentation for the current class.
+-            buildChildren(node);
++            buildChildren(node, classConstantTree);
+         }
++        summariesTree.addContent(classConstantTree);
+     }
+ 
+     /**
+-     * Build the header for the given class.
++     * Build the summary of constant members in the class.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classConstantTree the tree to which the constant members table
++     *                          will be added
+      */
+-    public void buildPackageHeader(XMLNode node) {
+-        String parsedPackageName = parsePackageName(currentPackage.name());
+-        if (! printedPackageHeaders.contains(parsedPackageName)) {
+-            writer.writePackageName(currentPackage,
+-                parsePackageName(currentPackage.name()));
+-            printedPackageHeaders.add(parsedPackageName);
+-        }
+-    }
+-
+-    /**
+-     * Build the header for the given class.
+-     */
+-    public void buildClassHeader(XMLNode node) {
+-        writer.writeConstantMembersHeader(currentClass);
+-    }
+-
+-    /**
+-     * Print summary of constant members in the
+-     * class.
+-     */
+-    public void buildConstantMembers(XMLNode node) {
+-        new ConstantFieldBuilder(currentClass).buildMembersSummary(node);
+-    }
+-
+-    /**
+-     * Build the footer for the given class.
+-     */
+-    public void buildClassFooter(XMLNode node) {
+-        writer.writeConstantMembersFooter(currentClass);
++    public void buildConstantMembers(XMLNode node, Content classConstantTree) {
++        new ConstantFieldBuilder(currentClass).buildMembersSummary(node, classConstantTree);
+     }
+ 
+     /**
+@@ -346,12 +330,16 @@
+ 
+         /**
+          * Builds the table of constants for a given class.
++         *
++         * @param node the XML element that specifies which components to document
++         * @param classConstantTree the tree to which the class constants table
++         *                          will be added
+          */
+-        protected void buildMembersSummary(XMLNode node) {
++        protected void buildMembersSummary(XMLNode node, Content classConstantTree) {
+             List members = new ArrayList(members());
+             if (members.size() > 0) {
+                 Collections.sort(members);
+-                writer.writeConstantMembers(classdoc, members);
++                writer.addConstantMembers(classdoc, members, classConstantTree);
+             }
+         }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
+@@ -25,10 +25,10 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
++import java.util.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+-import java.util.*;
+ 
+ /**
+  * Builds documentation for a constructor.
+@@ -38,202 +38,195 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class ConstructorBuilder extends AbstractMemberBuilder {
+ 
+-        /**
+-         * The name of this builder.
+-         */
+-        public static final String NAME = "ConstructorDetails";
++    /**
++     * The name of this builder.
++     */
++    public static final String NAME = "ConstructorDetails";
+ 
+-        /**
+-         * The index of the current field that is being documented at this point
+-         * in time.
+-         */
+-        private int currentMethodIndex;
++    /**
++     * The index of the current field that is being documented at this point
++     * in time.
++     */
++    private int currentConstructorIndex;
+ 
+-        /**
+-         * The class whose constructors are being documented.
+-         */
+-        private ClassDoc classDoc;
++    /**
++     * The class whose constructors are being documented.
++     */
++    private ClassDoc classDoc;
+ 
+-        /**
+-         * The visible constructors for the given class.
+-         */
+-        private VisibleMemberMap visibleMemberMap;
++    /**
++     * The visible constructors for the given class.
++     */
++    private VisibleMemberMap visibleMemberMap;
+ 
+-        /**
+-         * The writer to output the constructor documentation.
+-         */
+-        private ConstructorWriter writer;
++    /**
++     * The writer to output the constructor documentation.
++     */
++    private ConstructorWriter writer;
+ 
+-        /**
+-         * The constructors being documented.
+-         */
+-        private List constructors;
++    /**
++     * The constructors being documented.
++     */
++    private List<ProgramElementDoc> constructors;
+ 
+-        /**
+-         * Construct a new ConstructorBuilder.
+-         *
+-         * @param configuration the current configuration of the
+-         *                      doclet.
+-         */
+-        private ConstructorBuilder(Configuration configuration) {
+-                super(configuration);
++    /**
++     * Construct a new ConstructorBuilder.
++     *
++     * @param configuration the current configuration of the
++     *                      doclet.
++     */
++    private ConstructorBuilder(Configuration configuration) {
++	super(configuration);
++    }
++
++    /**
++     * Construct a new ConstructorBuilder.
++     *
++     * @param configuration the current configuration of the doclet.
++     * @param classDoc the class whoses members are being documented.
++     * @param writer the doclet specific writer.
++     */
++    public static ConstructorBuilder getInstance(
++            Configuration configuration,
++            ClassDoc classDoc,
++            ConstructorWriter writer) {
++        ConstructorBuilder builder = new ConstructorBuilder(configuration);
++        builder.classDoc = classDoc;
++        builder.writer = writer;
++        builder.visibleMemberMap =
++                new VisibleMemberMap(
++                classDoc,
++                VisibleMemberMap.CONSTRUCTORS,
++                configuration.nodeprecated);
++        builder.constructors =
++                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc));
++        for (int i = 0; i < builder.constructors.size(); i++) {
++            if (builder.constructors.get(i).isProtected()
++                    || builder.constructors.get(i).isPrivate()) {
++                writer.setFoundNonPubConstructor(true);
++            }
++         }
++        if (configuration.getMemberComparator() != null) {
++            Collections.sort(
++                    builder.constructors,
++                    configuration.getMemberComparator());
+         }
++        return builder;
++    }
+ 
+-        /**
+-         * Construct a new ConstructorBuilder.
+-         *
+-         * @param configuration the current configuration of the doclet.
+-         * @param classDoc the class whoses members are being documented.
+-         * @param writer the doclet specific writer.
+-         */
+-        public static ConstructorBuilder getInstance(
+-                Configuration configuration,
+-                ClassDoc classDoc,
+-                ConstructorWriter writer) {
+-                ConstructorBuilder builder = new ConstructorBuilder(configuration);
+-                builder.classDoc = classDoc;
+-                builder.writer = writer;
+-                builder.visibleMemberMap =
+-                        new VisibleMemberMap(
+-                                classDoc,
+-                                VisibleMemberMap.CONSTRUCTORS,
+-                                configuration.nodeprecated);
+-                builder.constructors =
+-                        new ArrayList(builder.visibleMemberMap.getMembersFor(classDoc));
+-                for (int i = 0; i < builder.constructors.size(); i++) {
+-                        if (((ProgramElementDoc) (builder.constructors.get(i)))
+-                                .isProtected()
+-                                || ((ProgramElementDoc) (builder.constructors.get(i)))
+-                                        .isPrivate()) {
+-                                writer.setFoundNonPubConstructor(true);
+-                        }
+-                }
+-                if (configuration.getMemberComparator() != null) {
+-                        Collections.sort(
+-                                builder.constructors,
+-                                configuration.getMemberComparator());
+-                }
+-                return builder;
++    /**
++     * {@inheritDoc}
++     */
++    public String getName() {
++        return NAME;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public boolean hasMembersToDocument() {
++        return constructors.size() > 0;
++    }
++
++    /**
++     * Returns a list of constructors that will be documented for the given class.
++     * This information can be used for doclet specific documentation
++     * generation.
++     *
++     * @return a list of constructors that will be documented.
++     */
++    public List<ProgramElementDoc> members(ClassDoc classDoc) {
++        return visibleMemberMap.getMembersFor(classDoc);
++    }
++
++    /**
++     * Return the constructor writer for this builder.
++     *
++     * @return the constructor writer for this builder.
++     */
++    public ConstructorWriter getWriter() {
++        return writer;
++    }
++
++    /**
++     * Build the constructor documentation.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
++     */
++    public void buildConstructorDoc(XMLNode node, Content memberDetailsTree) {
++        if (writer == null) {
++            return;
+         }
++        int size = constructors.size();
++        if (size > 0) {
++            Content constructorDetailsTree = writer.getConstructorDetailsTreeHeader(
++                    classDoc, memberDetailsTree);
++            for (currentConstructorIndex = 0; currentConstructorIndex < size;
++                    currentConstructorIndex++) {
++                Content constructorDocTree = writer.getConstructorDocTreeHeader(
++                        (ConstructorDoc) constructors.get(currentConstructorIndex),
++                        constructorDetailsTree);
++                buildChildren(node, constructorDocTree);
++                constructorDetailsTree.addContent(writer.getConstructorDoc(
++                        constructorDocTree, (currentConstructorIndex == size - 1)));
++            }
++            memberDetailsTree.addContent(
++                    writer.getConstructorDetails(constructorDetailsTree));
++        }
++    }
+ 
+-        /**
+-         * {@inheritDoc}
+-         */
+-        public String getName() {
+-                return NAME;
++    /**
++     * Build the signature.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param constructorDocTree the content tree to which the documentation will be added
++     */
++    public void buildSignature(XMLNode node, Content constructorDocTree) {
++        constructorDocTree.addContent(
++                writer.getSignature(
++                (ConstructorDoc) constructors.get(currentConstructorIndex)));
++    }
++
++    /**
++     * Build the deprecation information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param constructorDocTree the content tree to which the documentation will be added
++     */
++    public void buildDeprecationInfo(XMLNode node, Content constructorDocTree) {
++        writer.addDeprecated(
++                (ConstructorDoc) constructors.get(currentConstructorIndex), constructorDocTree);
++    }
++
++    /**
++     * Build the comments for the constructor.  Do nothing if
++     * {@link Configuration#nocomment} is set to true.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param constructorDocTree the content tree to which the documentation will be added
++     */
++    public void buildConstructorComments(XMLNode node, Content constructorDocTree) {
++        if (!configuration.nocomment) {
++            writer.addComments(
++                    (ConstructorDoc) constructors.get(currentConstructorIndex),
++                    constructorDocTree);
+         }
++    }
+ 
+-        /**
+-         * {@inheritDoc}
+-         */
+-        public boolean hasMembersToDocument() {
+-                return constructors.size() > 0;
+-        }
+-
+-        /**
+-         * Returns a list of constructors that will be documented for the given class.
+-         * This information can be used for doclet specific documentation
+-         * generation.
+-         *
+-         * @return a list of constructors that will be documented.
+-         */
+-        public List members(ClassDoc classDoc) {
+-                return visibleMemberMap.getMembersFor(classDoc);
+-        }
+-
+-        /**
+-         * Return the constructor writer for this builder.
+-         *
+-         * @return the constructor writer for this builder.
+-         */
+-        public ConstructorWriter getWriter() {
+-                return writer;
+-        }
+-
+-        /**
+-         * Build the constructor documentation.
+-         *
+-         * @param elements the XML elements that specify how to construct this
+-         *                documentation.
+-         */
+-        public void buildConstructorDoc(XMLNode node) {
+-                if (writer == null) {
+-                        return;
+-                }
+-                for (currentMethodIndex = 0;
+-                        currentMethodIndex < constructors.size();
+-                        currentMethodIndex++) {
+-                        buildChildren(node);
+-                }
+-        }
+-
+-        /**
+-         * Build the overall header.
+-         */
+-        public void buildHeader(XMLNode node) {
+-                writer.writeHeader(
+-                        classDoc,
+-                        configuration.getText("doclet.Constructor_Detail"));
+-        }
+-
+-        /**
+-         * Build the header for the individual constructor.
+-         */
+-        public void buildConstructorHeader(XMLNode node) {
+-                writer.writeConstructorHeader(
+-                        (ConstructorDoc) constructors.get(currentMethodIndex),
+-                        currentMethodIndex == 0);
+-        }
+-
+-        /**
+-         * Build the signature.
+-         */
+-        public void buildSignature(XMLNode node) {
+-                writer.writeSignature(
+-                        (ConstructorDoc) constructors.get(currentMethodIndex));
+-        }
+-
+-        /**
+-         * Build the deprecation information.
+-         */
+-        public void buildDeprecationInfo(XMLNode node) {
+-                writer.writeDeprecated(
+-                        (ConstructorDoc) constructors.get(currentMethodIndex));
+-        }
+-
+-        /**
+-         * Build the comments for the constructor.  Do nothing if
+-         * {@link Configuration#nocomment} is set to true.
+-         */
+-        public void buildConstructorComments(XMLNode node) {
+-                if (!configuration.nocomment) {
+-                        writer.writeComments(
+-                                (ConstructorDoc) constructors.get(currentMethodIndex));
+-                }
+-        }
+-
+-        /**
+-         * Build the tag information.
+-         */
+-        public void buildTagInfo(XMLNode node) {
+-                writer.writeTags((ConstructorDoc) constructors.get(currentMethodIndex));
+-        }
+-
+-        /**
+-         * Build the footer for the individual constructor.
+-         */
+-        public void buildConstructorFooter(XMLNode node) {
+-                writer.writeConstructorFooter();
+-        }
+-
+-        /**
+-         * Build the overall footer.
+-         */
+-        public void buildFooter(XMLNode node) {
+-                writer.writeFooter(classDoc);
+-        }
++    /**
++     * Build the tag information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param constructorDocTree the content tree to which the documentation will be added
++     */
++    public void buildTagInfo(XMLNode node, Content constructorDocTree) {
++        writer.addTags((ConstructorDoc) constructors.get(currentConstructorIndex),
++                constructorDocTree);
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
+@@ -25,10 +25,10 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
++import java.util.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+-import java.util.*;
+ 
+ /**
+  * Builds documentation for a enum constants.
+@@ -38,200 +38,195 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class EnumConstantBuilder extends AbstractMemberBuilder {
+ 
+-        /**
+-         * The class whose enum constants are being documented.
+-         */
+-        private ClassDoc classDoc;
++    /**
++     * The class whose enum constants are being documented.
++     */
++    private ClassDoc classDoc;
+ 
+-        /**
+-         * The visible enum constantss for the given class.
+-         */
+-        private VisibleMemberMap visibleMemberMap;
++    /**
++     * The visible enum constantss for the given class.
++     */
++    private VisibleMemberMap visibleMemberMap;
+ 
+-        /**
+-         * The writer to output the enum constants documentation.
+-         */
+-        private EnumConstantWriter writer;
++    /**
++     * The writer to output the enum constants documentation.
++     */
++    private EnumConstantWriter writer;
+ 
+-        /**
+-         * The list of enum constants being documented.
+-         */
+-        private List enumConstants;
++    /**
++     * The list of enum constants being documented.
++     */
++    private List<ProgramElementDoc> enumConstants;
+ 
+-        /**
+-         * The index of the current enum constant that is being documented at this point
+-         * in time.
+-         */
+-        private int currentEnumConstantsIndex;
++    /**
++     * The index of the current enum constant that is being documented at this point
++     * in time.
++     */
++    private int currentEnumConstantsIndex;
+ 
+-        /**
+-         * Construct a new EnumConstantsBuilder.
+-         *
+-         * @param configuration the current configuration of the
+-         *                      doclet.
+-         */
+-        private EnumConstantBuilder(Configuration configuration) {
+-                super(configuration);
++    /**
++     * Construct a new EnumConstantsBuilder.
++     *
++     * @param configuration the current configuration of the
++     *                      doclet.
++     */
++    private EnumConstantBuilder(Configuration configuration) {
++        super(configuration);
++    }
++
++    /**
++     * Construct a new EnumConstantsBuilder.
++     *
++     * @param configuration the current configuration of the doclet.
++     * @param classDoc the class whoses members are being documented.
++     * @param writer the doclet specific writer.
++     */
++    public static EnumConstantBuilder getInstance(
++            Configuration configuration,
++            ClassDoc classDoc,
++            EnumConstantWriter writer) {
++        EnumConstantBuilder builder = new EnumConstantBuilder(configuration);
++        builder.classDoc = classDoc;
++        builder.writer = writer;
++        builder.visibleMemberMap =
++                new VisibleMemberMap(
++                classDoc,
++                VisibleMemberMap.ENUM_CONSTANTS,
++                configuration.nodeprecated);
++        builder.enumConstants =
++                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getMembersFor(classDoc));
++        if (configuration.getMemberComparator() != null) {
++            Collections.sort(
++                    builder.enumConstants,
++                    configuration.getMemberComparator());
++         }
++        return builder;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getName() {
++        return "EnumConstantDetails";
++    }
++
++    /**
++     * Returns a list of enum constants that will be documented for the given class.
++     * This information can be used for doclet specific documentation
++     * generation.
++     *
++     * @param classDoc the {@link ClassDoc} we want to check.
++     * @return a list of enum constants that will be documented.
++     */
++    public List<ProgramElementDoc> members(ClassDoc classDoc) {
++        return visibleMemberMap.getMembersFor(classDoc);
++    }
++
++    /**
++     * Returns the visible member map for the enum constants of this class.
++     *
++     * @return the visible member map for the enum constants of this class.
++     */
++    public VisibleMemberMap getVisibleMemberMap() {
++        return visibleMemberMap;
++    }
++
++    /**
++     * summaryOrder.size()
++     */
++    public boolean hasMembersToDocument() {
++        return enumConstants.size() > 0;
++    }
++
++    /**
++     * Build the enum constant documentation.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
++     */
++    public void buildEnumConstant(XMLNode node, Content memberDetailsTree) {
++        if (writer == null) {
++            return;
+         }
++        int size = enumConstants.size();
++        if (size > 0) {
++            Content enumConstantsDetailsTree = writer.getEnumConstantsDetailsTreeHeader(
++                    classDoc, memberDetailsTree);
++            for (currentEnumConstantsIndex = 0; currentEnumConstantsIndex < size;
++                    currentEnumConstantsIndex++) {
++                Content enumConstantsTree = writer.getEnumConstantsTreeHeader(
++                        (FieldDoc) enumConstants.get(currentEnumConstantsIndex),
++                        enumConstantsDetailsTree);
++                buildChildren(node, enumConstantsTree);
++                enumConstantsDetailsTree.addContent(writer.getEnumConstants(
++                        enumConstantsTree, (currentEnumConstantsIndex == size - 1)));
++            }
++            memberDetailsTree.addContent(
++                    writer.getEnumConstantsDetails(enumConstantsDetailsTree));
++        }
++    }
+ 
+-        /**
+-         * Construct a new EnumConstantsBuilder.
+-         *
+-         * @param configuration the current configuration of the doclet.
+-         * @param classDoc the class whoses members are being documented.
+-         * @param writer the doclet specific writer.
+-         */
+-        public static EnumConstantBuilder getInstance(
+-                Configuration configuration,
+-                ClassDoc classDoc,
+-                EnumConstantWriter writer) {
+-                EnumConstantBuilder builder = new EnumConstantBuilder(configuration);
+-                builder.classDoc = classDoc;
+-                builder.writer = writer;
+-                builder.visibleMemberMap =
+-                        new VisibleMemberMap(
+-                                classDoc,
+-                                VisibleMemberMap.ENUM_CONSTANTS,
+-                                configuration.nodeprecated);
+-                builder.enumConstants =
+-                        new ArrayList(builder.visibleMemberMap.getMembersFor(classDoc));
+-                if (configuration.getMemberComparator() != null) {
+-                        Collections.sort(
+-                                builder.enumConstants,
+-                                configuration.getMemberComparator());
+-                }
+-                return builder;
++    /**
++     * Build the signature.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param enumConstantsTree the content tree to which the documentation will be added
++     */
++    public void buildSignature(XMLNode node, Content enumConstantsTree) {
++        enumConstantsTree.addContent(writer.getSignature(
++                (FieldDoc) enumConstants.get(currentEnumConstantsIndex)));
++    }
++
++    /**
++     * Build the deprecation information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param enumConstantsTree the content tree to which the documentation will be added
++     */
++    public void buildDeprecationInfo(XMLNode node, Content enumConstantsTree) {
++        writer.addDeprecated(
++                (FieldDoc) enumConstants.get(currentEnumConstantsIndex),
++                enumConstantsTree);
++    }
++
++    /**
++     * Build the comments for the enum constant.  Do nothing if
++     * {@link Configuration#nocomment} is set to true.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param enumConstantsTree the content tree to which the documentation will be added
++     */
++    public void buildEnumConstantComments(XMLNode node, Content enumConstantsTree) {
++        if (!configuration.nocomment) {
++            writer.addComments(
++                    (FieldDoc) enumConstants.get(currentEnumConstantsIndex),
++                    enumConstantsTree);
+         }
++    }
+ 
+-        /**
+-         * {@inheritDoc}
+-         */
+-        public String getName() {
+-                return "EnumConstantDetails";
+-        }
++    /**
++     * Build the tag information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param enumConstantsTree the content tree to which the documentation will be added
++     */
++    public void buildTagInfo(XMLNode node, Content enumConstantsTree) {
++        writer.addTags(
++                (FieldDoc) enumConstants.get(currentEnumConstantsIndex),
++                enumConstantsTree);
++    }
+ 
+-        /**
+-         * Returns a list of enum constants that will be documented for the given class.
+-         * This information can be used for doclet specific documentation
+-         * generation.
+-         *
+-         * @param classDoc the {@link ClassDoc} we want to check.
+-         * @return a list of enum constants that will be documented.
+-         */
+-        public List members(ClassDoc classDoc) {
+-                return visibleMemberMap.getMembersFor(classDoc);
+-        }
+-
+-        /**
+-         * Returns the visible member map for the enum constants of this class.
+-         *
+-         * @return the visible member map for the enum constants of this class.
+-         */
+-        public VisibleMemberMap getVisibleMemberMap() {
+-                return visibleMemberMap;
+-        }
+-
+-        /**
+-         * summaryOrder.size()
+-         */
+-        public boolean hasMembersToDocument() {
+-                return enumConstants.size() > 0;
+-        }
+-
+-        /**
+-         * Build the enum constant documentation.
+-         *
+-         * @param elements the XML elements that specify how to construct this
+-         *                documentation.
+-         */
+-        public void buildEnumConstant(XMLNode node) {
+-                if (writer == null) {
+-                        return;
+-                }
+-                for (currentEnumConstantsIndex = 0;
+-                        currentEnumConstantsIndex < enumConstants.size();
+-                        currentEnumConstantsIndex++) {
+-                        buildChildren(node);
+-                }
+-        }
+-
+-        /**
+-         * Build the overall header.
+-         */
+-        public void buildHeader(XMLNode node) {
+-                writer.writeHeader(
+-                        classDoc,
+-                        configuration.getText("doclet.Enum_Constant_Detail"));
+-        }
+-
+-        /**
+-         * Build the header for the individual enum constants.
+-         */
+-        public void buildEnumConstantHeader(XMLNode node) {
+-                writer.writeEnumConstantHeader(
+-                        (FieldDoc) enumConstants.get(currentEnumConstantsIndex),
+-                        currentEnumConstantsIndex == 0);
+-        }
+-
+-        /**
+-         * Build the signature.
+-         */
+-        public void buildSignature(XMLNode node) {
+-                writer.writeSignature(
+-                        (FieldDoc) enumConstants.get(currentEnumConstantsIndex));
+-        }
+-
+-        /**
+-         * Build the deprecation information.
+-         */
+-        public void buildDeprecationInfo(XMLNode node) {
+-                writer.writeDeprecated(
+-                        (FieldDoc) enumConstants.get(currentEnumConstantsIndex));
+-        }
+-
+-        /**
+-         * Build the comments for the enum constant.  Do nothing if
+-         * {@link Configuration#nocomment} is set to true.
+-         */
+-        public void buildEnumConstantComments(XMLNode node) {
+-                if (!configuration.nocomment) {
+-                        writer.writeComments(
+-                                (FieldDoc) enumConstants.get(currentEnumConstantsIndex));
+-                }
+-        }
+-
+-        /**
+-         * Build the tag information.
+-         */
+-        public void buildTagInfo(XMLNode node) {
+-                writer.writeTags(
+-                        (FieldDoc) enumConstants.get(currentEnumConstantsIndex));
+-        }
+-
+-        /**
+-         * Build the footer for the individual enum constants.
+-         */
+-        public void buildEnumConstantFooter(XMLNode node) {
+-                writer.writeEnumConstantFooter();
+-        }
+-
+-        /**
+-         * Build the overall footer.
+-         */
+-        public void buildFooter(XMLNode node) {
+-                writer.writeFooter(classDoc);
+-        }
+-
+-        /**
+-         * Return the enum constant writer for this builder.
+-         *
+-         * @return the enum constant writer for this builder.
+-         */
+-        public EnumConstantWriter getWriter() {
+-                return writer;
+-        }
++    /**
++     * Return the enum constant writer for this builder.
++     *
++     * @return the enum constant writer for this builder.
++     */
++    public EnumConstantWriter getWriter() {
++        return writer;
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
+@@ -25,10 +25,10 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
++import java.util.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+-import java.util.*;
+ 
+ /**
+  * Builds documentation for a field.
+@@ -38,197 +38,191 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class FieldBuilder extends AbstractMemberBuilder {
+ 
+-        /**
+-         * The class whose fields are being documented.
+-         */
+-        private ClassDoc classDoc;
++    /**
++     * The class whose fields are being documented.
++     */
++    private ClassDoc classDoc;
+ 
+-        /**
+-         * The visible fields for the given class.
+-         */
+-        private VisibleMemberMap visibleMemberMap;
++    /**
++     * The visible fields for the given class.
++     */
++    private VisibleMemberMap visibleMemberMap;
+ 
+-        /**
+-         * The writer to output the field documentation.
+-         */
+-        private FieldWriter writer;
++    /**
++     * The writer to output the field documentation.
++     */
++    private FieldWriter writer;
+ 
+-        /**
+-         * The list of fields being documented.
+-         */
+-        private List fields;
++    /**
++     * The list of fields being documented.
++     */
++    private List<ProgramElementDoc> fields;
+ 
+-        /**
+-         * The index of the current field that is being documented at this point
+-         * in time.
+-         */
+-        private int currentFieldIndex;
++    /**
++     * The index of the current field that is being documented at this point
++     * in time.
++     */
++    private int currentFieldIndex;
+ 
+-        /**
+-         * Construct a new FieldBuilder.
+-         *
+-         * @param configuration the current configuration of the
+-         *                      doclet.
+-         */
+-        private FieldBuilder(Configuration configuration) {
+-                super(configuration);
++    /**
++     * Construct a new FieldBuilder.
++     *
++     * @param configuration the current configuration of the
++     *                      doclet.
++     */
++    private FieldBuilder(Configuration configuration) {
++        super(configuration);
++    }
++
++    /**
++     * Construct a new FieldBuilder.
++     *
++     * @param configuration the current configuration of the doclet.
++     * @param classDoc the class whoses members are being documented.
++     * @param writer the doclet specific writer.
++     */
++    public static FieldBuilder getInstance(
++            Configuration configuration,
++            ClassDoc classDoc,
++            FieldWriter writer) {
++        FieldBuilder builder = new FieldBuilder(configuration);
++        builder.classDoc = classDoc;
++        builder.writer = writer;
++        builder.visibleMemberMap =
++                new VisibleMemberMap(
++                classDoc,
++                VisibleMemberMap.FIELDS,
++                configuration.nodeprecated);
++        builder.fields =
++                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getLeafClassMembers(
++                configuration));
++        if (configuration.getMemberComparator() != null) {
++            Collections.sort(
++                    builder.fields,
++                    configuration.getMemberComparator());
+         }
++        return builder;
++    }
+ 
+-        /**
+-         * Construct a new FieldBuilder.
+-         *
+-         * @param configuration the current configuration of the doclet.
+-         * @param classDoc the class whoses members are being documented.
+-         * @param writer the doclet specific writer.
+-         */
+-        public static FieldBuilder getInstance(
+-                Configuration configuration,
+-                ClassDoc classDoc,
+-                FieldWriter writer) {
+-                FieldBuilder builder = new FieldBuilder(configuration);
+-                builder.classDoc = classDoc;
+-                builder.writer = writer;
+-                builder.visibleMemberMap =
+-                        new VisibleMemberMap(
+-                                classDoc,
+-                                VisibleMemberMap.FIELDS,
+-                                configuration.nodeprecated);
+-                builder.fields =
+-                        new ArrayList(builder.visibleMemberMap.getLeafClassMembers(
+-                configuration));
+-                if (configuration.getMemberComparator() != null) {
+-                        Collections.sort(
+-                                builder.fields,
+-                                configuration.getMemberComparator());
+-                }
+-                return builder;
++    /**
++     * {@inheritDoc}
++     */
++    public String getName() {
++        return "FieldDetails";
++    }
++
++    /**
++     * Returns a list of fields that will be documented for the given class.
++     * This information can be used for doclet specific documentation
++     * generation.
++     *
++     * @param classDoc the {@link ClassDoc} we want to check.
++     * @return a list of fields that will be documented.
++     */
++    public List<ProgramElementDoc> members(ClassDoc classDoc) {
++        return visibleMemberMap.getMembersFor(classDoc);
++    }
++
++    /**
++     * Returns the visible member map for the fields of this class.
++     *
++     * @return the visible member map for the fields of this class.
++     */
++    public VisibleMemberMap getVisibleMemberMap() {
++        return visibleMemberMap;
++    }
++
++    /**
++     * summaryOrder.size()
++     */
++    public boolean hasMembersToDocument() {
++        return fields.size() > 0;
++    }
++
++    /**
++     * Build the field documentation.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
++     */
++    public void buildFieldDoc(XMLNode node, Content memberDetailsTree) {
++        if (writer == null) {
++            return;
++       }
++        int size = fields.size();
++        if (size > 0) {
++            Content fieldDetailsTree = writer.getFieldDetailsTreeHeader(
++                    classDoc, memberDetailsTree);
++            for (currentFieldIndex = 0; currentFieldIndex < size;
++                    currentFieldIndex++) {
++                Content fieldDocTree = writer.getFieldDocTreeHeader(
++                        (FieldDoc) fields.get(currentFieldIndex),
++                        fieldDetailsTree);
++                buildChildren(node, fieldDocTree);
++                fieldDetailsTree.addContent(writer.getFieldDoc(
++                        fieldDocTree, (currentFieldIndex == size - 1)));
++            }
++            memberDetailsTree.addContent(
++                    writer.getFieldDetails(fieldDetailsTree));
+         }
++    }
+ 
+-        /**
+-         * {@inheritDoc}
+-         */
+-        public String getName() {
+-                return "FieldDetails";
++    /**
++     * Build the signature.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param fieldDocTree the content tree to which the documentation will be added
++     */
++    public void buildSignature(XMLNode node, Content fieldDocTree) {
++        fieldDocTree.addContent(
++                writer.getSignature((FieldDoc) fields.get(currentFieldIndex)));
++    }
++
++    /**
++     * Build the deprecation information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param fieldDocTree the content tree to which the documentation will be added
++     */
++    public void buildDeprecationInfo(XMLNode node, Content fieldDocTree) {
++        writer.addDeprecated(
++                (FieldDoc) fields.get(currentFieldIndex), fieldDocTree);
++    }
++
++    /**
++     * Build the comments for the field.  Do nothing if
++     * {@link Configuration#nocomment} is set to true.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param fieldDocTree the content tree to which the documentation will be added
++     */
++    public void buildFieldComments(XMLNode node, Content fieldDocTree) {
++        if (!configuration.nocomment) {
++            writer.addComments((FieldDoc) fields.get(currentFieldIndex), fieldDocTree);
+         }
++    }
+ 
+-        /**
+-         * Returns a list of fields that will be documented for the given class.
+-         * This information can be used for doclet specific documentation
+-         * generation.
+-         *
+-         * @param classDoc the {@link ClassDoc} we want to check.
+-         * @return a list of fields that will be documented.
+-         */
+-        public List members(ClassDoc classDoc) {
+-                return visibleMemberMap.getMembersFor(classDoc);
+-        }
++    /**
++     * Build the tag information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param fieldDocTree the content tree to which the documentation will be added
++     */
++    public void buildTagInfo(XMLNode node, Content fieldDocTree) {
++        writer.addTags((FieldDoc) fields.get(currentFieldIndex), fieldDocTree);
++    }
+ 
+-        /**
+-         * Returns the visible member map for the fields of this class.
+-         *
+-         * @return the visible member map for the fields of this class.
+-         */
+-        public VisibleMemberMap getVisibleMemberMap() {
+-                return visibleMemberMap;
+-        }
+-
+-        /**
+-         * summaryOrder.size()
+-         */
+-        public boolean hasMembersToDocument() {
+-                return fields.size() > 0;
+-        }
+-
+-        /**
+-         * Build the field documentation.
+-         *
+-         * @param elements the XML elements that specify how to construct this
+-         *                documentation.
+-         */
+-        public void buildFieldDoc(XMLNode node) {
+-                if (writer == null) {
+-                        return;
+-                }
+-                for (currentFieldIndex = 0;
+-                        currentFieldIndex < fields.size();
+-                        currentFieldIndex++) {
+-                        buildChildren(node);
+-                }
+-        }
+-
+-        /**
+-         * Build the overall header.
+-         */
+-        public void buildHeader(XMLNode node) {
+-                writer.writeHeader(
+-                        classDoc,
+-                        configuration.getText("doclet.Field_Detail"));
+-        }
+-
+-        /**
+-         * Build the header for the individual field.
+-         */
+-        public void buildFieldHeader(XMLNode node) {
+-                writer.writeFieldHeader(
+-                        (FieldDoc) fields.get(currentFieldIndex),
+-                        currentFieldIndex == 0);
+-        }
+-
+-        /**
+-         * Build the signature.
+-         */
+-        public void buildSignature(XMLNode node) {
+-                writer.writeSignature((FieldDoc) fields.get(currentFieldIndex));
+-        }
+-
+-        /**
+-         * Build the deprecation information.
+-         */
+-        public void buildDeprecationInfo(XMLNode node) {
+-                writer.writeDeprecated((FieldDoc) fields.get(currentFieldIndex));
+-        }
+-
+-        /**
+-         * Build the comments for the field.  Do nothing if
+-         * {@link Configuration#nocomment} is set to true.
+-         */
+-        public void buildFieldComments(XMLNode node) {
+-                if (!configuration.nocomment) {
+-                        writer.writeComments((FieldDoc) fields.get(currentFieldIndex));
+-                }
+-        }
+-
+-        /**
+-         * Build the tag information.
+-         */
+-        public void buildTagInfo(XMLNode node) {
+-                writer.writeTags((FieldDoc) fields.get(currentFieldIndex));
+-        }
+-
+-        /**
+-         * Build the footer for the individual field.
+-         */
+-        public void buildFieldFooter(XMLNode node) {
+-                writer.writeFieldFooter();
+-        }
+-
+-        /**
+-         * Build the overall footer.
+-         */
+-        public void buildFooter(XMLNode node) {
+-                writer.writeFooter(classDoc);
+-        }
+-
+-        /**
+-         * Return the field writer for this builder.
+-         *
+-         * @return the field writer for this builder.
+-         */
+-        public FieldWriter getWriter() {
+-                return writer;
+-        }
++    /**
++     * Return the field writer for this builder.
++     *
++     * @return the field writer for this builder.
++     */
++    public FieldWriter getWriter() {
++        return writer;
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
+@@ -76,7 +76,7 @@
+     /**
+      * Parse the XML specifying the layout of the documentation.
+      *
+-     * @return List the list of XML elements parsed.
++     * @return the list of XML elements parsed.
+      */
+     public XMLNode parseXML(String root) {
+         if (xmlElementsMap.containsKey(root)) {
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
+@@ -25,10 +25,10 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
++import java.util.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+-import java.util.*;
+ 
+ /**
+  * Builds the member summary.
+@@ -38,49 +38,50 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class MemberSummaryBuilder extends AbstractMemberBuilder {
+ 
+-        /**
+-         * The XML root for this builder.
+-         */
+-        public static final String NAME = "MemberSummary";
++    /**
++     * The XML root for this builder.
++     */
++    public static final String NAME = "MemberSummary";
+ 
+-        /**
+-         * The visible members for the given class.
+-         */
+-        private VisibleMemberMap[] visibleMemberMaps;
++    /**
++     * The visible members for the given class.
++     */
++    private VisibleMemberMap[] visibleMemberMaps;
+ 
+-        /**
+-         * The member summary writers for the given class.
+-         */
+-        private MemberSummaryWriter[] memberSummaryWriters;
++    /**
++     * The member summary writers for the given class.
++     */
++    private MemberSummaryWriter[] memberSummaryWriters;
+ 
+-        /**
+-         * The type being documented.
+-         */
+-        private ClassDoc classDoc;
++    /**
++     * The type being documented.
++     */
++    private ClassDoc classDoc;
+ 
+-        private MemberSummaryBuilder(Configuration configuration) {
+-                super(configuration);
+-        }
++    private MemberSummaryBuilder(Configuration configuration) {
++        super(configuration);
++    }
+ 
+-        /**
+-         * Construct a new MemberSummaryBuilder.
+-         *
+-         * @param classWriter   the writer for the class whose members are being
+-         *                      summarized.
+-         * @param configuration the current configuration of the doclet.
+-         */
+-        public static MemberSummaryBuilder getInstance(
+-                ClassWriter classWriter, Configuration configuration)
+-        throws Exception {
+-                MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
+-                builder.classDoc = classWriter.getClassDoc();
+-                builder.init(classWriter);
+-                return builder;
+-        }
++    /**
++     * Construct a new MemberSummaryBuilder.
++     *
++     * @param classWriter   the writer for the class whose members are being
++     *                      summarized.
++     * @param configuration the current configuration of the doclet.
++     */
++    public static MemberSummaryBuilder getInstance(
++            ClassWriter classWriter, Configuration configuration)
++            throws Exception {
++        MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
++        builder.classDoc = classWriter.getClassDoc();
++        builder.init(classWriter);
++        return builder;
++    }
+ 
+     /**
+      * Construct a new MemberSummaryBuilder.
+@@ -90,8 +91,8 @@
+      * @param configuration the current configuration of the doclet.
+      */
+     public static MemberSummaryBuilder getInstance(
+-        AnnotationTypeWriter annotationTypeWriter, Configuration configuration)
+-    throws Exception {
++            AnnotationTypeWriter annotationTypeWriter, Configuration configuration)
++            throws Exception {
+         MemberSummaryBuilder builder = new MemberSummaryBuilder(configuration);
+         builder.classDoc = annotationTypeWriter.getAnnotationTypeDoc();
+         builder.init(annotationTypeWriter);
+@@ -100,200 +101,210 @@
+ 
+     private void init(Object writer) throws Exception {
+         visibleMemberMaps =
+-            new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
++                new VisibleMemberMap[VisibleMemberMap.NUM_MEMBER_TYPES];
+         for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
+             visibleMemberMaps[i] =
+-                new VisibleMemberMap(
++                    new VisibleMemberMap(
+                     classDoc,
+                     i,
+                     configuration.nodeprecated);
+         }
+         memberSummaryWriters =
+-            new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
++                new MemberSummaryWriter[VisibleMemberMap.NUM_MEMBER_TYPES];
+         for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
+             if (classDoc.isAnnotationType()) {
+                 memberSummaryWriters[i] =
+                     visibleMemberMaps[i].noVisibleMembers()?
+                         null :
+                         configuration.getWriterFactory().getMemberSummaryWriter(
+-                            (AnnotationTypeWriter) writer, i);
++                        (AnnotationTypeWriter) writer, i);
+             } else {
+                 memberSummaryWriters[i] =
+                     visibleMemberMaps[i].noVisibleMembers()?
+                         null :
+                         configuration.getWriterFactory().getMemberSummaryWriter(
+-                            (ClassWriter) writer, i);
++                        (ClassWriter) writer, i);
+             }
+         }
+ 
+     }
+ 
+-        /**
+-         * {@inheritDoc}
+-         */
+-        public String getName() {
+-                return NAME;
+-        }
++    /**
++     * {@inheritDoc}
++     */
++    public String getName() {
++        return NAME;
++    }
+ 
+-        /**
+-         * Return the specified visible member map.
+-         *
+-         * @param type the type of visible member map to return.
+-         * @return the specified visible member map.
+-         * @throws ArrayIndexOutOfBoundsException when the type is invalid.
+-         * @see VisibleMemberMap
+-         */
+-        public VisibleMemberMap getVisibleMemberMap(int type) {
+-                return visibleMemberMaps[type];
+-        }
++    /**
++     * Return the specified visible member map.
++     *
++     * @param type the type of visible member map to return.
++     * @return the specified visible member map.
++     * @throws ArrayIndexOutOfBoundsException when the type is invalid.
++     * @see VisibleMemberMap
++     */
++    public VisibleMemberMap getVisibleMemberMap(int type) {
++        return visibleMemberMaps[type];
++    }
+ 
+-        /**
+-         * Return the specified member summary writer.
+-         *
+-         * @param type the type of member summary writer to return.
+-         * @return the specified member summary writer.
+-         * @throws ArrayIndexOutOfBoundsException when the type is invalid.
+-         * @see VisibleMemberMap
+-         */
+-        public MemberSummaryWriter getMemberSummaryWriter(int type) {
+-                return memberSummaryWriters[type];
+-        }
++    /**
++     * Return the specified member summary writer.
++     *
++     * @param type the type of member summary writer to return.
++     * @return the specified member summary writer.
++     * @throws ArrayIndexOutOfBoundsException when the type is invalid.
++     * @see VisibleMemberMap
++     */
++    public MemberSummaryWriter getMemberSummaryWriter(int type) {
++        return memberSummaryWriters[type];
++    }
+ 
+-        /**
+-         * Returns a list of methods that will be documented for the given class.
+-         * This information can be used for doclet specific documentation
+-         * generation.
+-         *
+-         * @param classDoc the {@link ClassDoc} we want to check.
+-         * @param type the type of members to return.
+-         * @return a list of methods that will be documented.
+-         * @see VisibleMemberMap
+-         */
+-        public List members(int type) {
+-                return visibleMemberMaps[type].getLeafClassMembers(configuration);
+-        }
++    /**
++     * Returns a list of methods that will be documented for the given class.
++     * This information can be used for doclet specific documentation
++     * generation.
++     *
++     * @param classDoc the {@link ClassDoc} we want to check.
++     * @param type the type of members to return.
++     * @return a list of methods that will be documented.
++     * @see VisibleMemberMap
++     */
++    public List<ProgramElementDoc> members(int type) {
++        return visibleMemberMaps[type].getLeafClassMembers(configuration);
++    }
+ 
+-        /**
+-         * Return true it there are any members to summarize.
+-         *
+-         * @return true if there are any members to summarize.
+-         */
+-        public boolean hasMembersToDocument() {
++    /**
++     * Return true it there are any members to summarize.
++     *
++     * @return true if there are any members to summarize.
++     */
++    public boolean hasMembersToDocument() {
+         if (classDoc instanceof AnnotationTypeDoc) {
+             return ((AnnotationTypeDoc) classDoc).elements().length > 0;
+         }
+-                for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
+-                        VisibleMemberMap members = visibleMemberMaps[i];
+-                        if (!members.noVisibleMembers()) {
+-                                return true;
+-                        }
+-                }
+-                return false;
++        for (int i = 0; i < VisibleMemberMap.NUM_MEMBER_TYPES; i++) {
++            VisibleMemberMap members = visibleMemberMaps[i];
++            if (!members.noVisibleMembers()) {
++                return true;
++            }
+         }
+ 
+-        /**
+-         * Build the summary for the enum constants.
+-         */
+-        public void buildEnumConstantsSummary(XMLNode node) {
+-                buildSummary(
+-                        memberSummaryWriters[VisibleMemberMap.ENUM_CONSTANTS],
+-                        visibleMemberMaps[VisibleMemberMap.ENUM_CONSTANTS]);
+-        }
++        return false;
++    }
+ 
+     /**
+-     * Build the summary for the optional members.
++     * Build the summary for the enum constants.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberSummaryTree the content tree to which the documentation will be added
+      */
+-    public void buildAnnotationTypeOptionalMemberSummary(XMLNode node) {
+-        buildSummary(
+-            memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL],
+-                visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL]);
++    public void buildEnumConstantsSummary(XMLNode node, Content memberSummaryTree) {
++        MemberSummaryWriter writer =
++                memberSummaryWriters[VisibleMemberMap.ENUM_CONSTANTS];
++        VisibleMemberMap visibleMemberMap =
++                visibleMemberMaps[VisibleMemberMap.ENUM_CONSTANTS];
++        addSummary(writer, visibleMemberMap, false, memberSummaryTree);
+     }
+ 
+     /**
+      * Build the summary for the optional members.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberSummaryTree the content tree to which the documentation will be added
+      */
+-    public void buildAnnotationTypeRequiredMemberSummary(XMLNode node) {
+-        buildSummary(
+-            memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED],
+-                visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED]);
++    public void buildAnnotationTypeOptionalMemberSummary(XMLNode node, Content memberSummaryTree) {
++        MemberSummaryWriter writer =
++                memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL];
++        VisibleMemberMap visibleMemberMap =
++                visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL];
++        addSummary(writer, visibleMemberMap, false, memberSummaryTree);
+     }
+ 
+-        /**
+-         * Build the summary for the fields.
+-         */
+-        public void buildFieldsSummary(XMLNode node) {
+-                buildSummary(
+-                        memberSummaryWriters[VisibleMemberMap.FIELDS],
+-                        visibleMemberMaps[VisibleMemberMap.FIELDS]);
+-        }
++    /**
++     * Build the summary for the optional members.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberSummaryTree the content tree to which the documentation will be added
++     */
++    public void buildAnnotationTypeRequiredMemberSummary(XMLNode node, Content memberSummaryTree) {
++        MemberSummaryWriter writer =
++                memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED];
++        VisibleMemberMap visibleMemberMap =
++                visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED];
++        addSummary(writer, visibleMemberMap, false, memberSummaryTree);
++    }
+ 
+-        /**
+-         * Build the inherited summary for the fields.
+-         */
+-        public void buildFieldsInheritedSummary(XMLNode node) {
+-                buildInheritedSummary(
+-                        memberSummaryWriters[VisibleMemberMap.FIELDS],
+-                        visibleMemberMaps[VisibleMemberMap.FIELDS]);
+-        }
++    /**
++     * Build the summary for the fields.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberSummaryTree the content tree to which the documentation will be added
++     */
++    public void buildFieldsSummary(XMLNode node, Content memberSummaryTree) {
++        MemberSummaryWriter writer =
++                memberSummaryWriters[VisibleMemberMap.FIELDS];
++        VisibleMemberMap visibleMemberMap =
++                visibleMemberMaps[VisibleMemberMap.FIELDS];
++        addSummary(writer, visibleMemberMap, true, memberSummaryTree);
++    }
+ 
+-        /**
+-         * Build the summary for the nested classes.
+-         */
+-        public void buildNestedClassesSummary(XMLNode node) {
+-                buildSummary(
+-                        memberSummaryWriters[VisibleMemberMap.INNERCLASSES],
+-                        visibleMemberMaps[VisibleMemberMap.INNERCLASSES]);
+-        }
++    /**
++     * Build the summary for the nested classes.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberSummaryTree the content tree to which the documentation will be added
++     */
++    public void buildNestedClassesSummary(XMLNode node, Content memberSummaryTree) {
++        MemberSummaryWriter writer =
++                memberSummaryWriters[VisibleMemberMap.INNERCLASSES];
++        VisibleMemberMap visibleMemberMap =
++                visibleMemberMaps[VisibleMemberMap.INNERCLASSES];
++        addSummary(writer, visibleMemberMap, true, memberSummaryTree);
++    }
+ 
+-        /**
+-         * Build the inherited summary for the nested classes.
+-         */
+-        public void buildNestedClassesInheritedSummary(XMLNode node) {
+-                buildInheritedSummary(
+-                        memberSummaryWriters[VisibleMemberMap.INNERCLASSES],
+-                        visibleMemberMaps[VisibleMemberMap.INNERCLASSES]);
+-        }
++    /**
++     * Build the method summary.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberSummaryTree the content tree to which the documentation will be added
++     */
++    public void buildMethodsSummary(XMLNode node, Content memberSummaryTree) {
++        MemberSummaryWriter writer =
++                memberSummaryWriters[VisibleMemberMap.METHODS];
++        VisibleMemberMap visibleMemberMap =
++                visibleMemberMaps[VisibleMemberMap.METHODS];
++        addSummary(writer, visibleMemberMap, true, memberSummaryTree);
++    }
+ 
+-        /**
+-         * Build the method summary.
+-         */
+-        public void buildMethodsSummary(XMLNode node) {
+-                buildSummary(
+-                        memberSummaryWriters[VisibleMemberMap.METHODS],
+-                        visibleMemberMaps[VisibleMemberMap.METHODS]);
+-        }
++    /**
++     * Build the constructor summary.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberSummaryTree the content tree to which the documentation will be added
++     */
++    public void buildConstructorsSummary(XMLNode node, Content memberSummaryTree) {
++        MemberSummaryWriter writer =
++                memberSummaryWriters[VisibleMemberMap.CONSTRUCTORS];
++        VisibleMemberMap visibleMemberMap =
++                visibleMemberMaps[VisibleMemberMap.CONSTRUCTORS];
++        addSummary(writer, visibleMemberMap, false, memberSummaryTree);
++    }
+ 
+-        /**
+-         * Build the inherited method summary.
+-         */
+-        public void buildMethodsInheritedSummary(XMLNode node) {
+-                buildInheritedSummary(
+-                        memberSummaryWriters[VisibleMemberMap.METHODS],
+-                        visibleMemberMaps[VisibleMemberMap.METHODS]);
+-        }
+-
+-        /**
+-         * Build the constructor summary.
+-         */
+-        public void buildConstructorsSummary(XMLNode node) {
+-                buildSummary(
+-                        memberSummaryWriters[VisibleMemberMap.CONSTRUCTORS],
+-                        visibleMemberMaps[VisibleMemberMap.CONSTRUCTORS]);
+-        }
+-
+-        /**
+-         * Build the member summary for the given members.
+-         *
+-         * @param writer           the summary writer to write the output.
+-         * @param visibleMemberMap the given members to summarize.
+-         */
+-        private void buildSummary(MemberSummaryWriter writer,
+-            VisibleMemberMap visibleMemberMap) {
+-        List members = new ArrayList(visibleMemberMap.getLeafClassMembers(
+-            configuration));
++    /**
++     * Build the member summary for the given members.
++     *
++     * @param writer the summary writer to write the output.
++     * @param visibleMemberMap the given members to summarize.
++     * @param summaryTreeList list of content trees to which the documentation will be added
++     */
++    private void buildSummary(MemberSummaryWriter writer,
++            VisibleMemberMap visibleMemberMap, LinkedList<Content> summaryTreeList) {
++        List<ProgramElementDoc> members = new ArrayList(visibleMemberMap.getLeafClassMembers(
++                configuration));
+         if (members.size() > 0) {
+             Collections.sort(members);
+-            writer.writeMemberSummaryHeader(classDoc);
++            Content tableTree = writer.getSummaryTableTree(classDoc);
+             for (int i = 0; i < members.size(); i++) {
+                 ProgramElementDoc member = (ProgramElementDoc) members.get(i);
+                 Tag[] firstSentenceTags = member.firstSentenceTags();
+@@ -301,32 +312,32 @@
+                     //Inherit comments from overriden or implemented method if
+                     //necessary.
+                     DocFinder.Output inheritedDoc =
+-                        DocFinder.search(new DocFinder.Input((MethodDoc) member));
++                            DocFinder.search(new DocFinder.Input((MethodDoc) member));
+                     if (inheritedDoc.holder != null &&
+                             inheritedDoc.holder.firstSentenceTags().length > 0) {
+                         firstSentenceTags = inheritedDoc.holder.firstSentenceTags();
+                     }
+                 }
+-                writer.writeMemberSummary(classDoc, member, firstSentenceTags,
+-                    i == 0, i == members.size() - 1);
++                writer.addMemberSummary(classDoc, member, firstSentenceTags, tableTree, i);
+             }
+-            writer.writeMemberSummaryFooter(classDoc);
++            summaryTreeList.add(tableTree);
+         }
+-        }
++    }
+ 
+     /**
+      * Build the inherited member summary for the given methods.
+      *
+-     * @param writer           the writer for this member summary.
++     * @param writer the writer for this member summary.
+      * @param visibleMemberMap the map for the members to document.
++     * @param summaryTreeList list of content trees to which the documentation will be added
+      */
+-        private void buildInheritedSummary(MemberSummaryWriter writer,
+-            VisibleMemberMap visibleMemberMap) {
++    private void buildInheritedSummary(MemberSummaryWriter writer,
++            VisibleMemberMap visibleMemberMap, LinkedList<Content> summaryTreeList) {
+         for (Iterator iter = visibleMemberMap.getVisibleClassesList().iterator();
+                 iter.hasNext();) {
+             ClassDoc inhclass = (ClassDoc) (iter.next());
+             if (! (inhclass.isPublic() ||
+-                Util.isLinkable(inhclass, configuration))) {
++                    Util.isLinkable(inhclass, configuration))) {
+                 continue;
+             }
+             if (inhclass == classDoc) {
+@@ -335,18 +346,45 @@
+             List inhmembers = visibleMemberMap.getMembersFor(inhclass);
+             if (inhmembers.size() > 0) {
+                 Collections.sort(inhmembers);
+-                writer.writeInheritedMemberSummaryHeader(inhclass);
++                Content inheritedTree = writer.getInheritedSummaryHeader(inhclass);
++                Content linksTree = writer.getInheritedSummaryLinksTree();
+                 for (int j = 0; j < inhmembers.size(); ++j) {
+-                    writer.writeInheritedMemberSummary(
+-                        inhclass.isPackagePrivate() &&
++                    writer.addInheritedMemberSummary(
++                            inhclass.isPackagePrivate() &&
+                             ! Util.isLinkable(inhclass, configuration) ?
+                             classDoc : inhclass,
+-                        (ProgramElementDoc) inhmembers.get(j),
+-                        j == 0,
+-                        j == inhmembers.size() - 1);
++			    (ProgramElementDoc) inhmembers.get(j),
++			    j == 0,
++			    j == inhmembers.size() - 1, linksTree);
+                 }
+-                writer.writeInheritedMemberSummaryFooter(inhclass);
++                inheritedTree.addContent(linksTree);
++                summaryTreeList.add(writer.getMemberTree(inheritedTree));
+             }
+         }
+     }
++
++    /**
++     * Add the summary for the documentation.
++     *
++     * @param writer the writer for this member summary.
++     * @param visibleMemberMap the map for the members to document.
++     * @param showInheritedSummary true if inherited summary should be documented
++     * @param memberSummaryTree the content tree to which the documentation will be added
++     */
++    private void addSummary(MemberSummaryWriter writer,
++            VisibleMemberMap visibleMemberMap, boolean showInheritedSummary,
++            Content memberSummaryTree) {
++        LinkedList<Content> summaryTreeList = new LinkedList<Content>();
++        buildSummary(writer, visibleMemberMap, summaryTreeList);
++        if (showInheritedSummary)
++            buildInheritedSummary(writer, visibleMemberMap, summaryTreeList);
++        if (!summaryTreeList.isEmpty()) {
++            Content memberTree = writer.getMemberSummaryHeader(
++                    classDoc, memberSummaryTree);
++            for (int i = 0; i < summaryTreeList.size(); i++) {
++                memberTree.addContent(summaryTreeList.get(i));
++            }
++            memberSummaryTree.addContent(writer.getMemberTree(memberTree));
++        }
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
+@@ -25,10 +25,10 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
++import java.util.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+-import java.util.*;
+ 
+ /**
+  * Builds documentation for a method.
+@@ -38,164 +38,170 @@
+  * Do not use it as an API
+  *
+  * @author Jamie Ho
++ * @author Bhavesh Patel (Modified)
+  * @since 1.5
+  */
+ public class MethodBuilder extends AbstractMemberBuilder {
+ 
+-        /**
+-         * The index of the current field that is being documented at this point
+-         * in time.
+-         */
+-        private int currentMethodIndex;
++    /**
++     * The index of the current field that is being documented at this point
++     * in time.
++     */
++    private int currentMethodIndex;
+ 
+-        /**
+-         * The class whose methods are being documented.
+-         */
+-        private ClassDoc classDoc;
++    /**
++     * The class whose methods are being documented.
++     */
++    private ClassDoc classDoc;
+ 
+-        /**
+-         * The visible methods for the given class.
+-         */
+-        private VisibleMemberMap visibleMemberMap;
++    /**
++     * The visible methods for the given class.
++     */
++    private VisibleMemberMap visibleMemberMap;
+ 
+-        /**
+-         * The writer to output the method documentation.
+-         */
+-        private MethodWriter writer;
++    /**
++     * The writer to output the method documentation.
++     */
++    private MethodWriter writer;
+ 
+-        /**
+-         * The methods being documented.
+-         */
+-        private List methods;
++    /**
++     * The methods being documented.
++     */
++    private List<ProgramElementDoc> methods;
+ 
+-        private MethodBuilder(Configuration configuration) {
+-                super(configuration);
++    private MethodBuilder(Configuration configuration) {
++        super(configuration);
++    }
++
++    /**
++     * Construct a new MethodBuilder.
++     *
++     * @param configuration the current configuration of the doclet.
++     * @param classDoc the class whoses members are being documented.
++     * @param writer the doclet specific writer.
++     *
++     * @return an instance of a MethodBuilder.
++     */
++    public static MethodBuilder getInstance(
++            Configuration configuration,
++            ClassDoc classDoc,
++            MethodWriter writer) {
++        MethodBuilder builder = new MethodBuilder(configuration);
++        builder.classDoc = classDoc;
++        builder.writer = writer;
++        builder.visibleMemberMap =
++                new VisibleMemberMap(
++                classDoc,
++                VisibleMemberMap.METHODS,
++                configuration.nodeprecated);
++        builder.methods =
++                new ArrayList<ProgramElementDoc>(builder.visibleMemberMap.getLeafClassMembers(
++                configuration));
++        if (configuration.getMemberComparator() != null) {
++            Collections.sort(
++                    builder.methods,
++                    configuration.getMemberComparator());
+         }
+ 
+-        /**
+-         * Construct a new MethodBuilder.
+-         *
+-         * @param configuration the current configuration of the doclet.
+-         * @param classDoc the class whoses members are being documented.
+-         * @param writer the doclet specific writer.
+-         *
+-         * @return an instance of a MethodBuilder.
+-         */
+-        public static MethodBuilder getInstance(
+-                Configuration configuration,
+-                ClassDoc classDoc,
+-                MethodWriter writer) {
+-                MethodBuilder builder = new MethodBuilder(configuration);
+-                builder.classDoc = classDoc;
+-                builder.writer = writer;
+-                builder.visibleMemberMap =
+-                        new VisibleMemberMap(
+-                                classDoc,
+-                                VisibleMemberMap.METHODS,
+-                                configuration.nodeprecated);
+-                builder.methods =
+-                        new ArrayList(builder.visibleMemberMap.getLeafClassMembers(
+-                configuration));
+-                if (configuration.getMemberComparator() != null) {
+-                        Collections.sort(
+-                                builder.methods,
+-                                configuration.getMemberComparator());
+-                }
+-                return builder;
++    /**
++     * {@inheritDoc}
++     */
++    public String getName() {
++        return "MethodDetails";
++    }
++
++    /**
++     * Returns a list of methods that will be documented for the given class.
++     * This information can be used for doclet specific documentation
++     * generation.
++     *
++     * @param classDoc the {@link ClassDoc} we want to check.
++     * @return a list of methods that will be documented.
++     */
++    public List<ProgramElementDoc> members(ClassDoc classDoc) {
++        return visibleMemberMap.getMembersFor(classDoc);
++    }
++
++    /**
++     * Returns the visible member map for the methods of this class.
++     *
++     * @return the visible member map for the methods of this class.
++     */
++    public VisibleMemberMap getVisibleMemberMap() {
++        return visibleMemberMap;
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public boolean hasMembersToDocument() {
++        return methods.size() > 0;
++    }
++
++    /**
++     * Build the method documentation.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param memberDetailsTree the content tree to which the documentation will be added
++     */
++    public void buildMethodDoc(XMLNode node, Content memberDetailsTree) {
++        if (writer == null) {
++            return;
+         }
++        int size = methods.size();
++        if (size > 0) {
++            Content methodDetailsTree = writer.getMethodDetailsTreeHeader(
++                    classDoc, memberDetailsTree);
++            for (currentMethodIndex = 0; currentMethodIndex < size;
++                    currentMethodIndex++) {
++                Content methodDocTree = writer.getMethodDocTreeHeader(
++                        (MethodDoc) methods.get(currentMethodIndex),
++                        methodDetailsTree);
++                buildChildren(node, methodDocTree);
++                methodDetailsTree.addContent(writer.getMethodDoc(
++                        methodDocTree, (currentMethodIndex == size - 1)));
++            }
++            memberDetailsTree.addContent(
++                    writer.getMethodDetails(methodDetailsTree));
++        }
++    }
+ 
+-        /**
+-         * {@inheritDoc}
+-         */
+-        public String getName() {
+-                return "MethodDetails";
+-        }
++    /**
++     * Build the signature.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param methodDocTree the content tree to which the documentation will be added
++     */
++    public void buildSignature(XMLNode node, Content methodDocTree) {
++        methodDocTree.addContent(
++                writer.getSignature((MethodDoc) methods.get(currentMethodIndex)));
++    }
+ 
+-        /**
+-         * Returns a list of methods that will be documented for the given class.
+-         * This information can be used for doclet specific documentation
+-         * generation.
+-         *
+-         * @param classDoc the {@link ClassDoc} we want to check.
+-         * @return a list of methods that will be documented.
+-         */
+-        public List members(ClassDoc classDoc) {
+-                return visibleMemberMap.getMembersFor(classDoc);
+-        }
++    /**
++     * Build the deprecation information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param methodDocTree the content tree to which the documentation will be added
++     */
++    public void buildDeprecationInfo(XMLNode node, Content methodDocTree) {
++        writer.addDeprecated(
++                (MethodDoc) methods.get(currentMethodIndex), methodDocTree);
++    }
+ 
+-        /**
+-         * Returns the visible member map for the methods of this class.
+-         *
+-         * @return the visible member map for the methods of this class.
+-         */
+-        public VisibleMemberMap getVisibleMemberMap() {
+-                return visibleMemberMap;
+-        }
+-
+-        /**
+-         * {@inheritDoc}
+-         */
+-        public boolean hasMembersToDocument() {
+-                return methods.size() > 0;
+-        }
+-
+-        /**
+-         * Build the method documentation.
+-         */
+-        public void buildMethodDoc(XMLNode node) {
+-                if (writer == null) {
+-                        return;
+-                }
+-                for (currentMethodIndex = 0;
+-                        currentMethodIndex < methods.size();
+-                        currentMethodIndex++) {
+-                        buildChildren(node);
+-                }
+-        }
+-
+-        /**
+-         * Build the overall header.
+-         */
+-        public void buildHeader(XMLNode node) {
+-                writer.writeHeader(
+-                        classDoc,
+-                        configuration.getText("doclet.Method_Detail"));
+-        }
+-
+-        /**
+-         * Build the header for the individual method.
+-         */
+-        public void buildMethodHeader(XMLNode node) {
+-                writer.writeMethodHeader(
+-                        (MethodDoc) methods.get(currentMethodIndex),
+-                        currentMethodIndex == 0);
+-        }
+-
+-        /**
+-         * Build the signature.
+-         */
+-        public void buildSignature(XMLNode node) {
+-                writer.writeSignature((MethodDoc) methods.get(currentMethodIndex));
+-        }
+-
+-        /**
+-         * Build the deprecation information.
+-         */
+-        public void buildDeprecationInfo(XMLNode node) {
+-                writer.writeDeprecated((MethodDoc) methods.get(currentMethodIndex));
+-        }
+-
+-        /**
+-         * Build the comments for the method.  Do nothing if
+-         * {@link Configuration#nocomment} is set to true.  If this method
+-         */
+-        public void buildMethodComments(XMLNode node) {
+-                if (!configuration.nocomment) {
++    /**
++     * Build the comments for the method.  Do nothing if
++     * {@link Configuration#nocomment} is set to true.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param methodDocTree the content tree to which the documentation will be added
++     */
++    public void buildMethodComments(XMLNode node, Content methodDocTree) {
++        if (!configuration.nocomment) {
+             MethodDoc method = (MethodDoc) methods.get(currentMethodIndex);
+ 
+             if (method.inlineTags().length == 0) {
+                 DocFinder.Output docs = DocFinder.search(
+-                    new DocFinder.Input(method));
++                        new DocFinder.Input(method));
+                 method = docs.inlineTags != null && docs.inlineTags.length > 0 ?
+                     (MethodDoc) docs.holder : method;
+ 
+@@ -203,39 +209,27 @@
+             //NOTE:  When we fix the bug where ClassDoc.interfaceTypes() does
+             //       not pass all implemented interfaces, holder will be the
+             //       interface type.  For now, it is really the erasure.
+-            writer.writeComments(method.containingClass(), method);
+-                }
++            writer.addComments(method.containingClass(), method, methodDocTree);
+         }
++    }
+ 
++    /**
++     * Build the tag information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param methodDocTree the content tree to which the documentation will be added
++     */
++    public void buildTagInfo(XMLNode node, Content methodDocTree) {
++        writer.addTags((MethodDoc) methods.get(currentMethodIndex),
++                methodDocTree);
++    }
+ 
+-
+-        /**
+-         * Build the tag information.
+-         */
+-        public void buildTagInfo(XMLNode node) {
+-                writer.writeTags((MethodDoc) methods.get(currentMethodIndex));
+-        }
+-
+-        /**
+-         * Build the footer of the method.
+-         */
+-        public void buildMethodFooter(XMLNode node) {
+-                writer.writeMethodFooter();
+-        }
+-
+-        /**
+-         * Build the overall footer.
+-         */
+-        public void buildFooter(XMLNode node) {
+-                writer.writeFooter(classDoc);
+-        }
+-
+-        /**
+-         * Return the method writer for this builder.
+-         *
+-         * @return the method writer for this builder.
+-         */
+-        public MethodWriter getWriter() {
+-                return writer;
+-        }
++    /**
++     * Return the method writer for this builder.
++     *
++     * @return the method writer for this builder.
++     */
++    public MethodWriter getWriter() {
++        return writer;
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
+@@ -25,10 +25,10 @@
+ 
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
++import java.io.*;
++import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+-import com.sun.javadoc.*;
+-import java.io.*;
+ 
+ /**
+  * Builds the summary for a given package.
+@@ -42,281 +42,315 @@
+  * @since 1.5
+  */
+ public class PackageSummaryBuilder extends AbstractBuilder {
++    /**
++     * The root element of the package summary XML is {@value}.
++     */
++    public static final String ROOT = "PackageDoc";
+ 
+-        /**
+-         * The root element of the package summary XML is {@value}.
+-         */
+-        public static final String ROOT = "PackageDoc";
++    /**
++     * The package being documented.
++     */
++    private PackageDoc packageDoc;
+ 
+-        /**
+-         * The package being documented.
+-         */
+-        private PackageDoc packageDoc;
++    /**
++     * The doclet specific writer that will output the result.
++     */
++    private PackageSummaryWriter packageWriter;
+ 
+-        /**
+-         * The doclet specific writer that will output the result.
+-         */
+-        private PackageSummaryWriter packageWriter;
++    /**
++     * The content that will be added to the package summary documentation tree.
++     */
++    private Content contentTree;
+ 
+-        private PackageSummaryBuilder(Configuration configuration) {
+-                super(configuration);
++    private PackageSummaryBuilder(Configuration configuration) {
++        super(configuration);
++    }
++
++    /**
++     * Construct a new PackageSummaryBuilder.
++     * @param configuration the current configuration of the doclet.
++     * @param pkg the package being documented.
++     * @param packageWriter the doclet specific writer that will output the
++     *        result.
++     *
++     * @return an instance of a PackageSummaryBuilder.
++     */
++    public static PackageSummaryBuilder getInstance(
++        Configuration configuration,
++        PackageDoc pkg,
++        PackageSummaryWriter packageWriter) {
++        PackageSummaryBuilder builder =
++                new PackageSummaryBuilder(configuration);
++        builder.packageDoc = pkg;
++        builder.packageWriter = packageWriter;
++        return builder;
++    }
++
++    /**
++     * Build the package summary.
++     */
++    public void build() throws IOException {
++        if (packageWriter == null) {
++            //Doclet does not support this output.
++            return;
++        }
++        build(LayoutParser.getInstance(configuration).parseXML(ROOT), contentTree);
++    }
++
++    /**
++     * {@inheritDoc}
++     */
++    public String getName() {
++        return ROOT;
++    }
++
++    /**
++     * Build the package documentation.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param contentTree the content tree to which the documentation will be added
++     */
++    public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception {
++        contentTree = packageWriter.getPackageHeader(
++                Util.getPackageName(packageDoc));
++        buildChildren(node, contentTree);
++        packageWriter.addPackageFooter(contentTree);
++        packageWriter.printDocument(contentTree);
++        packageWriter.close();
++        Util.copyDocFiles(
++                configuration,
++                Util.getPackageSourcePath(configuration, packageDoc),
++                DirectoryManager.getDirectoryPath(packageDoc)
++                        + File.separator
++                        + DocletConstants.DOC_FILES_DIR_NAME,
++                true);
++    }
++
++    /**
++     * Build the content for the package doc.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param contentTree the content tree to which the package contents
++     *                    will be added
++     */
++    public void buildContent(XMLNode node, Content contentTree) {
++        Content packageContentTree = packageWriter.getContentHeader();
++        buildChildren(node, packageContentTree);
++        contentTree.addContent(packageContentTree);
++    }
++
++    /**
++     * Build the package summary.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param packageContentTree the package content tree to which the summaries will
++     *                           be added
++     */
++    public void buildSummary(XMLNode node, Content packageContentTree) {
++        Content summaryContentTree = packageWriter.getSummaryHeader();
++        buildChildren(node, summaryContentTree);
++        packageContentTree.addContent(summaryContentTree);
++    }
++
++    /**
++     * Build the summary for the interfaces in this package.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param summaryContentTree the summary tree to which the interface summary
++     *                           will be added
++     */
++    public void buildInterfaceSummary(XMLNode node, Content summaryContentTree) {
++        String interfaceTableSummary =
++                configuration.getText("doclet.Member_Table_Summary",
++                configuration.getText("doclet.Interface_Summary"),
++                configuration.getText("doclet.interfaces"));
++        String[] interfaceTableHeader = new String[] {
++           configuration.getText("doclet.Interface"),
++            configuration.getText("doclet.Description")
++        };
++        ClassDoc[] interfaces =
++                packageDoc.isIncluded()
++                        ? packageDoc.interfaces()
++                        : configuration.classDocCatalog.interfaces(
++                                Util.getPackageName(packageDoc));
++        if (interfaces.length > 0) {
++            packageWriter.addClassesSummary(
++                    interfaces,
++                    configuration.getText("doclet.Interface_Summary"),
++                    interfaceTableSummary, interfaceTableHeader, summaryContentTree);
+         }
+ 
+-        /**
+-         * Construct a new PackageSummaryBuilder.
+-         * @param configuration the current configuration of the doclet.
+-         * @param pkg the package being documented.
+-         * @param packageWriter the doclet specific writer that will output the
+-         *        result.
+-         *
+-         * @return an instance of a PackageSummaryBuilder.
+-         */
+-        public static PackageSummaryBuilder getInstance(
+-                Configuration configuration,
+-                PackageDoc pkg,
+-                PackageSummaryWriter packageWriter) {
+-                PackageSummaryBuilder builder =
+-                        new PackageSummaryBuilder(configuration);
+-                builder.packageDoc = pkg;
+-                builder.packageWriter = packageWriter;
+-                return builder;
++    /**
++     * Build the summary for the classes in this package.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param summaryContentTree the summary tree to which the class summary will
++     *                           be added
++     */
++    public void buildClassSummary(XMLNode node, Content summaryContentTree) {
++        String classTableSummary =
++                configuration.getText("doclet.Member_Table_Summary",
++                configuration.getText("doclet.Class_Summary"),
++                configuration.getText("doclet.classes"));
++        String[] classTableHeader = new String[] {
++            configuration.getText("doclet.Class"),
++            configuration.getText("doclet.Description")
++        };
++        ClassDoc[] classes =
++                packageDoc.isIncluded()
++                        ? packageDoc.ordinaryClasses()
++                        : configuration.classDocCatalog.ordinaryClasses(
++                                Util.getPackageName(packageDoc));
++        if (classes.length > 0) {
++            packageWriter.addClassesSummary(
++                    classes,
++                    configuration.getText("doclet.Class_Summary"),
++                    classTableSummary, classTableHeader, summaryContentTree);
++        }
++    }
++
++    /**
++     * Build the summary for the enums in this package.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param summaryContentTree the summary tree to which the enum summary will
++     *                           be added
++     */
++    public void buildEnumSummary(XMLNode node, Content summaryContentTree) {
++        String enumTableSummary =
++                configuration.getText("doclet.Member_Table_Summary",
++                configuration.getText("doclet.Enum_Summary"),
++                configuration.getText("doclet.enums"));
++        String[] enumTableHeader = new String[] {
++            configuration.getText("doclet.Enum"),
++            configuration.getText("doclet.Description")
++        };
++        ClassDoc[] enums =
++                packageDoc.isIncluded()
++                        ? packageDoc.enums()
++                        : configuration.classDocCatalog.enums(
++                                Util.getPackageName(packageDoc));
++        if (enums.length > 0) {
++            packageWriter.addClassesSummary(
++                    enums,
++                    configuration.getText("doclet.Enum_Summary"),
++                    enumTableSummary, enumTableHeader, summaryContentTree);
++        }
++    }
++
++    /**
++     * Build the summary for the exceptions in this package.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param summaryContentTree the summary tree to which the exception summary will
++     *                           be added
++     */
++    public void buildExceptionSummary(XMLNode node, Content summaryContentTree) {
++        String exceptionTableSummary =
++                configuration.getText("doclet.Member_Table_Summary",
++                configuration.getText("doclet.Exception_Summary"),
++                configuration.getText("doclet.exceptions"));
++        String[] exceptionTableHeader = new String[] {
++            configuration.getText("doclet.Exception"),
++            configuration.getText("doclet.Description")
++        };
++        ClassDoc[] exceptions =
++                packageDoc.isIncluded()
++                        ? packageDoc.exceptions()
++                        : configuration.classDocCatalog.exceptions(
++                                Util.getPackageName(packageDoc));
++        if (exceptions.length > 0) {
++            packageWriter.addClassesSummary(
++                    exceptions,
++                    configuration.getText("doclet.Exception_Summary"),
++                    exceptionTableSummary, exceptionTableHeader, summaryContentTree);
++         }
++    }
++
++    /**
++     * Build the summary for the errors in this package.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param summaryContentTree the summary tree to which the error summary will
++     *                           be added
++     */
++    public void buildErrorSummary(XMLNode node, Content summaryContentTree) {
++        String errorTableSummary =
++                configuration.getText("doclet.Member_Table_Summary",
++                configuration.getText("doclet.Error_Summary"),
++                configuration.getText("doclet.errors"));
++        String[] errorTableHeader = new String[] {
++            configuration.getText("doclet.Error"),
++            configuration.getText("doclet.Description")
++        };
++        ClassDoc[] errors =
++                packageDoc.isIncluded()
++                        ? packageDoc.errors()
++                        : configuration.classDocCatalog.errors(
++                                Util.getPackageName(packageDoc));
++        if (errors.length > 0) {
++            packageWriter.addClassesSummary(
++                    errors,
++                    configuration.getText("doclet.Error_Summary"),
++                    errorTableSummary, errorTableHeader, summaryContentTree);
++        }
++    }
++
++    /**
++     * Build the summary for the annotation type in this package.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param summaryContentTree the summary tree to which the annotation type
++     *                           summary will be added
++     */
++    public void buildAnnotationTypeSummary(XMLNode node, Content summaryContentTree) {
++        String annotationtypeTableSummary =
++                configuration.getText("doclet.Member_Table_Summary",
++                configuration.getText("doclet.Annotation_Types_Summary"),
++                configuration.getText("doclet.annotationtypes"));
++        String[] annotationtypeTableHeader = new String[] {
++            configuration.getText("doclet.AnnotationType"),
++            configuration.getText("doclet.Description")
++        };
++        ClassDoc[] annotationTypes =
++                packageDoc.isIncluded()
++                        ? packageDoc.annotationTypes()
++                        : configuration.classDocCatalog.annotationTypes(
++                                Util.getPackageName(packageDoc));
++        if (annotationTypes.length > 0) {
++            packageWriter.addClassesSummary(
++                    annotationTypes,
++                    configuration.getText("doclet.Annotation_Types_Summary"),
++                    annotationtypeTableSummary, annotationtypeTableHeader,
++                    summaryContentTree);
++        }
++    }
++
++    /**
++     * Build the description of the summary.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param packageContentTree the tree to which the package description will
++     *                           be added
++     */
++    public void buildPackageDescription(XMLNode node, Content packageContentTree) {
++        if (configuration.nocomment) {
++            return;
++        }
++        packageWriter.addPackageDescription(packageContentTree);
++    }
++
++    /**
++     * Build the tags of the summary.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param packageContentTree the tree to which the package tags will be added
++     */
++    public void buildPackageTags(XMLNode node, Content packageContentTree) {
++        if (configuration.nocomment) {
++            return;
+         }
+ 
+-        /**
+-         * Build the package summary.
+-         */
+-        public void build() throws IOException {
+-                if (packageWriter == null) {
+-                        //Doclet does not support this output.
+-                        return;
+-                }
+-                build(LayoutParser.getInstance(configuration).parseXML(ROOT));
+-        }
+-
+-        /**
+-         * {@inheritDoc}
+-         */
+-        public String getName() {
+-                return ROOT;
+-        }
+-
+-        /**
+-         * Build the package documentation.
+-         */
+-        public void buildPackageDoc(XMLNode node) throws Exception {
+-                buildChildren(node);
+-                packageWriter.close();
+-                Util.copyDocFiles(
+-                        configuration,
+-                        Util.getPackageSourcePath(configuration, packageDoc),
+-                        DirectoryManager.getDirectoryPath(packageDoc)
+-                                + File.separator
+-                                + DocletConstants.DOC_FILES_DIR_NAME,
+-                        true);
+-        }
+-
+-        /**
+-         * Build the header of the summary.
+-         */
+-        public void buildPackageHeader(XMLNode node) {
+-                packageWriter.writePackageHeader(Util.getPackageName(packageDoc));
+-        }
+-
+-        /**
+-         * Build the description of the summary.
+-         */
+-        public void buildPackageDescription(XMLNode node) {
+-                if (configuration.nocomment) {
+-                        return;
+-                }
+-                packageWriter.writePackageDescription();
+-        }
+-
+-        /**
+-         * Build the tags of the summary.
+-         */
+-        public void buildPackageTags(XMLNode node) {
+-                if (configuration.nocomment) {
+-                        return;
+-                }
+-                packageWriter.writePackageTags();
+-        }
+-
+-        /**
+-         * Build the package summary.
+-         */
+-        public void buildSummary(XMLNode node) {
+-                buildChildren(node);
+-        }
+-
+-        /**
+-         * Build the overall header.
+-         */
+-        public void buildSummaryHeader(XMLNode node) {
+-                packageWriter.writeSummaryHeader();
+-        }
+-
+-        /**
+-         * Build the overall footer.
+-         */
+-        public void buildSummaryFooter(XMLNode node) {
+-                packageWriter.writeSummaryFooter();
+-        }
+-
+-        /**
+-         * Build the summary for the classes in this package.
+-         */
+-        public void buildClassSummary(XMLNode node) {
+-            String classTableSummary =
+-                    configuration.getText("doclet.Member_Table_Summary",
+-                    configuration.getText("doclet.Class_Summary"),
+-                    configuration.getText("doclet.classes"));
+-            String[] classTableHeader = new String[] {
+-                configuration.getText("doclet.Class"),
+-                configuration.getText("doclet.Description")
+-            };
+-            ClassDoc[] classes =
+-                        packageDoc.isIncluded()
+-                                ? packageDoc.ordinaryClasses()
+-                                : configuration.classDocCatalog.ordinaryClasses(
+-                                        Util.getPackageName(packageDoc));
+-                if (classes.length > 0) {
+-                        packageWriter.writeClassesSummary(
+-                                classes,
+-                                configuration.getText("doclet.Class_Summary"),
+-                                classTableSummary, classTableHeader);
+-                }
+-        }
+-
+-        /**
+-         * Build the summary for the interfaces in this package.
+-         */
+-        public void buildInterfaceSummary(XMLNode node) {
+-            String interfaceTableSummary =
+-                    configuration.getText("doclet.Member_Table_Summary",
+-                    configuration.getText("doclet.Interface_Summary"),
+-                    configuration.getText("doclet.interfaces"));
+-            String[] interfaceTableHeader = new String[] {
+-                configuration.getText("doclet.Interface"),
+-                configuration.getText("doclet.Description")
+-            };
+-            ClassDoc[] interfaces =
+-                        packageDoc.isIncluded()
+-                                ? packageDoc.interfaces()
+-                                : configuration.classDocCatalog.interfaces(
+-                                        Util.getPackageName(packageDoc));
+-                if (interfaces.length > 0) {
+-                        packageWriter.writeClassesSummary(
+-                                interfaces,
+-                                configuration.getText("doclet.Interface_Summary"),
+-                                interfaceTableSummary, interfaceTableHeader);
+-                }
+-        }
+-
+-        /**
+-         * Build the summary for the enums in this package.
+-         */
+-        public void buildAnnotationTypeSummary(XMLNode node) {
+-            String annotationtypeTableSummary =
+-                    configuration.getText("doclet.Member_Table_Summary",
+-                    configuration.getText("doclet.Annotation_Types_Summary"),
+-                    configuration.getText("doclet.annotationtypes"));
+-            String[] annotationtypeTableHeader = new String[] {
+-                configuration.getText("doclet.AnnotationType"),
+-                configuration.getText("doclet.Description")
+-            };
+-            ClassDoc[] annotationTypes =
+-                        packageDoc.isIncluded()
+-                                ? packageDoc.annotationTypes()
+-                                : configuration.classDocCatalog.annotationTypes(
+-                                        Util.getPackageName(packageDoc));
+-                if (annotationTypes.length > 0) {
+-                        packageWriter.writeClassesSummary(
+-                                annotationTypes,
+-                                configuration.getText("doclet.Annotation_Types_Summary"),
+-                                annotationtypeTableSummary, annotationtypeTableHeader);
+-                }
+-        }
+-
+-        /**
+-         * Build the summary for the enums in this package.
+-         */
+-        public void buildEnumSummary(XMLNode node) {
+-            String enumTableSummary =
+-                    configuration.getText("doclet.Member_Table_Summary",
+-                    configuration.getText("doclet.Enum_Summary"),
+-                    configuration.getText("doclet.enums"));
+-            String[] enumTableHeader = new String[] {
+-                configuration.getText("doclet.Enum"),
+-                configuration.getText("doclet.Description")
+-            };
+-            ClassDoc[] enums =
+-                        packageDoc.isIncluded()
+-                                ? packageDoc.enums()
+-                                : configuration.classDocCatalog.enums(
+-                                        Util.getPackageName(packageDoc));
+-                if (enums.length > 0) {
+-                        packageWriter.writeClassesSummary(
+-                                enums,
+-                                configuration.getText("doclet.Enum_Summary"),
+-                                enumTableSummary, enumTableHeader);
+-                }
+-        }
+-
+-        /**
+-         * Build the summary for the exceptions in this package.
+-         */
+-        public void buildExceptionSummary(XMLNode node) {
+-            String exceptionTableSummary =
+-                    configuration.getText("doclet.Member_Table_Summary",
+-                    configuration.getText("doclet.Exception_Summary"),
+-                    configuration.getText("doclet.exceptions"));
+-            String[] exceptionTableHeader = new String[] {
+-                configuration.getText("doclet.Exception"),
+-                configuration.getText("doclet.Description")
+-            };
+-            ClassDoc[] exceptions =
+-                        packageDoc.isIncluded()
+-                                ? packageDoc.exceptions()
+-                                : configuration.classDocCatalog.exceptions(
+-                                        Util.getPackageName(packageDoc));
+-                if (exceptions.length > 0) {
+-                        packageWriter.writeClassesSummary(
+-                                exceptions,
+-                                configuration.getText("doclet.Exception_Summary"),
+-                                exceptionTableSummary, exceptionTableHeader);
+-                }
+-        }
+-
+-        /**
+-         * Build the summary for the errors in this package.
+-         */
+-        public void buildErrorSummary(XMLNode node) {
+-            String errorTableSummary =
+-                    configuration.getText("doclet.Member_Table_Summary",
+-                    configuration.getText("doclet.Error_Summary"),
+-                    configuration.getText("doclet.errors"));
+-            String[] errorTableHeader = new String[] {
+-                configuration.getText("doclet.Error"),
+-                configuration.getText("doclet.Description")
+-            };
+-            ClassDoc[] errors =
+-                        packageDoc.isIncluded()
+-                                ? packageDoc.errors()
+-                                : configuration.classDocCatalog.errors(
+-                                        Util.getPackageName(packageDoc));
+-                if (errors.length > 0) {
+-                        packageWriter.writeClassesSummary(
+-                                errors,
+-                                configuration.getText("doclet.Error_Summary"),
+-                                errorTableSummary, errorTableHeader);
+-                }
+-        }
+-
+-        /**
+-         * Build the footer of the summary.
+-         */
+-        public void buildPackageFooter(XMLNode node) {
+-                packageWriter.writePackageFooter();
+-        }
++        packageWriter.addPackageTags(packageContentTree);
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+@@ -27,7 +27,6 @@
+ 
+ import java.io.*;
+ import java.util.*;
+-
+ import com.sun.javadoc.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+@@ -87,6 +86,11 @@
+      */
+     protected MemberDoc currentMember;
+ 
++    /**
++     * The content that will be added to the serialized form documentation tree.
++     */
++    private Content contentTree;
++
+     private SerializedFormBuilder(Configuration configuration) {
+         super(configuration);
+     }
+@@ -117,7 +121,7 @@
+         } catch (Exception e) {
+             throw new DocletAbortException();
+         }
+-        build(LayoutParser.getInstance(configuration).parseXML(NAME));
++        build(LayoutParser.getInstance(configuration).parseXML(NAME), contentTree);
+         writer.close();
+     }
+ 
+@@ -130,34 +134,44 @@
+ 
+     /**
+      * Build the serialized form.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param serializedTree content tree to which the documentation will be added
+      */
+-    public void buildSerializedForm(XMLNode node) throws Exception {
+-        buildChildren(node);
++    public void buildSerializedForm(XMLNode node, Content serializedTree) throws Exception {
++        serializedTree = writer.getHeader(configuration.getText(
++                "doclet.Serialized_Form"));
++        buildChildren(node, serializedTree);
++        writer.addFooter(serializedTree);
++        writer.printDocument(serializedTree);
+         writer.close();
+     }
+ 
+     /**
+-     * Build the header.
++     * Build the serialized form summaries.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param serializedTree content tree to which the documentation will be added
+      */
+-    public void buildHeader(XMLNode node) {
+-        writer.writeHeader(configuration.getText("doclet.Serialized_Form"));
++    public void buildSerializedFormSummaries(XMLNode node, Content serializedTree) {
++        Content serializedSummariesTree = writer.getSerializedSummariesHeader();
++        PackageDoc[] packages = configuration.packages;
++        for (int i = 0; i < packages.length; i++) {
++            currentPackage = packages[i];
++            buildChildren(node, serializedSummariesTree);
++        }
++        serializedTree.addContent(writer.getSerializedContent(
++                serializedSummariesTree));
+     }
+ 
+     /**
+-     * Build the contents.
++     * Build the package serialized form for the current package being processed.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param serializedSummariesTree content tree to which the documentation will be added
+      */
+-    public void buildSerializedFormSummaries(XMLNode node) {
+-        PackageDoc[] packages = configuration.packages;
+-        for (int i = 0; i < packages.length; i++) {
+-            currentPackage = packages[i];
+-            buildChildren(node);
+-        }
+-    }
+-
+-    /**
+-     * Build the package serialized for for the current package being processed.
+-     */
+-    public void buildPackageSerializedForm(XMLNode node) {
++    public void buildPackageSerializedForm(XMLNode node, Content serializedSummariesTree) {
++        Content packageSerializedTree = writer.getPackageSerializedHeader();
+         String foo = currentPackage.name();
+         ClassDoc[] classes = currentPackage.allClasses(false);
+         if (classes == null || classes.length == 0) {
+@@ -169,14 +183,29 @@
+         if (!serialClassFoundToDocument(classes)) {
+             return;
+         }
+-        buildChildren(node);
++        buildChildren(node, packageSerializedTree);
++        serializedSummariesTree.addContent(packageSerializedTree);
+     }
+ 
+-    public void buildPackageHeader(XMLNode node) {
+-        writer.writePackageHeader(Util.getPackageName(currentPackage));
++    /**
++     * Build the package header.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param packageSerializedTree content tree to which the documentation will be added
++     */
++    public void buildPackageHeader(XMLNode node, Content packageSerializedTree) {
++        packageSerializedTree.addContent(writer.getPackageHeader(
++                Util.getPackageName(currentPackage)));
+     }
+ 
+-    public void buildClassSerializedForm(XMLNode node) {
++    /**
++     * Build the class serialized form.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param packageSerializedTree content tree to which the documentation will be added
++     */
++    public void buildClassSerializedForm(XMLNode node, Content packageSerializedTree) {
++        Content classSerializedTree = writer.getClassSerializedHeader();
+         ClassDoc[] classes = currentPackage.allClasses(false);
+         Arrays.sort(classes);
+         for (int j = 0; j < classes.length; j++) {
+@@ -187,35 +216,293 @@
+                 if(!serialClassInclude(currentClass)) {
+                     continue;
+                 }
+-                buildChildren(node);
++                Content classTree = writer.getClassHeader(currentClass);
++                buildChildren(node, classTree);
++                classSerializedTree.addContent(classTree);
+             }
+         }
+-    }
+-
+-    public void buildClassHeader(XMLNode node) {
+-        writer.writeClassHeader(currentClass);
++        packageSerializedTree.addContent(classSerializedTree);
+     }
+ 
+     /**
+      * Build the serial UID information for the given class.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classTree content tree to which the serial UID information will be added
+      */
+-    public void buildSerialUIDInfo(XMLNode node) {
++    public void buildSerialUIDInfo(XMLNode node, Content classTree) {
++        Content serialUidTree = writer.getSerialUIDInfoHeader();
+         FieldDoc[] fields = currentClass.fields(false);
+         for (int i = 0; i < fields.length; i++) {
+             if (fields[i].name().equals("serialVersionUID") &&
+                 fields[i].constantValueExpression() != null) {
+-                writer.writeSerialUIDInfo(SERIAL_VERSION_UID_HEADER,
+-                    fields[i].constantValueExpression());
+-                return;
++                writer.addSerialUIDInfo(SERIAL_VERSION_UID_HEADER,
++                        fields[i].constantValueExpression(), serialUidTree);
++                break;
++            }
++        }
++        classTree.addContent(serialUidTree);
++    }
++
++    /**
++     * Build the summaries for the methods and fields.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classTree content tree to which the documentation will be added
++     */
++    public void buildClassContent(XMLNode node, Content classTree) {
++        Content classContentTree = writer.getClassContentHeader();
++        buildChildren(node, classContentTree);
++        classTree.addContent(classContentTree);
++    }
++
++    /**
++     * Build the summaries for the methods that belong to the given
++     * class.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classContentTree content tree to which the documentation will be added
++     */
++    public void buildSerializableMethods(XMLNode node, Content classContentTree) {
++        Content serializableMethodTree = methodWriter.getSerializableMethodsHeader();
++        MemberDoc[] members = currentClass.serializationMethods();
++        int membersLength = members.length;
++        if (membersLength > 0) {
++            for (int i = 0; i < membersLength; i++) {
++                currentMember = members[i];
++                Content methodsContentTree = methodWriter.getMethodsContentHeader(
++                        (i == membersLength - 1));
++                buildChildren(node, methodsContentTree);
++                serializableMethodTree.addContent(methodsContentTree);
++            }
++        }
++        if (currentClass.serializationMethods().length > 0) {
++            classContentTree.addContent(methodWriter.getSerializableMethods(
++                    configuration.getText("doclet.Serialized_Form_methods"),
++                    serializableMethodTree));
++            if (currentClass.isSerializable() && !currentClass.isExternalizable()) {
++                if (currentClass.serializationMethods().length == 0) {
++                    Content noCustomizationMsg = methodWriter.getNoCustomizationMsg(
++                            configuration.getText(
++                            "doclet.Serializable_no_customization"));
++                    classContentTree.addContent(methodWriter.getSerializableMethods(
++                    configuration.getText("doclet.Serialized_Form_methods"),
++                    noCustomizationMsg));
++                }
+             }
+         }
+     }
+ 
+     /**
+-     * Build the footer.
++     * Build the method sub header.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param methodsContentTree content tree to which the documentation will be added
+      */
+-    public void buildFooter(XMLNode node) {
+-        writer.writeFooter();
++    public void buildMethodSubHeader(XMLNode node, Content methodsContentTree)  {
++        methodWriter.addMemberHeader((MethodDoc)currentMember, methodsContentTree);
++    }
++
++    /**
++     * Build the deprecated method description.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param methodsContentTree content tree to which the documentation will be added
++     */
++    public void buildDeprecatedMethodInfo(XMLNode node, Content methodsContentTree) {
++        methodWriter.addDeprecatedMemberInfo((MethodDoc) currentMember, methodsContentTree);
++    }
++
++    /**
++     * Build the information for the method.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param methodsContentTree content tree to which the documentation will be added
++     */
++    public void buildMethodInfo(XMLNode node, Content methodsContentTree)  {
++        if(configuration.nocomment){
++            return;
++        }
++        buildChildren(node, methodsContentTree);
++    }
++
++    /**
++     * Build method description.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param methodsContentTree content tree to which the documentation will be added
++     */
++    public void buildMethodDescription(XMLNode node, Content methodsContentTree) {
++        methodWriter.addMemberDescription((MethodDoc) currentMember, methodsContentTree);
++    }
++
++    /**
++     * Build the method tags.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param methodsContentTree content tree to which the documentation will be added
++     */
++    public void buildMethodTags(XMLNode node, Content methodsContentTree) {
++        methodWriter.addMemberTags((MethodDoc) currentMember, methodsContentTree);
++        MethodDoc method = (MethodDoc)currentMember;
++        if (method.name().compareTo("writeExternal") == 0
++                && method.tags("serialData").length == 0) {
++            if (configuration.serialwarn) {
++                configuration.getDocletSpecificMsg().warning(
++                        currentMember.position(), "doclet.MissingSerialDataTag",
++                        method.containingClass().qualifiedName(), method.name());
++            }
++        }
++    }
++
++    /**
++     * Build the field header.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classContentTree content tree to which the documentation will be added
++     */
++    public void buildFieldHeader(XMLNode node, Content classContentTree) {
++        if (currentClass.serializableFields().length > 0) {
++            buildFieldSerializationOverview(currentClass, classContentTree);
++        }
++    }
++
++    /**
++     * Build the serialization overview for the given class.
++     *
++     * @param classDoc the class to print the overview for.
++     * @param classContentTree content tree to which the documentation will be added
++     */
++    public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) {
++        if (classDoc.definesSerializableFields()) {
++            FieldDoc serialPersistentField =
++                Util.asList(classDoc.serializableFields()).get(0);
++            // Check to see if there are inline comments, tags or deprecation
++            // information to be printed.
++            if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
++                Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
++                Content fieldsOverviewContentTree = fieldWriter.getFieldsContentHeader(true);
++                fieldWriter.addMemberDeprecatedInfo(serialPersistentField,
++                        fieldsOverviewContentTree);
++                if (!configuration.nocomment) {
++                    fieldWriter.addMemberDescription(serialPersistentField,
++                            fieldsOverviewContentTree);
++                    fieldWriter.addMemberTags(serialPersistentField,
++                            fieldsOverviewContentTree);
++                }
++                serializableFieldsTree.addContent(fieldsOverviewContentTree);
++                classContentTree.addContent(fieldWriter.getSerializableFields(
++                        configuration.getText("doclet.Serialized_Form_class"),
++                        serializableFieldsTree));
++            }
++        }
++    }
++
++    /**
++     * Build the summaries for the fields that belong to the given class.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param classContentTree content tree to which the documentation will be added
++     */
++    public void buildSerializableFields(XMLNode node, Content classContentTree) {
++        MemberDoc[] members = currentClass.serializableFields();
++        int membersLength = members.length;
++        if (membersLength > 0) {
++            Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader();
++            for (int i = 0; i < membersLength; i++) {
++                currentMember = members[i];
++                if (!currentClass.definesSerializableFields()) {
++                    Content fieldsContentTree = fieldWriter.getFieldsContentHeader(
++                            (i == membersLength - 1));
++                    buildChildren(node, fieldsContentTree);
++                    serializableFieldsTree.addContent(fieldsContentTree);
++                }
++                else {
++                    buildSerialFieldTagsInfo(serializableFieldsTree);
++                }
++            }
++            classContentTree.addContent(fieldWriter.getSerializableFields(
++                    configuration.getText("doclet.Serialized_Form_fields"),
++                    serializableFieldsTree));
++        }
++    }
++
++    /**
++     * Build the field sub header.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param fieldsContentTree content tree to which the documentation will be added
++     */
++    public void buildFieldSubHeader(XMLNode node, Content fieldsContentTree) {
++        if (!currentClass.definesSerializableFields()) {
++            FieldDoc field = (FieldDoc) currentMember;
++            fieldWriter.addMemberHeader(field.type().asClassDoc(),
++                    field.type().typeName(), field.type().dimension(), field.name(),
++                    fieldsContentTree);
++        }
++    }
++
++    /**
++     * Build the field deprecation information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param fieldsContentTree content tree to which the documentation will be added
++     */
++    public void buildFieldDeprecationInfo(XMLNode node, Content fieldsContentTree) {
++        if (!currentClass.definesSerializableFields()) {
++            FieldDoc field = (FieldDoc)currentMember;
++            fieldWriter.addMemberDeprecatedInfo(field, fieldsContentTree);
++        }
++    }
++
++    /**
++     * Build the serial field tags information.
++     *
++     * @param serializableFieldsTree content tree to which the documentation will be added
++     */
++    public void buildSerialFieldTagsInfo(Content serializableFieldsTree) {
++        if(configuration.nocomment){
++            return;
++        }
++        FieldDoc field = (FieldDoc)currentMember;
++        // Process Serializable Fields specified as array of
++        // ObjectStreamFields. Print a member for each serialField tag.
++        // (There should be one serialField tag per ObjectStreamField
++        // element.)
++        SerialFieldTag[] tags = field.serialFieldTags();
++        Arrays.sort(tags);
++        int tagsLength = tags.length;
++        for (int i = 0; i < tagsLength; i++) {
++            Content fieldsContentTree = fieldWriter.getFieldsContentHeader(
++                    (i == tagsLength - 1));
++            fieldWriter.addMemberHeader(tags[i].fieldTypeDoc(),
++                    tags[i].fieldType(), "", tags[i].fieldName(), fieldsContentTree);
++            fieldWriter.addMemberDescription(tags[i], fieldsContentTree);
++            serializableFieldsTree.addContent(fieldsContentTree);
++        }
++    }
++
++    /**
++     * Build the field information.
++     *
++     * @param node the XML element that specifies which components to document
++     * @param fieldsContentTree content tree to which the documentation will be added
++     */
++    public void buildFieldInfo(XMLNode node, Content fieldsContentTree) {
++        if(configuration.nocomment){
++            return;
++        }
++        FieldDoc field = (FieldDoc)currentMember;
++        ClassDoc cd = field.containingClass();
++        // Process default Serializable field.
++        if ((field.tags("serial").length == 0) && ! field.isSynthetic()
++                && configuration.serialwarn) {
++            configuration.message.warning(field.position(),
++                    "doclet.MissingSerialTag", cd.qualifiedName(),
++                    field.name());
++        }
++        fieldWriter.addMemberDescription(field, fieldsContentTree);
++        fieldWriter.addMemberTags(field, fieldsContentTree);
+     }
+ 
+     /**
+@@ -298,208 +585,4 @@
+         return false;
+     }
+ 
+-    /**
+-     * Build the method header.
+-     */
+-    public void buildMethodHeader(XMLNode node) {
+-        if (currentClass.serializationMethods().length > 0) {
+-            methodWriter.writeHeader(
+-                configuration.getText("doclet.Serialized_Form_methods"));
+-            if (currentClass.isSerializable() && !currentClass.isExternalizable()) {
+-                if (currentClass.serializationMethods().length == 0) {
+-                    methodWriter.writeNoCustomizationMsg(
+-                        configuration.getText(
+-                            "doclet.Serializable_no_customization"));
+-                }
+-            }
+-        }
+-    }
+-
+-    /**
+-     * Build the method sub header.
+-     */
+-    public void buildMethodSubHeader(XMLNode node)  {
+-        methodWriter.writeMemberHeader((MethodDoc) currentMember);
+-    }
+-
+-    /**
+-     * Build the deprecated method description.
+-     */
+-    public void buildDeprecatedMethodInfo(XMLNode node) {
+-        methodWriter.writeDeprecatedMemberInfo((MethodDoc) currentMember);
+-    }
+-
+-    /**
+-     * Build method tags.
+-     */
+-    public void buildMethodDescription(XMLNode node) {
+-        methodWriter.writeMemberDescription((MethodDoc) currentMember);
+-    }
+-
+-    /**
+-     * Build the method tags.
+-     */
+-    public void buildMethodTags(XMLNode node) {
+-        methodWriter.writeMemberTags((MethodDoc) currentMember);
+-        MethodDoc method = (MethodDoc)currentMember;
+-        if (method.name().compareTo("writeExternal") == 0
+-            && method.tags("serialData").length == 0) {
+-            if (configuration.serialwarn) {
+-                configuration.getDocletSpecificMsg().warning(
+-                    currentMember.position(), "doclet.MissingSerialDataTag",
+-                    method.containingClass().qualifiedName(), method.name());
+-            }
+-        }
+-    }
+-
+-    /**
+-     * build the information for the method.
+-     */
+-    public void buildMethodInfo(XMLNode node)  {
+-        if(configuration.nocomment){
+-            return;
+-        }
+-        buildChildren(node);
+-    }
+-
+-    /**
+-     * Build the method footer.
+-     */
+-    public void buildMethodFooter(XMLNode node) {
+-        methodWriter.writeMemberFooter();
+-    }
+-
+-    /**
+-     * Build the field header.
+-     */
+-    public void buildFieldHeader(XMLNode node) {
+-        if (currentClass.serializableFields().length > 0) {
+-            buildFieldSerializationOverview(currentClass);
+-            fieldWriter.writeHeader(configuration.getText(
+-                "doclet.Serialized_Form_fields"));
+-        }
+-    }
+-
+-    /**
+-     * If possible, build the serialization overview for the given
+-     * class.
+-     *
+-     * @param classDoc the class to print the overview for.
+-     */
+-    public void buildFieldSerializationOverview(ClassDoc classDoc) {
+-        if (classDoc.definesSerializableFields()) {
+-            FieldDoc serialPersistentField =
+-                (FieldDoc)((Util.asList(classDoc.serializableFields()).get(0)));
+-            // Check to see if there are inline comments, tags or deprecation
+-            // information to be printed.
+-            if (fieldWriter.shouldPrintMemberDetails(serialPersistentField)) {
+-                fieldWriter.writeHeader(
+-                        configuration.getText("doclet.Serialized_Form_class"));
+-                fieldWriter.writeMemberDeprecatedInfo(serialPersistentField);
+-                if (!configuration.nocomment) {
+-                    fieldWriter.writeMemberDescription(serialPersistentField);
+-                    fieldWriter.writeMemberTags(serialPersistentField);
+-                }
+-                fieldWriter.writeMemberFooter(serialPersistentField);
+-                // Footer required to close the definition list tag
+-                // for serialization overview.
+-                fieldWriter.writeFooter(
+-                        configuration.getText("doclet.Serialized_Form_class"));
+-            }
+-        }
+-    }
+-
+-    /**
+-     * Build the field sub header.
+-     */
+-    public void buildFieldSubHeader(XMLNode node) {
+-        if (! currentClass.definesSerializableFields() ){
+-            FieldDoc field = (FieldDoc) currentMember;
+-            fieldWriter.writeMemberHeader(field.type().asClassDoc(),
+-                field.type().typeName(), field.type().dimension(), field.name());
+-        }
+-    }
+-
+-    /**
+-     * Build the field deprecation information.
+-     */
+-    public void buildFieldDeprecationInfo(XMLNode node) {
+-        if (!currentClass.definesSerializableFields()) {
+-            FieldDoc field = (FieldDoc)currentMember;
+-            fieldWriter.writeMemberDeprecatedInfo(field);
+-        }
+-    }
+-
+-    /**
+-     * Build the field information.
+-     */
+-    public void buildFieldInfo(XMLNode node) {
+-        if(configuration.nocomment){
+-            return;
+-        }
+-        FieldDoc field = (FieldDoc)currentMember;
+-        ClassDoc cd = field.containingClass();
+-        if (cd.definesSerializableFields()) {
+-            // Process Serializable Fields specified as array of
+-            // ObjectStreamFields. Print a member for each serialField tag.
+-            // (There should be one serialField tag per ObjectStreamField
+-            // element.)
+-            SerialFieldTag[] tags = field.serialFieldTags();
+-            Arrays.sort(tags);
+-            for (int i = 0; i < tags.length; i++) {
+-                fieldWriter.writeMemberHeader(tags[i].fieldTypeDoc(),
+-                        tags[i].fieldType(), "", tags[i].fieldName());
+-                fieldWriter.writeMemberDescription(tags[i]);
+-
+-            }
+-        } else {
+-
+-            // Process default Serializable field.
+-            if ((field.tags("serial").length == 0) && ! field.isSynthetic()
+-                && configuration.serialwarn) {
+-                configuration.message.warning(field.position(),
+-                        "doclet.MissingSerialTag", cd.qualifiedName(),
+-                        field.name());
+-            }
+-            fieldWriter.writeMemberDescription(field);
+-            fieldWriter.writeMemberTags(field);
+-        }
+-    }
+-
+-    /**
+-     * Build the field sub footer.
+-     */
+-    public void buildFieldSubFooter(XMLNode node) {
+-        if (! currentClass.definesSerializableFields()) {
+-            fieldWriter.writeMemberFooter();
+-        }
+-    }
+-
+-    /**
+-     * Build the summaries for the methods that belong to the given
+-     * class.
+-     */
+-    public void buildSerializableMethods(XMLNode node) {
+-        MemberDoc[] members = currentClass.serializationMethods();
+-        if (members.length > 0) {
+-            for (int i = 0; i < members.length; i++) {
+-                currentMember = members[i];
+-                buildChildren(node);
+-            }
+-        }
+-    }
+-
+-    /**
+-     * Build the summaries for the fields that belong to the given
+-     * class.
+-     */
+-    public void buildSerializableFields(XMLNode node) {
+-        MemberDoc[] members = currentClass.serializableFields();
+-        if (members.length > 0) {
+-            for (int i = 0; i < members.length; i++) {
+-                currentMember = members[i];
+-                buildChildren(node);
+-            }
+-        }
+-    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
+@@ -29,177 +29,145 @@
+ <Doclet>
+ 
+     <PackageDoc>
+-        <PackageHeader/>
+-        <Summary>
+-            <SummaryHeader/>
+-            <InterfaceSummary/>
+-            <ClassSummary/>
+-            <EnumSummary/>
+-            <ExceptionSummary/>
+-            <ErrorSummary/>
+-            <AnnotationTypeSummary/>
+-            <SummaryFooter/>
+-        </Summary>
+-        <PackageDescription/>
+-        <PackageTags/>
+-        <PackageFooter/>
++        <Content>
++            <Summary>
++                <InterfaceSummary/>
++                <ClassSummary/>
++                <EnumSummary/>
++                <ExceptionSummary/>
++                <ErrorSummary/>
++                <AnnotationTypeSummary/>
++            </Summary>
++            <PackageDescription/>
++            <PackageTags/>
++        </Content>
+     </PackageDoc>
+     
+     <AnnotationTypeDoc>
+-        <AnnotationTypeHeader/>
+-        <DeprecationInfo/>
+-        <AnnotationTypeSignature/>
+-        <AnnotationTypeDescription/>
+-        <AnnotationTypeTagInfo/>
++        <AnnotationTypeInfo>
++            <DeprecationInfo/>
++            <AnnotationTypeSignature/>
++            <AnnotationTypeDescription/>
++            <AnnotationTypeTagInfo/>
++        </AnnotationTypeInfo>
+         <MemberSummary>
+-        	<AnnotationTypeRequiredMemberSummary/>
++            <AnnotationTypeRequiredMemberSummary/>
+             <AnnotationTypeOptionalMemberSummary/>
+         </MemberSummary>
+-        <AnnotationTypeRequiredMemberDetails>
+-            <Header/>
+-           <AnnotationTypeRequiredMember>
+-                <MemberHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <MemberComments/>
+-                <TagInfo/>
+-                <MemberFooter/>
+-            </AnnotationTypeRequiredMember>
+-        </AnnotationTypeRequiredMemberDetails>
+-        <AnnotationTypeOptionalMemberDetails>
+-            <AnnotationTypeOptionalMember>
+-                <MemberHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <MemberComments/>
+-                <TagInfo/>
+-                <DefaultValueInfo/>
+-                <MemberFooter/>
+-            </AnnotationTypeOptionalMember>
+-            <Footer/>
+-        </AnnotationTypeOptionalMemberDetails>        
+-        <AnnotationTypeFooter/>
++        <AnnotationTypeMemberDetails>
++            <AnnotationTypeRequiredMemberDetails>
++                <AnnotationTypeRequiredMember>
++                    <Signature/>
++                    <DeprecationInfo/>
++                    <MemberComments/>
++                    <TagInfo/>
++                </AnnotationTypeRequiredMember>
++            </AnnotationTypeRequiredMemberDetails>
++            <AnnotationTypeOptionalMemberDetails>
++                <AnnotationTypeOptionalMember>
++                    <Signature/>
++                    <DeprecationInfo/>
++                    <MemberComments/>
++                    <TagInfo/>
++                    <DefaultValueInfo/>
++                </AnnotationTypeOptionalMember>
++            </AnnotationTypeOptionalMemberDetails>
++        </AnnotationTypeMemberDetails>
+     </AnnotationTypeDoc>
+     
+     <ClassDoc>
+-        <ClassHeader/>
+         <ClassTree/>
+-        <TypeParamInfo/>
+-        <SuperInterfacesInfo/>
+-        <ImplementedInterfacesInfo/>        
+-        <SubClassInfo/>
+-        <SubInterfacesInfo/>
+-        <InterfaceUsageInfo/>
+-        <NestedClassInfo/>
+-        <DeprecationInfo/>
+-        <ClassSignature/>
+-        <ClassDescription/>
+-        <ClassTagInfo/>
++        <ClassInfo>
++            <TypeParamInfo/>
++            <SuperInterfacesInfo/>
++            <ImplementedInterfacesInfo/>
++            <SubClassInfo/>
++            <SubInterfacesInfo/>
++            <InterfaceUsageInfo/>
++            <NestedClassInfo/>
++            <DeprecationInfo/>
++            <ClassSignature/>
++            <ClassDescription/>
++            <ClassTagInfo/>
++        </ClassInfo>
+         <MemberSummary>
+             <NestedClassesSummary/>
+-            <NestedClassesInheritedSummary/>
+             <EnumConstantsSummary/>
+             <FieldsSummary/>
+-            <FieldsInheritedSummary/>  
+             <ConstructorsSummary/>
+             <MethodsSummary/>
+-            <MethodsInheritedSummary/>
+         </MemberSummary>
+-        <EnumConstantsDetails>
+-           <Header/>
+-            <EnumConstant>
+-                <EnumConstantHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <EnumConstantComments/>
+-                <TagInfo/>
+-                <EnumConstantFooter/>
+-            </EnumConstant>
+-            <Footer/>
+-        </EnumConstantsDetails>
+-        <FieldDetails>
+-            <Header/>
+-            <FieldDoc>
+-                <FieldHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <FieldComments/>
+-                <TagInfo/>
+-                <FieldFooter/>
+-            </FieldDoc>
+-            <Footer/>
+-        </FieldDetails>
+-        <ConstructorDetails>
+-            <Header/>
+-            <ConstructorDoc>
+-                <ConstructorHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <ConstructorComments/>
+-                <TagInfo/>
+-                <ConstructorFooter/>
+-            </ConstructorDoc>
+-            <Footer/>
+-        </ConstructorDetails>
+-        <MethodDetails>
+-            <Header/>
+-            <MethodDoc>
+-                <MethodHeader/>
+-                <Signature/>
+-                <DeprecationInfo/>
+-                <MethodComments/>
+-                <TagInfo/>
+-                <MethodFooter/>
+-            </MethodDoc>
+-            <Footer/>
+-        </MethodDetails>
+-        <ClassFooter/>
++        <MemberDetails>
++            <EnumConstantsDetails>
++                <EnumConstant>
++                    <Signature/>
++                    <DeprecationInfo/>
++                    <EnumConstantComments/>
++                    <TagInfo/>
++                </EnumConstant>
++            </EnumConstantsDetails>
++            <FieldDetails>
++                <FieldDoc>
++                    <Signature/>
++                    <DeprecationInfo/>
++                    <FieldComments/>
++                    <TagInfo/>
++                </FieldDoc>
++            </FieldDetails>
++            <ConstructorDetails>
++                <ConstructorDoc>
++                    <Signature/>
++                    <DeprecationInfo/>
++                    <ConstructorComments/>
++                    <TagInfo/>
++                </ConstructorDoc>
++            </ConstructorDetails>
++            <MethodDetails>
++                <MethodDoc>
++                    <Signature/>
++                    <DeprecationInfo/>
++                    <MethodComments/>
++                    <TagInfo/>
++                </MethodDoc>
++            </MethodDetails>
++        </MemberDetails>
+     </ClassDoc>
+     
+     <ConstantSummary>
+-        <Header/>
+         <Contents/>
+         <ConstantSummaries>
+-            <PackageConstantSummary>
+-                <PackageHeader/>
+-                <ClassConstantSummary>
+-                    <ClassHeader/>
+-                    <ConstantMembers/>
+-                    <ClassFooter/>
+-                </ClassConstantSummary>     
+-            </PackageConstantSummary>
++            <PackageHeader/>
++            <ClassConstantSummary>
++                <ConstantMembers/>
++            </ClassConstantSummary>
+         </ConstantSummaries>    
+         <Footer/>
+     </ConstantSummary>
+     
+     <SerializedForm>
+-        <Header/>
+         <SerializedFormSummaries>
+             <PackageSerializedForm>
+                 <PackageHeader/>
+                 <ClassSerializedForm>
+-                    <ClassHeader/>
+                     <SerialUIDInfo/>
+-                    <MethodHeader/>
+-                    <SerializableMethods>
+-                        <MethodSubHeader/>
+-                        <DeprecatedMethodInfo/>
+-                        <MethodInfo>
+-                            <MethodDescription/>
+-                            <MethodTags/>
+-                        </MethodInfo>
+-                        <MethodFooter/>
+-                    </SerializableMethods>
+-                    <FieldHeader/>
+-                    <SerializableFields>
+-                        <FieldSubHeader/>
+-                        <FieldDeprecationInfo/>
+-                        <FieldInfo/>
+-                        <FieldSubFooter/>
+-                    </SerializableFields>
++                    <ClassContent>
++                        <SerializableMethods>
++                            <MethodSubHeader/>
++                            <DeprecatedMethodInfo/>
++                            <MethodInfo>
++                                <MethodDescription/>
++                                <MethodTags/>
++                            </MethodInfo>
++                        </SerializableMethods>
++                        <FieldHeader/>
++                        <SerializableFields>
++                            <FieldSubHeader/>
++                            <FieldDeprecationInfo/>
++                            <FieldInfo/>
++                        </SerializableFields>
++                    </ClassContent>
+                 </ClassSerializedForm>
+             </PackageSerializedForm>
+         </SerializedFormSummaries>
+-        <Footer/>
+     </SerializedForm>
+ </Doclet>
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclets.properties
+@@ -111,12 +111,12 @@
+ doclet.extends=extends
+ doclet.Package_private=(package private)
+ doclet.implements=implementsdoclet.Same_package_name_used=Package name format used twice: {0}
+-doclet.Nested_Classes_Interfaces_Inherited_From_Class=Nested classes/interfaces inherited from class {0}
+-doclet.Nested_Classes_Interface_Inherited_From_Interface=Nested classes/interfaces inherited from interface {0}
+-doclet.Methods_Inherited_From_Class=Methods inherited from class {0}
+-doclet.Methods_Inherited_From_Interface=Methods inherited from interface {0}
+-doclet.Fields_Inherited_From_Class=Fields inherited from class {0}
+-doclet.Fields_Inherited_From_Interface=Fields inherited from interface {0}
++doclet.Nested_Classes_Interfaces_Inherited_From_Class=Nested classes/interfaces inherited from class
++doclet.Nested_Classes_Interface_Inherited_From_Interface=Nested classes/interfaces inherited from interface
++doclet.Methods_Inherited_From_Class=Methods inherited from class
++doclet.Methods_Inherited_From_Interface=Methods inherited from interface
++doclet.Fields_Inherited_From_Class=Fields inherited from class
++doclet.Fields_Inherited_From_Interface=Fields inherited from interface
+ doclet.Serializable=Serializable
+ doclet.Externalizable=Externalizable
+ doclet.Annotation_Type_Member_Detail=Element Detail
+@@ -136,12 +136,19 @@
+ doclet.Constants_Table_Summary={0} table, listing constant fields, and values
+ doclet.Member_Table_Summary={0} table, listing {1}, and an explanation
+ doclet.fields=fields
++doclet.Fields=Fields
+ doclet.constructors=constructors
++doclet.Constructors=Constructors
+ doclet.methods=methods
++doclet.Methods=Methods
+ doclet.annotation_type_optional_members=optional elements
++doclet.Annotation_Type_Optional_Members=Optional Elements
+ doclet.annotation_type_required_members=required elements
++doclet.Annotation_Type_Required_Members=Required Elements
+ doclet.enum_constants=enum constants
++doclet.Enum_Constants=Enum Constants
+ doclet.nested_classes=nested classes
++doclet.Nested_Classes=Nested Classes
+ doclet.subclasses=subclasses
+ doclet.subinterfaces=subinterfaces
+ doclet.Modifier=Modifier
+@@ -173,7 +180,7 @@
+ 
+ doclet.enum_valueof_doc=\n\
+  Returns the enum constant of this type with the specified name.\n\
+- The string must match <I>exactly</I> an identifier used to declare an\n\
++ The string must match <i>exactly</i> an identifier used to declare an\n\
+  enum constant in this type.  (Extraneous whitespace characters are \n\
+  not permitted.)\n\
+  \n\
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/stylesheet.css
+@@ -0,0 +1,439 @@
++/* Javadoc style sheet */
++/*
++Overall document style
++*/
++* {
++    margin:0;
++    padding:0;
++}
++body {
++    font-family:Helvetica, Arial, sans-serif;
++    color:#000000;
++}
++p {
++    margin:20px 0;
++}
++pre {
++    font-size:1.0em;
++}
++h1 {
++    font-size:1.4em;
++}
++h2 {
++    font-size:1.35em;
++}
++h3 {
++    font-size:1.3em;
++}
++h4 {
++    font-size:1.25em;
++}
++ul {
++    margin:10px 0 10px 20px;
++}
++li {
++    list-style:disc;
++}
++dl dt {
++    font-size:0.95em;
++    font-weight:bold;
++    margin:10px 0 0 0;
++}
++dl dd {
++    margin:10px 0 10px 20px;
++}
++dl dd ul {
++    margin-left:0;
++}
++dl dd ul li {
++    list-style:none;
++    margin:10px 0 10px 0;
++}
++caption {
++    background: #CCCCFF;
++    color:#000000;
++    text-align: left;
++    font-size: 150%;
++    font-weight: bold;
++    border-left: 2px ridge;
++    border-right: 2px ridge;
++    border-top: 2px ridge;
++    padding-left: 5px;
++    width:auto;
++}
++/*
++Document title and Copyright styles
++*/
++.aboutLanguage {
++    float:right;
++    font-size:0.9em;
++    color:#000000;
++}
++.legalCopy {
++    margin:7px;
++}
++.bar {
++    font-size:1em;
++    margin:10px 0 0 10px;
++}
++.bar a {
++    font-weight:normal;
++}
++/*
++Navigation bar styles
++*/
++.topNav {
++    border-top:2px solid #C0C0C0;
++    margin:7px;
++    padding:7px 0;
++    height:2.8em;
++    width:99%;
++    min-width:600px;
++}
++.bottomNav {
++    border-top:2px solid #C0C0C0;
++    margin:7px;
++    padding:7px 0;
++    height:2.8em;
++    width:99%;
++}
++.subNav {
++    border-bottom:2px solid #C0C0C0;
++    float:left;
++    width:99%;
++    margin:7px;
++    min-width:600px;
++}
++.subNav div {
++    clear:left;
++    float:left;
++    padding:0 0 5px 2px;
++    width:100%;
++}
++.topNav a:link,.topNav a:active, .topNav a:visited, .topNav a:hover,
++.bottomNav a:link,.bottomNav a:active, .bottomNav a:visited, .bottomNav a:hover {
++    color:#000000;
++    font-weight:bold;
++    text-decoration:underline;
++    font-size:1em;
++}
++/* Navigation bar list styles */
++.topNav ul.navList, .bottomNav ul.navList {
++    background-color:#EEEEFF;
++    padding:7px 5px;
++    margin:0;
++    float:left;
++    width:80%;
++}
++ul.navList li{
++    list-style:none;
++    float:left;
++    padding:3px 4px;
++    color:#000000;
++    font-size:0.98em;
++}
++ul.navList li.navBarCell1Rev {
++    background-color:#00008B;
++    color:#FFFFFF;
++    font-weight:bold;
++    font-size:0.97em;
++}
++/* Sub-navigation bar list styles */
++.subNav ul.navList {
++    float:left;
++    margin:0;
++    font-size:0.7em;
++    width:350px;
++}
++ul.subNavList {
++    float:left;
++    margin:0;
++    font-size:0.7em;
++    width:350px;
++}
++ul.subNavList li{
++    list-style:none;
++    float:left;
++    font-size:90%;
++}
++/*
++Page header and footer styles
++*/
++.header, .footer {
++    clear:both;
++    margin:0 7px;
++}
++.indexHeader {
++    font-size:0.9em;
++    margin:10px 0 7px 10px;
++}
++.header ul {
++    padding-left:20px;
++}
++/* Header and footer title styles */ 
++.header h1.title {
++    font-size:1.4em;
++    text-align:center;
++    margin:0;
++}
++.header h2.title {
++    font-size:1.35em;
++    margin:0;
++}
++.subTitle {
++    margin:0;
++    padding-top:10px;
++    font-size:0.75em;
++    font-weight:bold;
++}
++/*
++Page layout container styles
++*/
++.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer,
++.constantValuesContainer {
++    clear:both;
++    padding:10px 10px;
++    position:relative;
++}
++.indexContainer {
++    padding:0 0 10px 10px;
++    font-size:0.9em;
++}
++/*
++Class inheritance information styles
++*/
++ul.inheritance {
++    margin:0;
++    padding:0;
++}
++ul.inheritance li {
++    display:inline;
++    list-style:none;
++}
++ul.inheritance li ul.inheritance {
++    margin-left:15px;
++    background-image:url(resources/inherit.gif);
++    background-repeat:no-repeat;
++    padding-left:15px;
++    padding-top:1px;
++}
++/*
++Heading styles
++*/
++.indexContainer h2 {
++    font-weight:normal;
++    font-size:1.0em;
++    padding:10px 0 0 0;
++}
++.contentContainer h2 {
++    margin:10px 0;
++}
++.constantValuesContainer h2 {
++    background:#CCCCFF;
++    border:2px ridge;
++    padding:3px;
++    margin:0 0 10px 0;
++}
++.serializedFormContainer ul.blockList li.blockList h2 {
++    background:#EEEEFF;
++    border:2px ridge;
++    padding:3px;
++    margin:0 0 15px 0;
++    text-align:center;
++}
++.classUseContainer ul li ul li h3 {
++    margin-bottom:30px;
++    padding:3px;
++}
++.serializedFormContainer ul.blockList li.blockList ul.blockList li.blockList h3 {
++    background:#EEEEFF;
++    margin:0 0 15px 0;
++    padding:3px;
++}
++.serializedFormContainer ul.blockList li.blockList ul.blockList li.blockList ul.blockList li.blockList h3 {
++    background:#CCCCFF;
++    margin:0 0 15px 0;
++    padding:3px;
++    border:2px ridge;
++}
++ul.blockList ul.blockList li.blockList h3, ul.blockList ul.blockList li.blockList h3 {
++    background:#CCCCFF;
++    border:2px ridge;
++    padding-left:5px;
++}
++div.summary ul.blockList ul.blockList li.blockList h3 {
++    background:#CCCCFF;
++    border:0;
++    border:2px ridge;
++    padding-left:5px;
++}
++div.summary ul.blockList ul.blockList ul.blockList li.blockList h3 {
++    background:#EEEEFF;
++    border:0;
++    border-bottom:2px ridge;
++}
++div.details ul.blockList ul.blockList ul.blockList li.blockList h4,
++div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 {
++    font-size:1.15em;
++    font-weight:bold;
++    padding:0 0 10px 0;
++}
++/*
++Table styles
++*/
++.contentContainer table {
++    border-collapse: collapse ;
++    width:100%;
++}
++.contentContainer table td, .contentContainer table th {
++    border:2px ridge;
++    padding:3px;
++}
++/* Constant values page table styles */
++.constantValuesContainer table {
++    border-collapse: collapse ;
++    margin:0 0 10px 0;
++}
++.constantValuesContainer table caption{
++    font-size:0.95em;
++    padding:3px;
++    background:#EEEEFF;
++}
++.constantValuesContainer table td, .constantValuesContainer table th {
++    border:2px ridge;
++    padding:3px;
++}
++/* Class-use/Package-use page table styles */
++.classUseContainer table {
++    border-collapse: collapse ;
++    width:100%;
++    margin:0 0 15px 0;
++}
++.classUseContainer ul li ul li table {
++    margin-bottom:30px;
++}
++.classUseContainer ul li ul li table caption{
++    font-size:0.95em;
++    padding:3px;
++    background:#EEEEFF;
++}
++.classUseContainer table td, .classUseContainer table th {
++    border:2px ridge;
++    padding:3px;
++}
++/* Summary table styles */
++ul.blockList li.blockList table.overviewSummary {
++    margin:0;
++    margin-bottom:15px;
++}
++ul.blockList li.blockList table caption {
++    padding:3px;
++}
++ul.blockList li.blockList table.overviewSummary td.colFirst{
++    text-align:right;
++}
++table.packageSummary td.colFirst, table.overviewSummary th.colFirst {
++    width:15%;
++}
++div.summary ul.blockList ul.blockList li.blockList caption {
++    display:none;
++}
++div.summary ul.blockList li.blockList ul.blockList li.blockList table.overviewSummary th {
++    border-top:0;
++}
++/* Table column block styles */
++ul.blockList li.blockList table.overviewSummary td.colLast div.block{
++    padding:0;
++    padding-left:40px;
++}
++ul.blockList li.blockList table.overviewSummary td.colOne div.block{
++    padding:0;
++    padding-left:40px;
++}
++.contentContainer ul.blockList li.blockList table .colOne div.block{
++    padding-left:40px;
++}
++.classUseContainer ul li ul li table .colLast div.block,
++.classUseContainer ul li ul li table .colOne div.block{
++    padding-left:40px;
++}
++/*
++List styles
++*/
++ul.horizontal li {
++    display:inline;
++    font-size:0.9em;   
++}
++/* Container specific list styles */
++.indexContainer ul {
++    margin:0;
++}
++.indexContainer ul li {
++    list-style:none;
++}
++.serializedFormContainer ul.blockList li.blockList ul.blockList li.blockList ul.blockList li.blockList {
++    border:0;
++}
++.serializedFormContainer ul.blockList li.blockList ul.blockList li.blockList ul.blockList li.blockList ul.blockList li.blockList {
++    list-style:none;
++    border:0;
++    border-bottom:2px ridge;
++}
++.serializedFormContainer ul.blockList li.blockList ul.blockList li.blockList ul.blockList li.blockList ul.blockList li.blockListLast {
++    list-style:none;
++}
++/* General list styles */
++ul.blockList, ul.blockListLast {
++    margin-left:0;
++    padding-left:0;
++}
++ul.blockList li.blockList, ul.blockListLast li.blockList {
++    list-style:none;
++    margin-bottom:25px;
++}
++ul.blockList ul.blockList ul.blockList li.blockList {
++    border:2px ridge;
++}
++div.details ul.blockList ul.blockList ul.blockList li.blockList {
++    border:0;
++    border-bottom:2px ridge;
++}
++/* Definition list styles */
++ul.blockList li.blockList dl{
++    margin-bottom:15px;
++}
++ul.blockList li.blockList dl dd{
++    margin:0 0 0 30px;
++}
++ul.blockList li.blockList ul.blockList li.blockList ul.blockList li.blockList dl,
++ul.blockList li.blockList ul.blockList li.blockList ul.blockListLast li.blockList dl{
++    padding:0 0 10px 35px;
++}
++dl.nameValue dt, dl.nameValue dd{
++    display:inline;
++}
++ul.blockList li.blockList pre{
++    margin:0 0 15px 0;
++}
++/* List content styles */
++ul.blockList li.blockList ul.blockList li.blockList pre{
++    margin:10px 0 15px 0;
++}
++ul.blockList li.blockList ul.blockList li.blockList ul.blockList li.blockList pre,
++ul.blockList li.blockList ul.blockList li.blockList ul.blockListLast li.blockList pre{
++    padding:0 0 10px 0;
++}
++ul.blockList li.blockList ul.blockList li.blockList ul.blockList li.blockList div.block,
++ul.blockList li.blockList ul.blockList li.blockList ul.blockListLast li.blockList div.block{
++    padding:0 0 10px 35px;
++}
++/*
++Formatting effect styles
++*/
++.strong {
++    font-weight:bold;
++}
++.sourceLineNo {
++    color:green;
++    padding:0 30px 0 0;
++}
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/DirectoryManager.java
+@@ -46,7 +46,7 @@
+     /**
+      * The file separator string, "/", used in the formation of the URL path.
+      */
+-    public static final String URL_FILE_SEPERATOR = "/";
++    public static final String URL_FILE_SEPARATOR = "/";
+ 
+     /**
+      * Never instaniated.
+@@ -123,13 +123,13 @@
+         for (int i = 0; i < packageName.length(); i++) {
+             char ch = packageName.charAt(i);
+             if (ch == '.') {
+-                pathstr.append(URL_FILE_SEPERATOR);
++                pathstr.append(URL_FILE_SEPARATOR);
+             } else {
+                 pathstr.append(ch);
+             }
+         }
+-        if (pathstr.length() > 0 && ! pathstr.toString().endsWith(URL_FILE_SEPERATOR)) {
+-            pathstr.append(URL_FILE_SEPERATOR);
++        if (pathstr.length() > 0 && ! pathstr.toString().endsWith(URL_FILE_SEPARATOR)) {
++            pathstr.append(URL_FILE_SEPARATOR);
+         }
+         return pathstr.toString();
+     }
+@@ -155,7 +155,7 @@
+         for (int i = 0; i < name.length(); i++) {
+             char ch = name.charAt(i);
+             if (ch == '.') {
+-                pathstr.append(URL_FILE_SEPERATOR);
++                pathstr.append(URL_FILE_SEPARATOR);
+             } else {
+                 pathstr.append(ch);
+             }
+@@ -184,7 +184,7 @@
+         StringBuffer pathstr = new StringBuffer();
+         pathstr.append(getRelativePath(from));
+         pathstr.append(getPath(to));
+-        pathstr.append(URL_FILE_SEPERATOR);
++        pathstr.append(URL_FILE_SEPARATOR);
+         return pathstr.toString();
+     }
+ 
+@@ -226,10 +226,10 @@
+         for (int i = 0; i < from.length(); i++) {
+             char ch = from.charAt(i);
+             if (ch == '.') {
+-                pathstr.append(".." + URL_FILE_SEPERATOR);
++                pathstr.append(".." + URL_FILE_SEPARATOR);
+             }
+         }
+-        pathstr.append(".." + URL_FILE_SEPERATOR);
++        pathstr.append(".." + URL_FILE_SEPARATOR);
+         return pathstr.toString();
+     }
+ 
+@@ -297,7 +297,7 @@
+         String pathstr = createPathString(pd);
+         if (pathstr.length() > 0) {
+             buf.append(pathstr);
+-            buf.append(URL_FILE_SEPERATOR);
++            buf.append(URL_FILE_SEPARATOR);
+         }
+         buf.append(filename);
+         return buf.toString();
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
+@@ -51,6 +51,11 @@
+     {{"&", "&amp;"}, {"<", "&lt;"}, {">", "&gt;"}};
+ 
+     /**
++     * Name of the resource directory.
++     */
++    public static final String RESOURCESDIR = "resources";
++
++    /**
+      * Return array of class members whose documentation is to be generated.
+      * If the member is deprecated do not include such a member in the
+      * returned array.
+@@ -236,8 +241,8 @@
+         String destname = configuration.docFileDestDirName;
+         File srcdir = new File(path + dir);
+         if (destname.length() > 0 && !destname.endsWith(
+-               DirectoryManager.URL_FILE_SEPERATOR)) {
+-            destname += DirectoryManager.URL_FILE_SEPERATOR;
++               DirectoryManager.URL_FILE_SEPARATOR)) {
++            destname += DirectoryManager.URL_FILE_SEPARATOR;
+         }
+         String dest = destname + dir;
+         try {
+@@ -263,7 +268,7 @@
+                         && ! configuration.shouldExcludeDocFileDir(
+                           srcfile.getName())){
+                         copyDocFiles(configuration, path, dir +
+-                                    DirectoryManager.URL_FILE_SEPERATOR + srcfile.getName(),
++                                    DirectoryManager.URL_FILE_SEPARATOR + srcfile.getName(),
+                                 overwrite);
+                     }
+                 }
+@@ -322,25 +327,38 @@
+      *                       it already exists.
+      */
+     public static void copyResourceFile(Configuration configuration,
+-            String resourcefile,
+-            boolean overwrite) {
+-        String destdir = configuration.destDirName;
+-        String destresourcesdir = destdir + "resources";
+-        DirectoryManager.createDirectory(configuration, destresourcesdir);
+-        File destfile = new File(destresourcesdir, resourcefile);
++            String resourcefile, boolean overwrite) {
++        String destresourcesdir = configuration.destDirName + RESOURCESDIR;
++        copyFile(configuration, resourcefile, RESOURCESDIR, destresourcesdir,
++                overwrite);
++    }
++
++    /**
++     * Copy a file from a source directory to a destination directory
++     * (if it is not there already). If <code>overwrite</code> is true and
++     * the destination file already exists, overwrite it.
++     *
++     * @param configuration Holds the error message
++     * @param file The name of the file to copy
++     * @param source The source directory
++     * @param destination The destination directory where the file needs to be copied
++     * @param overwrite A flag to indicate whether the file in the
++     *                  destination directory will be overwritten if
++     *                  it already exists.
++     */
++    public static void copyFile(Configuration configuration, String file, String source,
++            String destination, boolean overwrite) {
++        DirectoryManager.createDirectory(configuration, destination);
++        File destfile = new File(destination, file);
+         if(destfile.exists() && (! overwrite)) return;
+         try {
+-
+             InputStream in = Configuration.class.getResourceAsStream(
+-                "resources/" + resourcefile);
+-
++                source + DirectoryManager.URL_FILE_SEPARATOR + file);
+             if(in==null) return;
+-
+             OutputStream out = new FileOutputStream(destfile);
+             byte[] buf = new byte[2048];
+             int n;
+             while((n = in.read(buf))>0) out.write(buf,0,n);
+-
+             in.close();
+             out.close();
+         } catch(Throwable t) {}
+@@ -357,12 +375,12 @@
+         try{
+             String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc);
+             String completePath = new SourcePath(configuration.sourcepath).
+-                getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPERATOR;
++                getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR;
+             //Make sure that both paths are using the same seperators.
+             completePath = Util.replaceText(completePath, File.separator,
+-                    DirectoryManager.URL_FILE_SEPERATOR);
++                    DirectoryManager.URL_FILE_SEPARATOR);
+             pkgPath = Util.replaceText(pkgPath, File.separator,
+-                    DirectoryManager.URL_FILE_SEPERATOR);
++                    DirectoryManager.URL_FILE_SEPARATOR);
+             return completePath.substring(0, completePath.indexOf(pkgPath));
+         } catch (Exception e){
+             return "";
+@@ -572,6 +590,24 @@
+     }
+ 
+     /**
++     * Given a string, strips all html characters and
++     * return the result.
++     *
++     * @param rawString The string to check.
++     * @return the original string with all of the HTML characters
++     * stripped.
++     *
++     */
++    public static String stripHtml(String rawString) {
++        // remove HTML tags
++        rawString = rawString.replaceAll("\\<.*?>", " ");
++        // consolidate multiple spaces between a word to a single space
++        rawString = rawString.replaceAll("\\b\\s{2,}\\b", " ");
++        // remove extra whitespaces
++        return rawString.trim();
++    }
++
++    /**
+      * Create the directory path for the file to be generated, construct
+      * FileOutputStream and OutputStreamWriter depending upon docencoding.
+      *
+diff --git a/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java b/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java
+--- openjdk/langtools/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java
++++ openjdk/langtools/test/com/sun/javadoc/AccessAsciiArt/AccessAsciiArt.java
+@@ -84,17 +84,17 @@
+ 
+             // Test the top line of the class tree
+             {
+-"  <IMG SRC=\"../../resources/inherit.gif\" ALT=\"extended by \"><A HREF=\"../../p1/C.html\" title=\"class in p1\">p1.C</A>",
++"<li><a href=\"../../p1/C.html\" title=\"class in p1\">p1.C</a></li>",
+                      TMPDEST_DIR1 + "p1" + FS + "subpkg" + FS + "SSC.html" },
+ 
+             // Test the second line of the class tree
+             {
+-"      <IMG SRC=\"../../resources/inherit.gif\" ALT=\"extended by \"><A HREF=\"../../p1/SC.html\" title=\"class in p1\">p1.SC</A>",
++"<li><a href=\"../../p1/SC.html\" title=\"class in p1\">p1.SC</a></li>",
+                      TMPDEST_DIR1 + "p1" + FS + "subpkg" + FS + "SSC.html" },
+ 
+             // Test the third line of the class tree
+             {
+-"          <IMG SRC=\"../../resources/inherit.gif\" ALT=\"extended by \"><STRONG>p1.subpkg.SSC</STRONG>",
++"<li>p1.subpkg.SSC</li>",
+                      TMPDEST_DIR1 + "p1" + FS + "subpkg" + FS +"SSC.html" },
+ 
+         };
+diff --git a/test/com/sun/javadoc/AccessH1/AccessH1.java b/test/com/sun/javadoc/AccessH1/AccessH1.java
+--- openjdk/langtools/test/com/sun/javadoc/AccessH1/AccessH1.java
++++ openjdk/langtools/test/com/sun/javadoc/AccessH1/AccessH1.java
+@@ -83,18 +83,19 @@
+      * NOTE: The standard doclet uses the same separator "\n" for all OS's
+      */
+     private static final String[][] testArray = {
+-
+-            // Test the style sheet
+-            {
+-               "h1 { font-size: 145% }",
+-                     TMPDEST_DIR1 + "stylesheet.css"              },
+-
+-            // Test the doc title in the overview page
+-            {
+-               "<H1>" + LS + "Document Title" + LS + "</H1>",
+-                          TMPDEST_DIR1 + "overview-summary.html"  }
+-
+-        };
++        // Test the style sheet
++        {
++            ".header h1.title {" + LS + "    font-size:1.4em;" + LS +
++            "    text-align:center;" + LS + "    margin:0;" + LS +
++            "}",
++            TMPDEST_DIR1 + "stylesheet.css"
++        },
++        // Test the doc title in the overview page
++        {
++            "<h1 class=\"title\">Document Title</h1>",
++            TMPDEST_DIR1 + "overview-summary.html"
++        }
++    };
+ 
+     public static void runTestsOnHTML(String[][] testArray) {
+ 
+diff --git a/test/com/sun/javadoc/AccessSkipNav/AccessSkipNav.java b/test/com/sun/javadoc/AccessSkipNav/AccessSkipNav.java
+--- openjdk/langtools/test/com/sun/javadoc/AccessSkipNav/AccessSkipNav.java
++++ openjdk/langtools/test/com/sun/javadoc/AccessSkipNav/AccessSkipNav.java
+@@ -46,6 +46,7 @@
+     private static final String BUGNAME = "AccessSkipNav";
+     private static final String FS = System.getProperty("file.separator");
+     private static final String PS = System.getProperty("path.separator");
++    private static final String LS = System.getProperty("line.separator");
+     private static final String TMPDEST_DIR1 = "." + FS + "docs1" + FS;
+     private static final String TMPDEST_DIR2 = "." + FS + "docs2" + FS;
+ 
+@@ -84,20 +85,22 @@
+ 
+             // Testing only for the presence of the <a href> and <a name>
+ 
+-            // Top navbar <A HREF>
+-            { "<A HREF=\"#skip-navbar_top\" title=\"Skip navigation links\"></A>",
++            // Top navbar <a href>
++            { "<a href=\"#skip-navbar_top\" title=\"Skip navigation links\"></a>",
+                      TMPDEST_DIR1 + "p1" + FS + "C1.html" },
+ 
+-            // Top navbar <A NAME>
+-            { "<A NAME=\"skip-navbar_top\"></A>",
++            // Top navbar <a name>
++            { "<a name=\"skip-navbar_top\">" + LS +
++                      "<!--   -->" + LS + "</a>",
+                      TMPDEST_DIR1 + "p1" + FS + "C1.html" },
+ 
+-            // Bottom navbar <A HREF>
+-            { "<A HREF=\"#skip-navbar_bottom\" title=\"Skip navigation links\"></A>",
++            // Bottom navbar <a href>
++            { "<a href=\"#skip-navbar_bottom\" title=\"Skip navigation links\"></a>",
+                      TMPDEST_DIR1 + "p1" + FS + "C1.html" },
+ 
+-            // Bottom navbar <A NAME>
+-            { "<A NAME=\"skip-navbar_bottom\"></A>",
++            // Bottom navbar <a name>
++            { "<a name=\"skip-navbar_bottom\">" + LS +
++                      "<!--   -->" + LS + "</a>",
+                      TMPDEST_DIR1 + "p1" + FS + "C1.html" }
+         };
+ 
+diff --git a/test/com/sun/javadoc/AccessSummary/AccessSummary.java b/test/com/sun/javadoc/AccessSummary/AccessSummary.java
+--- openjdk/langtools/test/com/sun/javadoc/AccessSummary/AccessSummary.java
++++ openjdk/langtools/test/com/sun/javadoc/AccessSummary/AccessSummary.java
+@@ -24,7 +24,7 @@
+ /*
+  * @test   @(#)AccessSummary.java
+  * @bug      4637604 4775148
+- * @summary  Test the tables for summary=""
++ * @summary  Test the tables for summary attribute
+  * @author   dkramer
+  * @library  ../lib/
+  * @build    JavadocTester
+@@ -44,15 +44,15 @@
+ 
+         // Test that the summary attribute appears
+         { OUTPUT_DIR1 + "overview-summary.html",
+-                 "SUMMARY=\"\"" },
++                 "summary=\"Packages table, listing packages, and an explanation\"" },
+ 
+         // Test that the summary attribute appears
+         { OUTPUT_DIR1 + "p1" + FS + "C1.html",
+-                 "SUMMARY=\"\"" },
++                 "summary=\"Constructor Summary table, listing constructors, and an explanation\"" },
+ 
+         // Test that the summary attribute appears
+         { OUTPUT_DIR1 + "constant-values.html",
+-                 "SUMMARY=\"\"" }
++                 "summary=\"Constant Field Values table, listing constant fields, and values\"" }
+     };
+ 
+     // First test with -header only
+diff --git a/test/com/sun/javadoc/AuthorDD/AuthorDD.java b/test/com/sun/javadoc/AuthorDD/AuthorDD.java
+--- openjdk/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java
++++ openjdk/langtools/test/com/sun/javadoc/AuthorDD/AuthorDD.java
+@@ -86,12 +86,12 @@
+ 
+              // Test single @since tag:
+ 
+-            { "<DT><STRONG>Since:</STRONG></DT>"+NL+"  <DD>JDK 1.0</DD>",
++            { "<dt><span class=\"strong\">Since:</span></dt>"+NL+"  <dd>JDK 1.0</dd>",
+                                   BUGID + FS + "p1" + FS + "C1.html" },
+ 
+             // Test multiple @author tags:
+ 
+-            { "<DT><STRONG>Author:</STRONG></DT>"+NL+"  <DD>Doug Kramer, Jamie, Neal</DD>",
++            { "<dt><span class=\"strong\">Author:</span></dt>"+NL+"  <dd>Doug Kramer, Jamie, Neal</dd>",
+                                   BUGID + FS + "p1" + FS + "C1.html" },
+ 
+         };
+diff --git a/test/com/sun/javadoc/JavascriptWinTitle/JavascriptWinTitle.java b/test/com/sun/javadoc/JavascriptWinTitle/JavascriptWinTitle.java
+--- openjdk/langtools/test/com/sun/javadoc/JavascriptWinTitle/JavascriptWinTitle.java
++++ openjdk/langtools/test/com/sun/javadoc/JavascriptWinTitle/JavascriptWinTitle.java
+@@ -90,44 +90,34 @@
+     private static final String[][] testArray = {
+ 
+             // Test the javascript "type" attribute is present:
+-            {  "<SCRIPT type=\"text/javascript\">",
++            {  "<script type=\"text/javascript\">",
++                     TMPDEST_DIR1 + "overview-summary.html"  },
++
++            // Test onload is absent:
++            {  "<body>",
+                      TMPDEST_DIR1 + "overview-summary.html"  },
+ 
+             // Test onload is present:
+-            {  "onload=\"windowTitle();\"",
+-                     TMPDEST_DIR1 + "overview-summary.html"  },
+-
+-            // Test onload is present:
+-            {  "onload=\"windowTitle();\"",
++            {  "<body>",
+                      TMPDEST_DIR1 + FS + "p1" + FS + "package-summary.html"  },
+ 
+-            // Test onload is present:
+-            {  "onload=\"windowTitle();\"",
+-                     TMPDEST_DIR1 + FS + "p1" + FS + "C.html"  },
+-
+             // Test that "onload" is not present in BODY tag:
+-            {   "<BODY BGCOLOR=\"white\">",
++            {   "<body>",
+                      TMPDEST_DIR1 + "overview-frame.html"  },
+ 
+             // Test that "onload" is not present in BODY tag:
+-            {   "<BODY BGCOLOR=\"white\">",
++            {   "<body>",
+                      TMPDEST_DIR1 + "allclasses-frame.html"  },
+ 
+             // Test that "onload" is not present in BODY tag:
+-            {   "<BODY BGCOLOR=\"white\">",
++            {   "<body>",
+                      TMPDEST_DIR1 + FS + "p1" + FS + "package-frame.html"  },
+ 
+             // Test that win title javascript is followed by NOSCRIPT code.
+-            {"<SCRIPT type=\"text/javascript\">" + LS +
+-                    "function windowTitle()" + LS +
+-                    "{" + LS +
+-                    "    if (location.href.indexOf('is-external=true') == -1) {" + LS +
+-                    "        parent.document.title=\"C (Window Title)\";" + LS +
+-                    "    }" + LS +
+-                    "}" + LS +
+-             "</SCRIPT>" + LS +
+-             "<NOSCRIPT>" + LS +
+-             "</NOSCRIPT>",
++            {"<script type=\"text/javascript\"><!--" + LS +
++                     "    if (location.href.indexOf('is-external=true') == -1) {" + LS +
++                     "        parent.document.title=\"C (Window Title)\";" + LS +
++                     "    }" + LS + "//-->" + LS + "</script>",
+              TMPDEST_DIR1 + FS + "p1" + FS + "C.html"
+             }
+ 
+diff --git a/test/com/sun/javadoc/MetaTag/MetaTag.java b/test/com/sun/javadoc/MetaTag/MetaTag.java
+--- openjdk/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java
++++ openjdk/langtools/test/com/sun/javadoc/MetaTag/MetaTag.java
+@@ -67,31 +67,31 @@
+     private static final String[][] TEST = {
+ 
+         { OUTPUT_DIR + FS + "p1" + FS + "C1.html",
+-           "<META NAME=\"keywords\" CONTENT=\"p1.C1 class\">" },
++           "<meta name=\"keywords\" content=\"p1.C1 class\">" },
+ 
+         { OUTPUT_DIR + FS + "p1" + FS + "C1.html",
+-           "<META NAME=\"keywords\" CONTENT=\"field1\">" },
++           "<meta name=\"keywords\" content=\"field1\">" },
+ 
+         { OUTPUT_DIR + FS + "p1" + FS + "C1.html",
+-           "<META NAME=\"keywords\" CONTENT=\"field2\">" },
++           "<meta name=\"keywords\" content=\"field2\">" },
+ 
+         { OUTPUT_DIR + FS + "p1" + FS + "C1.html",
+-           "<META NAME=\"keywords\" CONTENT=\"method1()\">" },
++           "<meta name=\"keywords\" content=\"method1()\">" },
+ 
+         { OUTPUT_DIR + FS + "p1" + FS + "C1.html",
+-           "<META NAME=\"keywords\" CONTENT=\"method2()\">" },
++           "<meta name=\"keywords\" content=\"method2()\">" },
+ 
+         { OUTPUT_DIR + FS + "p1" + FS + "package-summary.html",
+-           "<META NAME=\"keywords\" CONTENT=\"p1 package\">" },
++           "<meta name=\"keywords\" content=\"p1 package\">" },
+ 
+         { OUTPUT_DIR + FS + "overview-summary.html",
+-           "<META NAME=\"keywords\" CONTENT=\"Overview, Sample Packages\">" },
++           "<meta name=\"keywords\" content=\"Overview, Sample Packages\">" },
+ 
+         //NOTE: Hopefully, this regression test is not run at midnight.  If the output
+         //was generated yesterday and this test is run today, the test will fail.
+         {OUTPUT_DIR + FS + "overview-summary.html",
+-           "<META NAME=\"date\" "
+-                            + "CONTENT=\"" + m_dateFormat.format(new Date()) + "\">"},
++           "<meta name=\"date\" "
++                            + "content=\"" + m_dateFormat.format(new Date()) + "\">"},
+     };
+ 
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/ValidHtml/ValidHtml.java b/test/com/sun/javadoc/ValidHtml/ValidHtml.java
+--- openjdk/langtools/test/com/sun/javadoc/ValidHtml/ValidHtml.java
++++ openjdk/langtools/test/com/sun/javadoc/ValidHtml/ValidHtml.java
+@@ -33,12 +33,10 @@
+  * @run main ValidHtml
+  */
+ 
+-
+ import com.sun.javadoc.*;
+ import java.util.*;
+ import java.io.*;
+ 
+-
+ /**
+  * Runs javadoc and runs regression tests on the resulting HTML.
+  * It reads each file, complete with newlines, into a string to easily
+@@ -66,13 +64,14 @@
+         String srcdir = System.getProperty("test.src", ".");
+ 
+         // Test for all cases except the split index page
+-        runJavadoc(new String[] {"-d", TMPDEST_DIR1,
+-                                 "-doctitle", "Document Title",
+-                                 "-windowtitle", "Window Title",
+-                                 "-use",
+-                                 "-overview", (srcdir + FS + "overview.html"),
+-                                 "-sourcepath", srcdir,
+-                                 "p1", "p2"});
++        runJavadoc(new String[]{"-d", TMPDEST_DIR1,
++                    "-doctitle", "Document Title",
++                    "-windowtitle", "Window Title",
++                    "-use",
++                    "-overview", (srcdir + FS + "overview.html"),
++                    "-sourcepath", srcdir,
++                    "p1", "p2"
++                });
+         runTestsOnHTML(testArray);
+ 
+         printSummary();
+@@ -90,53 +89,52 @@
+      * NOTE: The standard doclet uses the same separator "\n" for all OS's
+      */
+     private static final String[][] testArray = {
+-
+-            // Test the proper DOCTYPE element is present:
+-            {
+-"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">",
+-                     TMPDEST_DIR1 + "index.html"  },
+-
+-            // Test the proper DOCTYPE element is present:
+-            {
+-"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
+-                     TMPDEST_DIR1 + "overview-summary.html"  },
+-
+-            // Test the proper DOCTYPE element is present:
+-            {
+-"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
+-                     TMPDEST_DIR1 + "p1" + FS + "package-summary.html"  },
+-
+-            // Test the proper DOCTYPE element is present:
+-            {
+-"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
+-                     TMPDEST_DIR1 + "p1" + FS + "C.html"  },
+-
+-            // Test the proper DOCTYPE element is present:
+-            {
+-"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
+-                     TMPDEST_DIR1 + "overview-frame.html"  },
+-
+-            // Test the proper DOCTYPE element is present:
+-            {
+-"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
+-                     TMPDEST_DIR1 + "allclasses-frame.html"  },
+-
+-            // Test the proper DOCTYPE element is present:
+-            {
+-"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
+-                     TMPDEST_DIR1 + "p1" + FS + "package-frame.html"  },
+-
+-            // Test that <NOFRAMES> is inside <FRAMESET> element:
+-            {
+-"</NOFRAMES>" + LS + "</FRAMESET>",
+-                     TMPDEST_DIR1 + "index.html"  },
+-
+-            // Test the table elements are in the correct order:
+-            {
+-"</FONT></TD>" + LS + "</TR>",
+-                     TMPDEST_DIR1 + FS + "p1" + FS + "package-use.html"  }
+-
+-        };
++        // Test the proper DOCTYPE element is present:
++        {
++            "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">",
++            TMPDEST_DIR1 + "index.html"
++        },
++        // Test the proper DOCTYPE element is present:
++        {
++            "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
++            TMPDEST_DIR1 + "overview-summary.html"
++        },
++        // Test the proper DOCTYPE element is present:
++        {
++            "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
++            TMPDEST_DIR1 + "p1" + FS + "package-summary.html"
++        },
++        // Test the proper DOCTYPE element is present:
++        {
++            "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
++            TMPDEST_DIR1 + "p1" + FS + "C.html"
++        },
++        // Test the proper DOCTYPE element is present:
++        {
++            "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
++            TMPDEST_DIR1 + "overview-frame.html"
++        },
++        // Test the proper DOCTYPE element is present:
++        {
++            "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
++            TMPDEST_DIR1 + "allclasses-frame.html"
++        },
++        // Test the proper DOCTYPE element is present:
++        {
++            "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
++            TMPDEST_DIR1 + "p1" + FS + "package-frame.html"
++        },
++        // Test that <NOFRAMES> is inside <FRAMESET> element:
++        {
++            "</noframes>" + LS + "</frameset>",
++            TMPDEST_DIR1 + "index.html"
++        },
++        // Test the table elements are in the correct order:
++        {
++            "</td>" + LS + "</tr>",
++            TMPDEST_DIR1 + FS + "p1" + FS + "package-use.html"
++        }
++    };
+ 
+     public static void runTestsOnHTML(String[][] testArray) {
+ 
+@@ -152,10 +150,7 @@
+ 
+             // Find string in file's contents
+             if (findString(fileString, stringToFind) == -1) {
+-                System.out.println("\nSub-test " + (subtestNum)
+-                    + " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n"
+-                    + "when searching for:\n"
+-                    + stringToFind);
++                System.out.println("\nSub-test " + (subtestNum) + " for bug " + BUGID + " (" + BUGNAME + ") FAILED\n" + "when searching for:\n" + stringToFind);
+             } else {
+                 numSubtestsPassed += 1;
+                 System.out.println("\nSub-test " + (subtestNum) + " passed:\n" + stringToFind);
+@@ -164,11 +159,10 @@
+     }
+ 
+     public static void printSummary() {
+-        if ( numSubtestsPassed == subtestNum ) {
++        if (numSubtestsPassed == subtestNum) {
+             System.out.println("\nAll " + numSubtestsPassed + " subtests passed");
+         } else {
+-            throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum)
+-                             + " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
++            throw new Error("\n" + (subtestNum - numSubtestsPassed) + " of " + (subtestNum) + " subtests failed for bug " + BUGID + " (" + BUGNAME + ")\n");
+         }
+     }
+ 
+@@ -176,16 +170,16 @@
+     public static String readFileToString(String filename) {
+         try {
+             File file = new File(filename);
+-            if ( !file.exists() ) {
++            if (!file.exists()) {
+                 System.out.println("\nFILE DOES NOT EXIST: " + filename);
+             }
+             BufferedReader in = new BufferedReader(new FileReader(file));
+ 
+             // Create an array of characters the size of the file
+-            char[] allChars = new char[(int)file.length()];
++            char[] allChars = new char[(int) file.length()];
+ 
+             // Read the characters into the allChars array
+-            in.read(allChars, 0, (int)file.length());
++            in.read(allChars, 0, (int) file.length());
+             in.close();
+ 
+             // Convert to a string
+diff --git a/test/com/sun/javadoc/VersionNumber/VersionNumber.java b/test/com/sun/javadoc/VersionNumber/VersionNumber.java
+--- openjdk/langtools/test/com/sun/javadoc/VersionNumber/VersionNumber.java
++++ openjdk/langtools/test/com/sun/javadoc/VersionNumber/VersionNumber.java
+@@ -84,7 +84,7 @@
+ 
+             // Test the proper DOCTYPE element is present:
+             {
+-                 "<!-- Generated by javadoc (build",
++                 "<!-- Generated by javadoc (version",
+                      TMPDEST_DIR1 + "p1" + FS + "C.html"  },
+ 
+         };
+diff --git a/test/com/sun/javadoc/WindowTitles/WindowTitles.java b/test/com/sun/javadoc/WindowTitles/WindowTitles.java
+--- openjdk/langtools/test/com/sun/javadoc/WindowTitles/WindowTitles.java
++++ openjdk/langtools/test/com/sun/javadoc/WindowTitles/WindowTitles.java
+@@ -94,52 +94,52 @@
+      */
+     private static final String[][] testArray = {
+ 
+-            { "<TITLE>" + LS + "Overview" + LS + "</TITLE>",
++            { "<title>Overview</title>",
+                     TMPDIR_STRING1 + "overview-summary.html"                  },
+ 
+-            { "<TITLE>" + LS + "Class Hierarchy" + LS + "</TITLE>",
++            { "<title>Class Hierarchy</title>",
+                     TMPDIR_STRING1 + "overview-tree.html"                     },
+ 
+-            { "<TITLE>" + LS + "Overview List" + LS + "</TITLE>",
++            { "<title>Overview List</title>",
+                     TMPDIR_STRING1 + "overview-frame.html"                    },
+ 
+-            { "<TITLE>" + LS + "p1" + LS + "</TITLE>",
++            { "<title>p1</title>",
+                     TMPDIR_STRING1 + "p1" + FS + "package-summary.html"       },
+ 
+-            { "<TITLE>" + LS + "p1" + LS + "</TITLE>",
++            { "<title>p1</title>",
+                     TMPDIR_STRING1 + "p1" + FS + "package-frame.html"         },
+ 
+-            { "<TITLE>" + LS + "p1 Class Hierarchy" + LS + "</TITLE>",
++            { "<title>p1 Class Hierarchy</title>",
+                     TMPDIR_STRING1 + "p1" + FS + "package-tree.html"          },
+ 
+-            { "<TITLE>" + LS + "Uses of Package p1" + LS + "</TITLE>",
++            { "<title>Uses of Package p1</title>",
+                     TMPDIR_STRING1 + "p1" + FS + "package-use.html"           },
+ 
+-            { "<TITLE>" + LS + "C1" + LS + "</TITLE>",
++            { "<title>C1</title>",
+                     TMPDIR_STRING1 + "p1" + FS + "C1.html"                    },
+ 
+-            { "<TITLE>" + LS + "All Classes" + LS + "</TITLE>",
++            { "<title>All Classes</title>",
+                     TMPDIR_STRING1 + "allclasses-frame.html"                  },
+ 
+-            { "<TITLE>" + LS + "All Classes" + LS + "</TITLE>",
++            { "<title>All Classes</title>",
+                     TMPDIR_STRING1 + "allclasses-noframe.html"                },
+ 
+-            { "<TITLE>" + LS + "Constant Field Values" + LS + "</TITLE>",
++            { "<title>Constant Field Values</title>",
+                     TMPDIR_STRING1 + "constant-values.html"                   },
+ 
+-            { "<TITLE>" + LS + "Deprecated List" + LS + "</TITLE>",
++            { "<title>Deprecated List</title>",
+                     TMPDIR_STRING1 + "deprecated-list.html"                   },
+ 
+-            { "<TITLE>" + LS + "Serialized Form" + LS + "</TITLE>",
++            { "<title>Serialized Form</title>",
+                     TMPDIR_STRING1 + "serialized-form.html"                   },
+ 
+-            { "<TITLE>" + LS + "API Help" + LS + "</TITLE>",
++            { "<title>API Help</title>",
+                     TMPDIR_STRING1 + "help-doc.html"                          },
+ 
+-            { "<TITLE>" + LS + "Index" + LS + "</TITLE>",
++            { "<title>Index</title>",
+                     TMPDIR_STRING1 + "index-all.html"                         },
+ 
+-            { "<TITLE>" + LS + "Uses of Class p1.C1" + LS + "</TITLE>",
++            { "<title>Uses of Class p1.C1</title>",
+                     TMPDIR_STRING1 + "p1" + FS + "class-use" + FS + "C1.html" },
+         };
+ 
+@@ -147,7 +147,7 @@
+      * Assign value for [ stringToFind, filename ] for split index page
+      */
+     private static final String[][] testSplitIndexArray = {
+-            { "<TITLE>" + LS + "C-Index" + LS + "</TITLE>",
++            { "<title>C-Index</title>",
+                     TMPDIR_STRING2 + "index-files" + FS + "index-1.html"       },
+         };
+ 
+diff --git a/test/com/sun/javadoc/constantValues/TestConstantValuesDriver.java b/test/com/sun/javadoc/constantValues/TestConstantValuesDriver.java
+--- openjdk/langtools/test/com/sun/javadoc/constantValues/TestConstantValuesDriver.java
++++ openjdk/langtools/test/com/sun/javadoc/constantValues/TestConstantValuesDriver.java
+@@ -51,7 +51,7 @@
+             tests[i][1] = "TEST"+(i+1)+"PASSES";
+         }
+         tests[tests.length-1][0] = BUG_ID + FS + "constant-values.html";
+-        tests[tests.length-1][1] = "<CODE>\"&lt;Hello World&gt;\"</CODE>";
++        tests[tests.length-1][1] = "<code>\"&lt;Hello World&gt;\"</code>";
+         TestConstantValuesDriver tester = new TestConstantValuesDriver();
+         run(tester, ARGS, tests, NO_TEST);
+         tester.printSummary();
+diff --git a/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java b/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
+--- openjdk/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
++++ openjdk/langtools/test/com/sun/javadoc/testClassCrossReferences/TestClassCrossReferences.java
+@@ -37,18 +37,20 @@
+     private static final String BUG_ID = "4652655-4857717";
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "C.html",
+-            "<A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/math/package-summary.html?is-external=true\"><CODE>Link to math package</CODE></A>"},
++            "<a href=\"http://java.sun.com/j2se/1.4/docs/api/java/math/package-summary.html?is-external=true\"><code>Link to math package</code></a>"},
+         {BUG_ID + FS + "C.html",
+-            "<A HREF=\"http://java.sun.com/j2se/1.4/docs/api/javax/swing/text/AbstractDocument.AttributeContext.html?is-external=true\" " +
+-            "title=\"class or interface in javax.swing.text\"><CODE>Link to AttributeContext innerclass</CODE></A>"},
++            "<a href=\"http://java.sun.com/j2se/1.4/docs/api/javax/swing/text/AbstractDocument.AttributeContext.html?is-external=true\" " +
++            "title=\"class or interface in javax.swing.text\"><code>Link to AttributeContext innerclass</code></a>"},
+         {BUG_ID + FS + "C.html",
+-            "<A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/math/BigDecimal.html?is-external=true\" " +
+-                "title=\"class or interface in java.math\"><CODE>Link to external class BigDecimal</CODE></A>"},
++            "<a href=\"http://java.sun.com/j2se/1.4/docs/api/java/math/BigDecimal.html?is-external=true\" " +
++                "title=\"class or interface in java.math\"><code>Link to external class BigDecimal</code></a>"},
+         {BUG_ID + FS + "C.html",
+-            "<A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/math/BigInteger.html?is-external=true#gcd(java.math.BigInteger)\" " +
+-                "title=\"class or interface in java.math\"><CODE>Link to external member gcd</CODE></A>"},
++            "<a href=\"http://java.sun.com/j2se/1.4/docs/api/java/math/BigInteger.html?is-external=true#gcd(java.math.BigInteger)\" " +
++                "title=\"class or interface in java.math\"><code>Link to external member gcd</code></a>"},
+         {BUG_ID + FS + "C.html",
+-            "<STRONG>Overrides:</STRONG></DT><DD><CODE>toString</CODE> in class <CODE>java.lang.Object</CODE>"}
++            "<dl>" + NL + "<dt><strong>Overrides:</strong></dt>" + NL +
++            "<dd><code>toString</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>" + NL +
++            "</dl>"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testClassTree/TestClassTree.java b/test/com/sun/javadoc/testClassTree/TestClassTree.java
+--- openjdk/langtools/test/com/sun/javadoc/testClassTree/TestClassTree.java
++++ openjdk/langtools/test/com/sun/javadoc/testClassTree/TestClassTree.java
+@@ -48,32 +48,29 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "package-tree.html",
+-            "<LI TYPE=\"circle\">pkg.<A HREF=\"../pkg/ParentClass.html\" " +
+-            "title=\"class in pkg\"><STRONG>ParentClass</STRONG></A><UL>"},
++            "<ul>" + NL + "<li type=\"circle\">pkg.<a href=\"../pkg/ParentClass.html\" " +
++            "title=\"class in pkg\"><span class=\"strong\">ParentClass</span></a>"},
+ 
+         {BUG_ID + FS + "pkg" + FS + "package-tree.html",
+-            "Annotation Type Hierarchy" + NL + "</H2>" + NL + "<UL>" + NL +
+-            "<LI TYPE=\"circle\">pkg.<A HREF=\"../pkg/AnnotationType.html\" " +
+-            "title=\"annotation in pkg\"><STRONG>AnnotationType</STRONG></A> " +
+-            "(implements java.lang.annotation.Annotation)" + NL + "</UL>"},
++            "<h2 title=\"Annotation Type Hierarchy\">Annotation Type Hierarchy</h2>" + NL +
++            "<ul>" + NL + "<li type=\"circle\">pkg.<a href=\"../pkg/AnnotationType.html\" " +
++            "title=\"annotation in pkg\"><span class=\"strong\">AnnotationType</span></a> " +
++            "(implements java.lang.annotation.Annotation)</li>" + NL + "</ul>"},
+ 
+         {BUG_ID + FS + "pkg" + FS + "package-tree.html",
+-            "<H2>" + NL +
+-            "Enum Hierarchy" + NL +
+-            "</H2>" + NL +
+-            "<UL>" + NL +
+-            "<LI TYPE=\"circle\">java.lang.Object<UL>" + NL +
+-            "<LI TYPE=\"circle\">java.lang.Enum&lt;E&gt; (implements java.lang.Comparable&lt;T&gt;, java.io.Serializable)" + NL +
+-            "<UL>" + NL +
+-            "<LI TYPE=\"circle\">pkg.<A HREF=\"../pkg/Coin.html\" title=\"enum in pkg\"><STRONG>Coin</STRONG></A></UL>" + NL +
+-            "</UL>" + NL +
+-            "</UL>"
++            "<h2 title=\"Enum Hierarchy\">Enum Hierarchy</h2>" + NL + "<ul>" + NL +
++            "<li type=\"circle\">java.lang.Object" + NL + "<ul>" + NL +
++            "<li type=\"circle\">java.lang.Enum&lt;E&gt; (implements java.lang." +
++            "Comparable&lt;T&gt;, java.io.Serializable)" + NL + "<ul>" + NL +
++            "<li type=\"circle\">pkg.<a href=\"../pkg/Coin.html\" " +
++            "title=\"enum in pkg\"><span class=\"strong\">Coin</span></a></li>" + NL +
++            "</ul>" + NL + "</li>" + NL + "</ul>" + NL + "</li>" + NL + "</ul>"
+         },
+     };
+     private static final String[][] NEGATED_TEST = {
+         {BUG_ID + FS + "pkg" + FS + "package-tree.html",
+-            "<LI TYPE=\"circle\">class pkg.<A HREF=\"../pkg/ParentClass.html\" " +
+-            "title=\"class in pkg\"><STRONG>ParentClass</STRONG></A><UL>"}
++            "<li type=\"circle\">class pkg.<a href=\"../pkg/ParentClass.html\" " +
++            "title=\"class in pkg\"><span class=\"strong\">ParentClass</span></a></li>"}
+         };
+ 
+     /**
+diff --git a/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java b/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
+--- openjdk/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
++++ openjdk/langtools/test/com/sun/javadoc/testConstructorIndent/TestConstructorIndent.java
+@@ -45,10 +45,10 @@
+ 
+     //Input for string search tests.
+     private static final String[][] TEST = {
+-        {BUG_ID + FS + "C.html", "<DL>" + NL + "<DD>This is just a simple constructor." + NL +
+-            "<P>" + NL + "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Parameters:</STRONG>" +
+-            "</DT><DD><CODE>i</CODE> - a param.</DD></DL>" + NL +
+-            "</DD>" + NL + "</DL>"
++        {BUG_ID + FS + "C.html", "<div class=\"block\">" +
++                 "This is just a simple constructor.</div>" + NL +
++                 "<dl><dt><span class=\"strong\">Parameters:</span></dt><dd>" +
++                 "<code>i</code> - a param.</dd></dl>"
+         }
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java b/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
+--- openjdk/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
++++ openjdk/langtools/test/com/sun/javadoc/testDeprecatedDocs/TestDeprecatedDocs.java
+@@ -76,24 +76,21 @@
+         {TARGET_FILE, "pkg.DeprecatedClassByAnnotation.method()"},
+         {TARGET_FILE, "pkg.DeprecatedClassByAnnotation.field"},
+ 
+-        {TARGET_FILE2, "<STRONG>Deprecated.</STRONG>" + NL +
+-                "<P>" + NL +
+-            "<PRE><FONT SIZE=\"-1\">@Deprecated" + NL +
+-            "</FONT>public class <STRONG>DeprecatedClassByAnnotation</STRONG>"},
++        {TARGET_FILE2, "<pre>@Deprecated" + NL +
++                 "public class <strong>DeprecatedClassByAnnotation</strong>" + NL +
++                 "extends java.lang.Object</pre>"},
+ 
+-        {TARGET_FILE2, "public int <STRONG>field</STRONG></PRE>" + NL +
+-            "<DL>" + NL +
+-            "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD></DL>"},
++        {TARGET_FILE2, "<pre>@Deprecated" + NL +
++                 "public&nbsp;int field</pre>" + NL +
++                 "<div class=\"block\"><span class=\"strong\">Deprecated.</span>&nbsp;</div>"},
+ 
+-        {TARGET_FILE2, "<FONT SIZE=\"-1\">@Deprecated" + NL +
+-            "</FONT>public <STRONG>DeprecatedClassByAnnotation</STRONG>()</PRE>" + NL +
+-            "<DL>" + NL +
+-            "<DD><STRONG>Deprecated.</STRONG>"},
++        {TARGET_FILE2, "<pre>@Deprecated" + NL +
++                 "public&nbsp;DeprecatedClassByAnnotation()</pre>" + NL +
++                 "<div class=\"block\"><span class=\"strong\">Deprecated.</span>&nbsp;</div>"},
+ 
+-        {TARGET_FILE2, "<FONT SIZE=\"-1\">@Deprecated" + NL +
+-            "</FONT>public void <STRONG>method</STRONG>()</PRE>" + NL +
+-            "<DL>" + NL +
+-            "<DD><STRONG>Deprecated.</STRONG>"},
++        {TARGET_FILE2, "<pre>@Deprecated" + NL +
++                 "public&nbsp;void&nbsp;method()</pre>" + NL +
++                 "<div class=\"block\"><span class=\"strong\">Deprecated.</span>&nbsp;</div>"},
+     };
+ 
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testDocRootInlineTag/TestDocRootInlineTag.java b/test/com/sun/javadoc/testDocRootInlineTag/TestDocRootInlineTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testDocRootInlineTag/TestDocRootInlineTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testDocRootInlineTag/TestDocRootInlineTag.java
+@@ -39,13 +39,13 @@
+     private static final String BUG_ID = "4369014-4851991";
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "TestDocRootTag.html",
+-            "<A HREF=\"http://www.java.sun.com/j2se/1.4/docs/api/java/io/File.html?is-external=true\" " +
+-            "title=\"class or interface in java.io\"><CODE>File</CODE></A>"},
++            "<a href=\"http://www.java.sun.com/j2se/1.4/docs/api/java/io/File.html?is-external=true\" " +
++            "title=\"class or interface in java.io\"><code>File</code></a>"},
+         {BUG_ID + FS + "TestDocRootTag.html",
+             "<a href=\"./glossary.html\">glossary</a>"},
+         {BUG_ID + FS + "TestDocRootTag.html",
+-            "<A HREF=\"http://www.java.sun.com/j2se/1.4/docs/api/java/io/File.html?is-external=true\" " +
+-            "title=\"class or interface in java.io\"><CODE>Second File Link</CODE></A>"},
++            "<a href=\"http://www.java.sun.com/j2se/1.4/docs/api/java/io/File.html?is-external=true\" " +
++            "title=\"class or interface in java.io\"><code>Second File Link</code></a>"},
+         {BUG_ID + FS + "TestDocRootTag.html", "The value of @docRoot is \"./\""},
+         {BUG_ID + FS + "index-all.html", "My package page is " +
+             "<a href=\"./pkg/package-summary.html\">here</a>"}
+diff --git a/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java b/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
+--- openjdk/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
++++ openjdk/langtools/test/com/sun/javadoc/testExternalOverridenMethod/TestExternalOverridenMethod.java
+@@ -39,17 +39,17 @@
+     private static final String BUG_ID = "4857717";
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "XReader.html",
+-            "<STRONG>Overrides:</STRONG></DT><DD><CODE><A HREF=\"" +
+-            "http://java.sun.com/j2se/1.4.1/docs/api/java/io/FilterReader.html?is-external=true#read()\"" +
+-                " title=\"class or interface in java.io\">read</A></CODE> in class " +
+-                "<CODE><A HREF=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/FilterReader.html?is-external=true\"" +
+-                " title=\"class or interface in java.io\">FilterReader</A>"},
++            "<dt><strong>Overrides:</strong></dt>" + NL +
++            "<dd><code><a href=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/FilterReader.html?is-external=true#read()\" " +
++            "title=\"class or interface in java.io\">read</a></code>&nbsp;in class&nbsp;<code>" +
++            "<a href=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/FilterReader.html?is-external=true\" " +
++            "title=\"class or interface in java.io\">FilterReader</a></code></dd>"},
+         {BUG_ID + FS + "pkg" + FS + "XReader.html",
+-            "<STRONG>Specified by:</STRONG></DT><DD><CODE><A HREF=\"" +
+-            "http://java.sun.com/j2se/1.4.1/docs/api/java/io/DataInput.html?is-external=true#readInt()\"" +
+-            " title=\"class or interface in java.io\">readInt</A></CODE> in interface " +
+-            "<CODE><A HREF=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/DataInput.html?is-external=true\"" +
+-            " title=\"class or interface in java.io\">DataInput</A>"}};
++            "<dt><strong>Specified by:</strong></dt>" + NL +
++            "<dd><code><a href=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/DataInput.html?is-external=true#readInt()\" " +
++            "title=\"class or interface in java.io\">readInt</a></code>&nbsp;in interface&nbsp;<code>" +
++            "<a href=\"http://java.sun.com/j2se/1.4.1/docs/api/java/io/DataInput.html?is-external=true\" " +
++            "title=\"class or interface in java.io\">DataInput</a></code></dd>"}};
+ 
+ 
+ 
+diff --git a/test/com/sun/javadoc/testHeadings/TestHeadings.java b/test/com/sun/javadoc/testHeadings/TestHeadings.java
+--- openjdk/langtools/test/com/sun/javadoc/testHeadings/TestHeadings.java
++++ openjdk/langtools/test/com/sun/javadoc/testHeadings/TestHeadings.java
+@@ -47,80 +47,65 @@
+     private static final String[][] TEST = {
+         //Package summary
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Class</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-            " NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">" +
++            "Class</th>" + NL + "<th class=\"colLast\" scope=\"col\"" +
++            ">Description</th>"
+         },
+ 
+         // Class documentation
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Field and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Field and Description</th>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+-            "<TH ALIGN=\"left\"><STRONG>Methods inherited from class " +            "java.lang.Object</STRONG></TH>"
++            "<h3>Methods inherited from class&nbsp;java.lang.Object</h3>"
+         },
+ 
+         // Class use documentation
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Package</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Description</th>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+-            "Uses of <A HREF=\"../../pkg1/C1.html\" " +            "title=\"class in pkg1\">C1</A> in " +            "<A HREF=\"../../pkg2/package-summary.html\">pkg2</A></FONT></TH>"
+-        },
+-        {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Field and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Field and Description</th>"
+         },
+ 
+         // Deprecated
+         {BUG_ID + FS + "deprecated-list.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Method and Description</TH>"
++            "<th class=\"colOne\" scope=\"col\">Method and Description</th>"
+         },
+ 
+         // Constant values
+         {BUG_ID + FS + "constant-values.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Constant Field</TH>" + NL +
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>Value</TH>"
++            "<th class=\"colFirst\" scope=\"col\">" +
++            "Modifier and Type</th>" + NL + "<th scope=\"col\">Constant Field</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Value</th>"
+         },
+ 
+         // Serialized Form
+         {BUG_ID + FS + "serialized-form.html",
+-            "<TH ALIGN=\"center\"><FONT SIZE=\"+2\">" + NL +
+-            "<STRONG>Package</STRONG> <STRONG>pkg1</STRONG></FONT></TH>"
++            "<h2 title=\"Package\">Package&nbsp;pkg1</h2>"
+         },
+         {BUG_ID + FS + "serialized-form.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\">" + NL +
+-            "<STRONG>Class <A HREF=\"pkg1/C1.html\" " +            "title=\"class in pkg1\">pkg1.C1</A> extends java.lang.Object " +            "implements Serializable</STRONG></FONT></TH>"
++            "<h3>Class <a href=\"pkg1/C1.html\" title=\"class in pkg1\">" +
++            "pkg1.C1</a> extends java.lang.Object implements Serializable</h3>"
+         },
+         {BUG_ID + FS + "serialized-form.html",
+-            "<TH ALIGN=\"left\" COLSPAN=\"1\"><FONT SIZE=\"+2\">" + NL +
+-            "<STRONG>Serialized Fields</STRONG></FONT></TH>"
++            "<h3>Serialized Fields</h3>"
+         },
+ 
+         // Overview Frame
+         {BUG_ID + FS + "overview-frame.html",
+-            "<TH ALIGN=\"left\" NOWRAP><FONT size=\"+1\" " +            "CLASS=\"FrameTitleFont\">" + NL + "<STRONG>Test Files</STRONG></FONT></TH>"
++            "<h1 title=\"Test Files\" class=\"bar\">Test Files</h1>"
+         },
+         {BUG_ID + FS + "overview-frame.html",
+-            "<TITLE>" + NL +
+-            "Overview List" + NL +
+-            "</TITLE>"
++            "<title>Overview List</title>"
+         },
+ 
+         // Overview Summary
+         {BUG_ID + FS + "overview-summary.html",
+-            "<TITLE>" + NL +
+-            "Overview" + NL +
+-            "</TITLE>"
++            "<title>Overview</title>"
+         },
+ 
+     };
+diff --git a/test/com/sun/javadoc/testHelpOption/TestHelpOption.java b/test/com/sun/javadoc/testHelpOption/TestHelpOption.java
+--- openjdk/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java
++++ openjdk/langtools/test/com/sun/javadoc/testHelpOption/TestHelpOption.java
+@@ -91,8 +91,7 @@
+ 
+     private static final String[][] TEST2 = {
+         {BUG_ID + FS + "TestHelpOption.html",
+-            "<A HREF=\"help-doc.html\"><FONT CLASS=\"NavBarFont1\">" +
+-            "<STRONG>Help</STRONG></FONT></A>"
++            "<li><a href=\"help-doc.html\">Help</a></li>"
+         },
+     };
+     private static final String[][] NEGATED_TEST2 = NO_TEST;
+diff --git a/test/com/sun/javadoc/testHref/TestHref.java b/test/com/sun/javadoc/testHref/TestHref.java
+--- openjdk/langtools/test/com/sun/javadoc/testHref/TestHref.java
++++ openjdk/langtools/test/com/sun/javadoc/testHref/TestHref.java
+@@ -47,37 +47,41 @@
+     private static final String[][] TEST = {
+         //External link.
+         {BUG_ID + FS + "pkg" + FS + "C1.html",
+-            "HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait(long, int)\""
++            "href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true#wait(long, int)\""
+         },
+         //Member summary table link.
+         {BUG_ID + FS + "pkg" + FS + "C1.html",
+-            "HREF=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\""
++            "href=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\""
+         },
+         //Anchor test.
+         {BUG_ID + FS + "pkg" + FS + "C1.html",
+-            "<A NAME=\"method(int, int, java.util.ArrayList)\"><!-- --></A>"
++            "<a name=\"method(int, int, java.util.ArrayList)\">" + NL +
++            "<!--   -->" + NL +
++            "</a>"
+         },
+         //Backward compatibility anchor test.
+         {BUG_ID + FS + "pkg" + FS + "C1.html",
+-            "<A NAME=\"method(int, int, java.util.ArrayList)\"><!-- --></A>"
++            "<a name=\"method(int, int, java.util.ArrayList)\">" + NL +
++            "<!--   -->" + NL +
++            "</a>"
+         },
+         //{@link} test.
+         {BUG_ID + FS + "pkg" + FS + "C2.html",
+-            "Link: <A HREF=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
++            "Link: <a href=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
+         },
+         //@see test.
+         {BUG_ID + FS + "pkg" + FS + "C2.html",
+-            "See Also:</STRONG></DT><DD><A HREF=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
++            "See Also:</span></dt><dd><a href=\"../pkg/C1.html#method(int, int, java.util.ArrayList)\">"
+         },
+ 
+         //Header does not link to the page itself.
+         {BUG_ID + FS + "pkg" + FS + "C4.html",
+-            "Class C4&lt;E extends C4&lt;E&gt;&gt;</H2>"
++            "Class C4&lt;E extends C4&lt;E&gt;&gt;</h2>"
+         },
+ 
+         //Signature does not link to the page itself.
+         {BUG_ID + FS + "pkg" + FS + "C4.html",
+-            "public abstract class <STRONG>C4&lt;E extends C4&lt;E&gt;&gt;</STRONG>"
++            "public abstract class <strong>C4&lt;E extends C4&lt;E&gt;&gt;</strong>"
+         },
+     };
+     private static final String[][] NEGATED_TEST =
+diff --git a/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java b/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDefinitionListTag/TestHtmlDefinitionListTag.java
+@@ -43,149 +43,77 @@
+     // Optional Element should print properly nested definition list tags
+     // for default value.
+     private static final String[][] TEST_ALL = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<PRE>public class " +
+-                 "<STRONG>C1</STRONG>" + NL + "extends " +
+-                 "java.lang.Object" + NL + "implements " +
+-                 "java.io.Serializable</PRE>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C4.html", "<DL>" + NL + "<DD><DL>" + NL +
+-                 "<DT><STRONG>Default:</STRONG></DT><DD>true</DD>" + NL +
+-                 "</DL>" + NL + "</DD>" + NL + "</DL>"}};
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<pre>public class <strong>C1</strong>" + NL +
++                 "extends java.lang.Object" + NL + "implements java.io.Serializable</pre>"},
++        {BUG_ID + FS + "pkg1" + FS + "C4.html", "<dl>" + NL +
++                 "<dt>Default:</dt>" + NL + "<dd>true</dd>" + NL +
++                 "</dl>"}};
+ 
+     // Test for normal run of javadoc in which various ClassDocs and
+     // serialized form should have properly nested definition list tags
+     // enclosing comments, tags and deprecated information.
+     private static final String[][] TEST_CMNT_DEPR = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
+-                 "<DT><STRONG>Since:</STRONG></DT>" + NL +
+-                 "  <DD>JDK1.0</DD>" + NL + "<DT><STRONG>See Also:</STRONG></DT><DD>" +
+-                 "<A HREF=\"../pkg1/C2.html\" title=\"class in pkg1\">" +
+-                 "<CODE>C2</CODE></A>, " + NL +
+-                 "<A HREF=\"../serialized-form.html#pkg1.C1\">" +
+-                 "Serialized Form</A></DD></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
+-                 " 1.5, replaced by" + NL +
+-                 " <A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I></DD>" +
+-                 "<DD>This field indicates whether the C1 is undecorated." + NL +
+-                 "<P>" + NL + "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>" +
+-                 "Since:</STRONG></DT>" + NL + "  <DD>1.4</DD>" + NL + "<DT>" +
+-                 "<STRONG>See Also:</STRONG></DT><DD>" +
+-                 "<A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
+-                 "setUndecorated(boolean)</CODE></A></DD></DL>" + NL +"</DD>" + NL +
+-                 "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
+-                 "<DD>Constructor." + NL + "<P>" + NL + "</DD>" + NL +
+-                 "<DD><DL>" + NL + "<DT><STRONG>Parameters:</STRONG></DT><DD>" +
+-                 "<CODE>title</CODE> - the title</DD><DD><CODE>test</CODE>" +
+-                 " - boolean value</DD>" + NL + "<DT><STRONG>Throws:</STRONG></DT>" + NL +
+-                 "<DD><CODE>java.lang.IllegalArgumentException</CODE>" +
+-                 " - if the <code>owner</code>'s" + NL + "     <code>GraphicsConfiguration" +
+-                 "</code> is not from a screen device</DD>" + NL +"<DD><CODE>" +
+-                 "HeadlessException</CODE></DD></DL>" + NL + "</DD>" + NL +
+-                 "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
+-                 "<DD>Method comments." + NL + "<P>" + NL +
+-                 "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Parameters:" +
+-                 "</STRONG></DT><DD><CODE>undecorated</CODE> - <code>true</code>" +
+-                 " if no decorations are" + NL + "         to be enabled;" + NL +
+-                 "         <code>false</code> if decorations are to be enabled." +
+-                 "</DD><DT><STRONG>Since:</STRONG></DT>" + NL +
+-                 "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG></DT>" +
+-                 "<DD><A HREF=\"../pkg1/C1.html#readObject()\"><CODE>" +
+-                 "readObject()</CODE></A></DD></DL>" + NL + "</DD>" + NL +
+-                 "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL + "<DD><DL>" + NL +
+-                 "<DT><STRONG>Throws:</STRONG></DT>" + NL + "<DD><CODE>" +
+-                 "java.io.IOException</CODE></DD><DT><STRONG>See Also:" +
+-                 "</STRONG></DT><DD>" +
+-                 "<A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<DL>" + NL +
+-                 "<DD>No modal exclusion." + NL + "<P>" + NL +"</DD>" + NL +
+-                 "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL>" + NL + "<DD>Constructor." + NL +
+-                 "<P>" + NL +"</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced " +
+-                 "by" + NL + " <A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
+-                 "</DD><DD>Set visible." + NL + "<P>" + NL + "</DD>" +NL +
+-                 "<DD><DL>" + NL + "<DT><STRONG>Parameters:</STRONG></DT><DD>" +
+-                 "<CODE>set</CODE> - boolean</DD><DT><STRONG>Since:</STRONG></DT>" + NL +
+-                 "  <DD>1.4</DD></DL>" + NL + "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C3.html", "<DL>" + NL + "<DD>Comment." + NL +
+-                 "<P>" + NL + "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><DL>" + NL +
+-                 "<DT><STRONG>Throws:</STRONG></DT>" + NL + "<DD><CODE>" +
+-                 "java.io.IOException</CODE></DD><DT><STRONG>See Also:</STRONG>" +
+-                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version " +
+-                 "1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I></DD>" +
+-                 "<DD>This field indicates whether the C1 is undecorated." + NL +
+-                 "<P>" + NL + "</DD>" + NL + "<DD>&nbsp;</DD>" + NL +
+-                 "<DD><DL>" + NL + "<DT><STRONG>Since:</STRONG></DT>" + NL +
+-                 "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG>" +
+-                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
+-                 " 1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
+-                 "</DD><DD>Reads the object stream." + NL + "<P>" + NL +
+-                 "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Throws:" +
+-                 "</STRONG></DT>" + NL + "<DD><CODE><code>" +
+-                 "IOException</code></CODE></DD>" + NL +
+-                 "<DD><CODE>java.io.IOException</CODE></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD><DD>" +
+-                 "The name for this class." + NL + "<P>" + NL + "</DD>" + NL +
+-                 "<DD>&nbsp;</DD>" + NL + "</DL>"}};
+-
+-    // Test with -nocomment option. The ClassDocs and serialized form should
+-    // have properly nested definition list tags enclosing deprecated
+-    // information and should not display definition lists for comments
+-    // and tags.
+-    private static final String[][] TEST_NOCMNT = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced by" + NL +
+-                 " <A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
+-                 "setUndecorated(boolean)</CODE></A>.</I></DD></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
+-                 " 1.5, replaced by" + NL +
+-                 " <A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
+-                 "</DD></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C5.html", "<PRE>" + NL +
+-                 "protected <STRONG>C5</STRONG>()</PRE>" + NL + "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C5.html", "<PRE>" + NL +
+-                 "public void <STRONG>printInfo</STRONG>()</PRE>" + NL + "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD></DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "boolean <STRONG>" +
+-                 "undecorated</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
+-                 "setUndecorated(boolean)</CODE></A>.</I></DD></DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
+-                 " 1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
+-                 "</DD></DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "int <STRONG>" +
+-                 "publicKey</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;</DD></DL>"}};
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl>" +
++                 "<dt><span class=\"strong\">Since:</span></dt>" + NL +
++                 "  <dd>JDK1.0</dd></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
++                 "  <dd>JDK1.0</dd>" + NL + "<dt><span class=\"strong\">See Also:</span></dt>" +
++                 "<dd><a href=\"../pkg1/C2.html\" title=\"class in pkg1\"><code>" +
++                 "C2</code></a>, " + NL + "<a href=\"../serialized-form.html#pkg1.C1\">" +
++                 "Serialized Form</a></dd></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
++                 "  <dd>1.4</dd>" + NL +
++                 "<dt><span class=\"strong\">See Also:</span></dt><dd>" +
++                 "<a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a></dd></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Parameters:</span></dt><dd><code>title" +
++                 "</code> - the title</dd><dd><code>test</code> - boolean value" +
++                 "</dd>" + NL + "<dt><span class=\"strong\">Throws:</span></dt>" + NL +
++                 "<dd><code>java.lang.IllegalArgumentException</code> - if the " +
++                 "<code>owner</code>'s" + NL +
++                 "     <code>GraphicsConfiguration</code> is not from a screen " +
++                 "device</dd>" + NL + "<dd><code>HeadlessException</code></dd></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Parameters:</span></dt><dd><code>undecorated" +
++                 "</code> - <code>true</code> if no decorations are" + NL +
++                 "         to be enabled;" + NL + "         <code>false</code> " +
++                 "if decorations are to be enabled.</dd><dt><span class=\"strong\">Since:" +
++                 "</span></dt>" + NL + "  <dd>1.4</dd>" + NL +
++                 "<dt><span class=\"strong\">See Also:</span></dt><dd>" +
++                 "<a href=\"../pkg1/C1.html#readObject()\"><code>readObject()" +
++                 "</code></a></dd></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Throws:</span></dt>" + NL +
++                 "<dd><code>java.io.IOException</code></dd><dt><span class=\"strong\">See Also:" +
++                 "</span></dt><dd><a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a></dd></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<dl><dt><span class=\"strong\">Parameters:" +
++                 "</span></dt><dd><code>set</code> - boolean</dd><dt><span class=\"strong\">" +
++                 "Since:</span></dt>" + NL + "  <dd>1.4</dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<dl><dt><span class=\"strong\">Throws:</span>" +
++                 "</dt>" + NL + "<dd><code>" +
++                 "java.io.IOException</code></dd><dt><span class=\"strong\">See Also:</span>" +
++                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
++                 "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
++                 " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
++                 "<div class=\"block\">This field indicates whether the C1 is " +
++                 "undecorated.</div>" + NL + "&nbsp;" + NL + "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
++                 "  <dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
++                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
++                 "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
++                 " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
++                 "<div class=\"block\">Reads the object stream.</div>" + NL +
++                 "<dl><dt><span class=\"strong\">Throws:" +
++                 "</span></dt>" + NL + "<dd><code><code>" +
++                 "IOException</code></code></dd>" + NL +
++                 "<dd><code>java.io.IOException</code></dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
++                 "&nbsp;</div>" + NL +
++                 "<div class=\"block\">The name for this class.</div>"}};
+ 
+     // Test with -nodeprecated option. The ClassDocs should have properly nested
+     // definition list tags enclosing comments and tags. The ClassDocs should not
+@@ -193,133 +121,104 @@
+     // should display properly nested definition list tags for comments, tags
+     // and deprecated information.
+     private static final String[][] TEST_NODEPR = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
+-                 "<DT><STRONG>Since:</STRONG></DT>" + NL +
+-                 "  <DD>JDK1.0</DD>" + NL + "<DT><STRONG>See Also:</STRONG></DT><DD>" +
+-                 "<A HREF=\"../pkg1/C2.html\" title=\"class in pkg1\">" +
+-                 "<CODE>C2</CODE></A>, " + NL +
+-                 "<A HREF=\"../serialized-form.html#pkg1.C1\">" +
+-                 "Serialized Form</A></DD></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
+-                 "<DD>Constructor." + NL + "<P>" + NL + "</DD>" + NL +
+-                 "<DD><DL>" + NL + "<DT><STRONG>Parameters:</STRONG></DT><DD>" +
+-                 "<CODE>title</CODE> - the title</DD><DD><CODE>test</CODE>" +
+-                 " - boolean value</DD>" + NL + "<DT><STRONG>Throws:</STRONG></DT>" + NL +
+-                 "<DD><CODE>java.lang.IllegalArgumentException</CODE>" +
+-                 " - if the <code>owner</code>'s" + NL + "     <code>GraphicsConfiguration" +
+-                 "</code> is not from a screen device</DD>" + NL +"<DD><CODE>" +
+-                 "HeadlessException</CODE></DD></DL>" + NL + "</DD>" + NL +
+-                 "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL +
+-                 "<DD>Method comments." + NL + "<P>" + NL +
+-                 "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Parameters:" +
+-                 "</STRONG></DT><DD><CODE>undecorated</CODE> - <code>true</code>" +
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl>" +
++                 "<dt><span class=\"strong\">Since:</span></dt>" + NL +
++                 "  <dd>JDK1.0</dd></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Since:</span>" +
++                 "</dt>" + NL + "  <dd>JDK1.0</dd>" + NL + "<dt><span class=\"strong\">See Also:" +
++                 "</span></dt><dd><a href=\"../pkg1/C2.html\" title=\"class in pkg1\">" +
++                 "<code>C2</code></a>, " + NL + "<a href=\"../serialized-form.html#pkg1.C1\">" +
++                 "Serialized Form</a></dd></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Parameters:" +
++                 "</span></dt><dd><code>title</code> - the title</dd><dd><code>" +
++                 "test</code> - boolean value</dd>" + NL + "<dt><span class=\"strong\">Throws:" +
++                 "</span></dt>" + NL + "<dd><code>java.lang.IllegalArgumentException" +
++                 "</code> - if the <code>owner</code>'s" + NL + "     <code>GraphicsConfiguration" +
++                 "</code> is not from a screen device</dd>" + NL + "<dd><code>" +
++                 "HeadlessException</code></dd></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Parameters:" +
++                 "</span></dt><dd><code>undecorated</code> - <code>true</code>" +
+                  " if no decorations are" + NL + "         to be enabled;" + NL +
+                  "         <code>false</code> if decorations are to be enabled." +
+-                 "</DD><DT><STRONG>Since:</STRONG></DT>" + NL +
+-                 "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG></DT>" +
+-                 "<DD><A HREF=\"../pkg1/C1.html#readObject()\"><CODE>" +
+-                 "readObject()</CODE></A></DD></DL>" + NL + "</DD>" + NL +
+-                 "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL + "<DD><DL>" + NL +
+-                 "<DT><STRONG>Throws:</STRONG></DT>" + NL + "<DD><CODE>" +
+-                 "java.io.IOException</CODE></DD><DT><STRONG>See Also:" +
+-                 "</STRONG></DT><DD>" +
+-                 "<A HREF=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<DL>" + NL +
+-                 "<DD>No modal exclusion." + NL + "<P>" + NL +"</DD>" + NL +
+-                 "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL>" + NL + "<DD>Constructor." + NL +
+-                 "<P>" + NL +"</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C3.html", "<DL>" + NL + "<DD>Comment." + NL +
+-                 "<P>" + NL + "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><DL>" + NL +
+-                 "<DT><STRONG>Throws:</STRONG></DT>" + NL + "<DD><CODE>" +
+-                 "java.io.IOException</CODE></DD><DT><STRONG>See Also:</STRONG>" +
+-                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version " +
+-                 "1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I></DD>" +
+-                 "<DD>This field indicates whether the C1 is undecorated." + NL +
+-                 "<P>" + NL + "</DD>" + NL + "<DD>&nbsp;</DD>" + NL +
+-                 "<DD><DL>" + NL + "<DT><STRONG>Since:</STRONG></DT>" + NL +
+-                 "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG>" +
+-                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
+-                 " 1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
+-                 "</DD><DD>Reads the object stream." + NL + "<P>" + NL +
+-                 "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Throws:" +
+-                 "</STRONG></DT>" + NL + "<DD><CODE><code>" +
+-                 "IOException</code></CODE></DD>" + NL +
+-                 "<DD><CODE>java.io.IOException</CODE></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD><DD>" +
+-                 "The name for this class." + NL + "<P>" + NL + "</DD>" + NL +
+-                 "<DD>&nbsp;</DD>" + NL + "</DL>"}};
++                 "</dd><dt><span class=\"strong\">Since:</span></dt>" + NL + "  <dd>1.4</dd>" + NL +
++                 "<dt><span class=\"strong\">See Also:</span></dt><dd><a href=\"../pkg1/C1.html#readObject()\">" +
++                 "<code>readObject()</code></a></dd></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl><dt><span class=\"strong\">Throws:</span>" +
++                 "</dt>" + NL + "<dd><code>java.io.IOException</code></dd><dt>" +
++                 "<span class=\"strong\">See Also:</span></dt><dd><a href=\"../pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a></dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<dl><dt><span class=\"strong\">Throws:</span>" +
++                 "</dt>" + NL + "<dd><code>" +
++                 "java.io.IOException</code></dd><dt><span class=\"strong\">See Also:</span>" +
++                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
++                 "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
++                 " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
++                 "<div class=\"block\">This field indicates whether the C1 is " +
++                 "undecorated.</div>" + NL + "&nbsp;" + NL + "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
++                 "  <dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
++                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
++                 "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
++                 " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
++                 "<div class=\"block\">Reads the object stream.</div>" + NL +
++                 "<dl><dt><span class=\"strong\">Throws:" +
++                 "</span></dt>" + NL + "<dd><code><code>" +
++                 "IOException</code></code></dd>" + NL +
++                 "<dd><code>java.io.IOException</code></dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
++                 "&nbsp;</div>" + NL + "<div class=\"block\">" +
++                 "The name for this class.</div>"}};
+ 
+     // Test with -nocomment and -nodeprecated options. The ClassDocs whould
+-    // not display definition lists for any member details. The serialized
+-    // form should display properly nested definition list tags for
+-    // deprecated information only.
++    // not display definition lists for any member details.
+     private static final String[][] TEST_NOCMNT_NODEPR = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<PRE>" + NL + "public void " +
+-                 "<STRONG>readObject</STRONG>()" + NL + "                throws" +
+-                 " java.io.IOException</PRE>" + NL + "<HR>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<PRE>" +NL + "public <STRONG>" +
+-                 "C2</STRONG>()</PRE>" + NL + "<HR>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<PRE>" + NL +
+-                 "public static final " +
+-                 "<A HREF=\"../pkg1/C1.ModalExclusionType.html\" " +
+-                 "title=\"enum in pkg1\">C1.ModalExclusionType</A> <STRONG>" +
+-                 "APPLICATION_EXCLUDE</STRONG></PRE>" + NL + "<HR>"},
+-        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "boolean <STRONG>" +
+-                 "undecorated</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
+-                 "setUndecorated(boolean)</CODE></A>.</I></DD></DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<pre>public&nbsp;void&nbsp;readObject()" + NL +
++                 "                throws java.io.IOException</pre>" + NL + "</li>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<pre>public&nbsp;C2()</pre>" + NL +
++                 "</li>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<pre>public " +
++                 "static final&nbsp;<a href=\"../pkg1/C1.ModalExclusionType.html\" " +
++                 "title=\"enum in pkg1\">C1.ModalExclusionType</a> " +
++                 "APPLICATION_EXCLUDE</pre>" + NL + "</li>"},
++        {BUG_ID + FS + "serialized-form.html", "<pre>boolean " +
++                 "undecorated</pre>" + NL + "<div class=\"block\"><span class=\"strong\">" +
++                 "Deprecated.</span>&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
++                 " <a href=\"pkg1/C1.html#setUndecorated(boolean)\"><code>" +
++                 "setUndecorated(boolean)</code></a>.</i></div>" + NL + "</li>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">" +
++                 "Deprecated.</span>&nbsp;<i>As of JDK version" +
+                  " 1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
+-                 "</DD></DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "int <STRONG>" +
+-                 "publicKey</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;</DD></DL>"}};
++                 " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL + "</li>"}};
+ 
+     // Test for valid HTML generation which should not comprise of empty
+     // definition list tags.
+     private static final String[][] NEGATED_TEST = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<DL>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<DL></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<DL>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<DL>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C2.ModalType.html", "<DL></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C2.ModalType.html", "<DL>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C3.html", "<DL></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C3.html", "<DL>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C4.html", "<DL></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C4.html", "<DL>" + NL + "</DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C5.html", "<DL></DL>"},
+-        {BUG_ID + FS + "pkg1" + FS + "C5.html", "<DL>" + NL + "</DL>"},
+-        {BUG_ID + FS + "overview-tree.html", "<DL></DL>"},
+-        {BUG_ID + FS + "overview-tree.html", "<DL>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL></DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "</DL>"}};
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<dl>" + NL + "</dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<dl>" + NL + "</dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<dl></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C1.ModalExclusionType.html", "<dl>" + NL + "</dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<dl></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.html", "<dl>" + NL + "</dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.ModalType.html", "<dl></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C2.ModalType.html", "<dl>" + NL + "</dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C3.html", "<dl></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C3.html", "<dl>" + NL + "</dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C4.html", "<dl></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C4.html", "<dl>" + NL + "</dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C5.html", "<dl></dl>"},
++        {BUG_ID + FS + "pkg1" + FS + "C5.html", "<dl>" + NL + "</dl>"},
++        {BUG_ID + FS + "overview-tree.html", "<dl></dl>"},
++        {BUG_ID + FS + "overview-tree.html", "<dl>" + NL + "</dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<dl></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<dl>" + NL + "</dl>"}};
+ 
+     private static final String[] ARGS1 =
+         new String[] {
+@@ -346,7 +245,7 @@
+         run(tester, ARGS1, TEST_ALL, NEGATED_TEST);
+         run(tester, ARGS1, TEST_CMNT_DEPR, NEGATED_TEST);
+         run(tester, ARGS2, TEST_ALL, NEGATED_TEST);
+-        run(tester, ARGS2, TEST_NOCMNT, TEST_CMNT_DEPR);
++        run(tester, ARGS2, NO_TEST, TEST_CMNT_DEPR);
+         run(tester, ARGS3, TEST_ALL, NEGATED_TEST);
+         run(tester, ARGS3, TEST_NODEPR, TEST_NOCMNT_NODEPR);
+         run(tester, ARGS4, TEST_ALL, NEGATED_TEST);
+diff --git a/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java b/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java
+@@ -0,0 +1,155 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++/*
++ * @test
++ * @bug 6851834
++ * @summary This test verifies the HTML document generation for javadoc output.
++ * @author Bhavesh Patel
++ * @build TestHtmlDocument
++ * @run main TestHtmlDocument
++ */
++
++import java.io.*;
++import com.sun.tools.doclets.formats.html.markup.*;
++
++/**
++ * The class reads each file, complete with newlines, into a string to easily
++ * compare the existing markup with the generated markup.
++ */
++public class TestHtmlDocument {
++
++    private static final String BUGID = "6851834";
++    private static final String BUGNAME = "TestHtmlDocument";
++    private static final String FS = System.getProperty("file.separator");
++    private static String srcdir = System.getProperty("test.src", ".");
++
++    // Entry point
++    public static void main(String[] args) throws IOException {
++        // Check whether the generated markup is same as the existing markup.
++        if (generateHtmlTree().equals(readFileToString(srcdir + FS + "testMarkup.html"))) {
++            System.out.println("\nTest passed for bug " + BUGID + " (" + BUGNAME + ")\n");
++        } else {
++            throw new Error("\nTest failed for bug " + BUGID + " (" + BUGNAME + ")\n");
++        }
++    }
++
++    // Generate the HTML output using the HTML document generation within doclet.
++    public static String generateHtmlTree() {
++        // Document type for the HTML document
++        DocType htmlDocType = DocType.Transitional();
++        HtmlTree html = new HtmlTree(HtmlTag.HTML);
++        HtmlTree head = new HtmlTree(HtmlTag.HEAD);
++        HtmlTree title = new HtmlTree(HtmlTag.TITLE);
++        // String content within the document
++        StringContent titleContent = new StringContent("Markup test");
++        title.addContent(titleContent);
++        head.addContent(title);
++        // Test META tag
++        HtmlTree meta = new HtmlTree(HtmlTag.META);
++        meta.addAttr(HtmlAttr.NAME, "keywords");
++        meta.addAttr(HtmlAttr.CONTENT, "testContent");
++        head.addContent(meta);
++        // Test invalid META tag
++        HtmlTree invmeta = new HtmlTree(HtmlTag.META);
++        head.addContent(invmeta);
++        // Test LINK tag
++        HtmlTree link = new HtmlTree(HtmlTag.LINK);
++        link.addAttr(HtmlAttr.REL, "testRel");
++        link.addAttr(HtmlAttr.HREF, "testLink.html");
++        head.addContent(link);
++        // Test invalid LINK tag
++        HtmlTree invlink = new HtmlTree(HtmlTag.LINK);
++        head.addContent(invlink);
++        html.addContent(head);
++        // Comment within the document
++        Comment bodyMarker = new Comment("======== START OF BODY ========");
++        html.addContent(bodyMarker);
++        HtmlTree body = new HtmlTree(HtmlTag.BODY);
++        Comment pMarker = new Comment("======== START OF PARAGRAPH ========");
++        body.addContent(pMarker);
++        HtmlTree p = new HtmlTree(HtmlTag.P);
++        StringContent bodyContent = new StringContent(
++                "This document is generated from sample source code and HTML " +
++                "files with examples of a wide variety of Java language constructs: packages, " +
++                "subclasses, subinterfaces, nested classes, nested interfaces," +
++                "inheriting from other packages, constructors, fields," +
++                "methods, and so forth. ");
++        p.addContent(bodyContent);
++        StringContent anchorContent = new StringContent("Click Here");
++        p.addContent(HtmlTree.A("testLink.html", anchorContent));
++        StringContent pContent = new StringContent(" to <test> out a link.");
++        p.addContent(pContent);
++        body.addContent(p);
++        HtmlTree p1 = new HtmlTree(HtmlTag.P);
++        // Test another version of A tag.
++        HtmlTree anchor = new HtmlTree(HtmlTag.A);
++        anchor.addAttr(HtmlAttr.HREF, "testLink.html");
++        anchor.addAttr(HtmlAttr.NAME, "Another version of a tag");
++        p1.addContent(anchor);
++        body.addContent(p1);
++        // Test for empty tags.
++        HtmlTree dl = new HtmlTree(HtmlTag.DL);
++        html.addContent(dl);
++        // Test for empty nested tags.
++        HtmlTree dlTree = new HtmlTree(HtmlTag.DL);
++        dlTree.addContent(new HtmlTree(HtmlTag.DT));
++        dlTree.addContent(new HtmlTree (HtmlTag.DD));
++        html.addContent(dlTree);
++        HtmlTree dlDisplay = new HtmlTree(HtmlTag.DL);
++        dlDisplay.addContent(new HtmlTree(HtmlTag.DT));
++        HtmlTree dd = new HtmlTree (HtmlTag.DD);
++        StringContent ddContent = new StringContent("Test DD");
++        dd.addContent(ddContent);
++        dlDisplay.addContent(dd);
++        body.addContent(dlDisplay);
++        StringContent emptyString = new StringContent("");
++        body.addContent(emptyString);
++        Comment emptyComment = new Comment("");
++        body.addContent(emptyComment);
++        HtmlTree hr = new HtmlTree(HtmlTag.HR);
++        body.addContent(hr);
++        html.addContent(body);
++        HtmlDocument htmlDoc = new HtmlDocument(htmlDocType, html);
++        return htmlDoc.toString();
++    }
++
++    // Read the file into a String
++    public static String readFileToString(String filename) throws IOException {
++        File file = new File(filename);
++        if ( !file.exists() ) {
++            System.out.println("\nFILE DOES NOT EXIST: " + filename);
++        }
++        BufferedReader in = new BufferedReader(new FileReader(file));
++        // Create an array of characters the size of the file
++        char[] allChars = new char[(int)file.length()];
++        // Read the characters into the allChars array
++        in.read(allChars, 0, (int)file.length());
++        in.close();
++        // Convert to a string
++        String allCharsString = new String(allChars);
++        return allCharsString;
++    }
++}
+diff --git a/test/com/sun/javadoc/testHtmlDocument/testLink.html b/test/com/sun/javadoc/testHtmlDocument/testLink.html
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDocument/testLink.html
+@@ -0,0 +1,9 @@
++<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
++<html>
++<head>
++<title>Markup test</title>
++</head>
++<body>
++This is a test for link.
++</body>
++</html>
+diff --git a/test/com/sun/javadoc/testHtmlDocument/testMarkup.html b/test/com/sun/javadoc/testHtmlDocument/testMarkup.html
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDocument/testMarkup.html
+@@ -0,0 +1,18 @@
++<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
++<html>
++<head>
++<title>Markup test</title>
++<meta name="keywords" content="testContent">
++<link rel="testRel" href="testLink.html">
++</head>
++<!-- ======== START OF BODY ======== -->
++<body>
++<!-- ======== START OF PARAGRAPH ======== -->
++<p>This document is generated from sample source code and HTML files with examples of a wide variety of Java language constructs: packages, subclasses, subinterfaces, nested classes, nested interfaces,inheriting from other packages, constructors, fields,methods, and so forth. <a href="testLink.html">Click Here</a> to &lt;test&gt; out a link.</p>
++<p><a href="testLink.html" name="Another version of a tag"></a></p>
++<dl>
++<dd>Test DD</dd>
++</dl>
++<hr>
++</body>
++</html>
+diff --git a/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java b/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlStrongTag/TestHtmlStrongTag.java
+@@ -38,7 +38,7 @@
+ 
+     private static final String BUG_ID = "6786028";
+     private static final String[][] TEST1 = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<STRONG>See Also:</STRONG>"}};
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<span class=\"strong\">See Also:</span>"}};
+     private static final String[][] NEGATED_TEST1 = {
+         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<STRONG>Method Summary</STRONG>"},
+         {BUG_ID + FS + "pkg1" + FS + "C1.html", "<B>"},
+diff --git a/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java b/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java
+--- openjdk/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTableTags/TestHtmlTableTags.java
+@@ -50,139 +50,128 @@
+ 
+         //Package summary
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Class Summary table, " +
++            "<table class=\"packageSummary\" border=\"0\" cellpadding=\"3\"" +
++            " cellspacing=\"0\" summary=\"Class Summary table, " +
+             "listing classes, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Interface Summary table, " +
++            "<table class=\"packageSummary\" border=\"0\" cellpadding=\"3\"" +
++            " cellspacing=\"0\" summary=\"Interface Summary table, " +
+             "listing interfaces, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Enum Summary table, " +
++            "<table class=\"packageSummary\" border=\"0\" cellpadding=\"3\"" +
++            " cellspacing=\"0\" summary=\"Enum Summary table, " +
+             "listing enums, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Annotation Types Summary table, " +
++            "<table class=\"packageSummary\" border=\"0\" cellpadding=\"3\"" +
++            " cellspacing=\"0\" summary=\"Annotation Types Summary table, " +
+             "listing annotation types, and an explanation\">"
+         },
+         // Class documentation
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Field Summary table, " +
+-            "listing fields, and an explanation\">"
++            "<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" " +
++            "cellspacing=\"0\" summary=\"Field Summary table, listing fields, " +
++            "and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Method Summary table, " +
+-            "listing methods, and an explanation\">"
++            "<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" " +
++            "cellspacing=\"0\" summary=\"Method Summary table, listing methods, " +
++            "and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C2.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Nested Class Summary table, " +
+-            "listing nested classes, and an explanation\">"
++            "<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" " +
++            "cellspacing=\"0\" summary=\"Nested Class Summary table, listing " +
++            "nested classes, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C2.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Constructor Summary table, " +
+-            "listing constructors, and an explanation\">"
++            "<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" " +
++            "cellspacing=\"0\" summary=\"Constructor Summary table, listing " +
++            "constructors, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C2.ModalExclusionType.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Enum Constant Summary table, " +
+-            "listing enum constants, and an explanation\">"
++            "<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" " +
++            "cellspacing=\"0\" summary=\"Enum Constant Summary table, listing " +
++            "enum constants, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C3.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Required Element Summary table, " +
++            "<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" " +
++            "cellspacing=\"0\" summary=\"Required Element Summary table, " +
+             "listing required elements, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C4.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Optional Element Summary table, " +
++            "<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" " +
++            "cellspacing=\"0\" summary=\"Optional Element Summary table, " +
+             "listing optional elements, and an explanation\">"
+         },
+         // Class use documentation
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "I1.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing packages, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing packages, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing fields, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing fields, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing methods, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing methods, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing fields, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing fields, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing methods, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing methods, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.ModalExclusionType.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing packages, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing packages, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.ModalExclusionType.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing methods, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing methods, and an explanation\">"
+         },
+         // Package use documentation
+         {BUG_ID + FS + "pkg1" + FS + "package-use.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing packages, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing packages, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "package-use.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing classes, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing classes, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-use.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing packages, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing packages, and an explanation\">"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-use.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Use table, " +
+-            "listing classes, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" summary=\"Use " +
++            "table, listing classes, and an explanation\">"
+         },
+         // Deprecated
+         {BUG_ID + FS + "deprecated-list.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Deprecated Fields table, " +
+-            "listing deprecated fields, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" " +
++            "summary=\"Deprecated Fields table, listing deprecated fields, " +
++            "and an explanation\">"
+         },
+         {BUG_ID + FS + "deprecated-list.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Deprecated Methods table, " +
+-            "listing deprecated methods, and an explanation\">"
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" " +
++            "summary=\"Deprecated Methods table, listing deprecated methods, " +
++            "and an explanation\">"
+         },
+         // Constant values
+         {BUG_ID + FS + "constant-values.html",
+-            "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" " +
+-            "SUMMARY=\"Constant Field Values table, listing " +
++            "<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" " +
++            "summary=\"Constant Field Values table, listing " +
+             "constant fields, and values\">"
+         },
+         // Overview Summary
+         {BUG_ID + FS + "overview-summary.html",
+-            "<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" " +
+-            "CELLSPACING=\"0\" SUMMARY=\"Packages table, " +
++            "<table class=\"overviewSummary\" border=\"0\" cellpadding=\"3\" " +
++            "cellspacing=\"0\" summary=\"Packages table, " +
+             "listing packages, and an explanation\">"
+         },
+ 
+@@ -192,125 +181,117 @@
+ 
+         //Package summary
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Class Summary</CAPTION>"
++            "<caption><span>Class Summary</span><span class=\"tabEnd\">" +
++            "&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Interface Summary</CAPTION>"
++            "<caption><span>Interface Summary</span><span class=\"tabEnd\">" +
++            "&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Enum Summary</CAPTION>"
++            "<caption><span>Enum Summary</span><span class=\"tabEnd\">" +
++            "&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Annotation Types Summary</CAPTION>"
++            "<caption><span>Annotation Types Summary</span><span class=\"tabEnd\">" +
++            "&nbsp;</span></caption>"
+         },
+         // Class documentation
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Field Summary</CAPTION>"
++            "<caption><span>Fields</span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Method Summary</CAPTION>"
++            "<caption><span>Methods</span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C2.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Nested Class Summary</CAPTION>"
++            "<caption><span>Nested Classes</span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C2.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Constructor Summary</CAPTION>"
++            "<caption><span>Constructors</span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C2.ModalExclusionType.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Enum Constant Summary</CAPTION>"
++            "<caption><span>Enum Constants</span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C3.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Required Element Summary</CAPTION>"
++            "<caption><span>Required Elements</span><span class=\"tabEnd\">&nbsp;" +
++            "</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C4.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Optional Element Summary</CAPTION>"
++            "<caption><span>Optional Elements</span><span class=\"tabEnd\">&nbsp;" +
++            "</span></caption>"
+         },
+         // Class use documentation
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "I1.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Packages that use <A HREF=\"../../pkg1/I1.html\" " +
+-            "title=\"interface in pkg1\">I1</A></CAPTION>"
++            "<caption><span>Packages that use <a href=\"../../pkg1/I1.html\" " +
++            "title=\"interface in pkg1\">I1</a></span><span class=\"tabEnd\">" +
++            "&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-            "Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> " +
+-            "declared as <A HREF=\"../../pkg1/C1.html\" title=\"class in pkg1\">" +
+-            "C1</A></CAPTION>"
++            "<caption><span>Fields in <a href=\"../../pkg2/package-summary.html\">" +
++            "pkg2</a> declared as <a href=\"../../pkg1/C1.html\" " +
++            "title=\"class in pkg1\">C1</a></span><span class=\"tabEnd\">&nbsp;" +
++            "</span></caption>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-            "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> " +
+-            "with parameters of type <A HREF=\"../../pkg1/C1.html\" " +
+-            "title=\"class in pkg1\">C1</A></CAPTION>"
++            "<caption><span>Methods in <a href=\"../../pkg2/package-summary.html\">" +
++            "pkg2</a> that return <a href=\"../../pkg1/C1.html\" " +
++            "title=\"class in pkg1\">C1</a></span><span class=\"tabEnd\">" +
++            "&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
+-            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-            "Fields in <A HREF=\"../../pkg1/package-summary.html\">pkg1</A> " +
+-            "declared as <A HREF=\"../../pkg2/C2.html\" title=\"class in pkg2\">" +
+-            "C2</A></CAPTION>"
++            "<caption><span>Fields in <a href=\"../../pkg1/package-summary.html\">" +
++            "pkg1</a> declared as <a href=\"../../pkg2/C2.html\" " +
++            "title=\"class in pkg2\">C2</a></span><span class=\"tabEnd\">" +
++            "&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
+-            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-            "Methods in <A HREF=\"../../pkg1/package-summary.html\">pkg1</A> " +
+-            "with parameters of type <A HREF=\"../../pkg2/C2.html\" " +
+-            "title=\"class in pkg2\">C2</A></CAPTION>"
++            "<caption><span>Methods in <a href=\"../../pkg1/package-summary.html\">" +
++            "pkg1</a> that return <a href=\"../../pkg2/C2.html\" " +
++            "title=\"class in pkg2\">C2</a></span><span class=\"tabEnd\">" +
++            "&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.ModalExclusionType.html",
+-            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-            "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2</A> " +
+-            "that return <A HREF=\"../../pkg2/C2.ModalExclusionType.html\" " +
+-            "title=\"enum in pkg2\">C2.ModalExclusionType</A></CAPTION>"
++            "<caption><span>Methods in <a href=\"../../pkg2/package-summary.html\">" +
++            "pkg2</a> that return <a href=\"../../pkg2/C2.ModalExclusionType.html\" " +
++            "title=\"enum in pkg2\">C2.ModalExclusionType</a></span>" +
++            "<span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         // Package use documentation
+         {BUG_ID + FS + "pkg1" + FS + "package-use.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Packages that use <A HREF=\"../pkg1/package-summary.html\">" +
+-            "pkg1</A></CAPTION>"
++            "<caption><span>Packages that use <a href=\"../pkg1/package-summary.html\">" +
++            "pkg1</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "package-use.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Classes in <A HREF=\"../pkg1/package-summary.html\">pkg1</A> " +
+-            "used by <A HREF=\"../pkg1/package-summary.html\">pkg1</A></CAPTION>"
++            "<caption><span>Classes in <a href=\"../pkg1/package-summary.html\">" +
++            "pkg1</a> used by <a href=\"../pkg1/package-summary.html\">pkg1</a>" +
++            "</span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-use.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Packages that use <A HREF=\"../pkg2/package-summary.html\">" +
+-            "pkg2</A></CAPTION>"
++            "<caption><span>Packages that use <a href=\"../pkg2/package-summary.html\">" +
++            "pkg2</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-use.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Classes in <A HREF=\"../pkg2/package-summary.html\">pkg2</A> " +
+-            "used by <A HREF=\"../pkg1/package-summary.html\">pkg1</A></CAPTION>"
++            "<caption><span>Classes in <a href=\"../pkg2/package-summary.html\">" +
++            "pkg2</a> used by <a href=\"../pkg1/package-summary.html\">pkg1</a>" +
++            "</span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         // Deprecated
+         {BUG_ID + FS + "deprecated-list.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Deprecated Fields</CAPTION>"
++            "<caption><span>Deprecated Fields</span><span class=\"tabEnd\">" +
++            "&nbsp;</span></caption>"
+         },
+         {BUG_ID + FS + "deprecated-list.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Deprecated Methods</CAPTION>"
++            "<caption><span>Deprecated Methods</span><span class=\"tabEnd\">" +
++            "&nbsp;</span></caption>"
+         },
+         // Constant values
+         {BUG_ID + FS + "constant-values.html",
+-            "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-            "pkg1.<A HREF=\"pkg1/C1.html\" title=\"class in pkg1\">C1</A></CAPTION>"
++            "<caption><span>pkg1.<a href=\"pkg1/C1.html\" title=\"class in pkg1\">" +
++            "C1</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+         // Overview Summary
+         {BUG_ID + FS + "overview-summary.html",
+-            "<CAPTION CLASS=\"TableCaption\">" + NL +
+-            "Packages</CAPTION>"
++            "<caption><span>Packages</span><span class=\"tabEnd\">&nbsp;</span></caption>"
+         },
+ 
+         /*
+@@ -319,135 +300,115 @@
+ 
+         //Package summary
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Class</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-            " NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">" +
++            "Class</th>" + NL + "<th class=\"colLast\" scope=\"col\"" +
++            ">Description</th>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "package-summary.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Interface</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-            " NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">" +
++            "Interface</th>" + NL + "<th class=\"colLast\" scope=\"col\"" +
++            ">Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Enum</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-            " NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">" +
++            "Enum</th>" + NL + "<th class=\"colLast\" scope=\"col\"" +
++            ">Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Annotation Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">" +
++            "Annotation Type</th>" + NL + "<th class=\"colLast\"" +
++            " scope=\"col\">Description</th>"
+         },
+         // Class documentation
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Field and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Field and Description</th>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "C1.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Method and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Method and Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C2.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Class and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Class and Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C2.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Constructor and Description</TH>"
++            "<th class=\"colOne\" scope=\"col\">Constructor and Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C2.ModalExclusionType.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Enum Constant and Description</TH>"
++            "<th class=\"colOne\" scope=\"col\">Enum Constant and Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C3.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Required Element and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Required Element and Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "C4.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Optional Element and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Optional Element and Description</th>"
+         },
+         // Class use documentation
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "I1.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-            " NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Package</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Description</th>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Field and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Field and Description</th>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "class-use" + FS + "C1.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Method and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Method and Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Field and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Field and Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Method and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Method and Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.ModalExclusionType.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-            " NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Package</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "C2.ModalExclusionType.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Method and Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Method and Description</th>"
+         },
+         // Package use documentation
+         {BUG_ID + FS + "pkg1" + FS + "package-use.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-            " NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Package</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Description</th>"
+         },
+         {BUG_ID + FS + "pkg1" + FS + "package-use.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Class and Description</TH>"
++            "<th class=\"colOne\" scope=\"col\">Class and Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-use.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-            " NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">Package</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Description</th>"
+         },
+         {BUG_ID + FS + "pkg2" + FS + "package-use.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Class and Description</TH>"
++            "<th class=\"colOne\" scope=\"col\">Class and Description</th>"
+         },
+         // Deprecated
+         {BUG_ID + FS + "deprecated-list.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Field and Description</TH>"
++            "<th class=\"colOne\" scope=\"col\">Field and Description</th>"
+         },
+         {BUG_ID + FS + "deprecated-list.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Method and Description</TH>"
++            "<th class=\"colOne\" scope=\"col\">Method and Description</th>"
+         },
+         // Constant values
+         {BUG_ID + FS + "constant-values.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Modifier and Type</TH>" + NL + "<TH CLASS=\"TableHeader\"" +
+-            " SCOPE=\"col\" NOWRAP>Constant Field</TH>" + NL +
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>Value</TH>"
++            "<th class=\"colFirst\" scope=\"col\">" +
++            "Modifier and Type</th>" + NL + "<th" +
++            " scope=\"col\">Constant Field</th>" + NL +
++            "<th class=\"colLast\" scope=\"col\">Value</th>"
+         },
+         // Overview Summary
+         {BUG_ID + FS + "overview-summary.html",
+-            "<TH CLASS=\"TableHeader\" SCOPE=\"col\" NOWRAP>" +
+-            "Package</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-            " NOWRAP>Description</TH>"
++            "<th class=\"colFirst\" scope=\"col\">" +
++            "Package</th>" + NL + "<th class=\"colLast\" scope=\"col\"" +
++            ">Description</th>"
+         }
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java b/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlTag/TestHtmlTag.java
+@@ -40,20 +40,20 @@
+ 
+     private static final String BUG_ID = "6786682";
+     private static final String[][] TEST1 = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML lang=\"" + Locale.getDefault().getLanguage() + "\">"},
+-        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<HTML lang=\"" + Locale.getDefault().getLanguage() + "\">"}};
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<html lang=\"" + Locale.getDefault().getLanguage() + "\">"},
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<html lang=\"" + Locale.getDefault().getLanguage() + "\">"}};
+     private static final String[][] NEGATED_TEST1 = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML>"}};
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<html>"}};
+     private static final String[][] TEST2 = {
+-        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<HTML lang=\"ja\">"},
+-        {BUG_ID + FS + "pkg2" + FS + "package-summary.html", "<HTML lang=\"ja\">"}};
++        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<html lang=\"ja\">"},
++        {BUG_ID + FS + "pkg2" + FS + "package-summary.html", "<html lang=\"ja\">"}};
+     private static final String[][] NEGATED_TEST2 = {
+-        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<HTML>"}};
++        {BUG_ID + FS + "pkg2" + FS + "C2.html", "<html>"}};
+     private static final String[][] TEST3 = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML lang=\"en\">"},
+-        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<HTML lang=\"en\">"}};
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<html lang=\"en\">"},
++        {BUG_ID + FS + "pkg1" + FS + "package-summary.html", "<html lang=\"en\">"}};
+     private static final String[][] NEGATED_TEST3 = {
+-        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<HTML>"}};
++        {BUG_ID + FS + "pkg1" + FS + "C1.html", "<html>"}};
+ 
+     private static final String[] ARGS1 =
+         new String[] {
+diff --git a/test/com/sun/javadoc/testIndex/TestIndex.java b/test/com/sun/javadoc/testIndex/TestIndex.java
+--- openjdk/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
++++ openjdk/langtools/test/com/sun/javadoc/testIndex/TestIndex.java
+@@ -48,35 +48,34 @@
+     private static final String[][] TEST = {
+         //Make sure the horizontal scroll bar does not appear in class frame.
+         {BUG_ID + FS + "index.html",
+-            "<FRAME src=\"overview-summary.html\" name=\"classFrame\" " +
+-            "title=\"Package, class and interface descriptions\" " +
+-            "scrolling=\"yes\">"},
++            "<frame src=\"overview-summary.html\" name=\"classFrame\" title=\"" +
++            "Package, class and interface descriptions\" scrolling=\"yes\">"},
+ 
+         //Test index-all.html
+         {BUG_ID + FS + "index-all.html",
+-            "<A HREF=\"./pkg/C.html\" title=\"class in pkg\"><STRONG>C</STRONG></A>" +
+-            " - Class in <A HREF=\"./pkg/package-summary.html\">pkg</A>"},
++            "<a href=\"./pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">C</span></a>" +
++            " - Class in <a href=\"./pkg/package-summary.html\">pkg</a>"},
+         {BUG_ID + FS + "index-all.html",
+-            "<A HREF=\"./pkg/Interface.html\" title=\"interface in pkg\">" +
+-            "<STRONG>Interface</STRONG></A> - Interface in " +
+-            "<A HREF=\"./pkg/package-summary.html\">pkg</A>"},
++            "<a href=\"./pkg/Interface.html\" title=\"interface in pkg\">" +
++            "<span class=\"strong\">Interface</span></a> - Interface in " +
++            "<a href=\"./pkg/package-summary.html\">pkg</a>"},
+         {BUG_ID + FS + "index-all.html",
+-            "<A HREF=\"./pkg/AnnotationType.html\" title=\"annotation in pkg\">" +
+-            "<STRONG>AnnotationType</STRONG></A> - Annotation Type in " +
+-            "<A HREF=\"./pkg/package-summary.html\">pkg</A>"},
++            "<a href=\"./pkg/AnnotationType.html\" title=\"annotation in pkg\">" +
++            "<span class=\"strong\">AnnotationType</span></a> - Annotation Type in " +
++            "<a href=\"./pkg/package-summary.html\">pkg</a>"},
+         {BUG_ID + FS + "index-all.html",
+-            "<A HREF=\"./pkg/Coin.html\" title=\"enum in pkg\">" +
+-            "<STRONG>Coin</STRONG></A> - Enum in " +
+-            "<A HREF=\"./pkg/package-summary.html\">pkg</A>"},
++            "<a href=\"./pkg/Coin.html\" title=\"enum in pkg\">" +
++            "<span class=\"strong\">Coin</span></a> - Enum in " +
++            "<a href=\"./pkg/package-summary.html\">pkg</a>"},
+         {BUG_ID + FS + "index-all.html",
+-            "Class in <A HREF=\"./package-summary.html\">&lt;Unnamed&gt;</A>"},
++            "Class in <a href=\"./package-summary.html\">&lt;Unnamed&gt;</a>"},
+         {BUG_ID + FS + "index-all.html",
+-            "<DT><A HREF=\"./pkg/C.html#Java\"><STRONG>Java</STRONG></A> - " + NL +
+-            "Static variable in class pkg.<A HREF=\"./pkg/C.html\" title=\"class in pkg\">C</A>" + NL +
+-            "</DT><DD>&nbsp;</DD>" + NL + NL +
+-            "<DT><A HREF=\"./pkg/C.html#JDK\"><STRONG>JDK</STRONG></A> - " + NL +
+-            "Static variable in class pkg.<A HREF=\"./pkg/C.html\" title=\"class in pkg\">C</A>" + NL +
+-            "</DT><DD>&nbsp;</DD>"},
++            "<dl>" + NL + "<dt><span class=\"strong\"><a href=\"./pkg/C.html#Java\">" +
++            "Java</a></span> - Static variable in class pkg.<a href=\"./pkg/C.html\" " +
++            "title=\"class in pkg\">C</a></dt>" + NL + "<dd>&nbsp;</dd>" + NL +
++            "<dt><span class=\"strong\"><a href=\"./pkg/C.html#JDK\">JDK</a></span> " +
++            "- Static variable in class pkg.<a href=\"./pkg/C.html\" title=\"class in pkg\">" +
++            "C</a></dt>" + NL + "<dd>&nbsp;</dd>" + NL + "</dl>"},
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+ 
+diff --git a/test/com/sun/javadoc/testInlineLinkLabel/TestInlineLinkLabel.java b/test/com/sun/javadoc/testInlineLinkLabel/TestInlineLinkLabel.java
+--- openjdk/langtools/test/com/sun/javadoc/testInlineLinkLabel/TestInlineLinkLabel.java
++++ openjdk/langtools/test/com/sun/javadoc/testInlineLinkLabel/TestInlineLinkLabel.java
+@@ -37,10 +37,10 @@
+     private static final String BUG_ID = "4524136";
+     private static final String[][] TEST = {
+         //Search for the label to the package link.
+-        {BUG_ID + FS + "pkg" + FS + "C1.html" , "<A HREF=\"../pkg/package-summary.html\"><CODE>Here is a link to a package</CODE></A>"},
++        {BUG_ID + FS + "pkg" + FS + "C1.html" , "<a href=\"../pkg/package-summary.html\"><code>Here is a link to a package</code></a>"},
+ 
+         //Search for the label to the class link
+-        {BUG_ID + FS + "pkg" + FS + "C1.html" , "<A HREF=\"../pkg/C2.html\" title=\"class in pkg\"><CODE>Here is a link to a class</CODE></A>"}
++        {BUG_ID + FS + "pkg" + FS + "C1.html" , "<a href=\"../pkg/C2.html\" title=\"class in pkg\"><code>Here is a link to a class</code></a>"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testInterface/TestInterface.java b/test/com/sun/javadoc/testInterface/TestInterface.java
+--- openjdk/langtools/test/com/sun/javadoc/testInterface/TestInterface.java
++++ openjdk/langtools/test/com/sun/javadoc/testInterface/TestInterface.java
+@@ -48,51 +48,62 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "int <STRONG>method</STRONG>()"},
++            "<pre>int&nbsp;method()</pre>"},
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "static final int <STRONG>field</STRONG>"},
++            "<pre>static final&nbsp;int field</pre>"},
+ 
+ 
+         // Make sure known implementing class list is correct and omits type parameters.
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "<DT><STRONG>All Known Implementing Classes:</STRONG></DT> " +
+-            "<DD><A HREF=\"../pkg/Child.html\" " +
+-            "title=\"class in pkg\">Child</A>, " +
+-            "<A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">" +
+-            "Parent</A></DD>"},
++            "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL +
++            "<dd><a href=\"../pkg/Child.html\" title=\"class in pkg\">Child" +
++            "</a>, <a href=\"../pkg/Parent.html\" title=\"class in pkg\">Parent" +
++            "</a></dd>" + NL + "</dl>"},
+ 
+          // Make sure "All Implemented Interfaces": has substituted type parameters
+          {BUG_ID + FS + "pkg" + FS + "Child.html",
+-            "<STRONG>All Implemented Interfaces:</STRONG></DT> <DD>" +
+-            "<A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">" +
+-            "Interface</A>&lt;T&gt;"
++            "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
++            "<dd><a href=\"../pkg/Interface.html\" title=\"interface in pkg\">" +
++            "Interface</a>&lt;T&gt;</dd>" + NL + "</dl>"
+          },
+          //Make sure Class Tree has substituted type parameters.
+          {BUG_ID + FS + "pkg" + FS + "Child.html",
+-            "<PRE>" + NL +
+-            "java.lang.Object" + NL +
+-            "  <IMG SRC=\"../resources/inherit.gif\" ALT=\"extended by \"><A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">pkg.Parent</A>&lt;T&gt;" + NL +
+-            "      <IMG SRC=\"../resources/inherit.gif\" ALT=\"extended by \"><STRONG>pkg.Child&lt;T&gt;</STRONG>" + NL +
+-            "</PRE>"
++            "<ul class=\"inheritance\">" + NL + "<li>java.lang.Object</li>" + NL +
++            "<li>" + NL + "<ul class=\"inheritance\">" + NL +
++            "<li><a href=\"../pkg/Parent.html\" title=\"class in pkg\">" +
++            "pkg.Parent</a>&lt;T&gt;</li>" + NL + "<li>" + NL +
++            "<ul class=\"inheritance\">" + NL + "<li>pkg.Child&lt;T&gt;</li>" + NL +
++            "</ul>" + NL + "</li>" + NL + "</ul>" + NL + "</li>" + NL + "</ul>"
+          },
+          //Make sure "Direct Know Subclasses" omits type parameters
+         {BUG_ID + FS + "pkg" + FS + "Parent.html",
+-            "<STRONG>Direct Known Subclasses:</STRONG></DT> <DD><A HREF=\"../pkg/Child.html\" title=\"class in pkg\">Child</A>"
++            "<dl>" + NL + "<dt>Direct Known Subclasses:</dt>" + NL +
++            "<dd><a href=\"../pkg/Child.html\" title=\"class in pkg\">Child" +
++            "</a></dd>" + NL + "</dl>"
+         },
+         //Make sure "Specified By" has substituted type parameters.
+         {BUG_ID + FS + "pkg" + FS + "Child.html",
+-            "<STRONG>Specified by:</STRONG></DT><DD><CODE><A HREF=\"../pkg/Interface.html#method()\">method</A></CODE> in interface <CODE><A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">Interface</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
++            "<dt><strong>Specified by:</strong></dt>" + NL +
++            "<dd><code><a href=\"../pkg/Interface.html#method()\">method</a>" +
++            "</code>&nbsp;in interface&nbsp;<code>" +
++            "<a href=\"../pkg/Interface.html\" title=\"interface in pkg\">" +
++            "Interface</a>&lt;<a href=\"../pkg/Child.html\" title=\"type parameter in Child\">" +
++            "T</a>&gt;</code></dd>"
+          },
+         //Make sure "Overrides" has substituted type parameters.
+         {BUG_ID + FS + "pkg" + FS + "Child.html",
+-            "<STRONG>Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg/Parent.html#method()\">method</A></CODE> in class <CODE><A HREF=\"../pkg/Parent.html\" title=\"class in pkg\">Parent</A>&lt;<A HREF=\"../pkg/Child.html\" title=\"type parameter in Child\">T</A>&gt;</CODE>"
++            "<dt><strong>Overrides:</strong></dt>" + NL +
++            "<dd><code><a href=\"../pkg/Parent.html#method()\">method</a>" +
++            "</code>&nbsp;in class&nbsp;<code><a href=\"../pkg/Parent.html\" " +
++            "title=\"class in pkg\">Parent</a>&lt;<a href=\"../pkg/Child.html\" " +
++            "title=\"type parameter in Child\">T</a>&gt;</code></dd>"
+          },
+     };
+     private static final String[][] NEGATED_TEST = {
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "public int <STRONG>method</STRONG>()"},
++            "public int&nbsp;method()"},
+         {BUG_ID + FS + "pkg" + FS + "Interface.html",
+-            "public static final int <STRONG>field</STRONG>"},
++            "public static final&nbsp;int field"},
+     };
+ 
+     /**
+diff --git a/test/com/sun/javadoc/testJavascript/TestJavascript.java b/test/com/sun/javadoc/testJavascript/TestJavascript.java
+--- openjdk/langtools/test/com/sun/javadoc/testJavascript/TestJavascript.java
++++ openjdk/langtools/test/com/sun/javadoc/testJavascript/TestJavascript.java
+@@ -45,11 +45,11 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<A HREF=\"../index.html?pkg/C.html\" target=\"_top\"><STRONG>FRAMES</STRONG></A>"},
++            "<a href=\"../index.html?pkg/C.html\" target=\"_top\">FRAMES</a>"},
+         {BUG_ID + FS + "TestJavascript.html",
+-            "<A HREF=\"index.html?TestJavascript.html\" target=\"_top\"><STRONG>FRAMES</STRONG></A>"},
++            "<a href=\"index.html?TestJavascript.html\" target=\"_top\">FRAMES</a>"},
+         {BUG_ID + FS + "index.html",
+-            "<SCRIPT type=\"text/javascript\">" + NL +
++            "<script type=\"text/javascript\">" + NL +
+                         "    targetPage = \"\" + window.location.search;" + NL +
+             "    if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
+             "        targetPage = targetPage.substring(1);" + NL +
+@@ -59,7 +59,7 @@
+             "        if (targetPage != \"\" && targetPage != \"undefined\")" + NL +
+             "             top.classFrame.location = top.targetPage;" + NL +
+             "    }" + NL +
+-            "</SCRIPT>"},
++            "</script>"},
+ 
+         //Make sure title javascript only runs if is-external is not true
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+diff --git a/test/com/sun/javadoc/testLinkOption/TestLinkOption.java b/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
+--- openjdk/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
++++ openjdk/langtools/test/com/sun/javadoc/testLinkOption/TestLinkOption.java
+@@ -46,25 +46,25 @@
+ 
+     private static final String[][] TEST1 = {
+         {BUG_ID + "-1" + FS + "pkg" + FS + "C.html",
+-            "<A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html?is-external=true\" " +
+-            "title=\"class or interface in java.lang\"><CODE>Link to String Class</CODE></A>"
++            "<a href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html?is-external=true\" " +
++            "title=\"class or interface in java.lang\"><code>Link to String Class</code></a>"
+         },
+         //Make sure the parameters are indented properly when the -link option is used.
+         {BUG_ID + "-1" + FS + "pkg" + FS + "C.html",
+                                 "(int&nbsp;p1," + NL +
+-            "                     int&nbsp;p2," + NL +
+-            "                     int&nbsp;p3)"
++                                "      int&nbsp;p2," + NL +
++                                "      int&nbsp;p3)"
+         },
+         {BUG_ID + "-1" + FS + "pkg" + FS + "C.html",
+                                 "(int&nbsp;p1," + NL +
+-            "                     int&nbsp;p2," + NL +
+-            "                     " +
+-            "<A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true\" " +
+-            "title=\"class or interface in java.lang\">Object</A>&nbsp;p3)"
++                                "      int&nbsp;p2," + NL +
++                                "      <a href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true\" title=\"class or interface in java.lang\">" +
++                                "Object</a>&nbsp;p3)"
+         },
+         {BUG_ID + "-1" + FS + "java" + FS + "lang" + FS + "StringBuilderChild.html",
+-                "public abstract class <STRONG>StringBuilderChild</STRONG>" + NL +
+-                "extends <A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true\" title=\"class or interface in java.lang\">Object</A>"
++                "<pre>public abstract class <strong>StringBuilderChild</strong>" + NL +
++                "extends <a href=\"http://java.sun.com/j2se/1.4/docs/api/java/lang/Object.html?is-external=true\" " +
++                "title=\"class or interface in java.lang\">Object</a></pre>"
+         },
+ 
+     };
+@@ -79,8 +79,8 @@
+ 
+     private static final String[][] TEST2 = {
+         {BUG_ID + "-2" + FS + "pkg2" + FS + "C2.html",
+-            "This is a link to <A HREF=\"../../" + BUG_ID + "-1/pkg/C.html?is-external=true\" " +
+-            "title=\"class or interface in pkg\"><CODE>Class C</CODE></A>."
++            "This is a link to <a href=\"../../" + BUG_ID + "-1/pkg/C.html?is-external=true\" " +
++            "title=\"class or interface in pkg\"><code>Class C</code></a>."
+         }
+     };
+     private static final String[][] NEGATED_TEST2 = NO_TEST;
+diff --git a/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java b/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
+--- openjdk/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
++++ openjdk/langtools/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java
+@@ -46,20 +46,22 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "Qualified Link: <A HREF=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><CODE>C.InnerC</CODE></A>.<br/>\n" +
+-            " Unqualified Link1: <A HREF=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><CODE>C.InnerC</CODE></A>.<br/>\n" +
+-            " Unqualified Link2: <A HREF=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><CODE>C.InnerC</CODE></A>.<br/>\n" +
+-            " Qualified Link: <A HREF=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><CODE>method(pkg.C.InnerC, pkg.C.InnerC2)</CODE></A>.<br/>\n" +
+-            " Unqualified Link: <A HREF=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><CODE>method(C.InnerC, C.InnerC2)</CODE></A>.<br/>\n" +
+-            " Unqualified Link: <A HREF=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><CODE>method(InnerC, InnerC2)</CODE></A>.<br/>"
++            "Qualified Link: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>\n" +
++            " Unqualified Link1: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>\n" +
++            " Unqualified Link2: <a href=\"../pkg/C.InnerC.html\" title=\"class in pkg\"><code>C.InnerC</code></a>.<br/>\n" +
++            " Qualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(pkg.C.InnerC, pkg.C.InnerC2)</code></a>.<br/>\n" +
++            " Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(C.InnerC, C.InnerC2)</code></a>.<br/>\n" +
++            " Unqualified Link: <a href=\"../pkg/C.html#method(pkg.C.InnerC, pkg.C.InnerC2)\"><code>method(InnerC, InnerC2)</code></a>.<br/>"
+         },
+         {BUG_ID + FS + "pkg" + FS + "C.InnerC.html",
+-            "Link to member in outer class: <A HREF=\"../pkg/C.html#MEMBER\"><CODE>C.MEMBER</CODE></A> <br/>\n" +
+-            " Link to member in inner class: <A HREF=\"../pkg/C.InnerC2.html#MEMBER2\"><CODE>C.InnerC2.MEMBER2</CODE></A> <br/>\n" +
+-            " Link to another inner class: <A HREF=\"../pkg/C.InnerC2.html\" title=\"class in pkg\"><CODE>C.InnerC2</CODE></A>"
++            "Link to member in outer class: <a href=\"../pkg/C.html#MEMBER\"><code>C.MEMBER</code></a> <br/>\n" +
++            " Link to member in inner class: <a href=\"../pkg/C.InnerC2.html#MEMBER2\"><code>C.InnerC2.MEMBER2</code></a> <br/>\n" +
++            " Link to another inner class: <a href=\"../pkg/C.InnerC2.html\" title=\"class in pkg\"><code>C.InnerC2</code></a>"
+         },
+         {BUG_ID + FS + "pkg" + FS + "C.InnerC2.html",
+-            "Enclosing class:</STRONG></DT><DD><A HREF=\"../pkg/C.html\" title=\"class in pkg\">C</A>"
++            "<dl>" + NL + "<dt>Enclosing class:</dt>" + NL +
++            "<dd><a href=\"../pkg/C.html\" title=\"class in pkg\">C</a></dd>" + NL +
++            "</dl>"
+         },
+     };
+     private static final String[][] NEGATED_TEST = {
+diff --git a/test/com/sun/javadoc/testLinkToSerialForm/TestLinkToSerialForm.java b/test/com/sun/javadoc/testLinkToSerialForm/TestLinkToSerialForm.java
+--- openjdk/langtools/test/com/sun/javadoc/testLinkToSerialForm/TestLinkToSerialForm.java
++++ openjdk/langtools/test/com/sun/javadoc/testLinkToSerialForm/TestLinkToSerialForm.java
+@@ -37,8 +37,8 @@
+ 
+     private static final String BUG_ID = "4521661";
+     private static final String[][] TEST = {
+-        {BUG_ID + FS + "serialized-form.html", "<A NAME=\"pkg.C\">"},
+-        {BUG_ID + FS + "pkg" + FS + "C.html", "<A HREF=\"../serialized-form.html#pkg.C\">"}
++        {BUG_ID + FS + "serialized-form.html", "<a name=\"pkg.C\">"},
++        {BUG_ID + FS + "pkg" + FS + "C.html", "<a href=\"../serialized-form.html#pkg.C\">"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java b/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
+--- openjdk/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
++++ openjdk/langtools/test/com/sun/javadoc/testMemberInheritence/TestMemberInheritence.java
+@@ -40,55 +40,57 @@
+     private static final String[][] TEST = {
+         //Public field should be inherited
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-         "<A HREF=\"../pkg/BaseClass.html#pubField\">"},
++         "<a href=\"../pkg/BaseClass.html#pubField\">"},
+ 
+         //Public method should be inherited
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-         "<A HREF=\"../pkg/BaseClass.html#pubMethod()\">"},
++         "<a href=\"../pkg/BaseClass.html#pubMethod()\">"},
+ 
+         //Public inner class should be inherited.
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-         "<A HREF=\"../pkg/BaseClass.pubInnerClass.html\" title=\"class in pkg\">"},
++         "<a href=\"../pkg/BaseClass.pubInnerClass.html\" title=\"class in pkg\">"},
+ 
+         //Protected field should be inherited
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-         "<A HREF=\"../pkg/BaseClass.html#proField\">"},
++         "<a href=\"../pkg/BaseClass.html#proField\">"},
+ 
+         //Protected method should be inherited
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-         "<A HREF=\"../pkg/BaseClass.html#proMethod()\">"},
++         "<a href=\"../pkg/BaseClass.html#proMethod()\">"},
+ 
+         //Protected inner class should be inherited.
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-         "<A HREF=\"../pkg/BaseClass.proInnerClass.html\" title=\"class in pkg\">"},
++         "<a href=\"../pkg/BaseClass.proInnerClass.html\" title=\"class in pkg\">"},
+ 
+         // New labels as of 1.5.0
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-         "<STRONG>Nested classes/interfaces inherited from class pkg." +
+-         "<A HREF=\"../pkg/BaseClass.html\" title=\"class in pkg\">" +
+-         "BaseClass</A></STRONG>"},
++         "Nested classes/interfaces inherited from class&nbsp;pkg." +
++                 "<a href=\"../pkg/BaseClass.html\" title=\"class in pkg\">BaseClass</a>"},
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-         "<STRONG>Nested classes/interfaces inherited from interface pkg." +
+-         "<A HREF=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">" +
+-         "BaseInterface</A></STRONG>"},
++         "Nested classes/interfaces inherited from interface&nbsp;pkg." +
++                 "<a href=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">BaseInterface</a>"},
+ 
+          // Test overriding/implementing methods with generic parameters.
+                  {BUG_ID + FS + "pkg" + FS + "BaseClass.html",
+-         "<DT><STRONG>Specified by:</STRONG></DT><DD><CODE><A HREF=\"../pkg/BaseInterface.html#getAnnotation(java.lang.Class)\">getAnnotation</A></CODE> in interface <CODE><A HREF=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">BaseInterface</A></CODE></DD>"+NL+"</DL>"},
++         "<dl>" + NL + "<dt><strong>Specified by:</strong></dt>" + NL +
++                          "<dd><code><a href=\"../pkg/BaseInterface.html#getAnnotation(java.lang.Class)\">" +
++                          "getAnnotation</a></code>&nbsp;in interface&nbsp;<code>" +
++                          "<a href=\"../pkg/BaseInterface.html\" title=\"interface in pkg\">" +
++                          "BaseInterface</a></code></dd>" + NL + "</dl>"},
+ 
+          // Test diamond inheritence member summary (6256068)
+                  {BUG_ID + FS + "diamond" + FS + "Z.html",
+-                 "<TD><CODE><A HREF=\"../diamond/A.html#aMethod()\">aMethod</A></CODE></TD>"},
++                 "<code><a href=\"../diamond/A.html#aMethod()\">aMethod</a></code>"},
+ 
+          // Test that doc is inherited from closed parent (6270645)
+                  {BUG_ID + FS + "inheritDist" + FS + "C.html",
+-                 "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m1-B</TD>"},
++                 "<div class=\"block\">m1-B</div>"},
+ 
+     };
+ 
+     private static final String[][] NEGATED_TEST = {
+         {BUG_ID + FS + "pkg" + FS + "SubClass.html",
+-        "<A HREF=\"../pkg/BaseClass.html#staticMethod()\">staticMethod</A></CODE>"},
++        "<a href=\"../pkg/BaseClass.html#staticMethod()\">staticMethod</a></code>"},
+     };
+     private static final String[] ARGS =
+         new String[] {
+diff --git a/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java b/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java
+--- openjdk/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java
++++ openjdk/langtools/test/com/sun/javadoc/testMemberSummary/TestMemberSummary.java
+@@ -48,21 +48,23 @@
+     private static final String[][] TEST = {
+         // Check return type in member summary.
+         {BUG_ID + FS + "pkg" + FS + "PublicChild.html",
+-            "<CODE>&nbsp;<A HREF=\"../pkg/PublicChild.html\" " +
+-            "title=\"class in pkg\">PublicChild</A></CODE></FONT></TD>" + NL +
+-            "<TD><CODE><STRONG><A HREF=\"../pkg/PublicChild.html#" +
+-            "returnTypeTest()\">returnTypeTest</A></STRONG>()</CODE>"
++            "<code><a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild</a></code></td>" + NL +
++            "<td class=\"colLast\"><code><strong><a href=\"../pkg/PublicChild.html#returnTypeTest()\">" +
++            "returnTypeTest</a></strong>()</code>"
+         },
+         // Check return type in member detail.
+         {BUG_ID + FS + "pkg" + FS + "PublicChild.html",
+-            "public <A HREF=\"../pkg/PublicChild.html\" " +
+-            "title=\"class in pkg\">PublicChild</A> " +
+-            "<STRONG>returnTypeTest</STRONG>()"
++            "<pre>public&nbsp;<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">" +
++            "PublicChild</a>&nbsp;returnTypeTest()</pre>"
+         },
+ 
+          // Legacy anchor dimensions (6290760)
+         {BUG_ID + FS + "pkg2" + FS + "A.html",
+-            "<A NAME=\"f(java.lang.Object[])\"><!-- --></A><A NAME=\"f(T[])\"><!-- --></A>"
++            "<a name=\"f(java.lang.Object[])\">" + NL +
++            "<!--   -->" + NL +
++            "</a><a name=\"f(T[])\">" + NL +
++            "<!--   -->" + NL +
++            "</a>"
+         },
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testNavagation/TestNavagation.java b/test/com/sun/javadoc/testNavagation/TestNavagation.java
+--- openjdk/langtools/test/com/sun/javadoc/testNavagation/TestNavagation.java
++++ openjdk/langtools/test/com/sun/javadoc/testNavagation/TestNavagation.java
+@@ -45,24 +45,24 @@
+ 
+     //Input for string search tests.
+     private static final String[][] TEST = {
+-        {BUG_ID + FS + "pkg" + FS + "A.html", "&nbsp;PREV CLASS&nbsp;"},
++        {BUG_ID + FS + "pkg" + FS + "A.html", "<li>PREV CLASS</li>"},
+         {BUG_ID + FS + "pkg" + FS + "A.html",
+-            "<A HREF=\"../pkg/C.html\" title=\"class in pkg\"><STRONG>NEXT CLASS</STRONG></A>"},
++            "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">NEXT CLASS</span></a>"},
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<A HREF=\"../pkg/A.html\" title=\"annotation in pkg\"><STRONG>PREV CLASS</STRONG></A>"},
++            "<a href=\"../pkg/A.html\" title=\"annotation in pkg\"><span class=\"strong\">PREV CLASS</span></a>"},
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<A HREF=\"../pkg/E.html\" title=\"enum in pkg\"><STRONG>NEXT CLASS</STRONG></A>"},
++            "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"strong\">NEXT CLASS</span></a>"},
+         {BUG_ID + FS + "pkg" + FS + "E.html",
+-            "<A HREF=\"../pkg/C.html\" title=\"class in pkg\"><STRONG>PREV CLASS</STRONG></A>"},
++            "<a href=\"../pkg/C.html\" title=\"class in pkg\"><span class=\"strong\">PREV CLASS</span></a>"},
+         {BUG_ID + FS + "pkg" + FS + "E.html",
+-            "<A HREF=\"../pkg/I.html\" title=\"interface in pkg\"><STRONG>NEXT CLASS</STRONG></A>"},
++            "<a href=\"../pkg/I.html\" title=\"interface in pkg\"><span class=\"strong\">NEXT CLASS</span></a>"},
+         {BUG_ID + FS + "pkg" + FS + "I.html",
+-            "<A HREF=\"../pkg/E.html\" title=\"enum in pkg\"><STRONG>PREV CLASS</STRONG></A>"},
+-        {BUG_ID + FS + "pkg" + FS + "I.html", "&nbsp;NEXT CLASS"},
++            "<a href=\"../pkg/E.html\" title=\"enum in pkg\"><span class=\"strong\">PREV CLASS</span></a>"},
++        {BUG_ID + FS + "pkg" + FS + "I.html", "<li>NEXT CLASS</li>"},
+         // Test for 4664607
+         {BUG_ID + FS + "pkg" + FS + "I.html",
+-            "<TD COLSPAN=2 BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\">" + NL +
+-            "<A NAME=\"navbar_top_firstrow\"><!-- --></A>"}
++            "<a href=\"#skip-navbar_top\" title=\"Skip navigation links\"></a><a name=\"navbar_top_firstrow\">" + NL +
++            "<!--   -->" + NL + "</a>"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+ 
+diff --git a/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java b/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+--- openjdk/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
++++ openjdk/langtools/test/com/sun/javadoc/testNewLanguageFeatures/TestNewLanguageFeatures.java
+@@ -51,18 +51,18 @@
+             // ENUM TESTING
+             //=================================
+             //Make sure enum header is correct.
+-            {BUG_ID + FS + "pkg" + FS + "Coin.html", "Enum Coin</H2>"},
++            {BUG_ID + FS + "pkg" + FS + "Coin.html", "Enum Coin</h2>"},
+             //Make sure enum signature is correct.
+-            {BUG_ID + FS + "pkg" + FS + "Coin.html", "public enum "+
+-                "<STRONG>Coin</STRONG>" + NL + "extends java.lang.Enum&lt;" +
+-                "<A HREF=\"../pkg/Coin.html\" title=\"enum in pkg\">Coin</A>&gt;"
++            {BUG_ID + FS + "pkg" + FS + "Coin.html", "<pre>public enum <strong>Coin</strong>" + NL +
++                "extends java.lang.Enum&lt;<a href=\"../pkg/Coin.html\" " +
++                "title=\"enum in pkg\">Coin</a>&gt;</pre>"
+             },
+             //Check for enum constant section
+-            {BUG_ID + FS + "pkg" + FS + "Coin.html", "<CAPTION CLASS=\"TableCaption\">" + NL +
+-                     "Enum Constant Summary</CAPTION>"},
++            {BUG_ID + FS + "pkg" + FS + "Coin.html", "<caption><span>Enum Constants" +
++                     "</span><span class=\"tabEnd\">&nbsp;</span></caption>"},
+             //Detail for enum constant
+             {BUG_ID + FS + "pkg" + FS + "Coin.html",
+-                "<STRONG><A HREF=\"../pkg/Coin.html#Dime\">Dime</A></STRONG>"},
++                "<strong><a href=\"../pkg/Coin.html#Dime\">Dime</a></strong>"},
+             //Automatically insert documentation for values() and valueOf().
+             {BUG_ID + FS + "pkg" + FS + "Coin.html",
+                 "Returns an array containing the constants of this enum type,"},
+@@ -77,38 +77,39 @@
+             //=================================
+             //Make sure the header is correct.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "Class TypeParameters&lt;E&gt;</H2>"},
++                "Class TypeParameters&lt;E&gt;</h2>"},
+             //Check class type parameters section.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<DT><STRONG>Type Parameters:</STRONG></DT><DD><CODE>E</CODE> - " +
++                "<dt><span class=\"strong\">Type Parameters:</span></dt><dd><code>E</code> - " +
+                 "the type parameter for this class."},
+             //Type parameters in @see/@link
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<DT><STRONG>See Also:</STRONG></DT><DD><A HREF=\"../pkg/TypeParameters.html\" " +
+-                    "title=\"class in pkg\"><CODE>TypeParameters</CODE></A></DD></DL>"},
++                "<dl><dt><span class=\"strong\">See Also:</span></dt><dd>" +
++                "<a href=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
++                "<code>TypeParameters</code></a></dd></dl>"},
+             //Method that uses class type parameter.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "(<A HREF=\"../pkg/TypeParameters.html\" title=\"type " +
+-                    "parameter in TypeParameters\">E</A>&nbsp;param)"},
++                "(<a href=\"../pkg/TypeParameters.html\" title=\"type " +
++                    "parameter in TypeParameters\">E</a>&nbsp;param)"},
+             //Method type parameter section.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<STRONG>Type Parameters:</STRONG></DT><DD><CODE>T</CODE> - This is the first " +
+-                    "type parameter.</DD><DD><CODE>V</CODE> - This is the second type " +
++                "<span class=\"strong\">Type Parameters:</span></dt><dd><code>T</code> - This is the first " +
++                    "type parameter.</dd><dd><code>V</code> - This is the second type " +
+                     "parameter."},
+             //Signature of method with type parameters
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "public &lt;T extends java.util.List,V&gt; " +
+-                    "java.lang.String[] <STRONG>methodThatHasTypeParameters</STRONG>"},
++                "public&nbsp;&lt;T extends java.util.List,V&gt;&nbsp;" +
++                "java.lang.String[]&nbsp;methodThatHasTypeParameters"},
+             //Wildcard testing.
+             {BUG_ID + FS + "pkg" + FS + "Wildcards.html",
+-                "<A HREF=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
+-                "TypeParameters</A>&lt;? super java.lang.String&gt;&nbsp;a"},
++                "<a href=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
++                "TypeParameters</a>&lt;? super java.lang.String&gt;&nbsp;a"},
+             {BUG_ID + FS + "pkg" + FS + "Wildcards.html",
+-                "<A HREF=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
+-                "TypeParameters</A>&lt;? extends java.lang.StringBuffer&gt;&nbsp;b"},
++                "<a href=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
++                "TypeParameters</a>&lt;? extends java.lang.StringBuffer&gt;&nbsp;b"},
+             {BUG_ID + FS + "pkg" + FS + "Wildcards.html",
+-                "<A HREF=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
+-                    "TypeParameters</A>&nbsp;c"},
++                "<a href=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
++                    "TypeParameters</a>&nbsp;c"},
+             //Bad type parameter warnings.
+             {WARNING_OUTPUT, "warning - @param argument " +
+                 "\"<BadClassTypeParam>\" is not a type parameter name."},
+@@ -117,18 +118,27 @@
+ 
+             //Signature of subclass that has type parameters.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameterSubClass.html",
+-                "public class <STRONG>TypeParameterSubClass&lt;T extends java.lang.String&gt;" +
+-                "</STRONG>" + NL + "extends <A HREF=\"../pkg/TypeParameterSuperClass.html\" " +
+-                "title=\"class in pkg\">TypeParameterSuperClass</A>&lt;T&gt;"},
++                "<pre>public class <strong>TypeParameterSubClass&lt;T extends " +
++                "java.lang.String&gt;</strong>" + NL + "extends " +
++                "<a href=\"../pkg/TypeParameterSuperClass.html\" title=\"class in pkg\">" +
++                "TypeParameterSuperClass</a>&lt;T&gt;</pre>"},
+ 
+             //Interface generic parameter substitution
+             //Signature of subclass that has type parameters.
+             {BUG_ID + FS + "pkg" + FS + "TypeParameters.html",
+-                "<STRONG>All Implemented Interfaces:</STRONG></DT> <DD><A HREF=\"../pkg/SubInterface.html\" title=\"interface in pkg\">SubInterface</A>&lt;E&gt;, <A HREF=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">SuperInterface</A>&lt;E&gt;</DD>"},
++                "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
++                "<dd><a href=\"../pkg/SubInterface.html\" title=\"interface in pkg\">" +
++                "SubInterface</a>&lt;E&gt;, <a href=\"../pkg/SuperInterface.html\" " +
++                "title=\"interface in pkg\">SuperInterface</a>&lt;E&gt;</dd>" + NL +
++                "</dl>"},
+             {BUG_ID + FS + "pkg" + FS + "SuperInterface.html",
+-                "<STRONG>All Known Subinterfaces:</STRONG></DT> <DD><A HREF=\"../pkg/SubInterface.html\" title=\"interface in pkg\">SubInterface</A>&lt;V&gt;</DD>"},
++                "<dl>" + NL + "<dt>All Known Subinterfaces:</dt>" + NL +
++                "<dd><a href=\"../pkg/SubInterface.html\" title=\"interface in pkg\">" +
++                "SubInterface</a>&lt;V&gt;</dd>" + NL + "</dl>"},
+             {BUG_ID + FS + "pkg" + FS + "SubInterface.html",
+-                "<STRONG>All Superinterfaces:</STRONG></DT> <DD><A HREF=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">SuperInterface</A>&lt;V&gt;</DD>"},
++                "<dl>" + NL + "<dt>All Superinterfaces:</dt>" + NL +
++                "<dd><a href=\"../pkg/SuperInterface.html\" title=\"interface in pkg\">" +
++                "SuperInterface</a>&lt;V&gt;</dd>" + NL + "</dl>"},
+ 
+             //=================================
+             // VAR ARG TESTING
+@@ -137,39 +147,40 @@
+             {BUG_ID + FS + "pkg" + FS + "VarArgs.html", "(int[][]...&nbsp;i)"},
+             {BUG_ID + FS + "pkg" + FS + "VarArgs.html", "(int[]...)"},
+             {BUG_ID + FS + "pkg" + FS + "VarArgs.html",
+-                "<A HREF=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
+-                "TypeParameters</A>...&nbsp;t"},
++                "<a href=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
++                "TypeParameters</a>...&nbsp;t"},
+ 
+             //=================================
+             // ANNOTATION TYPE TESTING
+             //=================================
+             //Make sure the summary links are correct.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "SUMMARY:&nbsp;<A HREF=\"#annotation_type_required_element_summary\">" +
+-                "REQUIRED</A>&nbsp;|&nbsp;<A HREF=\"#annotation_type_optional_element_summary\">" +
+-                "OPTIONAL</A>"},
++                "<li>SUMMARY:&nbsp;</li>" + NL +
++                "<li><a href=\"#annotation_type_required_element_summary\">" +
++                "REQUIRED</a>&nbsp;|&nbsp;</li>" + NL + "<li>" +
++                "<a href=\"#annotation_type_optional_element_summary\">OPTIONAL</a></li>"},
+             //Make sure the detail links are correct.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "DETAIL:&nbsp;<A HREF=\"#annotation_type_element_detail\">ELEMENT</A>"},
++                "<li>DETAIL:&nbsp;</li>" + NL +
++                "<li><a href=\"#annotation_type_element_detail\">ELEMENT</a></li>"},
+             //Make sure the heading is correct.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "Annotation Type AnnotationType</H2>"},
++                "Annotation Type AnnotationType</h2>"},
+             //Make sure the signature is correct.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "public @interface <STRONG>AnnotationType</STRONG>"},
++                "public @interface <strong>AnnotationType</strong>"},
+             //Make sure member summary headings are correct.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "<CAPTION CLASS=\"TableCaption\">" + NL +
+-                "Required Element Summary</CAPTION>"},
++                "<h3>Required Element Summary</h3>"},
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "<CAPTION CLASS=\"TableCaption\">" + NL +
+-                "Optional Element Summary</CAPTION>"},
++                "<h3>Optional Element Summary</h3>"},
+             //Make sure element detail heading is correct
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+                 "Element Detail"},
+             //Make sure default annotation type value is printed when necessary.
+             {BUG_ID + FS + "pkg" + FS + "AnnotationType.html",
+-                "<STRONG>Default:</STRONG></DT><DD>\"unknown\"</DD>"},
++                "<dl>" + NL + "<dt>Default:</dt>" + NL + "<dd>\"unknown\"</dd>" + NL +
++                "</dl>"},
+ 
+             //=================================
+             // ANNOTATION TYPE USAGE TESTING
+@@ -177,51 +188,65 @@
+ 
+             //PACKAGE
+             {BUG_ID + FS + "pkg" + FS + "package-summary.html",
+-                "<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Package Annotation\"," + NL +
+-                "                <A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)"},
++                "<a href=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</a>(<a href=\"../pkg/AnnotationType.html#optional()\">optional</a>=\"Package Annotation\"," + NL +
++                "                <a href=\"../pkg/AnnotationType.html#required()\">required</a>=1994)"},
+ 
+             //CLASS
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+-                "<FONT SIZE=\"-1\">" +
+-                "<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Class Annotation\","+NL +
+-                "                <A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)"+NL +
+-                "</FONT>public class <STRONG>AnnotationTypeUsage</STRONG>" + NL +
+-                "extends java.lang.Object"},
++                "<pre><a href=\"../pkg/AnnotationType.html\" " +
++                "title=\"annotation in pkg\">@AnnotationType</a>(" +
++                "<a href=\"../pkg/AnnotationType.html#optional()\">optional</a>" +
++                "=\"Class Annotation\"," + NL +
++                "                <a href=\"../pkg/AnnotationType.html#required()\">" +
++                "required</a>=1994)" + NL + "public class <strong>" +
++                "AnnotationTypeUsage</strong>" + NL + "extends java.lang.Object</pre>"},
+ 
+             //FIELD
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+-                "<FONT SIZE=\"-1\">" +
+-                "<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Field Annotation\","+NL +
+-                "                <A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)"+NL +
+-                "</FONT>public int <STRONG>field</STRONG>"},
++                "<pre><a href=\"../pkg/AnnotationType.html\" " +
++                "title=\"annotation in pkg\">@AnnotationType</a>(" +
++                "<a href=\"../pkg/AnnotationType.html#optional()\">optional</a>" +
++                "=\"Field Annotation\"," + NL +
++                "                <a href=\"../pkg/AnnotationType.html#required()\">" +
++                "required</a>=1994)" + NL + "public&nbsp;int field</pre>"},
+ 
+             //CONSTRUCTOR
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+-                "<FONT SIZE=\"-1\">" +
+-                "<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Constructor Annotation\","+NL +
+-                "                <A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)"+NL +
+-                "</FONT>public <STRONG>AnnotationTypeUsage</STRONG>()"},
++                "<pre><a href=\"../pkg/AnnotationType.html\" " +
++                "title=\"annotation in pkg\">@AnnotationType</a>(" +
++                "<a href=\"../pkg/AnnotationType.html#optional()\">optional</a>" +
++                "=\"Constructor Annotation\"," + NL +
++                "                <a href=\"../pkg/AnnotationType.html#required()\">" +
++                "required</a>=1994)" + NL + "public&nbsp;AnnotationTypeUsage()</pre>"},
+ 
+             //METHOD
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+-                "<FONT SIZE=\"-1\">" +
+-                "<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Method Annotation\","+NL +
+-                "                <A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)"+NL +
+-                "</FONT>public void <STRONG>method</STRONG>()"},
++                "<pre><a href=\"../pkg/AnnotationType.html\" " +
++                "title=\"annotation in pkg\">@AnnotationType</a>(" +
++                "<a href=\"../pkg/AnnotationType.html#optional()\">optional</a>" +
++                "=\"Method Annotation\"," + NL +
++                "                <a href=\"../pkg/AnnotationType.html#required()\">" +
++                "required</a>=1994)" + NL + "public&nbsp;void&nbsp;method()</pre>"},
+ 
+             //METHOD PARAMS
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+-                "<PRE>" + NL +
+-                "public void <STRONG>methodWithParams</STRONG>(<FONT SIZE=\"-1\"><A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Parameter Annotation\",<A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)</FONT>" + NL +
+-                "                             int&nbsp;documented," + NL +
+-                "                             int&nbsp;undocmented)</PRE>"},
++                "<pre>public&nbsp;void&nbsp;methodWithParams(" +
++                "<a href=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">" +
++                "@AnnotationType</a>(<a href=\"../pkg/AnnotationType.html#optional()\">" +
++                "optional</a>=\"Parameter Annotation\",<a " +
++                "href=\"../pkg/AnnotationType.html#required()\">required</a>=1994)" + NL +
++                "                    int&nbsp;documented," + NL +
++                "                    int&nbsp;undocmented)</pre>"},
+ 
+             //CONSTRUCTOR PARAMS
+             {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+-                "<PRE>" + NL +
+-                                "public <STRONG>AnnotationTypeUsage</STRONG>(<FONT SIZE=\"-1\"><A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"Constructor Param Annotation\",<A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994)</FONT>" + NL +
+-                                "                           int&nbsp;documented," + NL +
+-                "                           int&nbsp;undocmented)</PRE>"},
++                "<pre>public&nbsp;AnnotationTypeUsage(<a " +
++                "href=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">" +
++                "@AnnotationType</a>(<a href=\"../pkg/AnnotationType.html#optional()\">" +
++                "optional</a>=\"Constructor Param Annotation\",<a " +
++                "href=\"../pkg/AnnotationType.html#required()\">required</a>=1994)" + NL +
++                "                   int&nbsp;documented," + NL +
++                "                   int&nbsp;undocmented)</pre>"},
+ 
+             //=================================
+             // ANNOTATION TYPE USAGE TESTING (All Different Types).
+@@ -229,59 +254,59 @@
+ 
+             //Integer
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<A HREF=\"../pkg1/A.html#d()\">d</A>=3.14,"},
++                "<a href=\"../pkg1/A.html#d()\">d</a>=3.14,"},
+ 
+             //Double
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<A HREF=\"../pkg1/A.html#d()\">d</A>=3.14,"},
++                "<a href=\"../pkg1/A.html#d()\">d</a>=3.14,"},
+ 
+             //Boolean
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<A HREF=\"../pkg1/A.html#b()\">b</A>=true,"},
++                "<a href=\"../pkg1/A.html#b()\">b</a>=true,"},
+ 
+             //String
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<A HREF=\"../pkg1/A.html#s()\">s</A>=\"sigh\","},
++                "<a href=\"../pkg1/A.html#s()\">s</a>=\"sigh\","},
+ 
+             //Class
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<A HREF=\"../pkg1/A.html#c()\">c</A>=<A HREF=\"../pkg2/Foo.html\" title=\"class in pkg2\">Foo.class</A>,"},
++                "<a href=\"../pkg1/A.html#c()\">c</a>=<a href=\"../pkg2/Foo.html\" title=\"class in pkg2\">Foo.class</a>,"},
+ 
+             //Bounded Class
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<A HREF=\"../pkg1/A.html#w()\">w</A>=<A HREF=\"../pkg/TypeParameterSubClass.html\" title=\"class in pkg\">TypeParameterSubClass.class</A>,"},
++                "<a href=\"../pkg1/A.html#w()\">w</a>=<a href=\"../pkg/TypeParameterSubClass.html\" title=\"class in pkg\">TypeParameterSubClass.class</a>,"},
+ 
+             //Enum
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<A HREF=\"../pkg1/A.html#e()\">e</A>=<A HREF=\"../pkg/Coin.html#Penny\">Penny</A>,"},
++                "<a href=\"../pkg1/A.html#e()\">e</a>=<a href=\"../pkg/Coin.html#Penny\">Penny</a>,"},
+ 
+             //Annotation Type
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<A HREF=\"../pkg1/A.html#a()\">a</A>=<A HREF=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</A>(<A HREF=\"../pkg/AnnotationType.html#optional()\">optional</A>=\"foo\",<A HREF=\"../pkg/AnnotationType.html#required()\">required</A>=1994),"},
++                "<a href=\"../pkg1/A.html#a()\">a</a>=<a href=\"../pkg/AnnotationType.html\" title=\"annotation in pkg\">@AnnotationType</a>(<a href=\"../pkg/AnnotationType.html#optional()\">optional</a>=\"foo\",<a href=\"../pkg/AnnotationType.html#required()\">required</a>=1994),"},
+ 
+             //String Array
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<A HREF=\"../pkg1/A.html#sa()\">sa</A>={\"up\",\"down\"},"},
++                "<a href=\"../pkg1/A.html#sa()\">sa</a>={\"up\",\"down\"},"},
+ 
+             //Primitive
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<A HREF=\"../pkg1/A.html#primitiveClassTest()\">primitiveClassTest</A>=boolean.class,"},
++                "<a href=\"../pkg1/A.html#primitiveClassTest()\">primitiveClassTest</a>=boolean.class,"},
+ 
+             //XXX:  Add array test case after this if fixed:
+             //5020899: Incorrect internal representation of class-valued annotation elements
+ 
+             //Make sure that annotations are surrounded by <pre> and </pre>
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "<PRE><FONT SIZE=\"-1\"><A HREF=\"../pkg1/A.html\" title=\"annotation in pkg1\">@A</A>"},
++                "<pre><a href=\"../pkg1/A.html\" title=\"annotation in pkg1\">@A</a>"},
+             {BUG_ID + FS + "pkg1" + FS + "B.html",
+-                "</FONT>public interface <STRONG>B</STRONG></PRE>"},
++                "public interface <strong>B</strong></pre>"},
+ 
+ 
+             //==============================================================
+             // Handle multiple bounds.
+             //==============================================================
+             {BUG_ID + FS + "pkg" + FS + "MultiTypeParameters.html",
+-                "public &lt;T extends java.lang.Number & java.lang.Runnable&gt; T <STRONG>foo</STRONG>(T&nbsp;t)"},
++                "public&nbsp;&lt;T extends java.lang.Number & java.lang.Runnable&gt;&nbsp;T&nbsp;foo(T&nbsp;t)"},
+ 
+             //==============================================================
+             // Test Class-Use Documenation for Type Parameters.
+@@ -289,347 +314,356 @@
+ 
+             //ClassUseTest1: <T extends Foo & Foo2>
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" " +
+-                     "title=\"class in pkg2\">Foo</A></CAPTION>"
++                     "<caption><span>Classes in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">" +
++                     "Foo</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html\" title=\"class in pkg2\">ClassUseTest1&lt;T extends Foo & Foo2&gt;</A></STRONG></CODE>"
++                     "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/" +
++                     "ClassUseTest1.html\" title=\"class in pkg2\">ClassUseTest1" +
++                     "&lt;T extends Foo & Foo2&gt;</a></strong></code>&nbsp;</td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" " +
+-                     "title=\"class in pkg2\">Foo</A></CAPTION>"
++                     "<caption><span>Methods in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/Foo.html\" title=\"class in " +
++                     "pkg2\">Foo</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                "<TD><CODE><STRONG>ClassUseTest1.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
++                     "<td class=\"colLast\"><span class=\"strong\">ClassUseTest1." +
++                     "</span><code><strong><a href=\"../../pkg2/" +
++                     "ClassUseTest1.html#method(T)\">method</a></strong>" +
++                     "(T&nbsp;t)</code>&nbsp;</td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo.html\" " +
+-                     "title=\"class in pkg2\">Foo</A></CAPTION>"
++                     "<caption><span>Fields in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">" +
++                     "Foo</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo.html",
+-                "<A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A>&lt;<A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A>&gt;</CODE></FONT></TD>"
++                     "td class=\"colFirst\"><code><a href=\"../../pkg2/" +
++                     "ParamTest.html\" title=\"class in pkg2\">ParamTest</a>" +
++                     "&lt;<a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\"" +
++                     ">Foo</a>&gt;</code></td>"
+             },
+ 
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> declared as <A HREF=\"../../pkg2/ParamTest.html\" " +
+-                     "title=\"class in pkg2\">ParamTest</A></CAPTION>"
++                     "<caption><span>Fields in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> declared as <a href=\"../" +
++                     "../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest" +
++                     "</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-                "<A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A>&lt;<A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A>&gt;</CODE></FONT></TD>"
++                     "<td class=\"colFirst\"><code><a href=\"../../pkg2/" +
++                     "ParamTest.html\" title=\"class in pkg2\">ParamTest</a>&lt;<a " +
++                     "href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</a" +
++                     ">&gt;</code></td>"
+             },
+ 
+            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+-                    "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                    "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                    "</A> with type parameters of type <A HREF=\"../../pkg2/Foo2.html\" " +
+-                    "title=\"interface in pkg2\">Foo2</A></CAPTION>"
++                    "<caption><span>Classes in <a href=\"../../pkg2/" +
++                    "package-summary.html\">pkg2</a> with type parameters of " +
++                    "type <a href=\"../../pkg2/Foo2.html\" title=\"interface " +
++                    "in pkg2\">Foo2</a></span><span class=\"tabEnd\">&nbsp;" +
++                    "</span></caption>"
+            },
+            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+-            "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html\" title=\"class in pkg2\">ClassUseTest1&lt;T extends Foo & Foo2&gt;</A></STRONG></CODE>"
++                    "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/" +
++                    "ClassUseTest1.html\" title=\"class in pkg2\">" +
++                    "ClassUseTest1&lt;T extends Foo & Foo2&gt;</a></strong>" +
++                    "</code>&nbsp;</td>"
+            },
+            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+-                    "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                    "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                    "</A> with type parameters of type <A HREF=\"../../pkg2/Foo2.html\" " +
+-                    "title=\"interface in pkg2\">Foo2</A></CAPTION>"
++                    "<caption><span>Methods in <a href=\"../../pkg2/" +
++                    "package-summary.html\">pkg2</a> with type parameters of " +
++                    "type <a href=\"../../pkg2/Foo2.html\" title=\"interface " +
++                    "in pkg2\">Foo2</a></span><span class=\"tabEnd\">&nbsp;" +
++                    "</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo2.html",
+-               "<TD><CODE><STRONG>ClassUseTest1.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest1.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
++                     "<td class=\"colLast\"><span class=\"strong\">" +
++                     "ClassUseTest1.</span><code><strong><a href=\"../../" +
++                     "pkg2/ClassUseTest1.html#method(T)\">method</a></strong>" +
++                     "(T&nbsp;t)</code>&nbsp;</td>"
+             },
+ 
+             //ClassUseTest2: <T extends ParamTest<Foo3>>
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" " +
+-                     "title=\"class in pkg2\">ParamTest</A></CAPTION>"
++                     "<caption><span>Classes in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/ParamTest.html\" title=\"class " +
++                     "in pkg2\">ParamTest</a></span><span class=\"tabEnd\">" +
++                     "&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-              "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html\" title=\"class in pkg2\">ClassUseTest2&lt;T extends ParamTest&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;</A></STRONG></CODE>"
++                     "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/" +
++                     "ClassUseTest2.html\" title=\"class in pkg2\">ClassUseTest2&lt;T " +
++                     "extends ParamTest&lt;<a href=\"../../pkg2/Foo3.html\" title=\"class " +
++                     "in pkg2\">Foo3</a>&gt;&gt;</a></strong></code>&nbsp;</td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" " +
+-                     "title=\"class in pkg2\">ParamTest</A></CAPTION>"
++                     "<caption><span>Methods in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/ParamTest.html\" title=\"class " +
++                     "in pkg2\">ParamTest</a></span><span class=\"tabEnd\">" +
++                     "&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-              "<TD><CODE><STRONG>ClassUseTest2.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
++                     "<td class=\"colLast\"><span class=\"strong\">ClassUseTest2." +
++                     "</span><code><strong><a href=\"../../pkg2/" +
++                     "ClassUseTest2.html#method(T)\">method</a></strong>" +
++                     "(T&nbsp;t)</code>&nbsp;</td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Fields in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> declared as <A HREF=\"../../pkg2/ParamTest.html\" " +
+-                     "title=\"class in pkg2\">ParamTest</A></CAPTION>"
++                     "<caption><span>Fields in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> declared as <a href=\"../" +
++                     "../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest" +
++                     "</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-              "<A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A>&lt;<A HREF=\"../../pkg2/Foo.html\" title=\"class in pkg2\">Foo</A>&gt;</CODE></FONT></TD>"
++                     "<td class=\"colFirst\"><code><a href=\"../../pkg2/" +
++                     "ParamTest.html\" title=\"class in pkg2\">ParamTest</a>" +
++                     "&lt;<a href=\"../../pkg2/Foo.html\" title=\"class in pkg2\">" +
++                     "Foo</a>&gt;</code></td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type <A HREF=\"../../pkg2/ParamTest.html\" " +
+-                     "title=\"class in pkg2\">ParamTest</A></CAPTION>"
++                     "<caption><span>Methods in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/ParamTest.html\" title=\"class " +
++                     "in pkg2\">ParamTest</a></span><span class=\"tabEnd\">" +
++                     "&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest.html",
+-              "&lt;T extends <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A>&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;"
++                     "<td class=\"colFirst\"><code>&lt;T extends <a href=\"../" +
++                     "../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest" +
++                     "</a>&lt;<a href=\"../../pkg2/Foo3.html\" title=\"class in " +
++                     "pkg2\">Foo3</a>&gt;&gt;&nbsp;<br><a href=\"../../pkg2/" +
++                     "ParamTest.html\" title=\"class in pkg2\">ParamTest</a>" +
++                     "&lt;<a href=\"../../pkg2/Foo3.html\" title=\"class in " +
++                     "pkg2\">Foo3</a>&gt;</code></td>"
+             },
+ 
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo3.html\" " +
+-                     "title=\"class in pkg2\">Foo3</A></CAPTION>"
++                     "<caption><span>Classes in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">" +
++                     "Foo3</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html\" title=\"class in pkg2\">ClassUseTest2&lt;T extends ParamTest&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;</A></STRONG></CODE>"
++                     "<td class=\"colLast\"><code><strong><a href=\"../../" +
++                     "pkg2/ClassUseTest2.html\" title=\"class in pkg2\">" +
++                     "ClassUseTest2&lt;T extends ParamTest&lt;<a href=\"../../" +
++                     "pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</a>&gt;&gt;" +
++                     "</a></strong></code>&nbsp;</td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo3.html\" " +
+-                     "title=\"class in pkg2\">Foo3</A></CAPTION>"
++                     "<caption><span>Methods in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/Foo3.html\" title=\"class in " +
++                     "pkg2\">Foo3</a></span><span class=\"tabEnd\">&nbsp;" +
++                     "</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                "<TD><CODE><STRONG>ClassUseTest2.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest2.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
++                     "<td class=\"colLast\"><span class=\"strong\">ClassUseTest2." +
++                     "</span><code><strong><a href=\"../../pkg2/" +
++                     "ClassUseTest2.html#method(T)\">method</a></strong>" +
++                     "(T&nbsp;t)</code>&nbsp;</td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> that return types with arguments of type " +
+-                     "<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">" +
+-                     "Foo3</A></CAPTION>"
++                     "<caption><span>Methods in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> that return types with " +
++                     "arguments of type <a href=\"../../pkg2/Foo3.html\" title" +
++                     "=\"class in pkg2\">Foo3</a></span><span class=\"tabEnd\">" +
++                     "&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo3.html",
+-                "&lt;T extends <A HREF=\"../../pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</A>&lt;<A HREF=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3</A>&gt;&gt;"
++                     "<td class=\"colFirst\"><code>&lt;T extends <a href=\"../../" +
++                     "pkg2/ParamTest.html\" title=\"class in pkg2\">ParamTest</a>&lt;" +
++                     "<a href=\"../../pkg2/Foo3.html\" title=\"class in pkg2\">Foo3" +
++                     "</a>&gt;&gt;&nbsp;<br><a href=\"../../pkg2/ParamTest.html\" " +
++                     "title=\"class in pkg2\">ParamTest</a>&lt;<a href=\"../../pkg2/" +
++                     "Foo3.html\" title=\"class in pkg2\">Foo3</a>&gt;</code></td>"
+             },
+ 
+             //ClassUseTest3: <T extends ParamTest2<List<? extends Foo4>>>
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type " +
+-                     "<A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
+-                     "ParamTest2</A></CAPTION>"
++                     "<caption><span>Classes in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/ParamTest2.html\" title=\"class " +
++                     "in pkg2\">ParamTest2</a></span><span class=\"tabEnd\">" +
++                     "&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html\" title=\"class in pkg2\">ClassUseTest3&lt;T extends ParamTest2&lt;java.util.List&lt;? extends Foo4&gt;&gt;&gt;</A></STRONG></CODE>"
++                     "<td class=\"colLast\"><code><strong><a href=\"../../pkg2/" +
++                     "ClassUseTest3.html\" title=\"class in pkg2\">" +
++                     "ClassUseTest3&lt;T extends ParamTest2&lt;java.util.List" +
++                     "&lt;? extends Foo4&gt;&gt;&gt;</a></strong></code>&nbsp;</td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type " +
+-                     "<A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
+-                     "ParamTest2</A></CAPTION>"
++                     "<caption><span>Methods in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/ParamTest2.html\" title=\"class " +
++                     "in pkg2\">ParamTest2</a></span><span class=\"tabEnd\">" +
++                     "&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                "<TD><CODE><STRONG>ClassUseTest3.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
++                     "<td class=\"colLast\"><span class=\"strong\">ClassUseTest3" +
++                     ".</span><code><strong><a href=\"../../pkg2/ClassUseTest3." +
++                     "html#method(T)\">method</a></strong>(T&nbsp;t)</code>&nbsp;</td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type " +
+-                     "<A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
+-                     "ParamTest2</A></CAPTION>"
+-            },
+-            {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "ParamTest2.html",
+-                "&lt;T extends <A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">ParamTest2</A>&lt;java.util.List&lt;? extends <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A>&gt;&gt;&gt;"
++                     "<td class=\"colFirst\"><code>&lt;T extends <a href=\"../" +
++                     "../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
++                     "ParamTest2</a>&lt;java.util.List&lt;? extends <a href=\".." +
++                     "/../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</a>&gt;" +
++                     "&gt;&gt;&nbsp;<br><a href=\"../../pkg2/ParamTest2.html\" " +
++                     "title=\"class in pkg2\">ParamTest2</a>&lt;java.util.List" +
++                     "&lt;? extends <a href=\"../../pkg2/Foo4.html\" title=\"" +
++                     "class in pkg2\">Foo4</a>&gt;&gt;</code></td>"
+             },
+ 
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Classes in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type " +
+-                     "<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">" +
+-                     "Foo4</A></CAPTION>"
++                     "<caption><span>Classes in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/Foo4.html\" title=\"class in " +
++                     "pkg2\">Foo4</a></span><span class=\"tabEnd\">&nbsp;" +
++                     "</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html\" title=\"class in pkg2\">ClassUseTest3&lt;T extends ParamTest2&lt;java.util.List&lt;? extends Foo4&gt;&gt;&gt;</A></STRONG></CODE>"
++                     "<td class=\"colLast\"><code><strong><a href=\"../../" +
++                     "pkg2/ClassUseTest3.html\" title=\"class in pkg2\">" +
++                     "ClassUseTest3&lt;T extends ParamTest2&lt;java.util.List" +
++                     "&lt;? extends Foo4&gt;&gt;&gt;</a></strong></code>&nbsp;</td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type parameters of type <A HREF=\"../../pkg2/Foo4.html\" " +
+-                     "title=\"class in pkg2\">Foo4</A></CAPTION>"
++                     "<caption><span>Methods in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type parameters of " +
++                     "type <a href=\"../../pkg2/Foo4.html\" title=\"class in " +
++                     "pkg2\">Foo4</a></span><span class=\"tabEnd\">&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                "<TD><CODE><STRONG>ClassUseTest3.</STRONG><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#method(T)\">method</A></STRONG>(T&nbsp;t)</CODE>"
++                     "<td class=\"colLast\"><span class=\"strong\">ClassUseTest3." +
++                     "</span><code><strong><a href=\"../../pkg2/ClassUseTest3." +
++                     "html#method(T)\">method</a></strong>(T&nbsp;t)</code>" +
++                     "&nbsp;</td>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Methods in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> that return types with arguments of type " +
+-                     "<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">" +
+-                     "Foo4</A></CAPTION>"
++                     "<caption><span>Methods in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> that return types with " +
++                     "arguments of type <a href=\"../../pkg2/Foo4.html\" " +
++                     "title=\"class in pkg2\">Foo4</a></span><span class=\"" +
++                     "tabEnd\">&nbsp;</span></caption>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                "&lt;T extends <A HREF=\"../../pkg2/ParamTest2.html\" title=\"class in pkg2\">ParamTest2</A>&lt;java.util.List&lt;? extends <A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</A>&gt;&gt;&gt;"
++                     "<td class=\"colFirst\"><code>&lt;T extends <a href=\"../" +
++                     "../pkg2/ParamTest2.html\" title=\"class in pkg2\">" +
++                     "ParamTest2</a>&lt;java.util.List&lt;? extends <a href=\".." +
++                     "/../pkg2/Foo4.html\" title=\"class in pkg2\">Foo4</a>&gt;" +
++                     "&gt;&gt;&nbsp;<br><a href=\"../../pkg2/ParamTest2.html\" " +
++                     "title=\"class in pkg2\">ParamTest2</a>&lt;java.util.List" +
++                     "&lt;? extends <a href=\"../../pkg2/Foo4.html\" title=\"" +
++                     "class in pkg2\">Foo4</a>&gt;&gt;</code></td>"
+             },
+ 
+             //Type parameters in constructor and method args
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Method parameters in <A HREF=\"../../pkg2/package-summary.html\">pkg2" +
+-                     "</A> with type arguments of type <A HREF=\"../../pkg2/Foo4.html\" " +
+-                     "title=\"class in pkg2\">Foo4</A></CAPTION>" + NL +
+-                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Modifier and Type" +
+-                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Method and Description</TH>" + NL +
+-                     "</TR>" + NL +
+-                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                     "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+-                     "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
+-                     "<TD><CODE><STRONG>ClassUseTest3.</STRONG><STRONG>" +
+-                     "<A HREF=\"../../pkg2/ClassUseTest3.html#method(java.util.Set)\">" +
+-                     "method</A></STRONG>(java.util.Set&lt;<A HREF=\"../../pkg2/Foo4.html\" " +
+-                     "title=\"class in pkg2\">Foo4</A>&gt;&nbsp;p)</CODE>"
++                     "<caption><span>Method parameters in <a href=\"../../pkg2/" +
++                     "package-summary.html\">pkg2</a> with type arguments of " +
++                     "type <a href=\"../../pkg2/Foo4.html\" title=\"class in " +
++                     "pkg2\">Foo4</a></span><span class=\"tabEnd\">&nbsp;" +
++                     "</span></caption>" + NL + "<tr>" + NL +
++                     "<th class=\"colFirst\" scope=\"col\">Modifier and Type</th>" + NL +
++                     "<th class=\"colLast\" scope=\"col\">Method and Description</th>" + NL +
++                     "</tr>" + NL + "<tbody>" + NL + "<tr class=\"altColor\">" + NL +
++                     "<td class=\"colFirst\"><code>void</code></td>" + NL +
++                     "<td class=\"colLast\"><span class=\"strong\">ClassUseTest3." +
++                     "</span><code><strong><a href=\"../../pkg2/ClassUseTest3." +
++                     "html#method(java.util.Set)\">method</a></strong>(java." +
++                     "util.Set&lt;<a href=\"../../pkg2/Foo4.html\" title=\"" +
++                     "class in pkg2\">Foo4</a>&gt;&nbsp;p)</code>&nbsp;</td>" + NL +
++                     "</tr>" + NL + "</tbody>"
+             },
+             {BUG_ID + FS + "pkg2" + FS + "class-use" + FS + "Foo4.html",
+-                     "<CAPTION CLASS=\"TableSubCaption\">" + NL +
+-                     "Constructor parameters in <A HREF=\"../../pkg2/package-summary.html\">" +
+-                     "pkg2</A> with type arguments of type <A HREF=\"../../pkg2/Foo4.html\" " +
+-                     "title=\"class in pkg2\">Foo4</A></CAPTION>" + NL +
+-                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Constructor and Description" +
+-                     "</TH>" + NL + "</TR>" + NL +
+-                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                     "<TD><CODE><STRONG><A HREF=\"../../pkg2/ClassUseTest3.html#ClassUseTest3" +
+-                     "(java.util.Set)\">ClassUseTest3</A></STRONG>(java.util.Set&lt;" +
+-                     "<A HREF=\"../../pkg2/Foo4.html\" title=\"class in pkg2\">" +
+-                     "Foo4</A>&gt;&nbsp;p)</CODE>"
++                     "<caption><span>Constructor parameters in <a href=\"../../" +
++                     "pkg2/package-summary.html\">pkg2</a> with type arguments " +
++                     "of type <a href=\"../../pkg2/Foo4.html\" title=\"class in " +
++                     "pkg2\">Foo4</a></span><span class=\"tabEnd\">&nbsp;" +
++                     "</span></caption>"
+             },
+ 
+             //=================================
+             // Annotatation Type Usage
+             //=================================
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                     "Packages with annotations of type " +
+-                     "<A HREF=\"../../pkg/AnnotationType.html\" " +
+-                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
+-                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Package" +
+-                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Description</TH>" + NL + "</TR>" + NL +
+-                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                     "<TD><A HREF=\"../../pkg/package-summary.html\"><STRONG>pkg" +
+-                     "</STRONG></A></TD>"
++                     "<caption><span>Packages with annotations of type <a href=\"" +
++                     "../../pkg/AnnotationType.html\" title=\"annotation in pkg\">" +
++                     "AnnotationType</a></span><span class=\"tabEnd\">&nbsp;" +
++                     "</span></caption>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                     "Classes in <A HREF=\"../../pkg/package-summary.html\">pkg" +
+-                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
+-                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
+-                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Modifier and Type" +
+-                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Class and Description</TH>" + NL +
+-                     "</TR>" + NL +
+-                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                     "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+-                     "<CODE>&nbsp;class</CODE></FONT></TD>" + NL +
+-                     "<TD><CODE><STRONG><A HREF=\"../../pkg/AnnotationTypeUsage.html\" " +
+-                     "title=\"class in pkg\">AnnotationTypeUsage</A></STRONG></CODE>"
++                     "<caption><span>Classes in <a href=\"../../pkg/" +
++                     "package-summary.html\">pkg</a> with annotations of type " +
++                     "<a href=\"../../pkg/AnnotationType.html\" title=\"" +
++                     "annotation in pkg\">AnnotationType</a></span><span class" +
++                     "=\"tabEnd\">&nbsp;</span></caption>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                     "Fields in <A HREF=\"../../pkg/package-summary.html\">pkg" +
+-                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
+-                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
+-                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Modifier and Type" +
+-                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Field and Description</TH>" + NL +
+-                     "</TR>" + NL +
+-                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                     "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+-                     "<CODE>&nbsp;int</CODE></FONT></TD>" + NL +
+-                     "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG>" +
+-                     "<A HREF=\"../../pkg/AnnotationTypeUsage.html#field\">field" +
+-                     "</A></STRONG></CODE>"
++                     "<caption><span>Fields in <a href=\"../../pkg/" +
++                     "package-summary.html\">pkg</a> with annotations of type " +
++                     "<a href=\"../../pkg/AnnotationType.html\" title=\"annotation " +
++                     "in pkg\">AnnotationType</a></span><span class=\"tabEnd\">" +
++                     "&nbsp;</span></caption>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                     "Methods in <A HREF=\"../../pkg/package-summary.html\">pkg" +
+-                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
+-                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
+-                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Modifier and Type" +
+-                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Method and Description</TH>" + NL +
+-                     "</TR>" + NL +
+-                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                     "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+-                     "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
+-                     "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG>" +
+-                     "<A HREF=\"../../pkg/AnnotationTypeUsage.html#method()\">" +
+-                     "method</A></STRONG>()</CODE>"
++                     "<caption><span>Methods in <a href=\"../../pkg/" +
++                     "package-summary.html\">pkg</a> with annotations of type " +
++                     "<a href=\"../../pkg/AnnotationType.html\" title=\"annotation " +
++                     "in pkg\">AnnotationType</a></span><span class=\"tabEnd\">" +
++                     "&nbsp;</span></caption>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                     "Method parameters in <A HREF=\"../../pkg/package-summary.html\">pkg" +
+-                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
+-                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
+-                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Modifier and Type" +
+-                     "</TH>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Method and Description</TH>" + NL +
+-                     "</TR>" + NL +
+-                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                     "<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\"><FONT SIZE=\"-1\">" + NL +
+-                     "<CODE>&nbsp;void</CODE></FONT></TD>" + NL +
+-                     "<TD><CODE><STRONG>AnnotationTypeUsage.</STRONG><STRONG>" +
+-                     "<A HREF=\"../../pkg/AnnotationTypeUsage.html#methodWithParams" +
+-                     "(int, int)\">methodWithParams</A></STRONG>(int&nbsp;documented," + NL +
+-                     "                 int&nbsp;undocmented)</CODE>"
++                     "<caption><span>Method parameters in <a href=\"../../pkg/" +
++                     "package-summary.html\">pkg</a> with annotations of type " +
++                     "<a href=\"../../pkg/AnnotationType.html\" title=\"annotation " +
++                     "in pkg\">AnnotationType</a></span><span class=\"tabEnd\">" +
++                     "&nbsp;</span></caption>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                     "Constructors in <A HREF=\"../../pkg/package-summary.html\">pkg" +
+-                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
+-                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
+-                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Constructor and Description" +
+-                     "</TH>" + NL + "</TR>" + NL +
+-                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                     "<TD><CODE><STRONG><A HREF=\"../../pkg/" +
+-                     "AnnotationTypeUsage.html#AnnotationTypeUsage()\">" +
+-                     "AnnotationTypeUsage</A></STRONG>()</CODE>"
++                     "<caption><span>Constructors in <a href=\"../../pkg/" +
++                     "package-summary.html\">pkg</a> with annotations of type " +
++                     "<a href=\"../../pkg/AnnotationType.html\" title=\"annotation " +
++                     "in pkg\">AnnotationType</a></span><span class=\"tabEnd\">" +
++                     "&nbsp;</span></caption>"
+             },
+ 
+             {BUG_ID + FS + "pkg" + FS + "class-use" + FS + "AnnotationType.html",
+-                     "Constructor parameters in <A HREF=\"../../pkg/package-summary.html\">pkg" +
+-                     "</A> with annotations of type <A HREF=\"../../pkg/AnnotationType.html\" " +
+-                     "title=\"annotation in pkg\">AnnotationType</A></CAPTION>" + NL +
+-                     "<TR>" + NL + "<TH CLASS=\"TableHeader\" SCOPE=\"col\"" +
+-                     " NOWRAP>Constructor and Description" +
+-                     "</TH>" + NL + "</TR>" + NL +
+-                     "<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">" + NL +
+-                     "<TD><CODE><STRONG><A HREF=\"../../pkg/" +
+-                     "AnnotationTypeUsage.html#AnnotationTypeUsage(int, int)\">" +
+-                     "AnnotationTypeUsage</A></STRONG>(int&nbsp;documented," + NL +
+-                     "                    int&nbsp;undocmented)</CODE>"
++                     "<caption><span>Constructor parameters in <a href=\"../../" +
++                     "pkg/package-summary.html\">pkg</a> with annotations of " +
++                     "type <a href=\"../../pkg/AnnotationType.html\" title=\"" +
++                     "annotation in pkg\">AnnotationType</a></span><span class=\"" +
++                     "tabEnd\">&nbsp;</span></caption>"
+             },
+ 
+             //=================================
+             // TYPE PARAMETER IN INDEX
+             //=================================
+             {BUG_ID + FS + "index-all.html",
+-                "<A HREF=\"./pkg2/Foo.html#method(java.util.Vector)\"><STRONG>method(Vector&lt;Object&gt;)</STRONG></A>"
++                "<span class=\"strong\"><a href=\"./pkg2/Foo.html#method(java.util.Vector)\">" +
++                "method(Vector&lt;Object&gt;)</a></span>"
+             },
+             //=================================
+             // TYPE PARAMETER IN INDEX
+             //=================================
+             {BUG_ID + FS + "index-all.html",
+-                "<A HREF=\"./pkg2/Foo.html#method(java.util.Vector)\"><STRONG>method(Vector&lt;Object&gt;)</STRONG></A>"
++                "<span class=\"strong\"><a href=\"./pkg2/Foo.html#method(java.util.Vector)\">" +
++                "method(Vector&lt;Object&gt;)</a></span>"
+             },
+         };
+     private static final String[][] NEGATED_TEST = {
+@@ -637,15 +671,15 @@
+         // ENUM TESTING
+         //=================================
+         //NO constructor section
+-        {BUG_ID + FS + "pkg" + FS + "Coin.html", "<STRONG>Constructor Summary</STRONG>"},
++        {BUG_ID + FS + "pkg" + FS + "Coin.html", "<span class=\"strong\">Constructor Summary</span>"},
+         //=================================
+         // TYPE PARAMETER TESTING
+         //=================================
+         //No type parameters in class frame.
+         {BUG_ID + FS + "allclasses-frame.html",
+-            "<A HREF=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
+-                    "TypeParameters</A>&lt;<A HREF=\"../pkg/TypeParameters.html\" " +
+-                    "title=\"type parameter in TypeParameters\">E</A>&gt;"
++            "<a href=\"../pkg/TypeParameters.html\" title=\"class in pkg\">" +
++                    "TypeParameters</a>&lt;<a href=\"../pkg/TypeParameters.html\" " +
++                    "title=\"type parameter in TypeParameters\">E</a>&gt;"
+         },
+ 
+         //==============================================================
+@@ -654,31 +688,27 @@
+ 
+         //CLASS
+         {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+-            "<FONT SIZE=\"-1\">" + NL +
+-            "<A HREF=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</A>(<A HREF=\"../pkg/AnnotationType.html#optional\">optional</A>=\"Class Annotation\"," + NL +
+-            "                <A HREF=\"../pkg/AnnotationType.html#required\">required</A>=1994)" + NL +
+-            "</FONT>public class <STRONG>AnnotationTypeUsage</STRONG></DT><DT>extends java.lang.Object</DT></DL>"},
++            "<a href=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</a>(<a href=\"../pkg/AnnotationType.html#optional\">optional</a>=\"Class Annotation\"," + NL +
++            "                <a href=\"../pkg/AnnotationType.html#required\">required</a>=1994)" + NL +
++            "public class <strong>AnnotationTypeUsage</strong></dt><dt>extends java.lang.Object</dt>"},
+ 
+         //FIELD
+         {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+-            "<FONT SIZE=\"-1\">" + NL +
+-            "<A HREF=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</A>(<A HREF=\"../pkg/AnnotationType.html#optional\">optional</A>=\"Field Annotation\"," + NL +
+-            "                <A HREF=\"../pkg/AnnotationType.html#required\">required</A>=1994)" + NL +
+-            "</FONT>public int <STRONG>field</STRONG>"},
++            "<a href=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</a>(<a href=\"../pkg/AnnotationType.html#optional\">optional</a>=\"Field Annotation\"," + NL +
++            "                <a href=\"../pkg/AnnotationType.html#required\">required</a>=1994)" + NL +
++            "public int <strong>field</strong>"},
+ 
+         //CONSTRUCTOR
+         {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+-            "<FONT SIZE=\"-1\">" + NL +
+-            "<A HREF=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</A>(<A HREF=\"../pkg/AnnotationType.html#optional\">optional</A>=\"Constructor Annotation\"," + NL +
+-            "                <A HREF=\"../pkg/AnnotationType.html#required\">required</A>=1994)" + NL +
+-            "</FONT>public <STRONG>AnnotationTypeUsage</STRONG>()"},
++            "<a href=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</a>(<a href=\"../pkg/AnnotationType.html#optional\">optional</a>=\"Constructor Annotation\"," + NL +
++            "                <a href=\"../pkg/AnnotationType.html#required\">required</a>=1994)" + NL +
++            "public <strong>AnnotationTypeUsage</strong>()"},
+ 
+         //METHOD
+         {BUG_ID + FS + "pkg" + FS + "AnnotationTypeUsage.html",
+-            "<FONT SIZE=\"-1\">" + NL +
+-            "<A HREF=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</A>(<A HREF=\"../pkg/AnnotationType.html#optional\">optional</A>=\"Method Annotation\"," + NL +
+-            "                <A HREF=\"../pkg/AnnotationType.html#required\">required</A>=1994)" + NL +
+-            "</FONT>public void <STRONG>method</STRONG>()"},
++            "<a href=\"../pkg/AnnotationTypeUndocumented.html\" title=\"annotation in pkg\">@AnnotationTypeUndocumented</a>(<a href=\"../pkg/AnnotationType.html#optional\">optional</a>=\"Method Annotation\"," + NL +
++            "                <a href=\"../pkg/AnnotationType.html#required\">required</a>=1994)" + NL +
++            "public void <strong>method</strong>()"},
+ 
+         //=================================
+         // Make sure annotation types do not
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestMultiInheritence.java b/test/com/sun/javadoc/testOverridenMethods/TestMultiInheritence.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestMultiInheritence.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestMultiInheritence.java
+@@ -46,27 +46,34 @@
+     //Method foo() is inherited from BOTH I2 and I3
+     private static final String[][] TEST = {
+        {BUG_ID + FS + "pkg3" + FS + "I1.html",
+-        "Methods inherited from interface pkg3." +
        "<A HREF=\"../pkg3/I2.html\" title=\"interface in pkg3\">I2</A>"},
++        "Methods inherited from interface&nbsp;pkg3." +
++                "<a href=\"../pkg3/I2.html\" title=\"interface in pkg3\">" +
++                "I2</a>"},
+         {BUG_ID + FS + "pkg3" + FS +"I1.html",
+-        "Methods inherited from interface pkg3." +
+-        "<A HREF=\"../pkg3/I3.html\" title=\"interface in pkg3\">I3</A>"},
++        "Methods inherited from interface&nbsp;pkg3." +
++                 "<a href=\"../pkg3/I3.html\" title=\"interface in pkg3\">" +
++                 "I3</a>"},
+         {BUG_ID + FS + "pkg3" + FS + "I0.html",
+-        "Methods inherited from interface pkg3." +
+-        "<A HREF=\"../pkg3/I2.html\" title=\"interface in pkg3\">I2</A>"},
++        "Methods inherited from interface&nbsp;pkg3." +
++                 "<a href=\"../pkg3/I2.html\" title=\"interface in pkg3\">" +
++                 "I2</a>"},
+         {BUG_ID + FS + "pkg3" + FS +"I0.html",
+-        "Methods inherited from interface pkg3." +
+-        "<A HREF=\"../pkg3/I3.html\" title=\"interface in pkg3\">I3</A>"},
++        "Methods inherited from interface&nbsp;pkg3." +
++                 "<a href=\"../pkg3/I3.html\" title=\"interface in pkg3\">" +
++                 "I3</a>"},
+     };
+ 
+     //Method foo() is NOT inherited from I4 because it is overriden by
+     //I3.
+     private static final String[][] NEGATED_TEST = {
+         {BUG_ID + FS + "pkg3" + FS + "I1.html",
+-        "Methods inherited from interface pkg3." +
+-        "<A HREF=\"../pkg3/I4.html\" title=\"interface in pkg3\">I4</A>"},
++        "Methods inherited from interface&nbsp;pkg3." +
++                 "<a href=\"../pkg3/I4.html\" title=\"interface in pkg3\">" +
++                 "I4</a>"},
+         {BUG_ID + FS + "pkg3" + FS + "I0.html",
+-        "Methods inherited from interface pkg3." +
+-        "<A HREF=\"../pkg3/I4.html\" title=\"interface in pkg3\">I4</A>"},
++        "Methods inherited from interface&nbsp;pkg3." +
++                 "<a href=\"../pkg3/I4.html\" title=\"interface in pkg3\">" +
++                 "I4</a>"},
+     };
+ 
+     /**
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenMethodDocCopy.java
+@@ -46,9 +46,9 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-            "<STRONG>Description copied from class: <CODE>" +
+-            "<A HREF=\"../pkg1/BaseClass.html#overridenMethodWithDocsToCopy()\">" +
+-            "BaseClass</A></CODE></STRONG>"
++            "<strong>Description copied from class:&nbsp;<code>" +
++            "<a href=\"../pkg1/BaseClass.html#overridenMethodWithDocsToCopy()\">" +
++            "BaseClass</a></code></strong>"
+         }
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethods.java
+@@ -40,11 +40,13 @@
+     private static final String[][] TEST = {
+         //The public method should be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#publicMethod"},
+ 
+         //The public method in different package should be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"}
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#publicMethod"}
+     };
+ 
+     private static final String[][] NEGATED_TEST = {
+@@ -52,20 +54,23 @@
+         //The package private method should be overriden since the base and sub class are in the same
+         //package.  However, the link should not show up because the package private methods are not documented.
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#packagePrivateMethod"},
+ 
+         //The private method in should not be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The private method in different package should not be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The package private method should not be overriden since the base and sub class are in
+         //different packages.
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
++         "Overrides:</strong></dt><dd><code><a href=\"../pkg1/BaseClass.html#packagePrivateMethod"}
+     };
+ 
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java
+@@ -40,32 +40,44 @@
+     private static final String[][] TEST = {
+         //The public method should be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#publicMethod()\">" +
++                 "publicMethod</a></code>&nbsp;in class&nbsp;<code>" +
++                 "<a href=\"../pkg1/BaseClass.html\" title=\"class in pkg1\">BaseClass</a></code></dd>"},
+ 
+         //The public method in different package should be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#publicMethod()\">" +
++                 "publicMethod</a></code>&nbsp;in class&nbsp;<code>" +
++                 "<a href=\"../pkg1/BaseClass.html\" title=\"class in pkg1\">BaseClass</a></code></dd>"},
+ 
+         //The package private method should be overriden since the base and sub class are in the same
+         //package.
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#packagePrivateMethod()\">" +
++                 "packagePrivateMethod</a></code>&nbsp;in class&nbsp;<code>" +
++                 "<a href=\"../pkg1/BaseClass.html\" title=\"class in pkg1\">BaseClass</a></code></dd>"}
+     };
+ 
+     private static final String[][] NEGATED_TEST = {
+ 
+         //The private method in should not be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#privateMethod()\">"},
+ 
+         //The private method in different package should not be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#privateMethod()\">"},
+ 
+         //The package private method should not be overriden since the base and sub class are in
+         //different packages.
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#packagePrivateMethod()\">"},
+     };
+ 
+     private static final String[] ARGS =
+diff --git a/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java b/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java
+--- openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java
++++ openjdk/langtools/test/com/sun/javadoc/testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java
+@@ -40,32 +40,38 @@
+     private static final String[][] TEST = {
+         //The public method should be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#publicMethod"},
+ 
+         //The package private method should be overriden since the base and sub class are in the same
+         //package.
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#packagePrivateMethod"},
+ 
+         //The public method in different package should be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#publicMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#publicMethod"},
+     };
+ 
+     private static final String[][] NEGATED_TEST = {
+ 
+         //The private method in should not be overriden
+         {BUG_ID + FS + "pkg1" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The private method in different package should not be overriden
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#privateMethod"},
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#privateMethod"},
+ 
+         //The package private method should not be overriden since the base and sub class are in
+         //different packages.
+         {BUG_ID + FS + "pkg2" + FS + "SubClass.html",
+-         "Overrides:</STRONG></DT><DD><CODE><A HREF=\"../pkg1/BaseClass.html#packagePrivateMethod"}
++         "<dt><strong>Overrides:</strong></dt>" + NL +
++                 "<dd><code><a href=\"../pkg1/BaseClass.html#packagePrivateMethod"}
+ 
+ 
+     };
+diff --git a/test/com/sun/javadoc/testPackagePage/TestPackagePage.java b/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
+--- openjdk/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
++++ openjdk/langtools/test/com/sun/javadoc/testPackagePage/TestPackagePage.java
+@@ -43,37 +43,32 @@
+         },
+         //With just one package, all general pages link to the single package page.
+         {BUG_ID + "-1" + FS + "com" + FS + "pkg" + FS + "C.html",
+-            "<A HREF=\"../../com/pkg/package-summary.html\">" +
+-            "<FONT CLASS=\"NavBarFont1\"><STRONG>Package</STRONG></FONT></A>"
++            "<a href=\"../../com/pkg/package-summary.html\">Package</a>"
+         },
+         {BUG_ID + "-1" + FS + "com" + FS + "pkg" + FS + "package-tree.html",
+-            "<A HREF=\"../../com/pkg/package-summary.html\">" +
+-            "<FONT CLASS=\"NavBarFont1\"><STRONG>Package</STRONG></FONT></A>"
++            "<li><a href=\"../../com/pkg/package-summary.html\">Package</a></li>"
+         },
+         {BUG_ID + "-1" + FS + "deprecated-list.html",
+-            "<A HREF=\"com/pkg/package-summary.html\">" +
+-            "<FONT CLASS=\"NavBarFont1\"><STRONG>Package</STRONG></FONT></A>"
++            "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
+         },
+         {BUG_ID + "-1" + FS + "index-all.html",
+-            "<A HREF=\"./com/pkg/package-summary.html\">" +
+-            "<FONT CLASS=\"NavBarFont1\"><STRONG>Package</STRONG></FONT></A>"
++            "<li><a href=\"./com/pkg/package-summary.html\">Package</a></li>"
+         },
+         {BUG_ID + "-1" + FS + "help-doc.html",
+-            "<A HREF=\"com/pkg/package-summary.html\">" +
+-            "<FONT CLASS=\"NavBarFont1\"><STRONG>Package</STRONG></FONT></A>"
++            "<li><a href=\"com/pkg/package-summary.html\">Package</a></li>"
+         },
+     };
+ 
+     private static final String[][] TEST2 = {
+         //With multiple packages, there is no package link in general pages.
+         {BUG_ID + "-2" + FS + "deprecated-list.html",
+-            " <FONT CLASS=\"NavBarFont1\">Package</FONT>&nbsp;"
++            "<li>Package</li>"
+         },
+         {BUG_ID + "-2" + FS + "index-all.html",
+-            " <FONT CLASS=\"NavBarFont1\">Package</FONT>&nbsp;"
++            "<li>Package</li>"
+         },
+         {BUG_ID + "-2" + FS + "help-doc.html",
+-            " <FONT CLASS=\"NavBarFont1\">Package</FONT>&nbsp;"
++            "<li>Package</li>"
+         },
+     };
+ 
+diff --git a/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java b/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
+--- openjdk/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
++++ openjdk/langtools/test/com/sun/javadoc/testParamTaglet/TestParamTaglet.java
+@@ -48,20 +48,20 @@
+     private static final String[][] TEST = {
+         //Regular param tags.
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<STRONG>Parameters:</STRONG></DT><DD><CODE>param1</CODE> - testing 1 2 3.</DD>" +
+-                "<DD><CODE>param2</CODE> - testing 1 2 3."
++            "<span class=\"strong\">Parameters:</span></dt><dd><code>param1</code> - testing 1 2 3.</dd>" +
++                "<dd><code>param2</code> - testing 1 2 3."
+         },
+         //Param tags that don't match with any real parameters.
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<STRONG>Parameters:</STRONG></DT><DD><CODE><I>p1</I></CODE> - testing 1 2 3.</DD>" +
+-                "<DD><CODE><I>p2</I></CODE> - testing 1 2 3."
++            "<span class=\"strong\">Parameters:</span></dt><dd><code><I>p1</I></code> - testing 1 2 3.</dd>" +
++                "<dd><code><I>p2</I></code> - testing 1 2 3."
+         },
+         //{@inherit} doc misuse does not cause doclet to throw exception.
+         // Param is printed with nothing inherited.
+         //XXX: in the future when Configuration is available during doc inheritence,
+         //print a warning for this mistake.
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<CODE><I>inheritBug</I></CODE> -"
++            "<code><I>inheritBug</I></code> -"
+         },
+ 
+     };
+diff --git a/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java b/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
+--- openjdk/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
++++ openjdk/langtools/test/com/sun/javadoc/testPrivateClasses/TestPrivateClasses.java
+@@ -58,50 +58,50 @@
+     private static final String[][] TEST1 = {
+         // Field inheritence from non-public superclass.
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-            "<A HREF=\"../pkg/PublicChild.html#fieldInheritedFromParent\">" +
+-                "fieldInheritedFromParent</A>"
++            "<a href=\"../pkg/PublicChild.html#fieldInheritedFromParent\">" +
++                "fieldInheritedFromParent</a>"
+         },
+ 
+         // Method inheritence from non-public superclass.
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-            "<A HREF=\"../pkg/PublicChild.html#methodInheritedFromParent(int)\">" +
+-                "methodInheritedFromParent</A>"
++            "<a href=\"../pkg/PublicChild.html#methodInheritedFromParent(int)\">" +
++                "methodInheritedFromParent</a>"
+         },
+ 
+         // Field inheritence from non-public superinterface.
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
+-            "<A HREF=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">" +
+-                "fieldInheritedFromInterface</A>"
++            "<a href=\"../pkg/PublicInterface.html#fieldInheritedFromInterface\">" +
++                "fieldInheritedFromInterface</a>"
+         },
+ 
+         // Method inheritence from non-public superinterface.
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
+-            "<A HREF=\"../pkg/PublicInterface.html#methodInterface(int)\">" +
+-                "methodInterface</A>"
++            "<a href=\"../pkg/PublicInterface.html#methodInterface(int)\">" +
++                "methodInterface</a>"
+         },
+ 
+         // private class does not show up in tree
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-            "<PRE>" + NL +
+-                "java.lang.Object" + NL +
+-                "  <IMG SRC=\"../resources/inherit.gif\" " +
+-                "ALT=\"extended by \"><STRONG>pkg.PublicChild</STRONG>" + NL +
+-            "</PRE>"
++            "<ul class=\"inheritance\">" + NL + "<li>java.lang.Object</li>" + NL +
++            "<li>" + NL + "<ul class=\"inheritance\">" + NL + "<li>pkg.PublicChild</li>" + NL +
++            "</ul>" + NL + "</li>" + NL + "</ul>"
+         },
+ 
+         // Method is documented as though it is declared in the inheriting method.
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-            "public void <STRONG>methodInheritedFromParent</STRONG>(int&nbsp;p1)"
++            "<pre>public&nbsp;void&nbsp;methodInheritedFromParent(int&nbsp;p1)"
+         },
+ 
+         //Make sure implemented interfaces from private superclass are inherited
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
+-            "<STRONG>All Known Implementing Classes:</STRONG></DT> <DD><A HREF=\"../pkg/PublicChild.html\" " +
+-            "title=\"class in pkg\">PublicChild</A>"},
++            "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL +
++            "<dd><a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">" +
++            "PublicChild</a></dd>" + NL + "</dl>"},
+ 
+         {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-            "<STRONG>All Implemented Interfaces:</STRONG></DT> <DD><A HREF=\"../pkg/PublicInterface.html\" " +
+-            "title=\"interface in pkg\">PublicInterface</A>"},
++            "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
++            "<dd><a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
++            "PublicInterface</a></dd>" + NL + "</dl>"},
+ 
+         //Generic interface method test.
+         {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html",
+@@ -110,12 +110,12 @@
+     private static final String[][] NEGATED_TEST1 = {
+        // Should not document that a method overrides method from private class.
+       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-        "<STRONG>Overrides:</STRONG>"},
++        "<strong>Overrides:</strong>"},
+       // Should not document that a method specified by private interface.
+       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+-        "<STRONG>Specified by:</STRONG>"},
++        "<strong>Specified by:</strong>"},
+       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicInterface.html",
+-        "<STRONG>Specified by:</STRONG>"},
++        "<strong>Specified by:</strong>"},
+       // Should not mention that any documentation was copied.
+       {BUG_ID + "-1" + FS + "pkg" + FS + "PublicChild.html",
+         "Description copied from"},
+@@ -137,64 +137,64 @@
+         //Do not inherit private interface method with generic parameters.
+         //This method has been implemented.
+         {BUG_ID + "-1" + FS + "pkg2" + FS + "C.html",
+-            "<STRONG><A HREF=\"../pkg2/I.html#hello(T)\">hello</A></STRONG>"},
++            "<strong><a href=\"../pkg2/I.html#hello(T)\">hello</a></strong>"},
+     };
+ 
+     // Test output when -private flag is used.
+     private static final String[][] TEST2 = {
+         // Field inheritence from non-public superclass.
+         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-            "Fields inherited from class " +
+-            "pkg.<A HREF=\"../pkg/PrivateParent.html\" " +
+-            "title=\"class in pkg\">PrivateParent</A>"
++            "Fields inherited from class&nbsp;pkg." +
++            "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
++            "PrivateParent</a>"
+         },
+         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-            "<A HREF=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">" +
+-                "fieldInheritedFromParent</A>"
++            "<a href=\"../pkg/PrivateParent.html#fieldInheritedFromParent\">" +
++                "fieldInheritedFromParent</a>"
+         },
+         // Field inheritence from non-public superinterface.
+         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
+-            "Fields inherited from interface " +
+-            "pkg.<A HREF=\"../pkg/PrivateInterface.html\" " +
+-            "title=\"interface in pkg\">PrivateInterface</A>"
++            "Fields inherited from interface&nbsp;pkg." +
++            "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
++            "PrivateInterface</a>"
+         },
+         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
+-            "<A HREF=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">" +
+-                "fieldInheritedFromInterface</A>"
++            "<a href=\"../pkg/PrivateInterface.html#fieldInheritedFromInterface\">" +
++                "fieldInheritedFromInterface</a>"
+         },
+         // Method inheritence from non-public superclass.
+         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-            "Methods inherited from class " +
+-            "pkg.<A HREF=\"../pkg/PrivateParent.html\" " +
+-            "title=\"class in pkg\">PrivateParent</A>"
++            "Methods inherited from class&nbsp;pkg." +
++            "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
++            "PrivateParent</a>"
+         },
+         {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-            "<A HREF=\"../pkg/PrivateParent.html#methodInheritedFromParent(int)\">" +
+-                "methodInheritedFromParent</A>"
++            "<a href=\"../pkg/PrivateParent.html#methodInheritedFromParent(int)\">" +
++                "methodInheritedFromParent</a>"
+         },
+         // Should document that a method overrides method from private class.
+        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-            "<STRONG>Overrides:</STRONG></DT><DD><CODE>" +
+-            "<A HREF=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" +
+-            "methodOverridenFromParent</A></CODE> in class <CODE>" +
+-            "<A HREF=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
+-            "PrivateParent</A></CODE></DD>" + NL + "</DL>"},
++            "<dt><strong>Overrides:</strong></dt>" + NL +
++            "<dd><code><a href=\"../pkg/PrivateParent.html#methodOverridenFromParent(char[], int, T, V, java.util.List)\">" +
++            "methodOverridenFromParent</a></code>&nbsp;in class&nbsp;<code>" +
++            "<a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
++            "PrivateParent</a></code></dd>"},
+        // Should document that a method is specified by private interface.
+        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-            "<STRONG>Specified by:</STRONG></DT><DD><CODE>" +
+-            "<A HREF=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
+-            "methodInterface</A></CODE> in interface <CODE>" +
+-            "<A HREF=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
+-            "PrivateInterface</A></CODE></DD>" + NL + "</DL>" + NL + "</DD>"},
++            "<dt><strong>Specified by:</strong></dt>" + NL +
++            "<dd><code><a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
++            "methodInterface</a></code>&nbsp;in interface&nbsp;<code>" +
++            "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
++            "PrivateInterface</a></code></dd>"},
+        // Method inheritence from non-public superinterface.
+        {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
+-            "Methods inherited from interface " +
+-            "pkg.<A HREF=\"../pkg/PrivateInterface.html\" " +
+-            "title=\"interface in pkg\">PrivateInterface</A>"
++            "Methods inherited from interface&nbsp;pkg." +
++            "<a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
++            "PrivateInterface</a>"
+         },
+         {BUG_ID + "-2" + FS + "pkg" + FS + "PrivateInterface.html",
+-            "<A HREF=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
+-                "methodInterface</A>"
++            "<a href=\"../pkg/PrivateInterface.html#methodInterface(int)\">" +
++                "methodInterface</a>"
+         },
+       // Should mention that any documentation was copied.
+       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+@@ -209,26 +209,31 @@
+ 
+       //Make sure implemented interfaces from private superclass are inherited
+       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicInterface.html",
+-        "<STRONG>All Known Implementing Classes:</STRONG></DT> <DD><A HREF=\"../pkg/PrivateParent.html\" " +
+-        "title=\"class in pkg\">PrivateParent</A>, " +
+-        "<A HREF=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild</A>"},
++        "<dl>" + NL + "<dt>All Known Implementing Classes:</dt>" + NL +
++        "<dd><a href=\"../pkg/PrivateParent.html\" title=\"class in pkg\">" +
++        "PrivateParent</a>, " +
++        "<a href=\"../pkg/PublicChild.html\" title=\"class in pkg\">PublicChild" +
++        "</a></dd>" + NL + "</dl>"},
+ 
+       {BUG_ID + "-2" + FS + "pkg" + FS + "PublicChild.html",
+-        "<STRONG>All Implemented Interfaces:</STRONG></DT> <DD><A HREF=\"../pkg/PrivateInterface.html\" " +
+-        "title=\"interface in pkg\">PrivateInterface</A>, " +
+-        "<A HREF=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
+-        "PublicInterface</A>"},
++        "<dl>" + NL + "<dt>All Implemented Interfaces:</dt>" + NL +
++        "<dd><a href=\"../pkg/PrivateInterface.html\" title=\"interface in pkg\">" +
++        "PrivateInterface</a>, " +
++        "<a href=\"../pkg/PublicInterface.html\" title=\"interface in pkg\">" +
++        "PublicInterface</a></dd>" + NL + "</dl>"},
+ 
+       //Since private flag is used, we can document that private interface method
+       //with generic parameters has been implemented.
+       {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
+-            "<STRONG>Description copied from interface: " +
+-            "<CODE><A HREF=\"../pkg2/I.html#hello(T)\">I</A></CODE></STRONG>"},
++            "<strong>Description copied from interface:&nbsp;<code>" +
++            "<a href=\"../pkg2/I.html#hello(T)\">I</a></code></strong>"},
+ 
+       {BUG_ID + "-2" + FS + "pkg2" + FS + "C.html",
+-            "<STRONG>Specified by:</STRONG></DT><DD><CODE><A HREF=\"../pkg2/I.html#hello(T)\">" +
+-            "hello</A></CODE> in interface <CODE><A HREF=\"../pkg2/I.html\" " +
+-            "title=\"interface in pkg2\">I</A>"},
++            "<dt><strong>Specified by:</strong></dt>" + NL +
++            "<dd><code><a href=\"../pkg2/I.html#hello(T)\">hello</a></code>" +
++            "&nbsp;in interface&nbsp;<code>" +
++            "<a href=\"../pkg2/I.html\" title=\"interface in pkg2\">I</a>" +
++            "&lt;java.lang.String&gt;</code></dd>"},
+     };
+     private static final String[][] NEGATED_TEST2 = NO_TEST;
+ 
+diff --git a/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java b/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java
+--- openjdk/langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java
++++ openjdk/langtools/test/com/sun/javadoc/testSerializedForm/TestSerializedForm.java
+@@ -47,11 +47,11 @@
+ 
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "serialized-form.html",
+-            "protected java.lang.Object <STRONG>readResolve</STRONG>()"},
++            "protected&nbsp;java.lang.Object&nbsp;readResolve()"},
+         {BUG_ID + FS + "serialized-form.html",
+-            "protected java.lang.Object <STRONG>writeReplace</STRONG>()"},
++            "protected&nbsp;java.lang.Object&nbsp;writeReplace()"},
+         {BUG_ID + FS + "serialized-form.html",
+-            "protected java.lang.Object <STRONG>readObjectNoData</STRONG>()"},
++            "protected&nbsp;java.lang.Object&nbsp;readObjectNoData()"},
+         {BUG_ID + FS + "serialized-form.html",
+             "See Also"},
+     };
+diff --git a/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java b/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
+--- openjdk/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
++++ openjdk/langtools/test/com/sun/javadoc/testSerializedFormDeprecationInfo/TestSerializedFormDeprecationInfo.java
+@@ -41,58 +41,47 @@
+     // Test for normal run of javadoc. The serialized-form.html should
+     // display the inline comments, tags and deprecation information if any.
+     private static final String[][] TEST_CMNT_DEPR = {
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><DL>" + NL +
+-                 "<DT><STRONG>Throws:</STRONG></DT>" + NL + "<DD><CODE>" +
+-                 "java.io.IOException</CODE></DD><DT><STRONG>See Also:</STRONG>" +
+-                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version " +
+-                 "1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I></DD>" +
+-                 "<DD>This field indicates whether the C1 is undecorated." + NL +
+-                 "<P>" + NL + "</DD>" + NL + "<DD>&nbsp;</DD>" + NL +
+-                 "<DD><DL>" + NL + "<DT><STRONG>Since:</STRONG></DT>" + NL +
+-                 "  <DD>1.4</DD>" + NL + "<DT><STRONG>See Also:</STRONG>" +
+-                 "</DT><DD><A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>C1.setUndecorated(boolean)</CODE></A></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
+-                 " 1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
+-                 "</DD><DD>Reads the object stream." + NL + "<P>" + NL +
+-                 "</DD>" + NL + "<DD><DL>" + NL + "<DT><STRONG>Throws:" +
+-                 "</STRONG></DT>" + NL + "<DD><CODE><code>" +
+-                 "IOException</code></CODE></DD>" + NL +
+-                 "<DD><CODE>java.io.IOException</CODE></DD></DL>" + NL +
+-                 "</DD>" + NL + "</DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL +
+-                 "<DD><STRONG>Deprecated.</STRONG>&nbsp;</DD><DD>" +
+-                 "The name for this class." + NL + "<P>" + NL + "</DD>" + NL +
+-                 "<DD>&nbsp;</DD>" + NL + "</DL>"}};
++        {BUG_ID + FS + "serialized-form.html", "<dl>" +
++                 "<dt><span class=\"strong\">Throws:</span></dt>" + NL + "<dd><code>" +
++                 "java.io.IOException</code></dd><dt><span class=\"strong\">See Also:</span>" +
++                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
++                 "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
++                 " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
++                 "<div class=\"block\">This field indicates whether the C1 " +
++                 "is undecorated.</div>" + NL + "&nbsp;" + NL +
++                 "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
++                 "  <dd>1.4</dd>" + NL + "<dt><span class=\"strong\">See Also:</span>" +
++                 "</dt><dd><a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>C1.setUndecorated(boolean)</code></a></dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
++                 "&nbsp;<i>As of JDK version 1.5, replaced by" + NL +
++                 " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL +
++                 "<div class=\"block\">Reads the object stream.</div>" + NL +
++                 "<dl><dt><span class=\"strong\">Throws:</span></dt>" + NL + "<dd><code><code>" +
++                 "IOException</code></code></dd>" + NL +
++                 "<dd><code>java.io.IOException</code></dd></dl>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">Deprecated.</span>" +
++                 "&nbsp;</div>" + NL + "<div class=\"block\">" +
++                 "The name for this class.</div>"}};
+ 
+     // Test with -nocomment option. The serialized-form.html should
+     // not display the inline comments and tags but should display deprecation
+     // information if any.
+     private static final String[][] TEST_NOCMNT = {
+-        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "boolean <STRONG>" +
+-                 "undecorated</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version 1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\"><CODE>" +
+-                 "setUndecorated(boolean)</CODE></A>.</I></DD></DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;<I>As of JDK version" +
++        {BUG_ID + FS + "serialized-form.html", "<pre>boolean undecorated</pre>" + NL +
++                 "<div class=\"block\"><span class=\"strong\">Deprecated.</span>&nbsp;<i>" +
++                 "As of JDK version 1.5, replaced by" + NL +
++                 " <a href=\"pkg1/C1.html#setUndecorated(boolean)\"><code>" +
++                 "setUndecorated(boolean)</code></a>.</i></div>" + NL + "</li>"},
++        {BUG_ID + FS + "serialized-form.html", "<span class=\"strong\">" +
++                 "Deprecated.</span>&nbsp;<i>As of JDK version" +
+                  " 1.5, replaced by" + NL +
+-                 " <A HREF=\"pkg1/C1.html#setUndecorated(boolean)\">" +
+-                 "<CODE>setUndecorated(boolean)</CODE></A>.</I>" + NL + "<P>" + NL +
+-                 "</DD></DL>"},
+-        {BUG_ID + FS + "serialized-form.html", "<PRE>" + NL + "int <STRONG>" +
+-                 "publicKey</STRONG></PRE>" + NL + "<DL>" + NL + "<DD><STRONG>" +
+-                 "Deprecated.</STRONG>&nbsp;</DD></DL>"}};
++                 " <a href=\"pkg1/C1.html#setUndecorated(boolean)\">" +
++                 "<code>setUndecorated(boolean)</code></a>.</i></div>" + NL + "</li>"}};
+ 
+     // Test with -nodeprecated option. The serialized-form.html should
+     // ignore the -nodeprecated tag and display the deprecation info. This
+diff --git a/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java b/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testSimpleTag/TestSimpleTag.java
+@@ -42,13 +42,13 @@
+     private static final String[][] TEST =
+         new String[][] {
+             {"./" + BUG_ID + "/C.html",
+-                "<STRONG>Todo:</STRONG>"},
++                "<span class=\"strong\">Todo:</span>"},
+             {"./" + BUG_ID + "/C.html",
+-                "<STRONG>EJB Beans:</STRONG>"},
++                "<span class=\"strong\">EJB Beans:</span>"},
+             {"./" + BUG_ID + "/C.html",
+-                "<STRONG>Regular Tag:</STRONG>"},
++                "<span class=\"strong\">Regular Tag:</span>"},
+             {"./" + BUG_ID + "/C.html",
+-                "<STRONG>Back-Slash-Tag:</STRONG>"},
++                "<span class=\"strong\">Back-Slash-Tag:</span>"},
+         };
+ 
+     private static final String[] ARGS = new String[] {
+diff --git a/test/com/sun/javadoc/testStylesheet/TestStylesheet.java b/test/com/sun/javadoc/testStylesheet/TestStylesheet.java
+--- openjdk/langtools/test/com/sun/javadoc/testStylesheet/TestStylesheet.java
++++ openjdk/langtools/test/com/sun/javadoc/testStylesheet/TestStylesheet.java
+@@ -45,32 +45,24 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "stylesheet.css",
+-                "body { background-color: #FFFFFF; color:#000000 }"},
++                "/* Javadoc style sheet */"},
+         {BUG_ID + FS + "stylesheet.css",
+-                ".TableHeadingColor     { background: #CCCCFF; color:#000000 }"},
++                "/*" + NL + "Overall document style" + NL + "*/"},
+         {BUG_ID + FS + "stylesheet.css",
+-                ".TableSubHeadingColor  { background: #EEEEFF; color:#000000 }"},
++                "/*" + NL + "Heading styles" + NL + "*/"},
+         {BUG_ID + FS + "stylesheet.css",
+-                ".TableRowColor         { background: #FFFFFF; color:#000000 }"},
++                "/*" + NL + "Navigation bar styles" + NL + "*/"},
+         {BUG_ID + FS + "stylesheet.css",
+-                ".FrameTitleFont   { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 }"},
++                "body {" + NL + "    font-family:Helvetica, Arial, sans-serif;" + NL +
++                "    color:#000000;" + NL + "}"},
+         {BUG_ID + FS + "stylesheet.css",
+-                ".FrameHeadingFont { font-size:  90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }"},
+-        {BUG_ID + FS + "stylesheet.css",
+-                ".FrameItemFont    { font-size:  90%; font-family: Helvetica, Arial, sans-serif; color:#000000 }"},
+-        {BUG_ID + FS + "stylesheet.css",
+-                ".NavBarCell1    { background-color:#EEEEFF; color:#000000}"},
+-        {BUG_ID + FS + "stylesheet.css",
+-                ".NavBarCell1Rev { background-color:#00008B; color:#FFFFFF}"},
+-        {BUG_ID + FS + "stylesheet.css",
+-                ".NavBarFont1    { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;}"},
+-        {BUG_ID + FS + "stylesheet.css",
+-                ".NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;}"},
+-        {BUG_ID + FS + "stylesheet.css",
+-                ".NavBarCell2    { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}"},
+-        {BUG_ID + FS + "stylesheet.css",
+-                ".NavBarCell3    { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000}"},
+-
++                "dl dd ul li {" + NL + "    list-style:none;" + NL +
++                "    margin:10px 0 10px 0;" + NL + "}"},
++        // Test whether a link to the stylesheet file is inserted properly
++        // in the class documentation.
++        {BUG_ID + FS + "pkg" + FS + "A.html",
++                "<link rel=\"stylesheet\" type=\"text/css\" " +
++                "href=\"../stylesheet.css\" title=\"Style\">"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+ 
+diff --git a/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java b/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java
+--- openjdk/langtools/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java
++++ openjdk/langtools/test/com/sun/javadoc/testSummaryHeading/TestSummaryHeading.java
+@@ -46,8 +46,7 @@
+ 
+     //Input for string search tests.
+     private static final String[][] TEST = {
+-        {BUG_ID + FS + "C.html",  "<CAPTION CLASS=\"TableCaption\">" + NL +
+-                 "Method Summary</CAPTION>"}
++        {BUG_ID + FS + "C.html",  "<h3>Method Summary</h3>"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+ 
+diff --git a/test/com/sun/javadoc/testSuperclassInSerialForm/TestSuperClassInSerialForm.java b/test/com/sun/javadoc/testSuperclassInSerialForm/TestSuperClassInSerialForm.java
+--- openjdk/langtools/test/com/sun/javadoc/testSuperclassInSerialForm/TestSuperClassInSerialForm.java
++++ openjdk/langtools/test/com/sun/javadoc/testSuperclassInSerialForm/TestSuperClassInSerialForm.java
+@@ -39,7 +39,7 @@
+ 
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "serialized-form.html",
+-         "<A HREF=\"pkg/SubClass.html\" title=\"class in pkg\">pkg.SubClass</A> extends <A HREF=\"pkg/SuperClass.html\" title=\"class in pkg\">SuperClass</A>"}
++         "<a href=\"pkg/SubClass.html\" title=\"class in pkg\">pkg.SubClass</a> extends <a href=\"pkg/SuperClass.html\" title=\"class in pkg\">SuperClass</a>"}
+     };
+ 
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java b/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java
+--- openjdk/langtools/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java
++++ openjdk/langtools/test/com/sun/javadoc/testTagInheritence/TestTagInheritence.java
+@@ -59,12 +59,12 @@
+         //First sentence test (6253614)
+         tests[tests.length - 2][0] =BUG_ID + FS + "firstSentence" + FS +
+             "B.html";
+-        tests[tests.length - 2][1] =  "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;First sentence.</TD>";
++        tests[tests.length - 2][1] =  "<div class=\"block\">First sentence.</div>";
+ 
+         //Another first sentence test (6253604)
+         tests[tests.length - 1][0] =BUG_ID + FS + "firstSentence2" + FS +
+             "C.html";
+-        tests[tests.length - 1][1] =  "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;First sentence.</TD>";
++        tests[tests.length - 1][1] =  "<div class=\"block\">First sentence.</div>";
+ 
+         TestTagInheritence tester = new TestTagInheritence();
+         run(tester, ARGS, tests, NO_TEST);
+diff --git a/test/com/sun/javadoc/testTaglets/TestTaglets.java b/test/com/sun/javadoc/testTaglets/TestTaglets.java
+--- openjdk/langtools/test/com/sun/javadoc/testTaglets/TestTaglets.java
++++ openjdk/langtools/test/com/sun/javadoc/testTaglets/TestTaglets.java
+@@ -55,13 +55,15 @@
+ 
+     //Input for string search tests.
+     private static final String[][] TEST_4654308 = new String[][] {
+-        {"4654308" + FS + "C.html", "<B>Foo:</B><DD>my only method is " +
            "<A HREF=\"C.html#method()\"><CODE>here</CODE></A>"}
++        {"4654308" + FS + "C.html", "<span class=\"strong\">Foo:</span></dt>" +
++                 "<dd>my only method is <a href=\"C.html#method()\"><code>here" +
++                 "</code></a></dd></dl>"}
+     };
+     private static final String[][] NEGATED_TEST_4654308 = NO_TEST;
+ 
+     private static final String[][] TEST_4767038 = new String[][] {
+         {"4767038" + FS + "Child.html",
+-            "&nbsp;This is the first sentence.</TD>"}
++            "This is the first sentence."}
+     };
+     private static final String[][] NEGATED_TEST_4767038 = NO_TEST;
+ 
+diff --git a/test/com/sun/javadoc/testTaglets/taglets/Foo.java b/test/com/sun/javadoc/testTaglets/taglets/Foo.java
+--- openjdk/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java
++++ openjdk/langtools/test/com/sun/javadoc/testTaglets/taglets/Foo.java
+@@ -50,9 +50,9 @@
+      */
+     public TagletOutput getTagletOutput(Tag tag, TagletWriter writer) {
+         ArrayList inlineTags = new ArrayList();
+-        inlineTags.add(new TextTag(tag.holder(), "<DT><B>Foo:</B><DD>"));
++        inlineTags.add(new TextTag(tag.holder(), "<dt><span class=\"strong\">Foo:</span></dt><dd>"));
+         inlineTags.addAll(Arrays.asList(tag.inlineTags()));
+-        inlineTags.add(new TextTag(tag.holder(), "</DD>"));
++        inlineTags.add(new TextTag(tag.holder(), "</dd>"));
+         return writer.commentTagsToOutput(tag,
+                 (Tag[]) inlineTags.toArray(new Tag[] {}));
+     }
+diff --git a/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java b/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java
+--- openjdk/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java
++++ openjdk/langtools/test/com/sun/javadoc/testThrowsHead/TestThrowsHead.java
+@@ -38,7 +38,7 @@
+ 
+     private static final String BUG_ID = "4530727";
+     private static final String[][] TEST = {
+-        {BUG_ID + FS + "C.html", "<DT><STRONG>Throws:</STRONG>"}
++        {BUG_ID + FS + "C.html", "<dt><span class=\"strong\">Throws:</span>"}
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+     private static final String[] ARGS = new String[] {
+diff --git a/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java b/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testThrowsTag/TestThrowsTag.java
+@@ -46,14 +46,14 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<DD><CODE><A HREF=\"../pkg/T1.html\" title=\"class in pkg\">T1</A></CODE> - the first throws tag.</DD>" + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T2.html\" title=\"class in pkg\">T2</A></CODE> - the second throws tag.</DD>" + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T3.html\" title=\"class in pkg\">T3</A></CODE> - the third throws tag.</DD>" + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T4.html\" title=\"class in pkg\">T4</A></CODE> - the fourth throws tag.</DD>" + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T5.html\" title=\"class in pkg\">T5</A></CODE> - the first inherited throws tag.</DD>" + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T6.html\" title=\"class in pkg\">T6</A></CODE> - the second inherited throws tag.</DD>" + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T7.html\" title=\"class in pkg\">T7</A></CODE> - the third inherited throws tag.</DD>" + NL +
+-            "<DD><CODE><A HREF=\"../pkg/T8.html\" title=\"class in pkg\">T8</A></CODE> - the fourth inherited throws tag.</DD>"
++            "<dd><code><a href=\"../pkg/T1.html\" title=\"class in pkg\">T1</a></code> - the first throws tag.</dd>" + NL +
++            "<dd><code><a href=\"../pkg/T2.html\" title=\"class in pkg\">T2</a></code> - the second throws tag.</dd>" + NL +
++            "<dd><code><a href=\"../pkg/T3.html\" title=\"class in pkg\">T3</a></code> - the third throws tag.</dd>" + NL +
++            "<dd><code><a href=\"../pkg/T4.html\" title=\"class in pkg\">T4</a></code> - the fourth throws tag.</dd>" + NL +
++            "<dd><code><a href=\"../pkg/T5.html\" title=\"class in pkg\">T5</a></code> - the first inherited throws tag.</dd>" + NL +
++            "<dd><code><a href=\"../pkg/T6.html\" title=\"class in pkg\">T6</a></code> - the second inherited throws tag.</dd>" + NL +
++            "<dd><code><a href=\"../pkg/T7.html\" title=\"class in pkg\">T7</a></code> - the third inherited throws tag.</dd>" + NL +
++            "<dd><code><a href=\"../pkg/T8.html\" title=\"class in pkg\">T8</a></code> - the fourth inherited throws tag.</dd>"
+         },
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testTitleInHref/TestTitleInHref.java b/test/com/sun/javadoc/testTitleInHref/TestTitleInHref.java
+--- openjdk/langtools/test/com/sun/javadoc/testTitleInHref/TestTitleInHref.java
++++ openjdk/langtools/test/com/sun/javadoc/testTitleInHref/TestTitleInHref.java
+@@ -38,13 +38,13 @@
+ 
+     private static final String[][] TEST = {
+         //Test to make sure that the title shows up in a class link.
+-        {BUG_ID + FS + "pkg" + FS + "Links.html", "<A HREF=\"../pkg/Class.html\" title=\"class in pkg\">"},
++        {BUG_ID + FS + "pkg" + FS + "Links.html", "<a href=\"../pkg/Class.html\" title=\"class in pkg\">"},
+ 
+         //Test to make sure that the title shows up in an interface link.
+-        {BUG_ID + FS + "pkg" + FS + "Links.html", "<A HREF=\"../pkg/Interface.html\" title=\"interface in pkg\">"},
++        {BUG_ID + FS + "pkg" + FS + "Links.html", "<a href=\"../pkg/Interface.html\" title=\"interface in pkg\">"},
+ 
+         //Test to make sure that the title shows up in cross link shows up
+-        {BUG_ID + FS + "pkg" + FS + "Links.html", "<A HREF=\"http://java.sun.com/j2se/1.4/docs/api/java/io/File.html?is-external=true\" title=\"class or interface in java.io\"><CODE>This is a cross link to class File</CODE></A>"},
++        {BUG_ID + FS + "pkg" + FS + "Links.html", "<a href=\"http://java.sun.com/j2se/1.4/docs/api/java/io/File.html?is-external=true\" title=\"class or interface in java.io\"><code>This is a cross link to class File</code></a>"},
+ 
+     };
+ 
+diff --git a/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java b/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java
+--- openjdk/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java
++++ openjdk/langtools/test/com/sun/javadoc/testTypeParams/TestTypeParameters.java
+@@ -49,16 +49,17 @@
+     private static final String[][] TEST =
+     {
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<CODE>&lt;W extends java.lang.String,V extends java.util.List&gt; " + NL +
+-            "<BR>" + NL +
+-            "java.lang.Object</CODE>"},
++            "<td class=\"colFirst\"><code>&lt;W extends java.lang.String,V extends " +
++            "java.util.List&gt;&nbsp;<br>java.lang.Object</code></td>"},
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<CODE>&lt;T&gt; java.lang.Object</CODE>"},
++            "<code>&lt;T&gt;&nbsp;java.lang.Object</code>"},
+         {BUG_ID + FS + "pkg" + FS + "package-summary.html",
+             "C&lt;E extends Parent&gt;"},
+         //Nested type parameters
+         {BUG_ID + FS + "pkg" + FS + "C.html",
+-            "<A NAME=\"formatDetails(java.util.Collection, java.util.Collection)\"><!-- --></A>"},
++            "<a name=\"formatDetails(java.util.Collection, java.util.Collection)\">" + NL +
++            "<!--   -->" + NL +
++            "</a>"},
+ 
+     };
+     private static final String[][] NEGATED_TEST = NO_TEST;
+diff --git a/test/com/sun/javadoc/testUnnamedPackage/TestUnnamedPackage.java b/test/com/sun/javadoc/testUnnamedPackage/TestUnnamedPackage.java
+--- openjdk/langtools/test/com/sun/javadoc/testUnnamedPackage/TestUnnamedPackage.java
++++ openjdk/langtools/test/com/sun/javadoc/testUnnamedPackage/TestUnnamedPackage.java
+@@ -46,7 +46,7 @@
+     //Input for string search tests.
+     private static final String[][] TEST = {
+         {BUG_ID + FS + "package-summary.html",
+-            "<H2>"+NL+"Package &lt;Unnamed&gt;"+NL+"</H2>"
++            "<h1 title=\"Package\" class=\"title\">Package&nbsp;&lt;Unnamed&gt;</h1>"
+         },
+         {BUG_ID + FS + "package-summary.html",
+             "This is a package comment for the unnamed package."
+@@ -55,12 +55,12 @@
+             "This is a class in the unnamed package."
+         },
+         {BUG_ID + FS + "package-tree.html",
+-            "<H2>"+NL+"Hierarchy For Package &lt;Unnamed&gt;"+NL+"</H2>"
++            "<h1 class=\"title\">Hierarchy For Package &lt;Unnamed&gt;</h1>"
+         },
+         {BUG_ID + FS + "index-all.html",
+             "title=\"class in &lt;Unnamed&gt;\""
+         },
+-        {BUG_ID + FS + "C.html", "<A HREF=\"package-summary.html\">"}
++        {BUG_ID + FS + "C.html", "<a href=\"package-summary.html\">"}
+     };
+     private static final String[][] NEGATED_TEST = {
+         {ERROR_OUTPUT, "BadSource"},
+diff --git a/test/com/sun/javadoc/testValueTag/TestValueTag.java b/test/com/sun/javadoc/testValueTag/TestValueTag.java
+--- openjdk/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java
++++ openjdk/langtools/test/com/sun/javadoc/testValueTag/TestValueTag.java
+@@ -52,44 +52,44 @@
+             "Result:  \"Test 1 passes\""},
+         //Retrieve value of constant in same class.
+         {BUG_ID + FS + "pkg1" + FS + "Class1.html",
+-            "Result:  <A HREF=\"../pkg1/Class1.html#TEST_2_PASSES\">\"Test 2 passes\"</A>"},
++            "Result:  <a href=\"../pkg1/Class1.html#TEST_2_PASSES\">\"Test 2 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class1.html",
+-            "Result:  <A HREF=\"../pkg1/Class1.html#TEST_3_PASSES\">\"Test 3 passes\"</A>"},
++            "Result:  <a href=\"../pkg1/Class1.html#TEST_3_PASSES\">\"Test 3 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class1.html",
+-            "Result:  <A HREF=\"../pkg1/Class1.html#TEST_4_PASSES\">\"Test 4 passes\"</A>"},
++            "Result:  <a href=\"../pkg1/Class1.html#TEST_4_PASSES\">\"Test 4 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class1.html",
+-            "Result:  <A HREF=\"../pkg1/Class1.html#TEST_5_PASSES\">\"Test 5 passes\"</A>"},
++            "Result:  <a href=\"../pkg1/Class1.html#TEST_5_PASSES\">\"Test 5 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class1.html",
+-            "Result:  <A HREF=\"../pkg1/Class1.html#TEST_6_PASSES\">\"Test 6 passes\"</A>"},
++            "Result:  <a href=\"../pkg1/Class1.html#TEST_6_PASSES\">\"Test 6 passes\"</a>"},
+         //Retrieve value of constant in different class.
+         {BUG_ID + FS + "pkg1" + FS + "Class2.html",
+-            "Result:  <A HREF=\"../pkg1/Class1.html#TEST_7_PASSES\">\"Test 7 passes\"</A>"},
++            "Result:  <a href=\"../pkg1/Class1.html#TEST_7_PASSES\">\"Test 7 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class2.html",
+-            "Result:  <A HREF=\"../pkg1/Class1.html#TEST_8_PASSES\">\"Test 8 passes\"</A>"},
++            "Result:  <a href=\"../pkg1/Class1.html#TEST_8_PASSES\">\"Test 8 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class2.html",
+-            "Result:  <A HREF=\"../pkg1/Class1.html#TEST_9_PASSES\">\"Test 9 passes\"</A>"},
++            "Result:  <a href=\"../pkg1/Class1.html#TEST_9_PASSES\">\"Test 9 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class2.html",
+-            "Result:  <A HREF=\"../pkg1/Class1.html#TEST_10_PASSES\">\"Test 10 passes\"</A>"},
++            "Result:  <a href=\"../pkg1/Class1.html#TEST_10_PASSES\">\"Test 10 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class2.html",
+-            "Result:  <A HREF=\"../pkg1/Class1.html#TEST_11_PASSES\">\"Test 11 passes\"</A>"},
++            "Result:  <a href=\"../pkg1/Class1.html#TEST_11_PASSES\">\"Test 11 passes\"</a>"},
+         //Retrieve value of constant in different package
+         {BUG_ID + FS + "pkg1" + FS + "Class2.html",
+-            "Result:  <A HREF=\"../pkg2/Class3.html#TEST_12_PASSES\">\"Test 12 passes\"</A>"},
++            "Result:  <a href=\"../pkg2/Class3.html#TEST_12_PASSES\">\"Test 12 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class2.html",
+-            "Result:  <A HREF=\"../pkg2/Class3.html#TEST_13_PASSES\">\"Test 13 passes\"</A>"},
++            "Result:  <a href=\"../pkg2/Class3.html#TEST_13_PASSES\">\"Test 13 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class2.html",
+-            "Result:  <A HREF=\"../pkg2/Class3.html#TEST_14_PASSES\">\"Test 14 passes\"</A>"},
++            "Result:  <a href=\"../pkg2/Class3.html#TEST_14_PASSES\">\"Test 14 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class2.html",
+-            "Result:  <A HREF=\"../pkg2/Class3.html#TEST_15_PASSES\">\"Test 15 passes\"</A>"},
++            "Result:  <a href=\"../pkg2/Class3.html#TEST_15_PASSES\">\"Test 15 passes\"</a>"},
+         {BUG_ID + FS + "pkg1" + FS + "Class2.html",
+-            "Result:  <A HREF=\"../pkg2/Class3.html#TEST_16_PASSES\">\"Test 16 passes\"</A>"},
++            "Result:  <a href=\"../pkg2/Class3.html#TEST_16_PASSES\">\"Test 16 passes\"</a>"},
+         //Retrieve value of constant from a package page
+         {BUG_ID + FS + "pkg2" + FS + "package-summary.html",
+-            "Result: <A HREF=\"../pkg2/Class3.html#TEST_17_PASSES\">\"Test 17 passes\"</A>"},
++            "Result: <a href=\"../pkg2/Class3.html#TEST_17_PASSES\">\"Test 17 passes\"</a>"},
+         //Test @value tag used with custom tag.
+         {BUG_ID + FS + "pkg1" + FS + "CustomTagUsage.html",
+-            "<DT><STRONG>Todo:</STRONG></DT>" + NL +
+-                "  <DD>the value of this constant is 55.</DD>"},
++            "<dt><span class=\"strong\">Todo:</span></dt>" + NL +
++                "  <dd>the value of this constant is 55.</dd>"},
+         //Test @value warning printed when used with non-constant.
+         {WARNING_OUTPUT,"warning - @value tag (which references nonConstant) " +
+             "can only be used in constants."
+diff --git a/test/com/sun/javadoc/testWarnings/TestWarnings.java b/test/com/sun/javadoc/testWarnings/TestWarnings.java
+--- openjdk/langtools/test/com/sun/javadoc/testWarnings/TestWarnings.java
++++ openjdk/langtools/test/com/sun/javadoc/testWarnings/TestWarnings.java
+@@ -65,9 +65,9 @@
+     };
+ 
+     private static final String[][] TEST2 = {
+-        {BUG_ID + FS + "pkg" + FS + "X.html", "<A HREF=\"../pkg/X.html#m()\"><CODE>m()</CODE></A><br/>"},
+-        {BUG_ID + FS + "pkg" + FS + "X.html", "<A HREF=\"../pkg/X.html#X()\"><CODE>X()</CODE></A><br/>"},
+-        {BUG_ID + FS + "pkg" + FS + "X.html", "<A HREF=\"../pkg/X.html#f\"><CODE>f</CODE></A><br/>"},
++        {BUG_ID + FS + "pkg" + FS + "X.html", "<a href=\"../pkg/X.html#m()\"><code>m()</code></a><br/>"},
++        {BUG_ID + FS + "pkg" + FS + "X.html", "<a href=\"../pkg/X.html#X()\"><code>X()</code></a><br/>"},
++        {BUG_ID + FS + "pkg" + FS + "X.html", "<a href=\"../pkg/X.html#f\"><code>f</code></a><br/>"},
+     };
+ 
+     private static final String[][] NEGATED_TEST2 = NO_TEST;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6888167-medialib_memory_leaks.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,134 @@
+# HG changeset patch
+# User bae
+# Date 1256300510 -14400
+# Node ID 0f5e355fe68c0ff29e28a962199185e4bd3d7e04
+# Parent  55257a533c9553d99e90e7b82affab14d5d6b056
+6888167: memory leaks in the medialib glue code
+Reviewed-by: igor, prr
+
+diff --git a/src/share/native/sun/awt/medialib/awt_ImagingLib.c b/src/share/native/sun/awt/medialib/awt_ImagingLib.c
+--- openjdk/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
++++ openjdk/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
+@@ -961,21 +961,15 @@
+     mlib_filter filter;
+     unsigned int *dP;
+ 
+-    if ((srcRasterP = (RasterS_t *) calloc(1, sizeof(RasterS_t))) == NULL) {
+-        JNU_ThrowOutOfMemoryError(env, "Out of memory");
+-        return -1;
+-    }
+-
+-    if ((dstRasterP = (RasterS_t *) calloc(1, sizeof(RasterS_t))) == NULL) {
+-        JNU_ThrowOutOfMemoryError(env, "Out of memory");
+-        free(srcRasterP);
+-        return -1;
+-    }
+-
+     /* This function requires a lot of local refs ??? Is 64 enough ??? */
+     if ((*env)->EnsureLocalCapacity(env, 64) < 0)
+         return 0;
+ 
++    if (s_nomlib) return 0;
++    if (s_timeIt) {
++        (*start_timer)(3600);
++    }
++
+     switch(interpType) {
+     case java_awt_image_AffineTransformOp_TYPE_BILINEAR:
+         filter = MLIB_BILINEAR;
+@@ -991,9 +985,15 @@
+         return -1;
+     }
+ 
+-    if (s_nomlib) return 0;
+-    if (s_timeIt) {
+-        (*start_timer)(3600);
++    if ((srcRasterP = (RasterS_t *) calloc(1, sizeof(RasterS_t))) == NULL) {
++        JNU_ThrowOutOfMemoryError(env, "Out of memory");
++        return -1;
++    }
++
++    if ((dstRasterP = (RasterS_t *) calloc(1, sizeof(RasterS_t))) == NULL) {
++        JNU_ThrowOutOfMemoryError(env, "Out of memory");
++        free(srcRasterP);
++        return -1;
+     }
+ 
+     if ((*env)->GetArrayLength(env, jmatrix) < 6) {
+@@ -1216,6 +1216,9 @@
+     }
+ 
+     if (tbl == NULL || table == NULL || jtable == NULL) {
++        if (tbl != NULL) free(tbl);
++        if (table != NULL) free(table);
++        if (jtable != NULL) free(jtable);
+         awt_freeParsedImage(srcImageP, TRUE);
+         awt_freeParsedImage(dstImageP, TRUE);
+         JNU_ThrowNullPointerException(env, "NULL LUT");
+@@ -1225,6 +1228,11 @@
+     for (i=0; i < jlen; i++) {
+         jtable[i] = (*env)->GetObjectArrayElement(env, jtableArrays, i);
+         if (jtable[i] == NULL) {
++            free(tbl);
++            free(table);
++            free(jtable);
++            awt_freeParsedImage(srcImageP, TRUE);
++            awt_freeParsedImage(dstImageP, TRUE);
+             return 0;
+         }
+     }
+@@ -1233,6 +1241,9 @@
+                         FALSE, &hint);
+     if (nbands < 1) {
+         /* Can't handle any custom images */
++        free(tbl);
++        free(table);
++        free(jtable);
+         awt_freeParsedImage(srcImageP, TRUE);
+         awt_freeParsedImage(dstImageP, TRUE);
+         return 0;
+@@ -1241,12 +1252,18 @@
+     /* Allocate the arrays */
+     if (allocateArray(env, srcImageP, &src, &sdata, TRUE, FALSE, FALSE) < 0) {
+         /* Must be some problem */
++        free(tbl);
++        free(table);
++        free(jtable);
+         awt_freeParsedImage(srcImageP, TRUE);
+         awt_freeParsedImage(dstImageP, TRUE);
+         return 0;
+     }
+     if (allocateArray(env, dstImageP, &dst, &ddata, FALSE, FALSE, FALSE) < 0) {
+         /* Must be some problem */
++        free(tbl);
++        free(table);
++        free(jtable);
+         freeArray(env, srcImageP, src, sdata, NULL, NULL, NULL);
+         awt_freeParsedImage(srcImageP, TRUE);
+         awt_freeParsedImage(dstImageP, TRUE);
+@@ -1285,6 +1302,9 @@
+                                                       (jbyte *) table[j],
+                                                       JNI_ABORT);
+             }
++            free(tbl);
++            free(table);
++            free(jtable);
+             freeArray(env, srcImageP, src, sdata, NULL, NULL, NULL);
+             awt_freeParsedImage(srcImageP, TRUE);
+             awt_freeParsedImage(dstImageP, TRUE);
+@@ -1414,12 +1434,15 @@
+ 
+     /* Parse the source raster - reject custom images */
+     if ((status = awt_parseRaster(env, jsrc, srcRasterP)) <= 0) {
++        free(srcRasterP);
++        free(dstRasterP);
+         return 0;
+     }
+ 
+     /* Parse the destination image - reject custom images */
+     if ((status = awt_parseRaster(env, jdst, dstRasterP)) <= 0) {
+         awt_freeParsedRaster(srcRasterP, TRUE);
++        free(dstRasterP);
+         return 0;
+     }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6961178-doclet_xml.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,1989 @@
+# HG changeset patch
+# User andrew
+# Date 1371665441 18000
+# Node ID c9c59391b86f45e4af2a89d95e1ba83ffdaf1d66
+# Parent  694e895f2b866d36ed7f8d4ea08ec64677d3fba1
+6961178: Allow doclet.xml to contain XML attributes
+Reviewed-by: bpatel
+
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
+@@ -92,44 +92,42 @@
+     public abstract void build() throws IOException;
+ 
+     /**
+-     * Build the documentation, as specified by the given XML elements.
++     * Build the documentation, as specified by the given XML element.
+      *
+-     * @param elements the XML elements that specify which components to
+-     *                 document.
++     * @param node the XML element that specifies which component to document.
+      */
+-    protected void build(List elements) {
+-        for (int i = 0; i < elements.size(); i++ ) {
+-            Object element = elements.get(i);
+-            String component = (String)
+-                ((element instanceof String) ?
+-                     element :
+-                    ((List) element).get(0));
+-            try {
+-                invokeMethod("build" + component,
+-                    element instanceof String ?
+-                        new Class[] {} :
+-                        new Class[] {List.class},
+-                    element instanceof String ?
+-                        new Object[] {} :
+-                        new Object[] {((List) element).subList(1,
+-                            ((List) element).size())});
+-            } catch (NoSuchMethodException e) {
+-                e.printStackTrace();
+-                configuration.root.printError("Unknown element: " + component);
+-                throw new DocletAbortException();
+-            } catch (InvocationTargetException e) {
+-                e.getCause().printStackTrace();
+-            } catch (Exception e) {
+-                e.printStackTrace();
+-                configuration.root.printError("Exception " +
+-                    e.getClass().getName() +
+-                    " thrown while processing element: " + component);
+-                throw new DocletAbortException();
+-            }
++    protected void build(XMLNode node) {
++        String component = node.name;
++        try {
++            invokeMethod("build" + component,
++                    new Class<?>[] { XMLNode.class },
++                    new Object[] { node });
++        } catch (NoSuchMethodException e) {
++            e.printStackTrace();
++            configuration.root.printError("Unknown element: " + component);
++            throw new DocletAbortException();
++        } catch (InvocationTargetException e) {
++            e.getCause().printStackTrace();
++        } catch (Exception e) {
++            e.printStackTrace();
++            configuration.root.printError("Exception " +
++                e.getClass().getName() +
++                " thrown while processing element: " + component);
++            throw new DocletAbortException();
+         }
+     }
+ 
+     /**
++     * Build the documentation, as specified by the children of the given XML element.
++     *
++     * @param node the XML element that specifies which components to document.
++     */
++    protected void buildChildren(XMLNode node) {
++        for (XMLNode child: node.children)
++            build(child);
++    }
++
++    /**
+      * Given the name and parameters, invoke the method in the builder.  This
+      * method is required to invoke the appropriate build method as instructed
+      * by the builder XML file.
+@@ -138,7 +136,14 @@
+      * @param paramClasses the types for each parameter.
+      * @param params       the parameters of the method.
+      */
+-    protected abstract void invokeMethod(String methodName, Class[] paramClasses,
+-            Object[] params)
+-    throws Exception;
++    protected void invokeMethod(String methodName, Class<?>[] paramClasses,
++             Object[] params)
++    throws Exception {
++        if (DEBUG) {
++            configuration.root.printError("DEBUG: " + this.getClass().getName()
++                + "." + methodName);
++        }
++        Method method = this.getClass().getMethod(methodName, paramClasses);
++        method.invoke(this, params);
++    }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractMemberBuilder.java
+@@ -27,7 +27,6 @@
+ 
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+-import java.util.*;
+ 
+ /**
+  * The superclass for all member builders.  Member builders are only executed
+@@ -69,9 +68,10 @@
+      *
+      * @param elements {@inheritDoc}
+      */
+-    public void build(List elements) {
++    @Override
++    public void build(XMLNode node) {
+         if (hasMembersToDocument()) {
+-            super.build(elements);
++            super.build(node);
+         }
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeBuilder.java
+@@ -30,7 +30,6 @@
+ import com.sun.javadoc.*;
+ import java.io.*;
+ import java.util.*;
+-import java.lang.reflect.*;
+ 
+ /**
+  * Builds the summary for a given annotation type.
+@@ -92,20 +91,6 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void invokeMethod(String methodName, Class[] paramClasses,
+-            Object[] params)
+-    throws Exception {
+-        if (DEBUG) {
+-            configuration.root.printError("DEBUG: " + this.getClass().getName()
+-                + "." + methodName);
+-        }
+-        Method method = this.getClass().getMethod(methodName, paramClasses);
+-        method.invoke(this, params);
+-    }
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+     public void build() throws IOException {
+         build(LayoutParser.getInstance(configuration).parseXML(ROOT));
+     }
+@@ -122,8 +107,8 @@
+       *
+       * @param elements the XML elements that specify how to document a class.
+       */
+-     public void buildAnnotationTypeDoc(List elements) throws Exception {
+-        build(elements);
++     public void buildAnnotationTypeDoc(XMLNode node) throws Exception {
++        buildChildren(node);
+         writer.close();
+         copyDocFiles();
+      }
+@@ -154,7 +139,7 @@
+     /**
+      * Build the header of the page.
+      */
+-    public void buildAnnotationTypeHeader() {
++    public void buildAnnotationTypeHeader(XMLNode node) {
+         writer.writeHeader(configuration.getText("doclet.AnnotationType") +
+             " " + annotationTypeDoc.name());
+     }
+@@ -162,14 +147,14 @@
+     /**
+      * If this class is deprecated, print the appropriate information.
+      */
+-    public void buildDeprecationInfo () {
++    public void buildDeprecationInfo (XMLNode node) {
+         writer.writeAnnotationTypeDeprecationInfo();
+     }
+ 
+     /**
+      * Build the signature of the current annotation type.
+      */
+-    public void buildAnnotationTypeSignature() {
++    public void buildAnnotationTypeSignature(XMLNode node) {
+         StringBuffer modifiers = new StringBuffer(
+             annotationTypeDoc.modifiers() + " ");
+         writer.writeAnnotationTypeSignature(
+@@ -180,14 +165,14 @@
+     /**
+      * Build the class description.
+      */
+-    public void buildAnnotationTypeDescription() {
++    public void buildAnnotationTypeDescription(XMLNode node) {
+        writer.writeAnnotationTypeDescription();
+     }
+ 
+     /**
+      * Build the tag information for the current class.
+      */
+-    public void buildAnnotationTypeTagInfo() {
++    public void buildAnnotationTypeTagInfo(XMLNode node) {
+        writer.writeAnnotationTypeTagInfo();
+     }
+ 
+@@ -197,9 +182,9 @@
+      * @param elements the XML elements that specify how a member summary is
+      *                 documented.
+      */
+-    public void buildMemberSummary(List elements) throws Exception {
++    public void buildMemberSummary(XMLNode node) throws Exception {
+         configuration.getBuilderFactory().
+-            getMemberSummaryBuilder(writer).build(elements);
++            getMemberSummaryBuilder(writer).buildChildren(node);
+         writer.completeMemberSummaryBuild();
+     }
+ 
+@@ -209,10 +194,10 @@
+      * @param elements the XML elements that specify how a annotation type
+      *                 members are documented.
+      */
+-    public void buildAnnotationTypeOptionalMemberDetails(List elements)
++    public void buildAnnotationTypeOptionalMemberDetails(XMLNode node)
+     throws Exception {
+         configuration.getBuilderFactory().
+-            getAnnotationTypeOptionalMemberBuilder(writer).build(elements);
++            getAnnotationTypeOptionalMemberBuilder(writer).buildChildren(node);
+     }
+ 
+     /**
+@@ -221,17 +206,17 @@
+      * @param elements the XML elements that specify how a annotation type
+      *                 members are documented.
+      */
+-    public void buildAnnotationTypeRequiredMemberDetails(List elements)
++    public void buildAnnotationTypeRequiredMemberDetails(XMLNode node)
+     throws Exception {
+         configuration.getBuilderFactory().
+-            getAnnotationTypeRequiredMemberBuilder(writer).build(elements);
++            getAnnotationTypeRequiredMemberBuilder(writer).buildChildren(node);
+     }
+ 
+ 
+     /**
+      * Build the footer of the page.
+      */
+-    public void buildAnnotationTypeFooter() {
++    public void buildAnnotationTypeFooter(XMLNode node) {
+         writer.writeFooter();
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java
+@@ -30,7 +30,6 @@
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+ import java.util.*;
+-import java.lang.reflect.*;
+ 
+ /**
+  * Builds documentation for optional annotation type members.
+@@ -85,6 +84,7 @@
+     /**
+      * {@inheritDoc}
+      */
++    @Override
+     public String getName() {
+         return "AnnotationTypeOptionalMemberDetails";
+     }
+@@ -95,34 +95,20 @@
+      * @param elements the XML elements that specify how to construct this
+      *                documentation.
+      */
+-    public void buildAnnotationTypeOptionalMember(List elements) {
++    public void buildAnnotationTypeOptionalMember(XMLNode node) {
+         if (writer == null) {
+             return;
+         }
+         for (currentMemberIndex = 0; currentMemberIndex < members.size();
+             currentMemberIndex++) {
+-            build(elements);
++            buildChildren(node);
+         }
+     }
+ 
+     /**
+-     * {@inheritDoc}
+-     */
+-    public void invokeMethod(String methodName, Class[] paramClasses,
+-            Object[] params)
+-    throws Exception {
+-        if (DEBUG) {
+-            configuration.root.printError("DEBUG: " + this.getClass().getName()
+-                + "." + methodName);
+-        }
+-        Method method = this.getClass().getMethod(methodName, paramClasses);
+-        method.invoke(this, params);
+-    }
+-
+-    /**
+      * Document the default value for this optional member.
+      */
+-    public void buildDefaultValueInfo() {
++    public void buildDefaultValueInfo(XMLNode node) {
+         ((AnnotationTypeOptionalMemberWriter) writer).writeDefaultValueInfo(
+             (MemberDoc) members.get(currentMemberIndex));
+     }
+@@ -130,6 +116,7 @@
+     /**
+      * {@inheritDoc}
+      */
++    @Override
+     public AnnotationTypeRequiredMemberWriter getWriter() {
+         return writer;
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java
+@@ -30,7 +30,6 @@
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+ import java.util.*;
+-import java.lang.reflect.*;
+ 
+ /**
+  * Builds documentation for required annotation type members.
+@@ -114,20 +113,6 @@
+     }
+ 
+     /**
+-     * {@inheritDoc}
+-     */
+-    public void invokeMethod(String methodName, Class[] paramClasses,
+-            Object[] params)
+-    throws Exception {
+-        if (DEBUG) {
+-            configuration.root.printError("DEBUG: " + this.getClass().getName()
+-                + "." + methodName);
+-        }
+-        Method method = this.getClass().getMethod(methodName, paramClasses);
+-        method.invoke(this, params);
+-    }
+-
+-    /**
+      * Returns a list of members that will be documented for the given class.
+      * This information can be used for doclet specific documentation
+      * generation.
+@@ -161,20 +146,20 @@
+      * @param elements the XML elements that specify how to construct this
+      *                documentation.
+      */
+-    public void buildAnnotationTypeRequiredMember(List elements) {
++    public void buildAnnotationTypeRequiredMember(XMLNode node) {
+         if (writer == null) {
+             return;
+         }
+         for (currentMemberIndex = 0; currentMemberIndex < members.size();
+             currentMemberIndex++) {
+-            build(elements);
++            buildChildren(node);
+         }
+     }
+ 
+     /**
+      * Build the overall header.
+      */
+-    public void buildHeader() {
++    public void buildHeader(XMLNode node) {
+         writer.writeHeader(classDoc,
+             configuration.getText("doclet.Annotation_Type_Member_Detail"));
+     }
+@@ -182,7 +167,7 @@
+     /**
+      * Build the header for the individual members.
+      */
+-    public void buildMemberHeader() {
++    public void buildMemberHeader(XMLNode node) {
+         writer.writeMemberHeader((MemberDoc) members.get(
+                 currentMemberIndex),
+             currentMemberIndex == 0);
+@@ -191,14 +176,14 @@
+     /**
+      * Build the signature.
+      */
+-    public void buildSignature() {
++    public void buildSignature(XMLNode node) {
+         writer.writeSignature((MemberDoc) members.get(currentMemberIndex));
+     }
+ 
+     /**
+      * Build the deprecation information.
+      */
+-    public void buildDeprecationInfo() {
++    public void buildDeprecationInfo(XMLNode node) {
+         writer.writeDeprecated((MemberDoc) members.get(currentMemberIndex));
+     }
+ 
+@@ -206,7 +191,7 @@
+      * Build the comments for the member.  Do nothing if
+      * {@link Configuration#nocomment} is set to true.
+      */
+-    public void buildMemberComments() {
++    public void buildMemberComments(XMLNode node) {
+         if(! configuration.nocomment){
+             writer.writeComments((MemberDoc) members.get(currentMemberIndex));
+         }
+@@ -215,21 +200,21 @@
+     /**
+      * Build the tag information.
+      */
+-    public void buildTagInfo() {
++    public void buildTagInfo(XMLNode node) {
+         writer.writeTags((MemberDoc) members.get(currentMemberIndex));
+     }
+ 
+     /**
+      * Build the footer for the individual member.
+      */
+-    public void buildMemberFooter() {
++    public void buildMemberFooter(XMLNode node) {
+         writer.writeMemberFooter();
+     }
+ 
+     /**
+      * Build the overall footer.
+      */
+-    public void buildFooter() {
++    public void buildFooter(XMLNode node) {
+         writer.writeFooter(classDoc);
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java
+@@ -30,7 +30,6 @@
+ import com.sun.javadoc.*;
+ import java.io.*;
+ import java.util.*;
+-import java.lang.reflect.*;
+ 
+ /**
+  * Builds the summary for a given class.
+@@ -108,20 +107,6 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void invokeMethod(String methodName, Class[] paramClasses,
+-            Object[] params)
+-    throws Exception {
+-        if (DEBUG) {
+-            configuration.root.printError("DEBUG: " + this.getClass().getName()
+-                + "." + methodName);
+-        }
+-        Method method = this.getClass().getMethod(methodName, paramClasses);
+-        method.invoke(this, params);
+-    }
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+     public void build() throws IOException {
+         build(LayoutParser.getInstance(configuration).parseXML(ROOT));
+     }
+@@ -138,8 +123,8 @@
+       *
+       * @param elements the XML elements that specify how to document a class.
+       */
+-     public void buildClassDoc(List elements) throws Exception {
+-        build(elements);
++     public void buildClassDoc(XMLNode node) throws Exception {
++        buildChildren(node);
+         writer.close();
+         copyDocFiles();
+      }
+@@ -169,7 +154,7 @@
+     /**
+      * Build the header of the page.
+      */
+-    public void buildClassHeader() {
++    public void buildClassHeader(XMLNode node) {
+         String key;
+         if (isInterface) {
+             key =  "doclet.Interface";
+@@ -185,7 +170,7 @@
+     /**
+      * Build the class tree documentation.
+      */
+-    public void buildClassTree() {
++    public void buildClassTree(XMLNode node) {
+         writer.writeClassTree();
+     }
+ 
+@@ -193,42 +178,42 @@
+      * If this is a class, list all interfaces
+      * implemented by this class.
+      */
+-    public void buildImplementedInterfacesInfo() {
++    public void buildImplementedInterfacesInfo(XMLNode node) {
+         writer.writeImplementedInterfacesInfo();
+     }
+ 
+     /**
+      * If this is an interface, list all super interfaces.
+      */
+-    public void buildSuperInterfacesInfo() {
++    public void buildSuperInterfacesInfo(XMLNode node) {
+         writer.writeSuperInterfacesInfo();
+     }
+ 
+     /**
+      * List the parameters of this class.
+      */
+-    public void buildTypeParamInfo() {
++    public void buildTypeParamInfo(XMLNode node) {
+         writer.writeTypeParamInfo();
+     }
+ 
+     /**
+      * List all the classes extend this one.
+      */
+-    public void buildSubClassInfo() {
++    public void buildSubClassInfo(XMLNode node) {
+         writer.writeSubClassInfo();
+     }
+ 
+     /**
+      * List all the interfaces that extend this one.
+      */
+-    public void buildSubInterfacesInfo() {
++    public void buildSubInterfacesInfo(XMLNode node) {
+         writer.writeSubInterfacesInfo();
+     }
+ 
+     /**
+      * If this is an interface, list all classes that implement this interface.
+      */
+-    public void buildInterfaceUsageInfo () {
++    public void buildInterfaceUsageInfo (XMLNode node) {
+         writer.writeInterfaceUsageInfo();
+     }
+ 
+@@ -236,21 +221,21 @@
+      * If this is an inner class or interface, list the enclosing class or
+      * interface.
+      */
+-    public void buildNestedClassInfo () {
++    public void buildNestedClassInfo (XMLNode node) {
+         writer.writeNestedClassInfo();
+     }
+ 
+     /**
+      * If this class is deprecated, print the appropriate information.
+      */
+-    public void buildDeprecationInfo () {
++    public void buildDeprecationInfo (XMLNode node) {
+         writer.writeClassDeprecationInfo();
+     }
+ 
+     /**
+      * Build the signature of the current class.
+      */
+-    public void buildClassSignature() {
++    public void buildClassSignature(XMLNode node) {
+         StringBuffer modifiers = new StringBuffer(classDoc.modifiers() + " ");
+         if (isEnum) {
+             modifiers.append("enum ");
+@@ -276,14 +261,14 @@
+     /**
+      * Build the class description.
+      */
+-    public void buildClassDescription() {
++    public void buildClassDescription(XMLNode node) {
+        writer.writeClassDescription();
+     }
+ 
+     /**
+      * Build the tag information for the current class.
+      */
+-    public void buildClassTagInfo() {
++    public void buildClassTagInfo(XMLNode node) {
+        writer.writeClassTagInfo();
+     }
+ 
+@@ -295,7 +280,7 @@
+      */
+     public void buildMemberSummary(List elements) throws Exception {
+         configuration.getBuilderFactory().
+-            getMemberSummaryBuilder(writer).build(elements);
++            getMemberSummaryBuilder(writer).buildChildren(node);
+         writer.completeMemberSummaryBuild();
+     }
+ 
+@@ -305,9 +290,9 @@
+      * @param elements the XML elements that specify how a enum constants are
+      *                 documented.
+      */
+-    public void buildEnumConstantsDetails(List elements) throws Exception {
++    public void buildEnumConstantsDetails(XMLNode node) throws Exception {
+         configuration.getBuilderFactory().
+-            getEnumConstantsBuilder(writer).build(elements);
++            getEnumConstantsBuilder(writer).buildChildren(node);
+     }
+ 
+     /**
+@@ -315,9 +300,9 @@
+      *
+      * @param elements the XML elements that specify how a field is documented.
+      */
+-    public void buildFieldDetails(List elements) throws Exception {
++    public void buildFieldDetails(XMLNode node) throws Exception {
+         configuration.getBuilderFactory().
+-            getFieldBuilder(writer).build(elements);
++            getFieldBuilder(writer).buildChildren(node);
+     }
+ 
+     /**
+@@ -326,9 +311,9 @@
+      * @param elements the XML elements that specify how to document a
+      * constructor.
+      */
+-    public void buildConstructorDetails(List elements) throws Exception {
++    public void buildConstructorDetails(XMLNode node) throws Exception {
+         configuration.getBuilderFactory().
+-            getConstructorBuilder(writer).build(elements);
++            getConstructorBuilder(writer).buildChildren(node);
+     }
+ 
+     /**
+@@ -336,15 +321,15 @@
+      *
+      * @param elements the XML elements that specify how a method is documented.
+      */
+-    public void buildMethodDetails(List elements) throws Exception {
++    public void buildMethodDetails(XMLNode node) throws Exception {
+         configuration.getBuilderFactory().
+-                getMethodBuilder(writer).build(elements);
++                getMethodBuilder(writer).buildChildren(node);
+     }
+ 
+     /**
+      * Build the footer of the page.
+      */
+-    public void buildClassFooter() {
++    public void buildClassFooter(XMLNode node) {
+         writer.writeFooter();
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstantsSummaryBuilder.java
+@@ -30,7 +30,6 @@
+ import com.sun.javadoc.*;
+ import java.io.*;
+ import java.util.*;
+-import java.lang.reflect.*;
+ 
+ /**
+  * Builds the Constants Summary Page.
+@@ -109,20 +108,6 @@
+     /**
+      * {@inheritDoc}
+      */
+-    public void invokeMethod(String methodName, Class[] paramClasses,
+-            Object[] params)
+-    throws Exception {
+-        if (DEBUG) {
+-            configuration.root.printError("DEBUG: " + this.getClass().getName()
+-                + "." + methodName);
+-        }
+-        Method method = this.getClass().getMethod(methodName, paramClasses);
+-        method.invoke(this, params);
+-    }
+-
+-    /**
+-     * {@inheritDoc}
+-     */
+     public void build() throws IOException {
+         if (writer == null) {
+             //Doclet does not support this output.
+@@ -144,29 +129,29 @@
+      * @param elements the list of elements describing constant summary
+      *                 documentation.
+      */
+-    public void buildConstantSummary(List elements) throws Exception {
+-        build(elements);
++    public void buildConstantSummary(XMLNode node) throws Exception {
++        buildChildren(node);
+         writer.close();
+     }
+ 
+     /**
+      * Build the header.
+      */
+-    public void buildHeader() {
++    public void buildHeader(XMLNode node) {
+         writer.writeHeader();
+     }
+ 
+     /**
+      * Build the footer.
+      */
+-    public void buildFooter() {
++    public void buildFooter(XMLNode node) {
+         writer.writeFooter();
+     }
+ 
+     /**
+      * Build the table of contents.
+      */
+-    public void buildContents() {
++    public void buildContents(XMLNode node) {
+         writer.writeContentsHeader();
+         PackageDoc[] packages = configuration.packages;
+         printedPackageHeaders = new HashSet();
+@@ -186,14 +171,14 @@
+      * @param elements the XML elements that represent the components
+      *                 of documentation for each package.
+      */
+-    public void buildConstantSummaries(List elements) {
++    public void buildConstantSummaries(XMLNode node) {
+         PackageDoc[] packages = configuration.packages;
+         printedPackageHeaders = new HashSet();
+         for (int i = 0; i < packages.length; i++) {
+             if (hasConstantField(packages[i])) {
+                 currentPackage = packages[i];
+                 //Build the documentation for the current package.
+-                build(elements);
++                buildChildren(node);
+             }
+         }
+     }
+@@ -204,8 +189,8 @@
+      * @param elements the list of XML elements that make up package
+      *                 documentation.
+      */
+-    public void buildPackageConstantSummary(List elements) {
+-        build(elements);
++    public void buildPackageConstantSummary(XMLNode node) {
++        buildChildren(node);
+     }
+ 
+     /**
+@@ -214,7 +199,7 @@
+      * @param elements the list of XML elements that make up the class
+      *                 constant summary.
+      */
+-    public void buildClassConstantSummary(List elements) {
++    public void buildClassConstantSummary(XMLNode node) {
+         ClassDoc[] classes = currentPackage.name().length() > 0 ?
+             currentPackage.allClasses() :
+             configuration.classDocCatalog.allClasses(
+@@ -227,14 +212,14 @@
+             }
+             currentClass = classes[i];
+             //Build the documentation for the current class.
+-            build(elements);
++            buildChildren(node);
+         }
+     }
+ 
+     /**
+      * Build the header for the given class.
+      */
+-    public void buildPackageHeader() {
++    public void buildPackageHeader(XMLNode node) {
+         String parsedPackageName = parsePackageName(currentPackage.name());
+         if (! printedPackageHeaders.contains(parsedPackageName)) {
+             writer.writePackageName(currentPackage,
+@@ -246,7 +231,7 @@
+     /**
+      * Build the header for the given class.
+      */
+-    public void buildClassHeader() {
++    public void buildClassHeader(XMLNode node) {
+         writer.writeConstantMembersHeader(currentClass);
+     }
+ 
+@@ -254,14 +239,14 @@
+      * Print summary of constant members in the
+      * class.
+      */
+-    public void buildConstantMembers() {
+-        new ConstantFieldBuilder(currentClass).buildMembersSummary();
++    public void buildConstantMembers(XMLNode node) {
++        new ConstantFieldBuilder(currentClass).buildMembersSummary(node);
+     }
+ 
+     /**
+      * Build the footer for the given class.
+      */
+-    public void buildClassFooter() {
++    public void buildClassFooter(XMLNode node) {
+         writer.writeConstantMembersFooter(currentClass);
+     }
+ 
+@@ -362,7 +347,7 @@
+         /**
+          * Builds the table of constants for a given class.
+          */
+-        protected void buildMembersSummary() {
++        protected void buildMembersSummary(XMLNode node) {
+             List members = new ArrayList(members());
+             if (members.size() > 0) {
+                 Collections.sort(members);
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ConstructorBuilder.java
+@@ -28,7 +28,6 @@
+ import com.sun.tools.doclets.internal.toolkit.util.*;
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+-import java.lang.reflect.*;
+ import java.util.*;
+ 
+ /**
+@@ -136,22 +135,6 @@
+         }
+ 
+         /**
+-         * {@inheritDoc}
+-         */
+-        public void invokeMethod(
+-                String methodName,
+-                Class[] paramClasses,
+-                Object[] params)
+-                throws Exception {
+-                if (DEBUG) {
+-                        configuration.root.printError(
+-                                "DEBUG: " + this.getClass().getName() + "." + methodName);
+-                }
+-                Method method = this.getClass().getMethod(methodName, paramClasses);
+-                method.invoke(this, params);
+-        }
+-
+-        /**
+          * Returns a list of constructors that will be documented for the given class.
+          * This information can be used for doclet specific documentation
+          * generation.
+@@ -177,21 +160,21 @@
+          * @param elements the XML elements that specify how to construct this
+          *                documentation.
+          */
+-        public void buildConstructorDoc(List elements) {
++        public void buildConstructorDoc(XMLNode node) {
+                 if (writer == null) {
+                         return;
+                 }
+                 for (currentMethodIndex = 0;
+                         currentMethodIndex < constructors.size();
+                         currentMethodIndex++) {
+-                        build(elements);
++                        buildChildren(node);
+                 }
+         }
+ 
+         /**
+          * Build the overall header.
+          */
+-        public void buildHeader() {
++        public void buildHeader(XMLNode node) {
+                 writer.writeHeader(
+                         classDoc,
+                         configuration.getText("doclet.Constructor_Detail"));
+@@ -200,7 +183,7 @@
+         /**
+          * Build the header for the individual constructor.
+          */
+-        public void buildConstructorHeader() {
++        public void buildConstructorHeader(XMLNode node) {
+                 writer.writeConstructorHeader(
+                         (ConstructorDoc) constructors.get(currentMethodIndex),
+                         currentMethodIndex == 0);
+@@ -209,7 +192,7 @@
+         /**
+          * Build the signature.
+          */
+-        public void buildSignature() {
++        public void buildSignature(XMLNode node) {
+                 writer.writeSignature(
+                         (ConstructorDoc) constructors.get(currentMethodIndex));
+         }
+@@ -217,7 +200,7 @@
+         /**
+          * Build the deprecation information.
+          */
+-        public void buildDeprecationInfo() {
++        public void buildDeprecationInfo(XMLNode node) {
+                 writer.writeDeprecated(
+                         (ConstructorDoc) constructors.get(currentMethodIndex));
+         }
+@@ -226,7 +209,7 @@
+          * Build the comments for the constructor.  Do nothing if
+          * {@link Configuration#nocomment} is set to true.
+          */
+-        public void buildConstructorComments() {
++        public void buildConstructorComments(XMLNode node) {
+                 if (!configuration.nocomment) {
+                         writer.writeComments(
+                                 (ConstructorDoc) constructors.get(currentMethodIndex));
+@@ -236,21 +219,21 @@
+         /**
+          * Build the tag information.
+          */
+-        public void buildTagInfo() {
++        public void buildTagInfo(XMLNode node) {
+                 writer.writeTags((ConstructorDoc) constructors.get(currentMethodIndex));
+         }
+ 
+         /**
+          * Build the footer for the individual constructor.
+          */
+-        public void buildConstructorFooter() {
++        public void buildConstructorFooter(XMLNode node) {
+                 writer.writeConstructorFooter();
+         }
+ 
+         /**
+          * Build the overall footer.
+          */
+-        public void buildFooter() {
++        public void buildFooter(XMLNode node) {
+                 writer.writeFooter(classDoc);
+         }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/EnumConstantBuilder.java
+@@ -29,7 +29,6 @@
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+ import java.util.*;
+-import java.lang.reflect.*;
+ 
+ /**
+  * Builds documentation for a enum constants.
+@@ -116,22 +115,6 @@
+         }
+ 
+         /**
+-         * {@inheritDoc}
+-         */
+-        public void invokeMethod(
+-                String methodName,
+-                Class[] paramClasses,
+-                Object[] params)
+-                throws Exception {
+-                if (DEBUG) {
+-                        configuration.root.printError(
+-                                "DEBUG: " + this.getClass().getName() + "." + methodName);
+-                }
+-                Method method = this.getClass().getMethod(methodName, paramClasses);
+-                method.invoke(this, params);
+-        }
+-
+-        /**
+          * Returns a list of enum constants that will be documented for the given class.
+          * This information can be used for doclet specific documentation
+          * generation.
+@@ -165,21 +148,21 @@
+          * @param elements the XML elements that specify how to construct this
+          *                documentation.
+          */
+-        public void buildEnumConstant(List elements) {
++        public void buildEnumConstant(XMLNode node) {
+                 if (writer == null) {
+                         return;
+                 }
+                 for (currentEnumConstantsIndex = 0;
+                         currentEnumConstantsIndex < enumConstants.size();
+                         currentEnumConstantsIndex++) {
+-                        build(elements);
++                        buildChildren(node);
+                 }
+         }
+ 
+         /**
+          * Build the overall header.
+          */
+-        public void buildHeader() {
++        public void buildHeader(XMLNode node) {
+                 writer.writeHeader(
+                         classDoc,
+                         configuration.getText("doclet.Enum_Constant_Detail"));
+@@ -188,7 +171,7 @@
+         /**
+          * Build the header for the individual enum constants.
+          */
+-        public void buildEnumConstantHeader() {
++        public void buildEnumConstantHeader(XMLNode node) {
+                 writer.writeEnumConstantHeader(
+                         (FieldDoc) enumConstants.get(currentEnumConstantsIndex),
+                         currentEnumConstantsIndex == 0);
+@@ -197,7 +180,7 @@
+         /**
+          * Build the signature.
+          */
+-        public void buildSignature() {
++        public void buildSignature(XMLNode node) {
+                 writer.writeSignature(
+                         (FieldDoc) enumConstants.get(currentEnumConstantsIndex));
+         }
+@@ -205,7 +188,7 @@
+         /**
+          * Build the deprecation information.
+          */
+-        public void buildDeprecationInfo() {
++        public void buildDeprecationInfo(XMLNode node) {
+                 writer.writeDeprecated(
+                         (FieldDoc) enumConstants.get(currentEnumConstantsIndex));
+         }
+@@ -214,7 +197,7 @@
+          * Build the comments for the enum constant.  Do nothing if
+          * {@link Configuration#nocomment} is set to true.
+          */
+-        public void buildEnumConstantComments() {
++        public void buildEnumConstantComments(XMLNode node) {
+                 if (!configuration.nocomment) {
+                         writer.writeComments(
+                                 (FieldDoc) enumConstants.get(currentEnumConstantsIndex));
+@@ -224,7 +207,7 @@
+         /**
+          * Build the tag information.
+          */
+-        public void buildTagInfo() {
++        public void buildTagInfo(XMLNode node) {
+                 writer.writeTags(
+                         (FieldDoc) enumConstants.get(currentEnumConstantsIndex));
+         }
+@@ -232,14 +215,14 @@
+         /**
+          * Build the footer for the individual enum constants.
+          */
+-        public void buildEnumConstantFooter() {
++        public void buildEnumConstantFooter(XMLNode node) {
+                 writer.writeEnumConstantFooter();
+         }
+ 
+         /**
+          * Build the overall footer.
+          */
+-        public void buildFooter() {
++        public void buildFooter(XMLNode node) {
+                 writer.writeFooter(classDoc);
+         }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/FieldBuilder.java
+@@ -29,7 +29,6 @@
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+ import java.util.*;
+-import java.lang.reflect.*;
+ 
+ /**
+  * Builds documentation for a field.
+@@ -117,22 +116,6 @@
+         }
+ 
+         /**
+-         * {@inheritDoc}
+-         */
+-        public void invokeMethod(
+-                String methodName,
+-                Class[] paramClasses,
+-                Object[] params)
+-                throws Exception {
+-                if (DEBUG) {
+-                        configuration.root.printError(
+-                                "DEBUG: " + this.getClass().getName() + "." + methodName);
+-                }
+-                Method method = this.getClass().getMethod(methodName, paramClasses);
+-                method.invoke(this, params);
+-        }
+-
+-        /**
+          * Returns a list of fields that will be documented for the given class.
+          * This information can be used for doclet specific documentation
+          * generation.
+@@ -166,21 +149,21 @@
+          * @param elements the XML elements that specify how to construct this
+          *                documentation.
+          */
+-        public void buildFieldDoc(List elements) {
++        public void buildFieldDoc(XMLNode node) {
+                 if (writer == null) {
+                         return;
+                 }
+                 for (currentFieldIndex = 0;
+                         currentFieldIndex < fields.size();
+                         currentFieldIndex++) {
+-                        build(elements);
++                        buildChildren(node);
+                 }
+         }
+ 
+         /**
+          * Build the overall header.
+          */
+-        public void buildHeader() {
++        public void buildHeader(XMLNode node) {
+                 writer.writeHeader(
+                         classDoc,
+                         configuration.getText("doclet.Field_Detail"));
+@@ -189,7 +172,7 @@
+         /**
+          * Build the header for the individual field.
+          */
+-        public void buildFieldHeader() {
++        public void buildFieldHeader(XMLNode node) {
+                 writer.writeFieldHeader(
+                         (FieldDoc) fields.get(currentFieldIndex),
+                         currentFieldIndex == 0);
+@@ -198,14 +181,14 @@
+         /**
+          * Build the signature.
+          */
+-        public void buildSignature() {
++        public void buildSignature(XMLNode node) {
+                 writer.writeSignature((FieldDoc) fields.get(currentFieldIndex));
+         }
+ 
+         /**
+          * Build the deprecation information.
+          */
+-        public void buildDeprecationInfo() {
++        public void buildDeprecationInfo(XMLNode node) {
+                 writer.writeDeprecated((FieldDoc) fields.get(currentFieldIndex));
+         }
+ 
+@@ -213,7 +196,7 @@
+          * Build the comments for the field.  Do nothing if
+          * {@link Configuration#nocomment} is set to true.
+          */
+-        public void buildFieldComments() {
++        public void buildFieldComments(XMLNode node) {
+                 if (!configuration.nocomment) {
+                         writer.writeComments((FieldDoc) fields.get(currentFieldIndex));
+                 }
+@@ -222,21 +205,21 @@
+         /**
+          * Build the tag information.
+          */
+-        public void buildTagInfo() {
++        public void buildTagInfo(XMLNode node) {
+                 writer.writeTags((FieldDoc) fields.get(currentFieldIndex));
+         }
+ 
+         /**
+          * Build the footer for the individual field.
+          */
+-        public void buildFieldFooter() {
++        public void buildFieldFooter(XMLNode node) {
+                 writer.writeFieldFooter();
+         }
+ 
+         /**
+          * Build the overall footer.
+          */
+-        public void buildFooter() {
++        public void buildFooter(XMLNode node) {
+                 writer.writeFooter(classDoc);
+         }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
+@@ -45,8 +45,8 @@
+     /**
+      * The map of XML elements that have been parsed.
+      */
+-    private Map xmlElementsMap;
+-
++    private Map<String,XMLNode> xmlElementsMap;
++    private XMLNode currentNode;
+     private Configuration configuration;
+     private static LayoutParser instance;
+     private String currentRoot;
+@@ -56,7 +56,7 @@
+      * This class is a singleton.
+      */
+     private LayoutParser(Configuration configuration) {
+-        xmlElementsMap = new HashMap();
++        xmlElementsMap = new HashMap<String,XMLNode>();
+         this.configuration = configuration;
+     }
+ 
+@@ -78,20 +78,18 @@
+      *
+      * @return List the list of XML elements parsed.
+      */
+-    public List parseXML(String root) {
++    public XMLNode parseXML(String root) {
+         if (xmlElementsMap.containsKey(root)) {
+             return (List) xmlElementsMap.get(root);
+         }
+         try {
+-            List xmlElements = new ArrayList();
+-            xmlElementsMap.put(root, xmlElements);
+             currentRoot = root;
+             isParsing = false;
+             SAXParserFactory factory = SAXParserFactory.newInstance();
+             SAXParser saxParser = factory.newSAXParser();
+             InputStream in = configuration.getBuilderXML();
+             saxParser.parse(in, this);
+-            return xmlElements;
++            return xmlElementsMap.get(root);
+         } catch (Throwable t) {
+             t.printStackTrace();
+             throw new DocletAbortException();
+@@ -106,8 +104,11 @@
+     throws SAXException {
+         if (isParsing || qName.equals(currentRoot)) {
+             isParsing = true;
+-            List xmlElements = (List) xmlElementsMap.get(currentRoot);
+-            xmlElements.add(qName);
++            currentNode = new XMLNode(currentNode, qName);
++            for (int i = 0; i < attrs.getLength(); i++)
++                currentNode.attrs.put(attrs.getLocalName(i), attrs.getValue(i));
++            if (qName.equals(currentRoot))
++                xmlElementsMap.put(qName, currentNode);
+         }
+     }
+ 
+@@ -117,23 +118,9 @@
+     public void endElement(String namespaceURI, String sName, String qName)
+     throws SAXException {
+         if (! isParsing) {
+-            isParsing = false;
+             return;
+         }
+-        List xmlElements = (List) xmlElementsMap.get(currentRoot);
+-        if (xmlElements.get(xmlElements.size()-1).equals(qName)) {
+-            return;
+-        } else {
+-            List subElements = new ArrayList();
+-            int targetIndex = xmlElements.indexOf(qName);
+-            int size = xmlElements.size();
+-            for (int i = targetIndex; i < size; i++) {
+-                subElements.add(xmlElements.get(targetIndex));
+-                xmlElements.remove(targetIndex);
+-            }
+-            //Save the sub elements as a list.
+-            xmlElements.add(subElements);
+-        }
++        currentNode = currentNode.parent;
+         isParsing = ! qName.equals(currentRoot);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MemberSummaryBuilder.java
+@@ -29,7 +29,6 @@
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+ import java.util.*;
+-import java.lang.reflect.*;
+ 
+ /**
+  * Builds the member summary.
+@@ -175,22 +174,6 @@
+         }
+ 
+         /**
+-         * {@inheritDoc}
+-         */
+-        public void invokeMethod(
+-                String methodName,
+-                Class[] paramClasses,
+-                Object[] params)
+-                throws Exception {
+-                if (DEBUG) {
+-                        configuration.root.printError(
+-                                "DEBUG: " + this.getClass().getName() + "." + methodName);
+-                }
+-                Method method = this.getClass().getMethod(methodName, paramClasses);
+-                method.invoke(this, params);
+-        }
+-
+-        /**
+          * Return true it there are any members to summarize.
+          *
+          * @return true if there are any members to summarize.
+@@ -211,7 +194,7 @@
+         /**
+          * Build the summary for the enum constants.
+          */
+-        public void buildEnumConstantsSummary() {
++        public void buildEnumConstantsSummary(XMLNode node) {
+                 buildSummary(
+                         memberSummaryWriters[VisibleMemberMap.ENUM_CONSTANTS],
+                         visibleMemberMaps[VisibleMemberMap.ENUM_CONSTANTS]);
+@@ -220,7 +203,7 @@
+     /**
+      * Build the summary for the optional members.
+      */
+-    public void buildAnnotationTypeOptionalMemberSummary() {
++    public void buildAnnotationTypeOptionalMemberSummary(XMLNode node) {
+         buildSummary(
+             memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL],
+                 visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL]);
+@@ -229,7 +212,7 @@
+     /**
+      * Build the summary for the optional members.
+      */
+-    public void buildAnnotationTypeRequiredMemberSummary() {
++    public void buildAnnotationTypeRequiredMemberSummary(XMLNode node) {
+         buildSummary(
+             memberSummaryWriters[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED],
+                 visibleMemberMaps[VisibleMemberMap.ANNOTATION_TYPE_MEMBER_REQUIRED]);
+@@ -238,7 +221,7 @@
+         /**
+          * Build the summary for the fields.
+          */
+-        public void buildFieldsSummary() {
++        public void buildFieldsSummary(XMLNode node) {
+                 buildSummary(
+                         memberSummaryWriters[VisibleMemberMap.FIELDS],
+                         visibleMemberMaps[VisibleMemberMap.FIELDS]);
+@@ -247,7 +230,7 @@
+         /**
+          * Build the inherited summary for the fields.
+          */
+-        public void buildFieldsInheritedSummary() {
++        public void buildFieldsInheritedSummary(XMLNode node) {
+                 buildInheritedSummary(
+                         memberSummaryWriters[VisibleMemberMap.FIELDS],
+                         visibleMemberMaps[VisibleMemberMap.FIELDS]);
+@@ -256,7 +239,7 @@
+         /**
+          * Build the summary for the nested classes.
+          */
+-        public void buildNestedClassesSummary() {
++        public void buildNestedClassesSummary(XMLNode node) {
+                 buildSummary(
+                         memberSummaryWriters[VisibleMemberMap.INNERCLASSES],
+                         visibleMemberMaps[VisibleMemberMap.INNERCLASSES]);
+@@ -265,7 +248,7 @@
+         /**
+          * Build the inherited summary for the nested classes.
+          */
+-        public void buildNestedClassesInheritedSummary() {
++        public void buildNestedClassesInheritedSummary(XMLNode node) {
+                 buildInheritedSummary(
+                         memberSummaryWriters[VisibleMemberMap.INNERCLASSES],
+                         visibleMemberMaps[VisibleMemberMap.INNERCLASSES]);
+@@ -274,7 +257,7 @@
+         /**
+          * Build the method summary.
+          */
+-        public void buildMethodsSummary() {
++        public void buildMethodsSummary(XMLNode node) {
+                 buildSummary(
+                         memberSummaryWriters[VisibleMemberMap.METHODS],
+                         visibleMemberMaps[VisibleMemberMap.METHODS]);
+@@ -283,7 +266,7 @@
+         /**
+          * Build the inherited method summary.
+          */
+-        public void buildMethodsInheritedSummary() {
++        public void buildMethodsInheritedSummary(XMLNode node) {
+                 buildInheritedSummary(
+                         memberSummaryWriters[VisibleMemberMap.METHODS],
+                         visibleMemberMaps[VisibleMemberMap.METHODS]);
+@@ -292,7 +275,7 @@
+         /**
+          * Build the constructor summary.
+          */
+-        public void buildConstructorsSummary() {
++        public void buildConstructorsSummary(XMLNode node) {
+                 buildSummary(
+                         memberSummaryWriters[VisibleMemberMap.CONSTRUCTORS],
+                         visibleMemberMaps[VisibleMemberMap.CONSTRUCTORS]);
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
+@@ -29,7 +29,7 @@
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+ import java.util.*;
+-import java.lang.reflect.*;
++
+ /**
+  * Builds documentation for a method.
+  *
+@@ -112,22 +112,6 @@
+         }
+ 
+         /**
+-         * {@inheritDoc}
+-         */
+-        public void invokeMethod(
+-                String methodName,
+-                Class[] paramClasses,
+-                Object[] params)
+-                throws Exception {
+-                if (DEBUG) {
+-                        configuration.root.printError(
+-                                "DEBUG: " + this.getClass().getName() + "." + methodName);
+-                }
+-                Method method = this.getClass().getMethod(methodName, paramClasses);
+-                method.invoke(this, params);
+-        }
+-
+-        /**
+          * Returns a list of methods that will be documented for the given class.
+          * This information can be used for doclet specific documentation
+          * generation.
+@@ -158,21 +142,21 @@
+         /**
+          * Build the method documentation.
+          */
+-        public void buildMethodDoc(List elements) {
++        public void buildMethodDoc(XMLNode node) {
+                 if (writer == null) {
+                         return;
+                 }
+                 for (currentMethodIndex = 0;
+                         currentMethodIndex < methods.size();
+                         currentMethodIndex++) {
+-                        build(elements);
++                        buildChildren(node);
+                 }
+         }
+ 
+         /**
+          * Build the overall header.
+          */
+-        public void buildHeader() {
++        public void buildHeader(XMLNode node) {
+                 writer.writeHeader(
+                         classDoc,
+                         configuration.getText("doclet.Method_Detail"));
+@@ -181,7 +165,7 @@
+         /**
+          * Build the header for the individual method.
+          */
+-        public void buildMethodHeader() {
++        public void buildMethodHeader(XMLNode node) {
+                 writer.writeMethodHeader(
+                         (MethodDoc) methods.get(currentMethodIndex),
+                         currentMethodIndex == 0);
+@@ -190,14 +174,14 @@
+         /**
+          * Build the signature.
+          */
+-        public void buildSignature() {
++        public void buildSignature(XMLNode node) {
+                 writer.writeSignature((MethodDoc) methods.get(currentMethodIndex));
+         }
+ 
+         /**
+          * Build the deprecation information.
+          */
+-        public void buildDeprecationInfo() {
++        public void buildDeprecationInfo(XMLNode node) {
+                 writer.writeDeprecated((MethodDoc) methods.get(currentMethodIndex));
+         }
+ 
+@@ -205,7 +189,7 @@
+          * Build the comments for the method.  Do nothing if
+          * {@link Configuration#nocomment} is set to true.  If this method
+          */
+-        public void buildMethodComments() {
++        public void buildMethodComments(XMLNode node) {
+                 if (!configuration.nocomment) {
+             MethodDoc method = (MethodDoc) methods.get(currentMethodIndex);
+ 
+@@ -228,21 +212,21 @@
+         /**
+          * Build the tag information.
+          */
+-        public void buildTagInfo() {
++        public void buildTagInfo(XMLNode node) {
+                 writer.writeTags((MethodDoc) methods.get(currentMethodIndex));
+         }
+ 
+         /**
+          * Build the footer of the method.
+          */
+-        public void buildMethodFooter() {
++        public void buildMethodFooter(XMLNode node) {
+                 writer.writeMethodFooter();
+         }
+ 
+         /**
+          * Build the overall footer.
+          */
+-        public void buildFooter() {
++        public void buildFooter(XMLNode node) {
+                 writer.writeFooter(classDoc);
+         }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
+@@ -29,8 +29,6 @@
+ import com.sun.tools.doclets.internal.toolkit.*;
+ import com.sun.javadoc.*;
+ import java.io.*;
+-import java.util.*;
+-import java.lang.reflect.*;
+ 
+ /**
+  * Builds the summary for a given package.
+@@ -85,22 +83,6 @@
+         }
+ 
+         /**
+-         * {@inheritDoc}
+-         */
+-        public void invokeMethod(
+-                String methodName,
+-                Class[] paramClasses,
+-                Object[] params)
+-                throws Exception {
+-                if (DEBUG) {
+-                        configuration.root.printError(
+-                                "DEBUG: " + this.getClass().getName() + "." + methodName);
+-                }
+-                Method method = this.getClass().getMethod(methodName, paramClasses);
+-                method.invoke(this, params);
+-        }
+-
+-        /**
+          * Build the package summary.
+          */
+         public void build() throws IOException {
+@@ -121,8 +103,8 @@
+         /**
+          * Build the package documentation.
+          */
+-        public void buildPackageDoc(List elements) throws Exception {
+-                build(elements);
++        public void buildPackageDoc(XMLNode node) throws Exception {
++                buildChildren(node);
+                 packageWriter.close();
+                 Util.copyDocFiles(
+                         configuration,
+@@ -136,14 +118,14 @@
+         /**
+          * Build the header of the summary.
+          */
+-        public void buildPackageHeader() {
++        public void buildPackageHeader(XMLNode node) {
+                 packageWriter.writePackageHeader(Util.getPackageName(packageDoc));
+         }
+ 
+         /**
+          * Build the description of the summary.
+          */
+-        public void buildPackageDescription() {
++        public void buildPackageDescription(XMLNode node) {
+                 if (configuration.nocomment) {
+                         return;
+                 }
+@@ -153,7 +135,7 @@
+         /**
+          * Build the tags of the summary.
+          */
+-        public void buildPackageTags() {
++        public void buildPackageTags(XMLNode node) {
+                 if (configuration.nocomment) {
+                         return;
+                 }
+@@ -163,28 +145,28 @@
+         /**
+          * Build the package summary.
+          */
+-        public void buildSummary(List elements) {
+-                build(elements);
++        public void buildSummary(XMLNode node) {
++                buildChildren(node);
+         }
+ 
+         /**
+          * Build the overall header.
+          */
+-        public void buildSummaryHeader() {
++        public void buildSummaryHeader(XMLNode node) {
+                 packageWriter.writeSummaryHeader();
+         }
+ 
+         /**
+          * Build the overall footer.
+          */
+-        public void buildSummaryFooter() {
++        public void buildSummaryFooter(XMLNode node) {
+                 packageWriter.writeSummaryFooter();
+         }
+ 
+         /**
+          * Build the summary for the classes in this package.
+          */
+-        public void buildClassSummary() {
++        public void buildClassSummary(XMLNode node) {
+             String classTableSummary =
+                     configuration.getText("doclet.Member_Table_Summary",
+                     configuration.getText("doclet.Class_Summary"),
+@@ -209,7 +191,7 @@
+         /**
+          * Build the summary for the interfaces in this package.
+          */
+-        public void buildInterfaceSummary() {
++        public void buildInterfaceSummary(XMLNode node) {
+             String interfaceTableSummary =
+                     configuration.getText("doclet.Member_Table_Summary",
+                     configuration.getText("doclet.Interface_Summary"),
+@@ -234,7 +216,7 @@
+         /**
+          * Build the summary for the enums in this package.
+          */
+-        public void buildAnnotationTypeSummary() {
++        public void buildAnnotationTypeSummary(XMLNode node) {
+             String annotationtypeTableSummary =
+                     configuration.getText("doclet.Member_Table_Summary",
+                     configuration.getText("doclet.Annotation_Types_Summary"),
+@@ -259,7 +241,7 @@
+         /**
+          * Build the summary for the enums in this package.
+          */
+-        public void buildEnumSummary() {
++        public void buildEnumSummary(XMLNode node) {
+             String enumTableSummary =
+                     configuration.getText("doclet.Member_Table_Summary",
+                     configuration.getText("doclet.Enum_Summary"),
+@@ -284,7 +266,7 @@
+         /**
+          * Build the summary for the exceptions in this package.
+          */
+-        public void buildExceptionSummary() {
++        public void buildExceptionSummary(XMLNode node) {
+             String exceptionTableSummary =
+                     configuration.getText("doclet.Member_Table_Summary",
+                     configuration.getText("doclet.Exception_Summary"),
+@@ -309,7 +291,7 @@
+         /**
+          * Build the summary for the errors in this package.
+          */
+-        public void buildErrorSummary() {
++        public void buildErrorSummary(XMLNode node) {
+             String errorTableSummary =
+                     configuration.getText("doclet.Member_Table_Summary",
+                     configuration.getText("doclet.Error_Summary"),
+@@ -334,7 +316,7 @@
+         /**
+          * Build the footer of the summary.
+          */
+-        public void buildPackageFooter() {
++        public void buildPackageFooter(XMLNode node) {
+                 packageWriter.writePackageFooter();
+         }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+@@ -26,7 +26,6 @@
+ package com.sun.tools.doclets.internal.toolkit.builders;
+ 
+ import java.io.*;
+-import java.lang.reflect.*;
+ import java.util.*;
+ 
+ import com.sun.javadoc.*;
+@@ -132,47 +131,33 @@
+     /**
+      * Build the serialized form.
+      */
+-    public void buildSerializedForm(List elements) throws Exception {
+-        build(elements);
++    public void buildSerializedForm(XMLNode node) throws Exception {
++        buildChildren(node);
+         writer.close();
+     }
+ 
+     /**
+-     * {@inheritDoc}
+-     */
+-    public void invokeMethod(String methodName, Class[] paramClasses,
+-            Object[] params)
+-    throws Exception {
+-        if (DEBUG) {
+-            configuration.root.printError("DEBUG: " + this.getClass().getName()
+-                + "." + methodName);
+-        }
+-        Method method = this.getClass().getMethod(methodName, paramClasses);
+-        method.invoke(this, params);
+-    }
+-
+-    /**
+      * Build the header.
+      */
+-    public void buildHeader() {
++    public void buildHeader(XMLNode node) {
+         writer.writeHeader(configuration.getText("doclet.Serialized_Form"));
+     }
+ 
+     /**
+      * Build the contents.
+      */
+-    public void buildSerializedFormSummaries(List elements) {
++    public void buildSerializedFormSummaries(XMLNode node) {
+         PackageDoc[] packages = configuration.packages;
+         for (int i = 0; i < packages.length; i++) {
+             currentPackage = packages[i];
+-            build(elements);
++            buildChildren(node);
+         }
+     }
+ 
+     /**
+      * Build the package serialized for for the current package being processed.
+      */
+-    public void buildPackageSerializedForm(List elements) {
++    public void buildPackageSerializedForm(XMLNode node) {
+         String foo = currentPackage.name();
+         ClassDoc[] classes = currentPackage.allClasses(false);
+         if (classes == null || classes.length == 0) {
+@@ -184,14 +169,14 @@
+         if (!serialClassFoundToDocument(classes)) {
+             return;
+         }
+-        build(elements);
++        buildChildren(node);
+     }
+ 
+-    public void buildPackageHeader() {
++    public void buildPackageHeader(XMLNode node) {
+         writer.writePackageHeader(Util.getPackageName(currentPackage));
+     }
+ 
+-    public void buildClassSerializedForm(List elements) {
++    public void buildClassSerializedForm(XMLNode node) {
+         ClassDoc[] classes = currentPackage.allClasses(false);
+         Arrays.sort(classes);
+         for (int j = 0; j < classes.length; j++) {
+@@ -202,19 +187,19 @@
+                 if(!serialClassInclude(currentClass)) {
+                     continue;
+                 }
+-                build(elements);
++                buildChildren(node);
+             }
+         }
+     }
+ 
+-    public void buildClassHeader() {
++    public void buildClassHeader(XMLNode node) {
+         writer.writeClassHeader(currentClass);
+     }
+ 
+     /**
+      * Build the serial UID information for the given class.
+      */
+-    public void buildSerialUIDInfo() {
++    public void buildSerialUIDInfo(XMLNode node) {
+         FieldDoc[] fields = currentClass.fields(false);
+         for (int i = 0; i < fields.length; i++) {
+             if (fields[i].name().equals("serialVersionUID") &&
+@@ -229,7 +214,7 @@
+     /**
+      * Build the footer.
+      */
+-    public void buildFooter() {
++    public void buildFooter(XMLNode node) {
+         writer.writeFooter();
+     }
+ 
+@@ -316,7 +301,7 @@
+     /**
+      * Build the method header.
+      */
+-    public void buildMethodHeader() {
++    public void buildMethodHeader(XMLNode node) {
+         if (currentClass.serializationMethods().length > 0) {
+             methodWriter.writeHeader(
+                 configuration.getText("doclet.Serialized_Form_methods"));
+@@ -333,28 +318,28 @@
+     /**
+      * Build the method sub header.
+      */
+-    public void buildMethodSubHeader()  {
++    public void buildMethodSubHeader(XMLNode node)  {
+         methodWriter.writeMemberHeader((MethodDoc) currentMember);
+     }
+ 
+     /**
+      * Build the deprecated method description.
+      */
+-    public void buildDeprecatedMethodInfo() {
++    public void buildDeprecatedMethodInfo(XMLNode node) {
+         methodWriter.writeDeprecatedMemberInfo((MethodDoc) currentMember);
+     }
+ 
+     /**
+      * Build method tags.
+      */
+-    public void buildMethodDescription() {
++    public void buildMethodDescription(XMLNode node) {
+         methodWriter.writeMemberDescription((MethodDoc) currentMember);
+     }
+ 
+     /**
+      * Build the method tags.
+      */
+-    public void buildMethodTags() {
++    public void buildMethodTags(XMLNode node) {
+         methodWriter.writeMemberTags((MethodDoc) currentMember);
+         MethodDoc method = (MethodDoc)currentMember;
+         if (method.name().compareTo("writeExternal") == 0
+@@ -370,24 +355,24 @@
+     /**
+      * build the information for the method.
+      */
+-    public void buildMethodInfo(List elements)  {
++    public void buildMethodInfo(XMLNode node)  {
+         if(configuration.nocomment){
+             return;
+         }
+-        build(elements);
++        buildChildren(node);
+     }
+ 
+     /**
+      * Build the method footer.
+      */
+-    public void buildMethodFooter() {
++    public void buildMethodFooter(XMLNode node) {
+         methodWriter.writeMemberFooter();
+     }
+ 
+     /**
+      * Build the field header.
+      */
+-    public void buildFieldHeader() {
++    public void buildFieldHeader(XMLNode node) {
+         if (currentClass.serializableFields().length > 0) {
+             buildFieldSerializationOverview(currentClass);
+             fieldWriter.writeHeader(configuration.getText(
+@@ -427,7 +412,7 @@
+     /**
+      * Build the field sub header.
+      */
+-    public void buildFieldSubHeader() {
++    public void buildFieldSubHeader(XMLNode node) {
+         if (! currentClass.definesSerializableFields() ){
+             FieldDoc field = (FieldDoc) currentMember;
+             fieldWriter.writeMemberHeader(field.type().asClassDoc(),
+@@ -438,7 +423,7 @@
+     /**
+      * Build the field deprecation information.
+      */
+-    public void buildFieldDeprecationInfo() {
++    public void buildFieldDeprecationInfo(XMLNode node) {
+         if (!currentClass.definesSerializableFields()) {
+             FieldDoc field = (FieldDoc)currentMember;
+             fieldWriter.writeMemberDeprecatedInfo(field);
+@@ -448,7 +433,7 @@
+     /**
+      * Build the field information.
+      */
+-    public void buildFieldInfo() {
++    public void buildFieldInfo(XMLNode node) {
+         if(configuration.nocomment){
+             return;
+         }
+@@ -484,7 +469,7 @@
+     /**
+      * Build the field sub footer.
+      */
+-    public void buildFieldSubFooter() {
++    public void buildFieldSubFooter(XMLNode node) {
+         if (! currentClass.definesSerializableFields()) {
+             fieldWriter.writeMemberFooter();
+         }
+@@ -494,12 +479,12 @@
+      * Build the summaries for the methods that belong to the given
+      * class.
+      */
+-    public void buildSerializableMethods(List elements) {
++    public void buildSerializableMethods(XMLNode node) {
+         MemberDoc[] members = currentClass.serializationMethods();
+         if (members.length > 0) {
+             for (int i = 0; i < members.length; i++) {
+                 currentMember = members[i];
+-                build(elements);
++                buildChildren(node);
+             }
+         }
+     }
+@@ -508,12 +493,12 @@
+      * Build the summaries for the fields that belong to the given
+      * class.
+      */
+-    public void buildSerializableFields(List elements) {
++    public void buildSerializableFields(XMLNode node) {
+         MemberDoc[] members = currentClass.serializableFields();
+         if (members.length > 0) {
+             for (int i = 0; i < members.length; i++) {
+                 currentMember = members[i];
+-                build(elements);
++                buildChildren(node);
+             }
+         }
+     }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java
+new file mode 100644
+--- /dev/null
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/XMLNode.java
+@@ -0,0 +1,69 @@
++/*
++ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package com.sun.tools.doclets.internal.toolkit.builders;
++
++import java.util.ArrayList;
++import java.util.HashMap;
++import java.util.List;
++import java.util.Map;
++
++/**
++ * Simple class to represent the attribute and elements of an XML node.
++ */
++public class XMLNode {
++    XMLNode(XMLNode parent, String qname) {
++        this.parent = parent;
++        name = qname;
++        attrs = new HashMap<String,String>();
++        children = new ArrayList<XMLNode>();
++
++        if (parent != null)
++            parent.children.add(this);
++    }
++
++    @Override
++    public String toString() {
++        StringBuilder sb = new StringBuilder();
++        sb.append("<");
++        sb.append(name);
++        for (Map.Entry<String,String> e: attrs.entrySet())
++            sb.append(" " + e.getKey() + "=\"" + e.getValue() + "\"");
++        if (children.size() == 0)
++            sb.append("/>");
++        else {
++            sb.append(">");
++            for (XMLNode c: children)
++                sb.append(c.toString());
++            sb.append("</" + name + ">");
++        }
++        return sb.toString();
++    }
++
++    final XMLNode parent;
++    final String name;
++    final Map<String,String> attrs;
++    final List<XMLNode> children;
++}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/6990754-use_native_memory_for_symboltable.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,18947 @@
+# HG changeset patch
+# User andrew
+# Date 1371745779 18000
+# Node ID afb96a923f7f2da64e711455257a024c100e8e2e
+# Parent  af33d9cd440e2851eaffb819d67f86b42c6a8030
+6990754: Use native memory and reference counting to implement SymbolTable
+Summary: move symbols from permgen into C heap and reference count them
+Reviewed-by: never, acorn, jmasa, stefank
+
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java b/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/CommandProcessor.java
+@@ -428,6 +428,36 @@
+                 }
+             }
+         },
++        new Command("symbol", "symbol address", false) {
++            public void doit(Tokens t) {
++                if (t.countTokens() != 1) {
++                    usage();
++                } else {
++                    Address a = VM.getVM().getDebugger().parseAddress(t.nextToken());
++                    Symbol.create(a).printValueOn(out);
++                    out.println();
++                }
++            }
++        },
++        new Command("symboltable", "symboltable name", false) {
++            public void doit(Tokens t) {
++                if (t.countTokens() != 1) {
++                    usage();
++                } else {
++                    out.println(SymbolTable.getTheTable().probe(t.nextToken()));
++                }
++            }
++        },
++        new Command("symboldump", "symboldump", false) {
++            public void doit(Tokens t) {
++                SymbolTable.getTheTable().symbolsDo(new SymbolTable.SymbolVisitor() {
++                        public void visit(Symbol sym) {
++                            sym.printValueOn(out);
++                            out.println();
++                        }
++                    });
++            }
++        },
+         new Command("flags", "flags [ flag ]", false) {
+             public void doit(Tokens t) {
+                 int tokens = t.countTokens();
+@@ -629,17 +659,6 @@
+                 }
+             }
+         },
+-        new Command("symbol", "symbol name", false) {
+-            public void doit(Tokens t) {
+-                if (t.countTokens() != 1) {
+-                    usage();
+-                } else {
+-                    String symbol = t.nextToken();
+-                    Address a = lookup(symbol);
+-                    out.println(symbol + " = " + a);
+-                }
+-            }
+-        },
+         new Command("printstatics", "printstatics [ type ]", false) {
+             public void doit(Tokens t) {
+                 if (t.countTokens() > 1) {
+@@ -1262,6 +1281,9 @@
+         this.err = err;
+         for (int i = 0; i < commandList.length; i++) {
+             Command c = commandList[i];
++            if (commands.get(c.name) != null) {
++                throw new InternalError(c.name + " has multiple definitions");
++            }
+             commands.put(c.name, c);
+         }
+         if (debugger.isAttached()) {
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java b/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java
+@@ -89,6 +89,37 @@
+     readVMLongConstants();
+   }
+ 
++  public Type lookupType(String cTypeName, boolean throwException) {
++    Type fieldType = super.lookupType(cTypeName, false);
++    if (fieldType == null && cTypeName.startsWith("const ")) {
++      fieldType = (BasicType)lookupType(cTypeName.substring(6), false);
++    }
++    if (fieldType == null && cTypeName.endsWith(" const")) {
++        fieldType = (BasicType)lookupType(cTypeName.substring(0, cTypeName.length() - 6), false);
++    }
++    if (fieldType == null) {
++      if (cTypeName.startsWith("GrowableArray<") && cTypeName.endsWith(">*")) {
++        String ttype = cTypeName.substring("GrowableArray<".length(),
++                                            cTypeName.length() - 2);
++        Type templateType = lookupType(ttype, false);
++        if (templateType == null && typeNameIsPointerType(ttype)) {
++          templateType = recursiveCreateBasicPointerType(ttype);
++        }
++        if (templateType == null) {
++          lookupOrFail(ttype);
++        }
++        fieldType = recursiveCreateBasicPointerType(cTypeName);
++      }
++    }
++    if (fieldType == null && typeNameIsPointerType(cTypeName)) {
++      fieldType = recursiveCreateBasicPointerType(cTypeName);
++    }
++    if (fieldType == null && throwException) {
++      super.lookupType(cTypeName, true);
++    }
++    return fieldType;
++  }
++
+   private void readVMTypes() {
+     // Get the variables we need in order to traverse the VMTypeEntry[]
+     long typeEntryTypeNameOffset;
+@@ -250,7 +281,7 @@
+         BasicType containingType = lookupOrFail(typeName);
+ 
+         // The field's Type must already be in the database -- no exceptions
+-        BasicType fieldType = lookupOrFail(typeString);
++        BasicType fieldType = (BasicType)lookupType(typeString);
+ 
+         // Create field by type
+         createField(containingType, fieldName, fieldType,
+@@ -442,10 +473,17 @@
+       workarounds due to incomplete information in the VMStructs
+       database. */
+   private BasicPointerType recursiveCreateBasicPointerType(String typeName) {
++    BasicPointerType result = (BasicPointerType)super.lookupType(typeName, false);
++    if (result != null) {
++      return result;
++    }
+     String targetTypeName = typeName.substring(0, typeName.lastIndexOf('*')).trim();
+     Type targetType = null;
+     if (typeNameIsPointerType(targetTypeName)) {
+-      targetType = recursiveCreateBasicPointerType(targetTypeName);
++      targetType = lookupType(targetTypeName, false);
++      if (targetType == null) {
++        targetType = recursiveCreateBasicPointerType(targetTypeName);
++      }
+     } else {
+       targetType = lookupType(targetTypeName, false);
+       if (targetType == null) {
+@@ -466,6 +504,20 @@
+           BasicType basicTargetType = createBasicType(targetTypeName, false, true, true);
+           basicTargetType.setSize(1);
+           targetType = basicTargetType;
++        } else if (targetTypeName.startsWith("GrowableArray<")) {
++          BasicType basicTargetType = createBasicType(targetTypeName, false, false, false);
++
++          // transfer fields from GenericGrowableArray to template instance
++          BasicType generic = lookupOrFail("GenericGrowableArray");
++          basicTargetType.setSize(generic.getSize());
++          Iterator fields = generic.getFields();
++          while (fields.hasNext()) {
++              Field f = (Field)fields.next();
++              basicTargetType.addField(internalCreateField(basicTargetType, f.getName(),
++                                                           f.getType(), f.isStatic(),
++                                                           f.getOffset(), null));
++          }
++          targetType = basicTargetType;
+         } else {
+           if (DEBUG) {
+             System.err.println("WARNING: missing target type \"" + targetTypeName + "\" for pointer type \"" + typeName + "\"");
+@@ -474,7 +526,10 @@
+         }
+       }
+     }
+-    return new BasicPointerType(this, typeName, targetType);
++    result = new BasicPointerType(this, typeName, targetType);
++    result.setSize(UNINITIALIZED_SIZE);
++    addType(result);
++    return result;
+   }
+ 
+   private boolean typeNameIsPointerType(String typeName) {
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java b/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeLoadConstant.java
+@@ -112,7 +112,7 @@
+   }
+ 
+   // return Symbol (if unresolved) or Klass (if resolved)
+-  public Oop getKlass() {
++  public Object getKlass() {
+     if (Assert.ASSERTS_ENABLED) {
+       Assert.that(isKlassConstant(), "not a klass literal");
+     }
+@@ -121,11 +121,11 @@
+     // decide based on the oop type.
+     ConstantPool cpool = method().getConstants();
+     int cpIndex = index();
+-    Oop oop = cpool.getObjAt(cpIndex);
+-    if (oop.isKlass()) {
+-       return (Klass) oop;
+-    } else if (oop.isSymbol()) {
+-       return (Symbol) oop;
++    ConstantPool.CPSlot oop = cpool.getSlotAt(cpIndex);
++    if (oop.isOop()) {
++      return (Klass) oop.getOop();
++    } else if (oop.isMetaData()) {
++      return oop.getSymbol();
+     } else {
+        throw new RuntimeException("should not reach here");
+     }
+@@ -165,12 +165,12 @@
+        // tag change from 'unresolved' to 'string' does not happen atomically.
+        // We just look at the object at the corresponding index and
+        // decide based on the oop type.
+-       Oop obj = cpool.getObjAt(cpIndex);
+-       if (obj.isSymbol()) {
+-          Symbol sym = (Symbol) obj;
+-          return "<String \"" + sym.asString() + "\">";
+-       } else if (obj.isInstance()) {
+-          return "<String \"" + OopUtilities.stringOopToString(obj) + "\">";
++       ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex);
++       if (obj.isMetaData()) {
++         Symbol sym = obj.getSymbol();
++         return "<String \"" + sym.asString() + "\">";
++       } else if (obj.isOop()) {
++         return "<String \"" + OopUtilities.stringOopToString(obj.getOop()) + "\">";
+        } else {
+           throw new RuntimeException("should not reach here");
+        }
+@@ -178,13 +178,13 @@
+        // tag change from 'unresolved' to 'klass' does not happen atomically.
+        // We just look at the object at the corresponding index and
+        // decide based on the oop type.
+-       Oop obj = cpool.getObjAt(cpIndex);
+-       if (obj.isKlass()) {
+-          Klass k = (Klass) obj;
+-          return "<Class " + k.getName().asString() + "@" + k.getHandle() + ">";
+-       } else if (obj.isSymbol()) {
+-          Symbol sym = (Symbol) obj;
+-          return "<Class " + sym.asString() + ">";
++       ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex);
++       if (obj.isOop()) {
++         Klass k = (Klass) obj.getOop();
++         return "<Class " + k.getName().asString() + "@" + k.getHandle() + ">";
++       } else if (obj.isMetaData()) {
++         Symbol sym = obj.getSymbol();
++         return "<Class " + sym.asString() + ">";
+        } else {
+           throw new RuntimeException("should not reach here");
+        }
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeWithKlass.java b/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeWithKlass.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeWithKlass.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/interpreter/BytecodeWithKlass.java
+@@ -37,11 +37,11 @@
+   }
+ 
+   public Symbol getClassName() {
+-    Oop obj = method().getConstants().getObjAt(index());
+-    if (obj instanceof Symbol) {
+-       return (Symbol)obj;
++    ConstantPool.CPSlot obj = method().getConstants().getSlotAt(index());
++    if (obj.isMetaData()) {
++      return obj.getSymbol();
+     } else {
+-       return ((Klass)obj).getName();
++      return ((Klass)obj.getOop()).getName();
+     }
+   }
+ 
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java b/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/DictionaryEntry.java
+@@ -63,7 +63,7 @@
+   }
+ 
+   public Klass klass() {
+-    return (Klass) literal();
++    return (Klass)VM.getVM().getObjectHeap().newOop(literalValue().addOffsetToAsOopHandle(0));
+   }
+ 
+   public DictionaryEntry(Address addr) {
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/memory/LoaderConstraintEntry.java b/agent/src/share/classes/sun/jvm/hotspot/memory/LoaderConstraintEntry.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/LoaderConstraintEntry.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/LoaderConstraintEntry.java
+@@ -42,14 +42,14 @@
+ 
+   private static synchronized void initialize(TypeDataBase db) {
+     Type type = db.lookupType("LoaderConstraintEntry");
+-    nameField = type.getOopField("_name");
++    nameField = type.getAddressField("_name");
+     numLoadersField = type.getCIntegerField("_num_loaders");
+     maxLoadersField = type.getCIntegerField("_max_loaders");
+     loadersField = type.getAddressField("_loaders");
+   }
+ 
+   // Fields
+-  private static sun.jvm.hotspot.types.OopField nameField;
++  private static AddressField nameField;
+   private static CIntegerField numLoadersField;
+   private static CIntegerField maxLoadersField;
+   private static AddressField loadersField;
+@@ -57,7 +57,7 @@
+   // Accessors
+ 
+   public Symbol name() {
+-    return (Symbol) VM.getVM().getObjectHeap().newOop(nameField.getValue(addr));
++    return Symbol.create(nameField.getValue(addr));
+   }
+ 
+   public int numLoaders() {
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/memory/PlaceholderEntry.java b/agent/src/share/classes/sun/jvm/hotspot/memory/PlaceholderEntry.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/PlaceholderEntry.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/PlaceholderEntry.java
+@@ -58,7 +58,7 @@
+   }
+ 
+   public Symbol klass() {
+-    return (Symbol) literal();
++    return Symbol.create(literalValue());
+   }
+ 
+   /* covariant return type :-(
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/memory/StringTable.java b/agent/src/share/classes/sun/jvm/hotspot/memory/StringTable.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/StringTable.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/StringTable.java
+@@ -70,11 +70,13 @@
+   }
+ 
+   public void stringsDo(StringVisitor visitor) {
++    ObjectHeap oh = VM.getVM().getObjectHeap();
+     int numBuckets = tableSize();
+     for (int i = 0; i < numBuckets; i++) {
+       for (HashtableEntry e = (HashtableEntry) bucket(i); e != null;
+            e = (HashtableEntry) e.next()) {
+-        visitor.visit((Instance) e.literal());
++        Instance s = (Instance)oh.newOop(e.literalValue().addOffsetToAsOopHandle(0));
++        visitor.visit(s);
+       }
+     }
+   }
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java b/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SymbolTable.java
+@@ -85,7 +85,7 @@
+     long hashValue = hashSymbol(name);
+     for (HashtableEntry e = (HashtableEntry) bucket(hashToIndex(hashValue)); e != null; e = (HashtableEntry) e.next()) {
+       if (e.hash() == hashValue) {
+-         Symbol sym = (Symbol) e.literal();
++         Symbol sym = Symbol.create(e.literalValue());
+          if (sym.equals(name)) {
+            return sym;
+          }
+@@ -103,7 +103,7 @@
+     for (int i = 0; i < numBuckets; i++) {
+       for (HashtableEntry e = (HashtableEntry) bucket(i); e != null;
+            e = (HashtableEntry) e.next()) {
+-        visitor.visit((Symbol) e.literal());
++        visitor.visit(Symbol.create(e.literalValue()));
+       }
+     }
+   }
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java b/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ConstantPool.java
+@@ -35,6 +35,38 @@
+ // as described in the class file
+ 
+ public class ConstantPool extends Oop implements ClassConstants {
++
++  public class CPSlot {
++    private Address ptr;
++
++    CPSlot(Address ptr) {
++      this.ptr = ptr;
++    }
++    CPSlot(Symbol sym) {
++      this.ptr = sym.getAddress().orWithMask(1);
++    }
++
++    public boolean isOop() {
++      return (ptr.minus(null) & 1) == 0;
++    }
++    public boolean isMetaData() {
++      return (ptr.minus(null) & 1) == 1;
++    }
++
++    public Symbol getSymbol() {
++      if (isMetaData()) {
++        return Symbol.create(ptr.xorWithMask(1));
++      }
++      throw new InternalError("not a symbol");
++    }
++    public Oop getOop() {
++      if (isOop()) {
++        return VM.getVM().getObjectHeap().newOop(ptr.addOffsetToAsOopHandle(0));
++      }
++      throw new InternalError("not an oop");
++    }
++  }
++
+   // Used for debugging this code
+   private static final boolean DEBUG = false;
+ 
+@@ -110,12 +142,17 @@
+     return new ConstantTag(getTags().getByteAt((int) index));
+   }
+ 
+-  public Oop getObjAt(long index){
++  public CPSlot getSlotAt(long index) {
++    return new CPSlot(getHandle().getAddressAt(indexOffset(index)));
++  }
++
++  public Oop getObjAtRaw(long index){
+     return getHeap().newOop(getHandle().getOopHandleAt(indexOffset(index)));
+   }
+ 
+   public Symbol getSymbolAt(long index) {
+-    return (Symbol) getObjAt(index);
++    CPSlot slot = getSlotAt(index);
++    return slot.getSymbol();
+   }
+ 
+   public int getIntAt(long index){
+@@ -187,7 +224,7 @@
+   // returns null, if not resolved.
+   public Klass getKlassRefAt(int which) {
+     if( ! getTagAt(which).isKlass()) return null;
+-    return (Klass) getObjAt(which);
++    return (Klass) getObjAtRaw(which);
+   }
+ 
+   // returns null, if not resolved.
+@@ -477,7 +514,7 @@
+               case JVM_CONSTANT_Class: {
+                   dos.writeByte(cpConstType);
+                   // Klass already resolved. ConstantPool constains klassOop.
+-                  Klass refKls = (Klass) getObjAt(ci);
++                  Klass refKls = (Klass) getObjAtRaw(ci);
+                   String klassName = refKls.getName().asString();
+                   Short s = (Short) utf8ToIndex.get(klassName);
+                   dos.writeShort(s.shortValue());
+@@ -498,7 +535,7 @@
+ 
+               case JVM_CONSTANT_String: {
+                   dos.writeByte(cpConstType);
+-                  String str = OopUtilities.stringOopToString(getObjAt(ci));
++                  String str = OopUtilities.stringOopToString(getObjAtRaw(ci));
+                   Short s = (Short) utf8ToIndex.get(str);
+                   dos.writeShort(s.shortValue());
+                   if (DEBUG) debugMessage("CP[" + ci + "] = string " + s);
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/GenerateOopMap.java b/agent/src/share/classes/sun/jvm/hotspot/oops/GenerateOopMap.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/GenerateOopMap.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/GenerateOopMap.java
+@@ -576,7 +576,7 @@
+           ConstantPool cp       = method().getConstants();
+           int nameAndTypeIdx    = cp.name_and_type_ref_index_at(idx);
+           int signatureIdx      = cp.signature_ref_index_at(nameAndTypeIdx);
+-          symbolOop signature   = cp.symbol_at(signatureIdx);
++          Symbol* signature     = cp.symbol_at(signatureIdx);
+           tty.print("%s", signature.as_C_string());
+         */
+       }
+@@ -616,7 +616,7 @@
+           constantPoolOop cp    = method().constants();
+           int nameAndTypeIdx    = cp.name_and_type_ref_index_at(idx);
+           int signatureIdx      = cp.signature_ref_index_at(nameAndTypeIdx);
+-          symbolOop signature   = cp.symbol_at(signatureIdx);
++          Symbol* signature     = cp.symbol_at(signatureIdx);
+           tty.print("%s", signature.as_C_string());
+         */
+       }
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
+@@ -82,8 +82,8 @@
+     classLoader          = new OopField(type.getOopField("_class_loader"), Oop.getHeaderSize());
+     protectionDomain     = new OopField(type.getOopField("_protection_domain"), Oop.getHeaderSize());
+     signers              = new OopField(type.getOopField("_signers"), Oop.getHeaderSize());
+-    sourceFileName       = new OopField(type.getOopField("_source_file_name"), Oop.getHeaderSize());
+-    sourceDebugExtension = new OopField(type.getOopField("_source_debug_extension"), Oop.getHeaderSize());
++    sourceFileName       = type.getAddressField("_source_file_name");
++    sourceDebugExtension = type.getAddressField("_source_debug_extension");
+     innerClasses         = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize());
+     nonstaticFieldSize   = new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize());
+     staticFieldSize      = new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize());
+@@ -94,7 +94,7 @@
+     vtableLen            = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize());
+     itableLen            = new CIntField(type.getCIntegerField("_itable_len"), Oop.getHeaderSize());
+     breakpoints          = type.getAddressField("_breakpoints");
+-    genericSignature     = new OopField(type.getOopField("_generic_signature"), Oop.getHeaderSize());
++    genericSignature     = type.getAddressField("_generic_signature");
+     majorVersion         = new CIntField(type.getCIntegerField("_major_version"), Oop.getHeaderSize());
+     minorVersion         = new CIntField(type.getCIntegerField("_minor_version"), Oop.getHeaderSize());
+     headerSize           = alignObjectOffset(Oop.getHeaderSize() + type.getSize());
+@@ -135,8 +135,8 @@
+   private static OopField  classLoader;
+   private static OopField  protectionDomain;
+   private static OopField  signers;
+-  private static OopField  sourceFileName;
+-  private static OopField  sourceDebugExtension;
++  private static AddressField  sourceFileName;
++  private static AddressField  sourceDebugExtension;
+   private static OopField  innerClasses;
+   private static CIntField nonstaticFieldSize;
+   private static CIntField staticFieldSize;
+@@ -147,7 +147,7 @@
+   private static CIntField vtableLen;
+   private static CIntField itableLen;
+   private static AddressField breakpoints;
+-  private static OopField  genericSignature;
++  private static AddressField  genericSignature;
+   private static CIntField majorVersion;
+   private static CIntField minorVersion;
+ 
+@@ -257,8 +257,8 @@
+   public Oop       getClassLoader()         { return                classLoader.getValue(this); }
+   public Oop       getProtectionDomain()    { return                protectionDomain.getValue(this); }
+   public ObjArray  getSigners()             { return (ObjArray)     signers.getValue(this); }
+-  public Symbol    getSourceFileName()      { return (Symbol)       sourceFileName.getValue(this); }
+-  public Symbol    getSourceDebugExtension(){ return (Symbol)       sourceDebugExtension.getValue(this); }
++  public Symbol    getSourceFileName()      { return getSymbol(sourceFileName); }
++  public Symbol    getSourceDebugExtension(){ return getSymbol(sourceDebugExtension); }
+   public TypeArray getInnerClasses()        { return (TypeArray)    innerClasses.getValue(this); }
+   public long      getNonstaticFieldSize()  { return                nonstaticFieldSize.getValue(this); }
+   public long      getStaticOopFieldCount() { return                staticOopFieldCount.getValue(this); }
+@@ -266,7 +266,7 @@
+   public boolean   getIsMarkedDependent()   { return                isMarkedDependent.getValue(this) != 0; }
+   public long      getVtableLen()           { return                vtableLen.getValue(this); }
+   public long      getItableLen()           { return                itableLen.getValue(this); }
+-  public Symbol    getGenericSignature()    { return (Symbol)       genericSignature.getValue(this); }
++  public Symbol    getGenericSignature()    { return getSymbol(genericSignature); }
+   public long      majorVersion()           { return                majorVersion.getValue(this); }
+   public long      minorVersion()           { return                minorVersion.getValue(this); }
+ 
+@@ -307,12 +307,12 @@
+           if (ioff != 0) {
+              // only look at classes that are already loaded
+              // since we are looking for the flags for our self.
+-             Oop classInfo = getConstants().getObjAt(ioff);
++             ConstantPool.CPSlot classInfo = getConstants().getSlotAt(ioff);
+              Symbol name = null;
+-             if (classInfo instanceof Klass) {
+-                name = ((Klass) classInfo).getName();
+-             } else if (classInfo instanceof Symbol) {
+-                name = (Symbol) classInfo;
++             if (classInfo.isOop()) {
++               name = ((Klass) classInfo.getOop()).getName();
++             } else if (classInfo.isMetaData()) {
++               name = classInfo.getSymbol();
+              } else {
+                 throw new RuntimeException("should not reach here");
+              }
+@@ -357,12 +357,12 @@
+          // 'ioff' can be zero.
+          // refer to JVM spec. section 4.7.5.
+          if (ioff != 0) {
+-            Oop iclassInfo = getConstants().getObjAt(ioff);
++            ConstantPool.CPSlot iclassInfo = getConstants().getSlotAt(ioff);
+             Symbol innerName = null;
+-            if (iclassInfo instanceof Klass) {
+-               innerName = ((Klass) iclassInfo).getName();
+-            } else if (iclassInfo instanceof Symbol) {
+-               innerName = (Symbol) iclassInfo;
++            if (iclassInfo.isOop()) {
++              innerName = ((Klass) iclassInfo.getOop()).getName();
++            } else if (iclassInfo.isMetaData()) {
++              innerName = iclassInfo.getSymbol();
+             } else {
+                throw new RuntimeException("should not reach here");
+             }
+@@ -386,12 +386,12 @@
+                   }
+                }
+             } else {
+-               Oop oclassInfo = getConstants().getObjAt(ooff);
++               ConstantPool.CPSlot oclassInfo = getConstants().getSlotAt(ooff);
+                Symbol outerName = null;
+-               if (oclassInfo instanceof Klass) {
+-                  outerName = ((Klass) oclassInfo).getName();
+-               } else if (oclassInfo instanceof Symbol) {
+-                  outerName = (Symbol) oclassInfo;
++               if (oclassInfo.isOop()) {
++                 outerName = ((Klass) oclassInfo.getOop()).getName();
++               } else if (oclassInfo.isMetaData()) {
++                 outerName = oclassInfo.getSymbol();
+                } else {
+                   throw new RuntimeException("should not reach here");
+                }
+@@ -449,7 +449,6 @@
+       visitor.doOop(classLoader, true);
+       visitor.doOop(protectionDomain, true);
+       visitor.doOop(signers, true);
+-      visitor.doOop(sourceFileName, true);
+       visitor.doOop(innerClasses, true);
+       visitor.doCInt(nonstaticFieldSize, true);
+       visitor.doCInt(staticFieldSize, true);
+@@ -466,7 +465,7 @@
+     for (int index = 0; index < length; index += NEXT_OFFSET) {
+       short accessFlags    = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
+       short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
+-      FieldType   type   = new FieldType((Symbol) getConstants().getObjAt(signatureIndex));
++      FieldType   type   = new FieldType(getConstants().getSymbolAt(signatureIndex));
+       AccessFlags access = new AccessFlags(accessFlags);
+       if (access.isStatic()) {
+         visitField(visitor, type, index);
+@@ -489,7 +488,7 @@
+       short accessFlags    = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
+       short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
+ 
+-      FieldType   type   = new FieldType((Symbol) getConstants().getObjAt(signatureIndex));
++      FieldType   type   = new FieldType(getConstants().getSymbolAt(signatureIndex));
+       AccessFlags access = new AccessFlags(accessFlags);
+       if (!access.isStatic()) {
+         visitField(visitor, type, index);
+@@ -786,7 +785,7 @@
+   private Field newField(int index) {
+     TypeArray fields = getFields();
+     short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
+-    FieldType type = new FieldType((Symbol) getConstants().getObjAt(signatureIndex));
++    FieldType type = new FieldType(getConstants().getSymbolAt(signatureIndex));
+     if (type.isOop()) {
+      if (VM.getVM().isCompressedOopsEnabled()) {
+         return new NarrowOopField(this, index);
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java b/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Klass.java
+@@ -53,7 +53,7 @@
+     javaMirror   = new OopField(type.getOopField("_java_mirror"), Oop.getHeaderSize());
+     superField   = new OopField(type.getOopField("_super"), Oop.getHeaderSize());
+     layoutHelper = new IntField(type.getJIntField("_layout_helper"), Oop.getHeaderSize());
+-    name         = new OopField(type.getOopField("_name"), Oop.getHeaderSize());
++    name         = type.getAddressField("_name");
+     accessFlags  = new CIntField(type.getCIntegerField("_access_flags"), Oop.getHeaderSize());
+     subklass     = new OopField(type.getOopField("_subklass"), Oop.getHeaderSize());
+     nextSibling  = new OopField(type.getOopField("_next_sibling"), Oop.getHeaderSize());
+@@ -83,18 +83,26 @@
+   private static OopField  javaMirror;
+   private static OopField  superField;
+   private static IntField layoutHelper;
+-  private static OopField  name;
++  private static AddressField  name;
+   private static CIntField accessFlags;
+   private static OopField  subklass;
+   private static OopField  nextSibling;
+   private static CIntField allocCount;
+ 
++  private Address getValue(AddressField field) {
++    return getHandle().getAddressAt(field.getOffset() + Oop.getHeaderSize());
++  }
++
++  protected Symbol getSymbol(AddressField field) {
++    return Symbol.create(getHandle().getAddressAt(field.getOffset() + Oop.getHeaderSize()));
++  }
++
+   // Accessors for declared fields
+   public Instance getJavaMirror()       { return (Instance) javaMirror.getValue(this);   }
+   public Klass    getSuper()            { return (Klass)    superField.getValue(this);   }
+   public Klass    getJavaSuper()        { return null;  }
+   public int      getLayoutHelper()     { return (int)           layoutHelper.getValue(this); }
+-  public Symbol   getName()             { return (Symbol)   name.getValue(this);         }
++  public Symbol   getName()             { return getSymbol(name); }
+   public long     getAccessFlags()      { return            accessFlags.getValue(this);  }
+   // Convenience routine
+   public AccessFlags getAccessFlagsObj(){ return new AccessFlags(getAccessFlags());      }
+@@ -162,7 +170,7 @@
+       visitor.doOop(javaMirror, true);
+       visitor.doOop(superField, true);
+       visitor.doInt(layoutHelper, true);
+-      visitor.doOop(name, true);
++      // visitor.doOop(name, true);
+       visitor.doCInt(accessFlags, true);
+       visitor.doOop(subklass, true);
+       visitor.doOop(nextSibling, true);
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java b/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Method.java
+@@ -196,11 +196,11 @@
+   public Address      getFromCompiledCodeEntryPoint() { return fromCompiledCodeEntryPointField.getValue(this); }
+   */
+   // Accessors
+-  public Symbol  getName()          { return (Symbol) getConstants().getObjAt(getNameIndex());         }
+-  public Symbol  getSignature()     { return (Symbol) getConstants().getObjAt(getSignatureIndex());    }
++  public Symbol  getName()          { return getConstants().getSymbolAt(getNameIndex());         }
++  public Symbol  getSignature()     { return getConstants().getSymbolAt(getSignatureIndex());    }
+   public Symbol  getGenericSignature() {
+      long index = getGenericSignatureIndex();
+-     return (index != 0L) ? (Symbol) getConstants().getObjAt(index) : null;
++     return (index != 0L) ? getConstants().getSymbolAt(index) : null;
+   }
+ 
+   // Method holder (the Klass holding this method)
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java b/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java
+@@ -47,7 +47,6 @@
+     DEBUG = System.getProperty("sun.jvm.hotspot.oops.ObjectHeap.DEBUG") != null;
+   }
+ 
+-  private OopHandle              symbolKlassHandle;
+   private OopHandle              methodKlassHandle;
+   private OopHandle              constMethodKlassHandle;
+   private OopHandle              methodDataKlassHandle;
+@@ -68,7 +67,6 @@
+   private OopHandle              arrayKlassKlassHandle;
+   private OopHandle              compiledICHolderKlassHandle;
+ 
+-  private SymbolKlass            symbolKlassObj;
+   private MethodKlass            methodKlassObj;
+   private ConstMethodKlass       constMethodKlassObj;
+   private MethodDataKlass        methodDataKlassObj;
+@@ -93,9 +91,6 @@
+     // Lookup the roots in the object hierarchy.
+     Type universeType = db.lookupType("Universe");
+ 
+-    symbolKlassHandle         = universeType.getOopField("_symbolKlassObj").getValue();
+-    symbolKlassObj            = new SymbolKlass(symbolKlassHandle, this);
+-
+     methodKlassHandle         = universeType.getOopField("_methodKlassObj").getValue();
+     methodKlassObj            = new MethodKlass(methodKlassHandle, this);
+ 
+@@ -199,7 +194,6 @@
+   public long getDoubleSize()  { return doubleSize;  }
+ 
+   // Accessors for well-known system classes (from Universe)
+-  public SymbolKlass            getSymbolKlassObj()            { return symbolKlassObj; }
+   public MethodKlass            getMethodKlassObj()            { return methodKlassObj; }
+   public ConstMethodKlass       getConstMethodKlassObj()       { return constMethodKlassObj; }
+   public MethodDataKlass        getMethodDataKlassObj()        { return methodDataKlassObj; }
+@@ -337,7 +331,6 @@
+     // First check if handle is one of the root objects
+     if (handle.equals(methodKlassHandle))              return getMethodKlassObj();
+     if (handle.equals(constMethodKlassHandle))         return getConstMethodKlassObj();
+-    if (handle.equals(symbolKlassHandle))              return getSymbolKlassObj();
+     if (handle.equals(constantPoolKlassHandle))        return getConstantPoolKlassObj();
+     if (handle.equals(constantPoolCacheKlassHandle))   return getConstantPoolCacheKlassObj();
+     if (handle.equals(instanceKlassKlassHandle))       return getInstanceKlassKlassObj();
+@@ -363,7 +356,6 @@
+     if (klass != null) {
+       if (klass.equals(methodKlassHandle))              return new Method(handle, this);
+       if (klass.equals(constMethodKlassHandle))         return new ConstMethod(handle, this);
+-      if (klass.equals(symbolKlassHandle))              return new Symbol(handle, this);
+       if (klass.equals(constantPoolKlassHandle))        return new ConstantPool(handle, this);
+       if (klass.equals(constantPoolCacheKlassHandle))   return new ConstantPoolCache(handle, this);
+       if (!VM.getVM().isCore()) {
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/Symbol.java b/agent/src/share/classes/sun/jvm/hotspot/oops/Symbol.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Symbol.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Symbol.java
+@@ -34,7 +34,7 @@
+ // A Symbol is a canonicalized string.
+ // All Symbols reside in global symbolTable.
+ 
+-public class Symbol extends Oop {
++public class Symbol extends VMObject {
+   static {
+     VM.registerVMInitializedObserver(new Observer() {
+         public void update(Observable o, Object data) {
+@@ -44,9 +44,10 @@
+   }
+ 
+   private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+-    Type type  = db.lookupType("symbolOopDesc");
+-    length     = new CIntField(type.getCIntegerField("_length"), 0);
++    Type type  = db.lookupType("Symbol");
++    length     = type.getCIntegerField("_length");
+     baseOffset = type.getField("_body").getOffset();
++    idHash = type.getCIntegerField("_identity_hash");
+   }
+ 
+   // Format:
+@@ -55,8 +56,15 @@
+   //   [length] byte size of uft8 string
+   //   ..body..
+ 
+-  Symbol(OopHandle handle, ObjectHeap heap) {
+-    super(handle, heap);
++  public static Symbol create(Address addr) {
++    if (addr == null) {
++      return null;
++    }
++    return new Symbol(addr);
++  }
++
++  Symbol(Address addr) {
++    super(addr);
+   }
+ 
+   public boolean isSymbol()            { return true; }
+@@ -64,15 +72,19 @@
+   private static long baseOffset; // tells where the array part starts
+ 
+   // Fields
+-  private static CIntField length;
++  private static CIntegerField length;
+ 
+   // Accessors for declared fields
+-  public long   getLength() { return          length.getValue(this); }
++  public long   getLength() { return          length.getValue(this.addr); }
+ 
+   public byte getByteAt(long index) {
+-    return getHandle().getJByteAt(baseOffset + index);
++    return addr.getJByteAt(baseOffset + index);
+   }
+ 
++  private static CIntegerField idHash;
++
++  public int identityHash() { return     (int)idHash.getValue(this.addr); }
++
+   public boolean equals(byte[] modUTF8Chars) {
+     int l = (int) getLength();
+     if (l != modUTF8Chars.length) return false;
+@@ -98,7 +110,9 @@
+     // Decode the byte array and return the string.
+     try {
+       return readModifiedUTF8(asByteArray());
+-    } catch(IOException e) {
++    } catch(Exception e) {
++      System.err.println(addr);
++      e.printStackTrace();
+       return null;
+     }
+   }
+@@ -111,28 +125,13 @@
+     tty.print("#" + asString());
+   }
+ 
+-  public long getObjectSize() {
+-    return alignObjectSize(baseOffset + getLength());
+-  }
+-
+-  void iterateFields(OopVisitor visitor, boolean doVMFields) {
+-    super.iterateFields(visitor, doVMFields);
+-    if (doVMFields) {
+-      visitor.doCInt(length, true);
+-      int length = (int) getLength();
+-      for (int index = 0; index < length; index++) {
+-        visitor.doByte(new ByteField(new IndexableFieldIdentifier(index), baseOffset + index, false), true);
+-      }
+-    }
+-  }
+-
+   /** Note: this comparison is used for vtable sorting only; it
+       doesn't matter what order it defines, as long as it is a total,
+-      time-invariant order Since symbolOops are in permSpace, their
++      time-invariant order Since Symbol* are in C_HEAP, their
+       relative order in memory never changes, so use address
+       comparison for speed. */
+   public int fastCompare(Symbol other) {
+-    return (int) getHandle().minus(other.getHandle());
++    return (int) addr.minus(other.addr);
+   }
+ 
+   private static String readModifiedUTF8(byte[] buf) throws IOException {
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/SymbolKlass.java b/agent/src/share/classes/sun/jvm/hotspot/oops/SymbolKlass.java
+deleted file mode 100644
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/SymbolKlass.java
++++ /dev/null
+@@ -1,60 +0,0 @@
+-/*
+- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+- *
+- */
+-
+-package sun.jvm.hotspot.oops;
+-
+-import java.io.*;
+-import java.util.*;
+-import sun.jvm.hotspot.debugger.*;
+-import sun.jvm.hotspot.runtime.*;
+-import sun.jvm.hotspot.types.*;
+-
+-// A SymbolKlass is the klass for all Symbols
+-
+-public class SymbolKlass extends Klass {
+-  static {
+-    VM.registerVMInitializedObserver(new Observer() {
+-        public void update(Observable o, Object data) {
+-          initialize(VM.getVM().getTypeDataBase());
+-        }
+-      });
+-  }
+-
+-  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
+-    Type type  = db.lookupType("symbolKlass");
+-    headerSize = type.getSize() + Oop.getHeaderSize();
+-  }
+-
+-  SymbolKlass(OopHandle handle, ObjectHeap heap) {
+-    super(handle, heap);
+-  }
+-
+-  private static long headerSize;
+-
+-  public long getObjectSize() { return alignObjectSize(headerSize); }
+-
+-  public void printValueOn(PrintStream tty) {
+-    tty.print("SymbolKlass");
+-  }
+-}
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java b/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java
+@@ -229,7 +229,7 @@
+                 case JVM_CONSTANT_Class: {
+                      dos.writeByte(cpConstType);
+                      // Klass already resolved. ConstantPool constains klassOop.
+-                     Klass refKls = (Klass) cpool.getObjAt(ci);
++                     Klass refKls = (Klass) cpool.getObjAtRaw(ci);
+                      String klassName = refKls.getName().asString();
+ 
+                      Short s = (Short) utf8ToIndex.get(klassName);
+@@ -255,7 +255,7 @@
+ 
+                 case JVM_CONSTANT_String: {
+                      dos.writeByte(cpConstType);
+-                     String str = OopUtilities.stringOopToString(cpool.getObjAt(ci));
++                     String str = OopUtilities.stringOopToString(cpool.getObjAtRaw(ci));
+                      Short s = (Short) utf8ToIndex.get(str);
+                      dos.writeShort(s.shortValue());
+                      if (DEBUG) debugMessage("CP[" + ci + "] = string " + s);
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/types/Field.java b/agent/src/share/classes/sun/jvm/hotspot/types/Field.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/types/Field.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/types/Field.java
+@@ -56,7 +56,7 @@
+     </PRE>
+ 
+     FIXME: among other things, this interface is not sufficient to
+-    describe fields which are themselves arrays (like symbolOop's
++    describe fields which are themselves arrays (like Symbol's
+     jbyte _body[1]).  */
+ public interface Field {
+   /** Get the name of this field */
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java b/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java
+@@ -530,7 +530,7 @@
+ 
+             case JVM_CONSTANT_Class:
+                buf.cell("JVM_CONSTANT_Class");
+-               Klass klass = (Klass) cpool.getObjAt(index);
++               Klass klass = (Klass) cpool.getObjAtRaw(index);
+                if (klass instanceof InstanceKlass) {
+                   buf.cell(genKlassLink((InstanceKlass) klass));
+                } else {
+@@ -555,7 +555,7 @@
+             case JVM_CONSTANT_String:
+                buf.cell("JVM_CONSTANT_String");
+                buf.cell("\"" +
+-                 escapeHTMLSpecialChars(OopUtilities.stringOopToString(cpool.getObjAt(index))) + "\"");
++                 escapeHTMLSpecialChars(OopUtilities.stringOopToString(cpool.getObjAtRaw(index))) + "\"");
+                break;
+ 
+             case JVM_CONSTANT_Fieldref:
+@@ -672,11 +672,11 @@
+             buf.beginTag("ul");
+             for (int exp = 0; exp < exceptions.length; exp++) {
+                short cpIndex = (short) exceptions[exp].getClassCPIndex();
+-               Oop obj = cpool.getObjAt(cpIndex);
+-               if (obj instanceof Symbol) {
+-                  buf.li(((Symbol)obj).asString().replace('/', '.'));
++               ConstantPool.CPSlot obj = cpool.getSlotAt(cpIndex);
++               if (obj.isMetaData()) {
++                 buf.li((obj.getSymbol()).asString().replace('/', '.'));
+                } else {
+-                  buf.li(genKlassLink((InstanceKlass)obj));
++                 buf.li(genKlassLink((InstanceKlass)obj.getOop()));
+                }
+             }
+             buf.endTag("ul");
+@@ -756,7 +756,7 @@
+                              } else if (instr instanceof BytecodeLoadConstant) {
+                                 BytecodeLoadConstant ldc = (BytecodeLoadConstant) instr;
+                                 if (ldc.isKlassConstant()) {
+-                                   Oop oop = ldc.getKlass();
++                                   Object oop = ldc.getKlass();
+                                    if (oop instanceof Klass) {
+                                       buf.append("<a href='");
+                                       buf.append(genKlassHref((InstanceKlass) oop));
+@@ -803,13 +803,13 @@
+                buf.cell(Integer.toString(exceptionTable.getIntAt(e + 1)));
+                buf.cell(Integer.toString(exceptionTable.getIntAt(e + 2)));
+                short cpIndex = (short) exceptionTable.getIntAt(e + 3);
+-               Oop obj = cpIndex == 0? null : cpool.getObjAt(cpIndex);
++               ConstantPool.CPSlot obj = cpIndex == 0? null : cpool.getSlotAt(cpIndex);
+                if (obj == null) {
+                   buf.cell("Any");
+-               } else if (obj instanceof Symbol) {
+-                  buf.cell(((Symbol)obj).asString().replace('/', '.'));
++               } else if (obj.isMetaData()) {
++                 buf.cell(obj.getSymbol().asString().replace('/', '.'));
+                } else {
+-                  buf.cell(genKlassLink((InstanceKlass)obj));
++                 buf.cell(genKlassLink((InstanceKlass)obj.getOop()));
+                }
+                buf.endTag("tr");
+             }
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/utilities/Hashtable.java b/agent/src/share/classes/sun/jvm/hotspot/utilities/Hashtable.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/Hashtable.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/Hashtable.java
+@@ -40,7 +40,7 @@
+ 
+   private static synchronized void initialize(TypeDataBase db) {
+     // just to confirm that type exists
+-    Type type = db.lookupType("Hashtable");
++    Type type = db.lookupType("Hashtable<intptr_t>");
+   }
+ 
+   // derived class may return Class<? extends HashtableEntry>
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/utilities/HashtableEntry.java b/agent/src/share/classes/sun/jvm/hotspot/utilities/HashtableEntry.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HashtableEntry.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HashtableEntry.java
+@@ -41,16 +41,16 @@
+   }
+ 
+   private static synchronized void initialize(TypeDataBase db) {
+-    Type type = db.lookupType("HashtableEntry");
+-    literalField   = type.getOopField("_literal");
++    Type type = db.lookupType("HashtableEntry<intptr_t>");
++    literalField   = type.getAddressField("_literal");
+   }
+ 
+   // Fields
+-  private static OopField      literalField;
++  private static AddressField      literalField;
+ 
+   // Accessors
+-  public Oop literal() {
+-    return VM.getVM().getObjectHeap().newOop(literalField.getValue(addr));
++  public Address literalValue() {
++    return literalField.getValue(addr);
+   }
+ 
+   public HashtableEntry(Address addr) {
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java b/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
+@@ -740,7 +740,7 @@
+         for (Iterator itr = fields.iterator(); itr.hasNext();) {
+             Field field = (Field) itr.next();
+             Symbol name = symTbl.probe(field.getID().getName());
+-            writeObjectID(name);
++            writeSymbolID(name);
+             char typeCode = (char) field.getSignature().getByteAt(0);
+             int kind = signatureToHprofKind(typeCode);
+             out.writeByte((byte)kind);
+@@ -852,7 +852,7 @@
+     private void writeSymbol(Symbol sym) throws IOException {
+         byte[] buf = sym.asString().getBytes("UTF-8");
+         writeHeader(HPROF_UTF8, buf.length + OBJ_ID_SIZE);
+-        writeObjectID(sym);
++        writeSymbolID(sym);
+         out.write(buf);
+     }
+ 
+@@ -869,7 +869,7 @@
+                         out.writeInt(serialNum);
+                         writeObjectID(clazz);
+                         out.writeInt(DUMMY_STACK_TRACE_ID);
+-                        writeObjectID(k.getName());
++                        writeSymbolID(k.getName());
+                         serialNum++;
+                     } catch (IOException exp) {
+                         throw new RuntimeException(exp);
+@@ -901,6 +901,10 @@
+         writeObjectID(address);
+     }
+ 
++    private void writeSymbolID(Symbol sym) throws IOException {
++        writeObjectID(getAddressValue(sym.getAddress()));
++    }
++
+     private void writeObjectID(long address) throws IOException {
+         if (OBJ_ID_SIZE == 4) {
+             out.writeInt((int) address);
+diff --git a/src/cpu/sparc/vm/sharedRuntime_sparc.cpp b/src/cpu/sparc/vm/sharedRuntime_sparc.cpp
+--- openjdk/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp
++++ openjdk/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp
+@@ -2541,7 +2541,7 @@
+     in_sig_bt[i++] = bt;  // Collect remaining bits of signature
+     out_sig_bt[total_c_args++] = bt;
+     if( bt == T_OBJECT) {
+-      symbolOop s = ss.as_symbol_or_null();
++      Symbol* s = ss.as_symbol_or_null();
+       if (s == vmSymbols::java_lang_String()) {
+         total_strings++;
+         out_sig_bt[total_c_args-1] = T_ADDRESS;
+diff --git a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
+--- openjdk/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
++++ openjdk/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
+@@ -1974,7 +1974,7 @@
+     in_sig_bt[i++] = bt;  // Collect remaining bits of signature
+     out_sig_bt[total_c_args++] = bt;
+     if( bt == T_OBJECT) {
+-      symbolOop s = ss.as_symbol_or_null();
++      Symbol* s = ss.as_symbol_or_null();   // symbol is created
+       if (s == vmSymbols::java_lang_String()) {
+         total_strings++;
+         out_sig_bt[total_c_args-1] = T_ADDRESS;
+diff --git a/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
+--- openjdk/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
++++ openjdk/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp
+@@ -1980,7 +1980,7 @@
+     in_sig_bt[i++] = bt;  // Collect remaining bits of signature
+     out_sig_bt[total_c_args++] = bt;
+     if( bt == T_OBJECT) {
+-      symbolOop s = ss.as_symbol_or_null();
++      Symbol* s = ss.as_symbol_or_null();   // symbol is created
+       if (s == vmSymbols::java_lang_String()) {
+         total_strings++;
+         out_sig_bt[total_c_args-1] = T_ADDRESS;
+diff --git a/src/os/solaris/dtrace/generateJvmOffsets.cpp b/src/os/solaris/dtrace/generateJvmOffsets.cpp
+--- openjdk/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp
++++ openjdk/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp
+@@ -49,7 +49,7 @@
+ #include "oops/klass.hpp"
+ #include "oops/methodOop.hpp"
+ #include "oops/oop.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/virtualspace.hpp"
+ #include "runtime/vmStructs.hpp"
+ #include "utilities/accessFlags.hpp"
+@@ -215,8 +215,8 @@
+   GEN_VALUE(AccessFlags_NATIVE, JVM_ACC_NATIVE);
+   GEN_VALUE(constMethodOopDesc_has_linenumber_table, constMethodOopDesc::_has_linenumber_table);
+   GEN_OFFS(AccessFlags, _flags);
+-  GEN_OFFS(symbolOopDesc, _length);
+-  GEN_OFFS(symbolOopDesc, _body);
++  GEN_OFFS(Symbol, _length);
++  GEN_OFFS(Symbol, _body);
+   printf("\n");
+ 
+   GEN_OFFS(methodOopDesc, _constMethod);
+diff --git a/src/os/solaris/dtrace/jhelper.d b/src/os/solaris/dtrace/jhelper.d
+--- openjdk/hotspot/src/os/solaris/dtrace/jhelper.d
++++ openjdk/hotspot/src/os/solaris/dtrace/jhelper.d
+@@ -114,8 +114,8 @@
+   copyin_offset(OFFSET_HeapBlockHeader_used);
+   copyin_offset(OFFSET_oopDesc_metadata);
+ 
+-  copyin_offset(OFFSET_symbolOopDesc_length);
+-  copyin_offset(OFFSET_symbolOopDesc_body);
++  copyin_offset(OFFSET_Symbol_length);
++  copyin_offset(OFFSET_Symbol_body);
+ 
+   copyin_offset(OFFSET_methodOopDesc_constMethod);
+   copyin_offset(OFFSET_methodOopDesc_constants);
+@@ -366,13 +366,13 @@
+       this->nameIndex * sizeof (pointer) + SIZE_constantPoolOopDesc);
+ 
+   this->nameSymbolLength = copyin_uint16(this->nameSymbol +
+-      OFFSET_symbolOopDesc_length);
++      OFFSET_Symbol_length);
+ 
+   this->signatureSymbol = copyin_ptr(this->constantPool +
+       this->signatureIndex * sizeof (pointer) + SIZE_constantPoolOopDesc);
+ 
+   this->signatureSymbolLength = copyin_uint16(this->signatureSymbol +
+-      OFFSET_symbolOopDesc_length);
++      OFFSET_Symbol_length);
+ 
+   this->klassPtr = copyin_ptr(this->constantPool +
+       OFFSET_constantPoolOopDesc_pool_holder);
+@@ -381,7 +381,7 @@
+       OFFSET_Klass_name + SIZE_oopDesc);
+ 
+   this->klassSymbolLength = copyin_uint16(this->klassSymbol +
+-      OFFSET_symbolOopDesc_length);
++      OFFSET_Symbol_length);
+ 
+   /*
+    * Enough for three strings, plus the '.', plus the trailing '\0'.
+@@ -390,7 +390,7 @@
+       this->nameSymbolLength +
+       this->signatureSymbolLength + 2 + 1);
+ 
+-  copyinto(this->klassSymbol + OFFSET_symbolOopDesc_body,
++  copyinto(this->klassSymbol + OFFSET_Symbol_body,
+       this->klassSymbolLength, this->result);
+ 
+   /*
+@@ -398,11 +398,11 @@
+    */
+   this->result[this->klassSymbolLength] = '.';
+ 
+-  copyinto(this->nameSymbol + OFFSET_symbolOopDesc_body,
++  copyinto(this->nameSymbol + OFFSET_Symbol_body,
+       this->nameSymbolLength,
+       this->result + this->klassSymbolLength + 1);
+ 
+-  copyinto(this->signatureSymbol + OFFSET_symbolOopDesc_body,
++  copyinto(this->signatureSymbol + OFFSET_Symbol_body,
+       this->signatureSymbolLength,
+       this->result + this->klassSymbolLength +
+       this->nameSymbolLength + 1);
+diff --git a/src/os/solaris/dtrace/libjvm_db.c b/src/os/solaris/dtrace/libjvm_db.c
+--- openjdk/hotspot/src/os/solaris/dtrace/libjvm_db.c
++++ openjdk/hotspot/src/os/solaris/dtrace/libjvm_db.c
+@@ -524,10 +524,10 @@
+   CHECK_FAIL(err);
+   err = read_pointer(J, constantPool + nameIndex * POINTER_SIZE + SIZE_constantPoolOopDesc, &nameSymbol);
+   CHECK_FAIL(err);
+-  err = ps_pread(J->P, nameSymbol + OFFSET_symbolOopDesc_length, &nameSymbolLength, 2);
++  err = ps_pread(J->P, nameSymbol + OFFSET_Symbol_length, &nameSymbolLength, 2);
+   CHECK_FAIL(err);
+   nameString = (char*)calloc(nameSymbolLength + 1, 1);
+-  err = ps_pread(J->P, nameSymbol + OFFSET_symbolOopDesc_body, nameString, nameSymbolLength);
++  err = ps_pread(J->P, nameSymbol + OFFSET_Symbol_body, nameString, nameSymbolLength);
+   CHECK_FAIL(err);
+ 
+   /* To get signature string */
+@@ -535,10 +535,10 @@
+   CHECK_FAIL(err);
+   err = read_pointer(J, constantPool + signatureIndex * POINTER_SIZE + SIZE_constantPoolOopDesc, &signatureSymbol);
+   CHECK_FAIL(err);
+-  err = ps_pread(J->P, signatureSymbol + OFFSET_symbolOopDesc_length, &signatureSymbolLength, 2);
++  err = ps_pread(J->P, signatureSymbol + OFFSET_Symbol_length, &signatureSymbolLength, 2);
+   CHECK_FAIL(err);
+   signatureString = (char*)calloc(signatureSymbolLength + 1, 1);
+-  err = ps_pread(J->P, signatureSymbol + OFFSET_symbolOopDesc_body, signatureString, signatureSymbolLength);
++  err = ps_pread(J->P, signatureSymbol + OFFSET_Symbol_body, signatureString, signatureSymbolLength);
+   CHECK_FAIL(err);
+ 
+   /* To get klass string */
+@@ -546,10 +546,10 @@
+   CHECK_FAIL(err);
+   err = read_pointer(J, klassPtr + OFFSET_Klass_name + SIZE_oopDesc, &klassSymbol);
+   CHECK_FAIL(err);
+-  err = ps_pread(J->P, klassSymbol + OFFSET_symbolOopDesc_length, &klassSymbolLength, 2);
++  err = ps_pread(J->P, klassSymbol + OFFSET_Symbol_length, &klassSymbolLength, 2);
+   CHECK_FAIL(err);
+   klassString = (char*)calloc(klassSymbolLength + 1, 1);
+-  err = ps_pread(J->P, klassSymbol + OFFSET_symbolOopDesc_body, klassString, klassSymbolLength);
++  err = ps_pread(J->P, klassSymbol + OFFSET_Symbol_body, klassString, klassSymbolLength);
+   CHECK_FAIL(err);
+ 
+   result[0] = '\0';
+diff --git a/src/os/solaris/vm/dtraceJSDT_solaris.cpp b/src/os/solaris/vm/dtraceJSDT_solaris.cpp
+--- openjdk/hotspot/src/os/solaris/vm/dtraceJSDT_solaris.cpp
++++ openjdk/hotspot/src/os/solaris/vm/dtraceJSDT_solaris.cpp
+@@ -142,7 +142,7 @@
+     ++strcount;
+     for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
+       JVM_DTraceProbe* p = &(provider->probes[prbc]);
+-      symbolOop sig = JNIHandles::resolve_jmethod_id(p->method)->signature();
++      Symbol* sig = JNIHandles::resolve_jmethod_id(p->method)->signature();
+       // function + name + one per argument
+       strcount += 2 + ArgumentCount(sig).size();
+     }
+@@ -178,7 +178,7 @@
+       stroffs[curstr++] = string_index;
+       string_index += strlen(name) + 1;
+ 
+-      symbolOop sig = JNIHandles::resolve_jmethod_id(p->method)->signature();
++      Symbol* sig = JNIHandles::resolve_jmethod_id(p->method)->signature();
+       SignatureStream ss(sig);
+       for ( ; !ss.at_return_type(); ss.next()) {
+         BasicType bt = ss.type();
+@@ -227,7 +227,7 @@
+     uint32_t argscount = 0;
+     for(int prbc = 0; prbc < provider->probe_count; ++prbc) {
+        JVM_DTraceProbe* p = &(provider->probes[prbc]);
+-       symbolOop sig = JNIHandles::resolve_jmethod_id(p->method)->signature();
++       Symbol* sig = JNIHandles::resolve_jmethod_id(p->method)->signature();
+        argscount += ArgumentCount(sig).size();
+     }
+     secoffs[argoffs_sec] = align_size_up(offset, alignment_for[ARG_OFFSETS]);
+@@ -298,7 +298,7 @@
+       strcpy(str, name);
+       str += strlen(name) + 1;
+ 
+-      symbolOop sig = JNIHandles::resolve_jmethod_id(p->method)->signature();
++      Symbol* sig = JNIHandles::resolve_jmethod_id(p->method)->signature();
+       SignatureStream ss(sig);
+       for ( ; !ss.at_return_type(); ss.next()) {
+         BasicType bt = ss.type();
+@@ -433,7 +433,7 @@
+     uint8_t* par = (uint8_t*)(dof + sec->dofs_offset);
+     for (int prbc = 0; prbc < provider->probe_count; ++prbc) {
+       JVM_DTraceProbe* p = &(provider->probes[prbc]);
+-      symbolOop sig = JNIHandles::resolve_jmethod_id(p->method)->signature();
++      Symbol* sig = JNIHandles::resolve_jmethod_id(p->method)->signature();
+       uint8_t count = (uint8_t)ArgumentCount(sig).size();
+       for (uint8_t i = 0; i < count; ++i) {
+         *par++ = i;
+diff --git a/src/share/vm/ci/ciClassList.hpp b/src/share/vm/ci/ciClassList.hpp
+--- openjdk/hotspot/src/share/vm/ci/ciClassList.hpp
++++ openjdk/hotspot/src/share/vm/ci/ciClassList.hpp
+@@ -60,7 +60,6 @@
+ class    ciKlass;
+ class     ciInstanceKlass;
+ class     ciMethodKlass;
+-class     ciSymbolKlass;
+ class     ciArrayKlass;
+ class       ciObjArrayKlass;
+ class       ciTypeArrayKlass;
+@@ -112,7 +111,6 @@
+ friend class ciKlass;                  \
+ friend class ciInstanceKlass;          \
+ friend class ciMethodKlass;            \
+-friend class ciSymbolKlass;            \
+ friend class ciArrayKlass;             \
+ friend class ciObjArrayKlass;          \
+ friend class ciTypeArrayKlass;         \
+diff --git a/src/share/vm/ci/ciEnv.cpp b/src/share/vm/ci/ciEnv.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciEnv.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciEnv.cpp
+@@ -68,7 +68,6 @@
+ 
+ ciObject*              ciEnv::_null_object_instance;
+ ciMethodKlass*         ciEnv::_method_klass_instance;
+-ciSymbolKlass*         ciEnv::_symbol_klass_instance;
+ ciKlassKlass*          ciEnv::_klass_klass_instance;
+ ciInstanceKlassKlass*  ciEnv::_instance_klass_klass_instance;
+ ciTypeArrayKlassKlass* ciEnv::_type_array_klass_klass_instance;
+@@ -202,6 +201,7 @@
+ 
+ ciEnv::~ciEnv() {
+   CompilerThread* current_thread = CompilerThread::current();
++  _factory->remove_symbols();
+   current_thread->set_env(NULL);
+ }
+ 
+@@ -234,7 +234,7 @@
+ 
+ // ------------------------------------------------------------------
+ // helper for lazy exception creation
+-ciInstance* ciEnv::get_or_create_exception(jobject& handle, symbolHandle name) {
++ciInstance* ciEnv::get_or_create_exception(jobject& handle, Symbol* name) {
+   VM_ENTRY_MARK;
+   if (handle == NULL) {
+     // Cf. universe.cpp, creation of Universe::_null_ptr_exception_instance.
+@@ -261,7 +261,7 @@
+   if (_ArrayIndexOutOfBoundsException_instance == NULL) {
+     _ArrayIndexOutOfBoundsException_instance
+           = get_or_create_exception(_ArrayIndexOutOfBoundsException_handle,
+-          vmSymbolHandles::java_lang_ArrayIndexOutOfBoundsException());
++          vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
+   }
+   return _ArrayIndexOutOfBoundsException_instance;
+ }
+@@ -269,7 +269,7 @@
+   if (_ArrayStoreException_instance == NULL) {
+     _ArrayStoreException_instance
+           = get_or_create_exception(_ArrayStoreException_handle,
+-          vmSymbolHandles::java_lang_ArrayStoreException());
++          vmSymbols::java_lang_ArrayStoreException());
+   }
+   return _ArrayStoreException_instance;
+ }
+@@ -277,7 +277,7 @@
+   if (_ClassCastException_instance == NULL) {
+     _ClassCastException_instance
+           = get_or_create_exception(_ClassCastException_handle,
+-          vmSymbolHandles::java_lang_ClassCastException());
++          vmSymbols::java_lang_ClassCastException());
+   }
+   return _ClassCastException_instance;
+ }
+@@ -377,14 +377,16 @@
+   EXCEPTION_CONTEXT;
+ 
+   // Now we need to check the SystemDictionary
+-  symbolHandle sym(THREAD, name->get_symbolOop());
++  Symbol* sym = name->get_symbol();
+   if (sym->byte_at(0) == 'L' &&
+     sym->byte_at(sym->utf8_length()-1) == ';') {
+     // This is a name from a signature.  Strip off the trimmings.
+-    sym = oopFactory::new_symbol_handle(sym->as_utf8()+1,
+-                                        sym->utf8_length()-2,
+-                                        KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass));
+-    name = get_object(sym())->as_symbol();
++    // Call recursive to keep scope of strippedsym.
++    TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
++                    sym->utf8_length()-2,
++                    KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass));
++    ciSymbol* strippedname = get_symbol(strippedsym);
++    return get_klass_by_name_impl(accessing_klass, strippedname, require_local);
+   }
+ 
+   // Check for prior unloaded klass.  The SystemDictionary's answers
+@@ -430,13 +432,14 @@
+       (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) {
+     // We have an unloaded array.
+     // Build it on the fly if the element class exists.
+-    symbolOop elem_sym = oopFactory::new_symbol(sym->as_utf8()+1,
+-                                                sym->utf8_length()-1,
+-                                                KILL_COMPILE_ON_FATAL_(fail_type));
++    TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
++                                                 sym->utf8_length()-1,
++                                                 KILL_COMPILE_ON_FATAL_(fail_type));
++
+     // Get element ciKlass recursively.
+     ciKlass* elem_klass =
+       get_klass_by_name_impl(accessing_klass,
+-                             get_object(elem_sym)->as_symbol(),
++                             get_symbol(elem_sym),
+                              require_local);
+     if (elem_klass != NULL && elem_klass->is_loaded()) {
+       // Now make an array for it
+@@ -475,7 +478,7 @@
+                                         ciInstanceKlass* accessor) {
+   EXCEPTION_CONTEXT;
+   KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
+-  symbolHandle klass_name;
++  Symbol* klass_name = NULL;
+   if (klass.is_null()) {
+     // The klass has not been inserted into the constant pool.
+     // Try to look it up by name.
+@@ -490,10 +493,10 @@
+         // very recently.
+         klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
+       } else if (tag.is_symbol()) {
+-        klass_name = symbolHandle(THREAD, cpool->symbol_at(index));
++        klass_name = cpool->symbol_at(index);
+       } else {
+         assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
+-        klass_name = symbolHandle(THREAD, cpool->unresolved_klass_at(index));
++        klass_name = cpool->unresolved_klass_at(index);
+       }
+     }
+   }
+@@ -501,7 +504,7 @@
+   if (klass.is_null()) {
+     // Not found in constant pool.  Use the name to do the lookup.
+     ciKlass* k = get_klass_by_name_impl(accessor,
+-                                        get_object(klass_name())->as_symbol(),
++                                        get_symbol(klass_name),
+                                         false);
+     // Calculate accessibility the hard way.
+     if (!k->is_loaded()) {
+@@ -519,7 +522,7 @@
+ 
+   // Check for prior unloaded klass.  The SystemDictionary's answers
+   // can vary over time but the compiler needs consistency.
+-  ciSymbol* name = get_object(klass()->klass_part()->name())->as_symbol();
++  ciSymbol* name = get_symbol(klass()->klass_part()->name());
+   ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);
+   if (unloaded_klass != NULL) {
+     is_accessible = false;
+@@ -605,7 +608,7 @@
+     return ciConstant(T_OBJECT, ciobj);
+   } else if (tag.is_method_type()) {
+     // must execute Java code to link this CP entry into cache[i].f1
+-    ciSymbol* signature = get_object(cpool->method_type_signature_at(index))->as_symbol();
++    ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index));
+     ciObject* ciobj = get_unloaded_method_type_constant(signature);
+     return ciConstant(T_OBJECT, ciobj);
+   } else if (tag.is_method_handle()) {
+@@ -613,8 +616,8 @@
+     int ref_kind        = cpool->method_handle_ref_kind_at(index);
+     int callee_index    = cpool->method_handle_klass_index_at(index);
+     ciKlass* callee     = get_klass_by_index_impl(cpool, callee_index, ignore_will_link, accessor);
+-    ciSymbol* name      = get_object(cpool->method_handle_name_ref_at(index))->as_symbol();
+-    ciSymbol* signature = get_object(cpool->method_handle_signature_ref_at(index))->as_symbol();
++    ciSymbol* name      = get_symbol(cpool->method_handle_name_ref_at(index));
++    ciSymbol* signature = get_symbol(cpool->method_handle_signature_ref_at(index));
+     ciObject* ciobj     = get_unloaded_method_handle_constant(callee, name, signature, ref_kind);
+     return ciConstant(T_OBJECT, ciobj);
+   } else {
+@@ -674,33 +677,31 @@
+ // name, signature, and bytecode.
+ methodOop ciEnv::lookup_method(instanceKlass*  accessor,
+                                instanceKlass*  holder,
+-                               symbolOop       name,
+-                               symbolOop       sig,
++                               Symbol*       name,
++                               Symbol*       sig,
+                                Bytecodes::Code bc) {
+   EXCEPTION_CONTEXT;
+   KlassHandle h_accessor(THREAD, accessor);
+   KlassHandle h_holder(THREAD, holder);
+-  symbolHandle h_name(THREAD, name);
+-  symbolHandle h_sig(THREAD, sig);
+   LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
+   methodHandle dest_method;
+   switch (bc) {
+   case Bytecodes::_invokestatic:
+     dest_method =
+-      LinkResolver::resolve_static_call_or_null(h_holder, h_name, h_sig, h_accessor);
++      LinkResolver::resolve_static_call_or_null(h_holder, name, sig, h_accessor);
+     break;
+   case Bytecodes::_invokespecial:
+     dest_method =
+-      LinkResolver::resolve_special_call_or_null(h_holder, h_name, h_sig, h_accessor);
++      LinkResolver::resolve_special_call_or_null(h_holder, name, sig, h_accessor);
+     break;
+   case Bytecodes::_invokeinterface:
+     dest_method =
+-      LinkResolver::linktime_resolve_interface_method_or_null(h_holder, h_name, h_sig,
++      LinkResolver::linktime_resolve_interface_method_or_null(h_holder, name, sig,
+                                                               h_accessor, true);
+     break;
+   case Bytecodes::_invokevirtual:
+     dest_method =
+-      LinkResolver::linktime_resolve_virtual_method_or_null(h_holder, h_name, h_sig,
++      LinkResolver::linktime_resolve_virtual_method_or_null(h_holder, name, sig,
+                                                             h_accessor, true);
+     break;
+   default: ShouldNotReachHere();
+@@ -721,8 +722,8 @@
+   ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
+ 
+   // Get the method's name and signature.
+-  symbolOop name_sym = cpool->name_ref_at(index);
+-  symbolOop sig_sym  = cpool->signature_ref_at(index);
++  Symbol* name_sym = cpool->name_ref_at(index);
++  Symbol* sig_sym  = cpool->signature_ref_at(index);
+ 
+   if (holder_is_accessible) { // Our declared holder is loaded.
+     instanceKlass* lookup = declared_holder->get_instanceKlass();
+@@ -738,8 +739,8 @@
+   // lookup.
+ 
+   return get_unloaded_method(declared_holder,
+-                             get_object(name_sym)->as_symbol(),
+-                             get_object(sig_sym)->as_symbol());
++                             get_symbol(name_sym),
++                             get_symbol(sig_sym));
+ }
+ 
+ 
+@@ -759,7 +760,7 @@
+   // compiler, but it is simpler to stop the code path here with an unlinked method.
+   if (!is_resolved) {
+     ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass();
+-    ciSymbol*        sig_sym  = get_object(cpool->signature_ref_at(index))->as_symbol();
++    ciSymbol*        sig_sym  = get_symbol(cpool->signature_ref_at(index));
+     return get_unloaded_method(mh_klass, ciSymbol::invokeExact_name(), sig_sym);
+   }
+ 
+diff --git a/src/share/vm/ci/ciEnv.hpp b/src/share/vm/ci/ciEnv.hpp
+--- openjdk/hotspot/src/share/vm/ci/ciEnv.hpp
++++ openjdk/hotspot/src/share/vm/ci/ciEnv.hpp
+@@ -79,7 +79,6 @@
+   // Distinguished instances of certain ciObjects..
+   static ciObject*              _null_object_instance;
+   static ciMethodKlass*         _method_klass_instance;
+-  static ciSymbolKlass*         _symbol_klass_instance;
+   static ciKlassKlass*          _klass_klass_instance;
+   static ciInstanceKlassKlass*  _instance_klass_klass_instance;
+   static ciTypeArrayKlassKlass* _type_array_klass_klass_instance;
+@@ -160,8 +159,8 @@
+                                       klassOop resolved_klassOop);
+   methodOop  lookup_method(instanceKlass*  accessor,
+                            instanceKlass*  holder,
+-                           symbolOop       name,
+-                           symbolOop       sig,
++                           Symbol*         name,
++                           Symbol*         sig,
+                            Bytecodes::Code bc);
+ 
+   // Get a ciObject from the object factory.  Ensures uniqueness
+@@ -174,9 +173,18 @@
+     }
+   }
+ 
++  ciSymbol* get_symbol(Symbol* o) {
++    if (o == NULL) {
++      ShouldNotReachHere();
++      return NULL;
++    } else {
++      return _factory->get_symbol(o);
++    }
++  }
++
+   ciMethod* get_method_from_handle(jobject method);
+ 
+-  ciInstance* get_or_create_exception(jobject& handle, symbolHandle name);
++  ciInstance* get_or_create_exception(jobject& handle, Symbol* name);
+ 
+   // Get a ciMethod representing either an unfound method or
+   // a method with an unloaded holder.  Ensures uniqueness of
+diff --git a/src/share/vm/ci/ciField.cpp b/src/share/vm/ci/ciField.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciField.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciField.cpp
+@@ -79,15 +79,15 @@
+   constantPoolHandle cpool(thread, klass->get_instanceKlass()->constants());
+ 
+   // Get the field's name, signature, and type.
+-  symbolHandle name  (thread, cpool->name_ref_at(index));
+-  _name = ciEnv::current(thread)->get_object(name())->as_symbol();
++  Symbol* name  = cpool->name_ref_at(index);
++  _name = ciEnv::current(thread)->get_symbol(name);
+ 
+   int nt_index = cpool->name_and_type_ref_index_at(index);
+   int sig_index = cpool->signature_ref_index_at(nt_index);
+-  symbolHandle signature (thread, cpool->symbol_at(sig_index));
+-  _signature = ciEnv::current(thread)->get_object(signature())->as_symbol();
++  Symbol* signature = cpool->symbol_at(sig_index);
++  _signature = ciEnv::current(thread)->get_symbol(signature);
+ 
+-  BasicType field_type = FieldType::basic_type(signature());
++  BasicType field_type = FieldType::basic_type(signature);
+ 
+   // If the field is a pointer type, get the klass of the
+   // field.
+@@ -100,7 +100,7 @@
+     _type = ciType::make(field_type);
+   }
+ 
+-  _name = (ciSymbol*)ciEnv::current(thread)->get_object(name());
++  _name = (ciSymbol*)ciEnv::current(thread)->get_symbol(name);
+ 
+   // Get the field's declared holder.
+   //
+@@ -130,7 +130,7 @@
+   // Perform the field lookup.
+   fieldDescriptor field_desc;
+   klassOop canonical_holder =
+-    loaded_decl_holder->find_field(name(), signature(), &field_desc);
++    loaded_decl_holder->find_field(name, signature, &field_desc);
+   if (canonical_holder == NULL) {
+     // Field lookup failed.  Will be detected by will_link.
+     _holder = declared_holder;
+@@ -150,8 +150,8 @@
+ 
+   // Get the field's name, signature, and type.
+   ciEnv* env = CURRENT_ENV;
+-  _name = env->get_object(fd->name())->as_symbol();
+-  _signature = env->get_object(fd->signature())->as_symbol();
++  _name = env->get_symbol(fd->name());
++  _signature = env->get_symbol(fd->signature());
+ 
+   BasicType field_type = fd->field_type();
+ 
+diff --git a/src/share/vm/ci/ciInstanceKlass.cpp b/src/share/vm/ci/ciInstanceKlass.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciInstanceKlass.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciInstanceKlass.cpp
+@@ -382,7 +382,7 @@
+   VM_ENTRY_MARK;
+   instanceKlass* k = get_instanceKlass();
+   fieldDescriptor fd;
+-  klassOop def = k->find_field(name->get_symbolOop(), signature->get_symbolOop(), is_static, &fd);
++  klassOop def = k->find_field(name->get_symbol(), signature->get_symbol(), is_static, &fd);
+   if (def == NULL) {
+     return NULL;
+   }
+@@ -543,8 +543,8 @@
+ ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
+   VM_ENTRY_MARK;
+   instanceKlass* k = get_instanceKlass();
+-  symbolOop name_sym = name->get_symbolOop();
+-  symbolOop sig_sym= signature->get_symbolOop();
++  Symbol* name_sym = name->get_symbol();
++  Symbol* sig_sym= signature->get_symbol();
+ 
+   methodOop m = k->find_method(name_sym, sig_sym);
+   if (m == NULL)  return NULL;
+diff --git a/src/share/vm/ci/ciKlass.cpp b/src/share/vm/ci/ciKlass.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciKlass.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciKlass.cpp
+@@ -39,9 +39,9 @@
+   assert(get_oop()->is_klass(), "wrong type");
+   Klass* k = get_Klass();
+   _layout_helper = k->layout_helper();
+-  symbolOop klass_name = k->name();
++  Symbol* klass_name = k->name();
+   assert(klass_name != NULL, "wrong ciKlass constructor");
+-  _name = CURRENT_ENV->get_object(klass_name)->as_symbol();
++  _name = CURRENT_ENV->get_symbol(klass_name);
+ }
+ 
+ // ------------------------------------------------------------------
+diff --git a/src/share/vm/ci/ciMethod.cpp b/src/share/vm/ci/ciMethod.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciMethod.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciMethod.cpp
+@@ -122,9 +122,9 @@
+ 
+   // generating _signature may allow GC and therefore move m.
+   // These fields are always filled in.
+-  _name = env->get_object(h_m()->name())->as_symbol();
++  _name = env->get_symbol(h_m()->name());
+   _holder = env->get_object(h_m()->method_holder())->as_instance_klass();
+-  ciSymbol* sig_symbol = env->get_object(h_m()->signature())->as_symbol();
++  ciSymbol* sig_symbol = env->get_symbol(h_m()->signature());
+   _signature = new (env->arena()) ciSignature(_holder, sig_symbol);
+   _method_data = NULL;
+   // Take a snapshot of these values, so they will be commensurate with the MDO.
+@@ -649,8 +649,8 @@
+    KlassHandle caller_klass (THREAD, caller->get_klassOop());
+    KlassHandle h_recv       (THREAD, exact_receiver->get_klassOop());
+    KlassHandle h_resolved   (THREAD, holder()->get_klassOop());
+-   symbolHandle h_name      (THREAD, name()->get_symbolOop());
+-   symbolHandle h_signature (THREAD, signature()->get_symbolOop());
++   Symbol* h_name      = name()->get_symbol();
++   Symbol* h_signature = signature()->get_symbol();
+ 
+    methodHandle m;
+    // Only do exact lookup if receiver klass has been linked.  Otherwise,
+@@ -702,8 +702,8 @@
+ 
+      KlassHandle caller_klass (THREAD, caller->get_klassOop());
+      KlassHandle h_recv       (THREAD, receiver->get_klassOop());
+-     symbolHandle h_name      (THREAD, name()->get_symbolOop());
+-     symbolHandle h_signature (THREAD, signature()->get_symbolOop());
++     Symbol* h_name = name()->get_symbol();
++     Symbol* h_signature = signature()->get_symbol();
+ 
+      vtable_index = LinkResolver::resolve_virtual_vtable_index(h_recv, h_recv, h_name, h_signature, caller_klass);
+      if (vtable_index == methodOopDesc::nonvirtual_vtable_index) {
+diff --git a/src/share/vm/ci/ciObjArrayKlass.cpp b/src/share/vm/ci/ciObjArrayKlass.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciObjArrayKlass.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciObjArrayKlass.cpp
+@@ -110,7 +110,7 @@
+   EXCEPTION_CONTEXT;
+   int element_len = element_name->utf8_length();
+ 
+-  symbolOop base_name_sym = element_name->get_symbolOop();
++  Symbol* base_name_sym = element_name->get_symbol();
+   char* name;
+ 
+   if (base_name_sym->byte_at(0) == '[' ||
+diff --git a/src/share/vm/ci/ciObject.hpp b/src/share/vm/ci/ciObject.hpp
+--- openjdk/hotspot/src/share/vm/ci/ciObject.hpp
++++ openjdk/hotspot/src/share/vm/ci/ciObject.hpp
+@@ -268,10 +268,6 @@
+     assert(is_type_array_klass(), "bad cast");
+     return (ciTypeArrayKlass*)this;
+   }
+-  ciSymbolKlass*           as_symbol_klass() {
+-    assert(is_symbol_klass(), "bad cast");
+-    return (ciSymbolKlass*)this;
+-  }
+   ciKlassKlass*            as_klass_klass() {
+     assert(is_klass_klass(), "bad cast");
+     return (ciKlassKlass*)this;
+diff --git a/src/share/vm/ci/ciObjectFactory.cpp b/src/share/vm/ci/ciObjectFactory.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciObjectFactory.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciObjectFactory.cpp
+@@ -38,7 +38,6 @@
+ #include "ci/ciObjArrayKlassKlass.hpp"
+ #include "ci/ciObjectFactory.hpp"
+ #include "ci/ciSymbol.hpp"
+-#include "ci/ciSymbolKlass.hpp"
+ #include "ci/ciTypeArray.hpp"
+ #include "ci/ciTypeArrayKlass.hpp"
+ #include "ci/ciTypeArrayKlassKlass.hpp"
+@@ -98,6 +97,8 @@
+   _unloaded_instances = new (arena) GrowableArray<ciInstance*>(arena, 4, 0, NULL);
+   _return_addresses =
+     new (arena) GrowableArray<ciReturnAddress*>(arena, 8, 0, NULL);
++
++  _symbols = new (arena) GrowableArray<ciSymbol*>(arena, 100, 0, NULL);
+ }
+ 
+ // ------------------------------------------------------------------
+@@ -127,19 +128,19 @@
+     // Create the shared symbols, but not in _shared_ci_objects.
+     int i;
+     for (i = vmSymbols::FIRST_SID; i < vmSymbols::SID_LIMIT; i++) {
+-      symbolHandle sym_handle = vmSymbolHandles::symbol_handle_at((vmSymbols::SID) i);
+-      assert(vmSymbols::find_sid(sym_handle()) == i, "1-1 mapping");
+-      ciSymbol* sym = new (_arena) ciSymbol(sym_handle, (vmSymbols::SID) i);
++      Symbol* vmsym = vmSymbols::symbol_at((vmSymbols::SID) i);
++      assert(vmSymbols::find_sid(vmsym) == i, "1-1 mapping");
++      ciSymbol* sym = new (_arena) ciSymbol(vmsym, (vmSymbols::SID) i);
+       init_ident_of(sym);
+       _shared_ci_symbols[i] = sym;
+     }
+ #ifdef ASSERT
+     for (i = vmSymbols::FIRST_SID; i < vmSymbols::SID_LIMIT; i++) {
+-      symbolHandle sym_handle = vmSymbolHandles::symbol_handle_at((vmSymbols::SID) i);
++      Symbol* vmsym = vmSymbols::symbol_at((vmSymbols::SID) i);
+       ciSymbol* sym = vm_symbol_at((vmSymbols::SID) i);
+-      assert(sym->get_oop() == sym_handle(), "oop must match");
++      assert(sym->get_symbol() == vmsym, "oop must match");
+     }
+-    assert(ciSymbol::void_class_signature()->get_oop() == vmSymbols::void_class_signature(), "spot check");
++    assert(ciSymbol::void_class_signature()->get_symbol() == vmSymbols::void_class_signature(), "spot check");
+ #endif
+   }
+ 
+@@ -157,8 +158,6 @@
+   init_ident_of(ciEnv::_null_object_instance);
+   ciEnv::_method_klass_instance =
+     get(Universe::methodKlassObj())->as_method_klass();
+-  ciEnv::_symbol_klass_instance =
+-    get(Universe::symbolKlassObj())->as_symbol_klass();
+   ciEnv::_klass_klass_instance =
+     get(Universe::klassKlassObj())->as_klass_klass();
+   ciEnv::_instance_klass_klass_instance =
+@@ -188,7 +187,7 @@
+     }
+   }
+ 
+-  ciEnv::_unloaded_cisymbol = (ciSymbol*) ciObjectFactory::get(vmSymbols::dummy_symbol_oop());
++  ciEnv::_unloaded_cisymbol = ciObjectFactory::get_symbol(vmSymbols::dummy_symbol());
+   // Create dummy instanceKlass and objArrayKlass object and assign them idents
+   ciEnv::_unloaded_ciinstance_klass = new (_arena) ciInstanceKlass(ciEnv::_unloaded_cisymbol, NULL, NULL);
+   init_ident_of(ciEnv::_unloaded_ciinstance_klass);
+@@ -218,6 +217,30 @@
+   _shared_ci_objects = _ci_objects;
+ }
+ 
++
++ciSymbol* ciObjectFactory::get_symbol(Symbol* key) {
++  vmSymbols::SID sid = vmSymbols::find_sid(key);
++  if (sid != vmSymbols::NO_SID) {
++    // do not pollute the main cache with it
++    return vm_symbol_at(sid);
++  }
++
++  assert(vmSymbols::find_sid(key) == vmSymbols::NO_SID, "");
++  ciSymbol* s = new (arena()) ciSymbol(key, vmSymbols::NO_SID);
++  _symbols->push(s);
++  return s;
++}
++
++// Decrement the refcount when done on symbols referenced by this compilation.
++void ciObjectFactory::remove_symbols() {
++  for (int i = 0; i < _symbols->length(); i++) {
++    ciSymbol* s = _symbols->at(i);
++    s->get_symbol()->decrement_refcount();
++  }
++  // Since _symbols is resource allocated we're not allowed to delete it
++  // but it'll go away just the same.
++}
++
+ // ------------------------------------------------------------------
+ // ciObjectFactory::get
+ //
+@@ -255,15 +278,6 @@
+       return bucket->object();
+     }
+ 
+-    // Check in the shared symbol area before putting it in the list.
+-    if (key->is_symbol()) {
+-      vmSymbols::SID sid = vmSymbols::find_sid((symbolOop)key);
+-      if (sid != vmSymbols::NO_SID) {
+-        // do not pollute the main cache with it
+-        return vm_symbol_at(sid);
+-      }
+-    }
+-
+     // The ciObject does not yet exist.  Create it and insert it
+     // into the cache.
+     Handle keyHandle(key);
+@@ -297,11 +311,7 @@
+ ciObject* ciObjectFactory::create_new_object(oop o) {
+   EXCEPTION_CONTEXT;
+ 
+-  if (o->is_symbol()) {
+-    symbolHandle h_o(THREAD, (symbolOop)o);
+-    assert(vmSymbols::find_sid(h_o()) == vmSymbols::NO_SID, "");
+-    return new (arena()) ciSymbol(h_o, vmSymbols::NO_SID);
+-  } else if (o->is_klass()) {
++  if (o->is_klass()) {
+     KlassHandle h_k(THREAD, (klassOop)o);
+     Klass* k = ((klassOop)o)->klass_part();
+     if (k->oop_is_instance()) {
+@@ -312,8 +322,6 @@
+       return new (arena()) ciTypeArrayKlass(h_k);
+     } else if (k->oop_is_method()) {
+       return new (arena()) ciMethodKlass(h_k);
+-    } else if (k->oop_is_symbol()) {
+-      return new (arena()) ciSymbolKlass(h_k);
+     } else if (k->oop_is_klass()) {
+       if (k->oop_is_objArrayKlass()) {
+         return new (arena()) ciObjArrayKlassKlass(h_k);
+@@ -426,22 +434,20 @@
+   // unloaded instanceKlass.  Deal with both.
+   if (name->byte_at(0) == '[') {
+     // Decompose the name.'
+-    jint dimension = 0;
+-    symbolOop element_name = NULL;
+-    BasicType element_type= FieldType::get_array_info(name->get_symbolOop(),
+-                                                      &dimension,
+-                                                      &element_name,
+-                                                      THREAD);
++    FieldArrayInfo fd;
++    BasicType element_type = FieldType::get_array_info(name->get_symbol(),
++                                                       fd, THREAD);
+     if (HAS_PENDING_EXCEPTION) {
+       CLEAR_PENDING_EXCEPTION;
+       CURRENT_THREAD_ENV->record_out_of_memory_failure();
+       return ciEnv::_unloaded_ciobjarrayklass;
+     }
++    int dimension = fd.dimension();
+     assert(element_type != T_ARRAY, "unsuccessful decomposition");
+     ciKlass* element_klass = NULL;
+     if (element_type == T_OBJECT) {
+       ciEnv *env = CURRENT_THREAD_ENV;
+-      ciSymbol* ci_name = env->get_object(element_name)->as_symbol();
++      ciSymbol* ci_name = env->get_symbol(fd.object_key());
+       element_klass =
+         env->get_klass_by_name(accessing_klass, ci_name, false)->as_instance_klass();
+     } else {
+@@ -573,6 +579,10 @@
+   obj->set_ident(_next_ident++);
+ }
+ 
++void ciObjectFactory::init_ident_of(ciSymbol* obj) {
++  obj->set_ident(_next_ident++);
++}
++
+ 
+ // ------------------------------------------------------------------
+ // ciObjectFactory::find
+diff --git a/src/share/vm/ci/ciObjectFactory.hpp b/src/share/vm/ci/ciObjectFactory.hpp
+--- openjdk/hotspot/src/share/vm/ci/ciObjectFactory.hpp
++++ openjdk/hotspot/src/share/vm/ci/ciObjectFactory.hpp
+@@ -48,6 +48,7 @@
+   GrowableArray<ciKlass*>* _unloaded_klasses;
+   GrowableArray<ciInstance*>* _unloaded_instances;
+   GrowableArray<ciReturnAddress*>* _return_addresses;
++  GrowableArray<ciSymbol*>* _symbols;  // keep list of symbols created
+   int                       _next_ident;
+ 
+ public:
+@@ -76,6 +77,7 @@
+   void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj);
+ 
+   void init_ident_of(ciObject* obj);
++  void init_ident_of(ciSymbol* obj);
+ 
+   Arena* arena() { return _arena; }
+ 
+@@ -88,13 +90,15 @@
+ 
+   static void initialize();
+   void init_shared_objects();
++  void remove_symbols();
+ 
+   ciObjectFactory(Arena* arena, int expected_size);
+ 
+-
+   // Get the ciObject corresponding to some oop.
+   ciObject* get(oop key);
+ 
++  ciSymbol* get_symbol(Symbol* key);
++
+   // Get the ciSymbol corresponding to one of the vmSymbols.
+   static ciSymbol* vm_symbol_at(int index);
+ 
+diff --git a/src/share/vm/ci/ciSignature.cpp b/src/share/vm/ci/ciSignature.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciSignature.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciSignature.cpp
+@@ -47,7 +47,8 @@
+ 
+   int size = 0;
+   int count = 0;
+-  symbolHandle sh (THREAD, symbol->get_symbolOop());
++  ResourceMark rm(THREAD);
++  Symbol* sh = symbol->get_symbol();
+   SignatureStream ss(sh);
+   for (; ; ss.next()) {
+     // Process one element of the signature
+@@ -55,14 +56,14 @@
+     if (!ss.is_object()) {
+       type = ciType::make(ss.type());
+     } else {
+-      symbolOop name = ss.as_symbol(THREAD);
++      Symbol* name = ss.as_symbol(THREAD);
+       if (HAS_PENDING_EXCEPTION) {
+         type = ss.is_array() ? (ciType*)ciEnv::unloaded_ciobjarrayklass()
+           : (ciType*)ciEnv::unloaded_ciinstance_klass();
+         env->record_out_of_memory_failure();
+         CLEAR_PENDING_EXCEPTION;
+       } else {
+-        ciSymbol* klass_name = env->get_object(name)->as_symbol();
++        ciSymbol* klass_name = env->get_symbol(name);
+         type = env->get_klass_by_name_impl(_accessing_klass, klass_name, false);
+       }
+     }
+diff --git a/src/share/vm/ci/ciSignature.hpp b/src/share/vm/ci/ciSignature.hpp
+--- openjdk/hotspot/src/share/vm/ci/ciSignature.hpp
++++ openjdk/hotspot/src/share/vm/ci/ciSignature.hpp
+@@ -48,7 +48,7 @@
+ 
+   void get_all_klasses();
+ 
+-  symbolOop get_symbolOop() const                { return _symbol->get_symbolOop(); }
++  Symbol* get_symbol() const                     { return _symbol->get_symbol(); }
+ 
+ public:
+   ciSymbol* as_symbol() const                    { return _symbol; }
+diff --git a/src/share/vm/ci/ciSymbol.cpp b/src/share/vm/ci/ciSymbol.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciSymbol.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciSymbol.cpp
+@@ -30,23 +30,27 @@
+ // ------------------------------------------------------------------
+ // ciSymbol::ciSymbol
+ //
+-// Preallocated handle variant.  Used with handles from vmSymboHandles.
+-ciSymbol::ciSymbol(symbolHandle h_s, vmSymbols::SID sid)
+-  : ciObject(h_s), _sid(sid)
++// Preallocated symbol variant.  Used with symbols from vmSymbols.
++ciSymbol::ciSymbol(Symbol* s, vmSymbols::SID sid)
++  : _symbol(s), _sid(sid)
+ {
++  assert(_symbol != NULL, "adding null symbol");
++  _symbol->increment_refcount();  // increment ref count
+   assert(sid_ok(), "must be in vmSymbols");
+ }
+ 
+ // Normal case for non-famous symbols.
+-ciSymbol::ciSymbol(symbolOop s)
+-  : ciObject(s), _sid(vmSymbols::NO_SID)
++ciSymbol::ciSymbol(Symbol* s)
++  : _symbol(s), _sid(vmSymbols::NO_SID)
+ {
++  assert(_symbol != NULL, "adding null symbol");
++  _symbol->increment_refcount();  // increment ref count
+   assert(sid_ok(), "must not be in vmSymbols");
+ }
+ 
+ // ciSymbol
+ //
+-// This class represents a symbolOop in the HotSpot virtual
++// This class represents a Symbol* in the HotSpot virtual
+ // machine.
+ 
+ // ------------------------------------------------------------------
+@@ -55,20 +59,20 @@
+ // The text of the symbol as a null-terminated C string.
+ const char* ciSymbol::as_utf8() {
+   VM_QUICK_ENTRY_MARK;
+-  symbolOop s = get_symbolOop();
++  Symbol* s = get_symbol();
+   return s->as_utf8();
+ }
+ 
+ // ------------------------------------------------------------------
+ // ciSymbol::base
+-jbyte* ciSymbol::base() {
+-  GUARDED_VM_ENTRY(return get_symbolOop()->base();)
++const jbyte* ciSymbol::base() {
++  GUARDED_VM_ENTRY(return get_symbol()->base();)
+ }
+ 
+ // ------------------------------------------------------------------
+ // ciSymbol::byte_at
+ int ciSymbol::byte_at(int i) {
+-  GUARDED_VM_ENTRY(return get_symbolOop()->byte_at(i);)
++  GUARDED_VM_ENTRY(return get_symbol()->byte_at(i);)
+ }
+ 
+ // ------------------------------------------------------------------
+@@ -76,7 +80,7 @@
+ //
+ // Tests if the symbol starts with the given prefix.
+ bool ciSymbol::starts_with(const char* prefix, int len) const {
+-  GUARDED_VM_ENTRY(return get_symbolOop()->starts_with(prefix, len);)
++  GUARDED_VM_ENTRY(return get_symbol()->starts_with(prefix, len);)
+ }
+ 
+ // ------------------------------------------------------------------
+@@ -84,13 +88,13 @@
+ //
+ // Determines where the symbol contains the given substring.
+ int ciSymbol::index_of_at(int i, const char* str, int len) const {
+-  GUARDED_VM_ENTRY(return get_symbolOop()->index_of_at(i, str, len);)
++  GUARDED_VM_ENTRY(return get_symbol()->index_of_at(i, str, len);)
+ }
+ 
+ // ------------------------------------------------------------------
+ // ciSymbol::utf8_length
+ int ciSymbol::utf8_length() {
+-  GUARDED_VM_ENTRY(return get_symbolOop()->utf8_length();)
++  GUARDED_VM_ENTRY(return get_symbol()->utf8_length();)
+ }
+ 
+ // ------------------------------------------------------------------
+@@ -107,7 +111,7 @@
+ //
+ // Print the value of this symbol on an outputStream
+ void ciSymbol::print_symbol_on(outputStream *st) {
+-  GUARDED_VM_ENTRY(get_symbolOop()->print_symbol_on(st);)
++  GUARDED_VM_ENTRY(get_symbol()->print_symbol_on(st);)
+ }
+ 
+ // ------------------------------------------------------------------
+@@ -116,15 +120,13 @@
+ // Make a ciSymbol from a C string (implementation).
+ ciSymbol* ciSymbol::make_impl(const char* s) {
+   EXCEPTION_CONTEXT;
+-  // For some reason, oopFactory::new_symbol doesn't declare its
+-  // char* argument as const.
+-  symbolOop sym = oopFactory::new_symbol((char*)s, (int)strlen(s), THREAD);
++  TempNewSymbol sym = SymbolTable::new_symbol(s, THREAD);
+   if (HAS_PENDING_EXCEPTION) {
+     CLEAR_PENDING_EXCEPTION;
+     CURRENT_THREAD_ENV->record_out_of_memory_failure();
+     return ciEnv::_unloaded_cisymbol;
+   }
+-  return CURRENT_THREAD_ENV->get_object(sym)->as_symbol();
++  return CURRENT_THREAD_ENV->get_symbol(sym);
+ }
+ 
+ // ------------------------------------------------------------------
+diff --git a/src/share/vm/ci/ciSymbol.hpp b/src/share/vm/ci/ciSymbol.hpp
+--- openjdk/hotspot/src/share/vm/ci/ciSymbol.hpp
++++ openjdk/hotspot/src/share/vm/ci/ciSymbol.hpp
+@@ -28,15 +28,18 @@
+ #include "ci/ciObject.hpp"
+ #include "ci/ciObjectFactory.hpp"
+ #include "classfile/vmSymbols.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ 
+ // ciSymbol
+ //
+-// This class represents a symbolOop in the HotSpot virtual
++// This class represents a Symbol* in the HotSpot virtual
+ // machine.
+-class ciSymbol : public ciObject {
++class ciSymbol : public ResourceObj {
++  Symbol* _symbol;
++  uint _ident;
++
+   CI_PACKAGE_ACCESS
+-  // These friends all make direct use of get_symbolOop:
++  // These friends all make direct use of get_symbol:
+   friend class ciEnv;
+   friend class ciInstanceKlass;
+   friend class ciSignature;
+@@ -45,24 +48,28 @@
+ 
+ private:
+   const vmSymbols::SID _sid;
+-  DEBUG_ONLY( bool sid_ok() { return vmSymbols::find_sid(get_symbolOop()) == _sid; } )
++  DEBUG_ONLY( bool sid_ok() { return vmSymbols::find_sid(get_symbol()) == _sid; } )
+ 
+-  ciSymbol(symbolOop s);  // normal case, for symbols not mentioned in vmSymbols
+-  ciSymbol(symbolHandle s, vmSymbols::SID sid);   // for use with vmSymbolHandles
++  ciSymbol(Symbol* s);  // normal case, for symbols not mentioned in vmSymbols
++  ciSymbol(Symbol* s, vmSymbols::SID sid);   // for use with vmSymbols
+ 
+-  symbolOop get_symbolOop() const { return (symbolOop)get_oop(); }
++  Symbol* get_symbol() const { return _symbol; }
+ 
+   const char* type_string() { return "ciSymbol"; }
+ 
+   void print_impl(outputStream* st);
+ 
+-  // This is public in symbolOop but private here, because the base can move:
+-  jbyte*      base();
++  // This is public in Symbol* but private here, because the base can move:
++  const jbyte* base();
+ 
+   // Make a ciSymbol from a C string (implementation).
+   static ciSymbol* make_impl(const char* s);
+ 
++  void set_ident(uint id) { _ident = id; }
+ public:
++  // A number unique to this object.
++  uint ident() { return _ident; }
++
+   // The enumeration ID from vmSymbols, or vmSymbols::NO_SID if none.
+   vmSymbols::SID sid() const { return _sid; }
+ 
+@@ -79,9 +86,6 @@
+   // Determines where the symbol contains the given substring.
+   int index_of_at(int i, const char* str, int len) const;
+ 
+-  // What kind of ciObject is this?
+-  bool is_symbol() { return true; }
+-
+   void print_symbol_on(outputStream* st);
+   void print_symbol() {
+     print_symbol_on(tty);
+@@ -96,6 +100,13 @@
+   static ciSymbol* name() { return ciObjectFactory::vm_symbol_at(vmSymbols::VM_SYMBOL_ENUM_NAME(name)); }
+   VM_SYMBOLS_DO(CI_SYMBOL_DECLARE, CI_SYMBOL_DECLARE)
+ #undef CI_SYMBOL_DECLARE
++
++  void print() {
++    _symbol->print();
++  }
++
++  // Are two ciSymbols equal?
++  bool equals(ciSymbol* obj) { return this->_symbol == obj->get_symbol(); }
+ };
+ 
+ #endif // SHARE_VM_CI_CISYMBOL_HPP
+diff --git a/src/share/vm/ci/ciSymbolKlass.cpp b/src/share/vm/ci/ciSymbolKlass.cpp
+deleted file mode 100644
+--- openjdk/hotspot/src/share/vm/ci/ciSymbolKlass.cpp
++++ /dev/null
+@@ -1,40 +0,0 @@
+-/*
+- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+- *
+- */
+-
+-#include "precompiled.hpp"
+-#include "ci/ciSymbolKlass.hpp"
+-#include "ci/ciUtilities.hpp"
+-
+-// ciSymbolKlass
+-//
+-// This class represents a klassOop in the HotSpot virtual machine
+-// whose Klass part is a symbolKlass.
+-
+-// ------------------------------------------------------------------
+-// ciSymbolKlass::instance
+-//
+-// Return the distinguished instance of this class
+-ciSymbolKlass* ciSymbolKlass::make() {
+-  return CURRENT_ENV->_symbol_klass_instance;
+-}
+diff --git a/src/share/vm/ci/ciSymbolKlass.hpp b/src/share/vm/ci/ciSymbolKlass.hpp
+deleted file mode 100644
+--- openjdk/hotspot/src/share/vm/ci/ciSymbolKlass.hpp
++++ /dev/null
+@@ -1,60 +0,0 @@
+-/*
+- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+- *
+- */
+-
+-#ifndef SHARE_VM_CI_CISYMBOLKLASS_HPP
+-#define SHARE_VM_CI_CISYMBOLKLASS_HPP
+-
+-#include "ci/ciKlass.hpp"
+-#include "ci/ciSymbol.hpp"
+-
+-// ciSymbolKlass
+-//
+-// This class represents a klassOop in the HotSpot virtual machine
+-// whose Klass part in a symbolKlass.  Although, in the VM
+-// Klass hierarchy, symbolKlass is a direct subclass of typeArrayKlass,
+-// we do not model this relationship in the ciObject hierarchy -- the
+-// subclassing is used to share implementation and is not of note
+-// to compiler writers.
+-class ciSymbolKlass : public ciKlass {
+-  CI_PACKAGE_ACCESS
+-
+-protected:
+-  ciSymbolKlass(KlassHandle h_k)
+-    : ciKlass(h_k, ciSymbol::make("unique_symbolKlass")) {
+-    assert(get_Klass()->oop_is_symbol(), "wrong type");
+-  }
+-
+-  symbolKlass* get_symbolKlass() { return (symbolKlass*)get_Klass(); }
+-
+-  const char* type_string() { return "ciSymbolKlass"; }
+-
+-public:
+-  // What kind of ciObject is this?
+-  bool is_symbol_klass() { return true; }
+-
+-  // Return the distinguished ciSymbolKlass instance.
+-  static ciSymbolKlass* make();
+-};
+-
+-#endif // SHARE_VM_CI_CISYMBOLKLASS_HPP
+diff --git a/src/share/vm/ci/compilerInterface.hpp b/src/share/vm/ci/compilerInterface.hpp
+--- openjdk/hotspot/src/share/vm/ci/compilerInterface.hpp
++++ openjdk/hotspot/src/share/vm/ci/compilerInterface.hpp
+@@ -49,7 +49,6 @@
+ #include "ci/ciSignature.hpp"
+ #include "ci/ciStreams.hpp"
+ #include "ci/ciSymbol.hpp"
+-#include "ci/ciSymbolKlass.hpp"
+ #include "ci/ciTypeArray.hpp"
+ #include "ci/ciTypeArrayKlass.hpp"
+ #include "ci/ciTypeArrayKlassKlass.hpp"
+diff --git a/src/share/vm/classfile/classFileError.cpp b/src/share/vm/classfile/classFileError.cpp
+--- openjdk/hotspot/src/share/vm/classfile/classFileError.cpp
++++ openjdk/hotspot/src/share/vm/classfile/classFileError.cpp
+@@ -31,25 +31,25 @@
+ 
+ void ClassFileParser::classfile_parse_error(const char* msg, TRAPS) {
+     ResourceMark rm(THREAD);
+-    Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbolHandles::java_lang_ClassFormatError(),
++    Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(),
+                        msg, _class_name->as_C_string());
+ }
+ 
+ void ClassFileParser::classfile_parse_error(const char* msg, int index, TRAPS) {
+     ResourceMark rm(THREAD);
+-    Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbolHandles::java_lang_ClassFormatError(),
++    Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(),
+                        msg, index, _class_name->as_C_string());
+ }
+ 
+ void ClassFileParser::classfile_parse_error(const char* msg, const char *name, TRAPS) {
+     ResourceMark rm(THREAD);
+-    Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbolHandles::java_lang_ClassFormatError(),
++    Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(),
+                        msg, name, _class_name->as_C_string());
+ }
+ 
+ void ClassFileParser::classfile_parse_error(const char* msg, int index, const char *name, TRAPS) {
+     ResourceMark rm(THREAD);
+-    Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbolHandles::java_lang_ClassFormatError(),
++    Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_ClassFormatError(),
+                        msg, index, name, _class_name->as_C_string());
+ }
+ 
+@@ -57,7 +57,7 @@
+   ResourceMark rm(THREAD);
+   Exceptions::fthrow(
+     THREAD_AND_LOCATION,
+-    vmSymbolHandles::java_lang_ClassFormatError(),
++    vmSymbols::java_lang_ClassFormatError(),
+     "StackMapTable format error: %s", msg
+   );
+ }
+diff --git a/src/share/vm/classfile/classFileParser.cpp b/src/share/vm/classfile/classFileParser.cpp
+--- openjdk/hotspot/src/share/vm/classfile/classFileParser.cpp
++++ openjdk/hotspot/src/share/vm/classfile/classFileParser.cpp
+@@ -42,7 +42,7 @@
+ #include "oops/klassOop.hpp"
+ #include "oops/klassVtable.hpp"
+ #include "oops/methodOop.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "prims/jvmtiExport.hpp"
+ #include "runtime/javaCalls.hpp"
+ #include "runtime/perfData.hpp"
+@@ -268,14 +268,14 @@
+           }
+ 
+           unsigned int hash;
+-          symbolOop result = SymbolTable::lookup_only((char*)utf8_buffer, utf8_length, hash);
++          Symbol* result = SymbolTable::lookup_only((char*)utf8_buffer, utf8_length, hash);
+           if (result == NULL) {
+             names[names_count] = (char*)utf8_buffer;
+             lengths[names_count] = utf8_length;
+             indices[names_count] = index;
+             hashValues[names_count++] = hash;
+             if (names_count == SymbolTable::symbol_alloc_batch_size) {
+-              oopFactory::new_symbols(cp, names_count, names, lengths, indices, hashValues, CHECK);
++              SymbolTable::new_symbols(cp, names_count, names, lengths, indices, hashValues, CHECK);
+               names_count = 0;
+             }
+           } else {
+@@ -292,7 +292,7 @@
+ 
+   // Allocate the remaining symbols
+   if (names_count > 0) {
+-    oopFactory::new_symbols(cp, names_count, names, lengths, indices, hashValues, CHECK);
++    SymbolTable::new_symbols(cp, names_count, names, lengths, indices, hashValues, CHECK);
+   }
+ 
+   // Copy _current pointer of local copy back to stream().
+@@ -302,6 +302,23 @@
+   cfs0->set_current(cfs1.current());
+ }
+ 
++// This class unreferences constant pool symbols if an error has occurred
++// while parsing the class before it is assigned into the class.
++// If it gets an error after that it is unloaded and the constant pool will
++// be cleaned up then.
++class ConstantPoolCleaner : public StackObj {
++  constantPoolHandle _cphandle;
++  bool               _in_error;
++ public:
++  ConstantPoolCleaner(constantPoolHandle cp) : _cphandle(cp), _in_error(true) {}
++  ~ConstantPoolCleaner() {
++    if (_in_error && _cphandle.not_null()) {
++      _cphandle->unreference_symbols();
++    }
++  }
++  void set_in_error(bool clean) { _in_error = clean; }
++};
++
+ bool inline valid_cp_range(int index, int length) { return (index > 0 && index < length); }
+ 
+ constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) {
+@@ -320,6 +337,7 @@
+   constantPoolHandle cp (THREAD, constant_pool);
+ 
+   cp->set_partially_loaded();    // Enables heap verify to work on partial constantPoolOops
++  ConstantPoolCleaner cp_in_error(cp); // set constant pool to be cleaned up.
+ 
+   // parsing constant pool entries
+   parse_constant_pool_entries(cp, length, CHECK_(nullHandle));
+@@ -412,7 +430,7 @@
+               cp->tag_at(string_index).is_utf8(),
+             "Invalid constant pool index %u in class file %s",
+             string_index, CHECK_(nullHandle));
+-          symbolOop sym = cp->symbol_at(string_index);
++          Symbol* sym = cp->symbol_at(string_index);
+           cp->unresolved_string_at_put(index, sym);
+         }
+         break;
+@@ -527,6 +545,7 @@
+   }
+ 
+   if (!_need_verify) {
++    cp_in_error.set_in_error(false);
+     return cp;
+   }
+ 
+@@ -536,7 +555,7 @@
+     jbyte tag = cp->tag_at(index).value();
+     switch (tag) {
+       case JVM_CONSTANT_UnresolvedClass: {
+-        symbolHandle class_name(THREAD, cp->unresolved_klass_at(index));
++        Symbol*  class_name = cp->unresolved_klass_at(index);
+         // check the name, even if _cp_patches will overwrite it
+         verify_legal_class_name(class_name, CHECK_(nullHandle));
+         break;
+@@ -545,8 +564,8 @@
+         if (_need_verify && _major_version >= JAVA_7_VERSION) {
+           int sig_index = cp->signature_ref_index_at(index);
+           int name_index = cp->name_ref_index_at(index);
+-          symbolHandle name(THREAD, cp->symbol_at(name_index));
+-          symbolHandle sig(THREAD, cp->symbol_at(sig_index));
++          Symbol*  name = cp->symbol_at(name_index);
++          Symbol*  sig = cp->symbol_at(sig_index);
+           if (sig->byte_at(0) == JVM_SIGNATURE_FUNC) {
+             verify_legal_method_signature(name, sig, CHECK_(nullHandle));
+           } else {
+@@ -563,8 +582,8 @@
+         int name_ref_index = cp->name_ref_index_at(name_and_type_ref_index);
+         // already verified to be utf8
+         int signature_ref_index = cp->signature_ref_index_at(name_and_type_ref_index);
+-        symbolHandle name(THREAD, cp->symbol_at(name_ref_index));
+-        symbolHandle signature(THREAD, cp->symbol_at(signature_ref_index));
++        Symbol*  name = cp->symbol_at(name_ref_index);
++        Symbol*  signature = cp->symbol_at(signature_ref_index);
+         if (tag == JVM_CONSTANT_Fieldref) {
+           verify_legal_field_name(name, CHECK_(nullHandle));
+           if (_need_verify && _major_version >= JAVA_7_VERSION) {
+@@ -591,11 +610,11 @@
+           }
+           if (tag == JVM_CONSTANT_Methodref) {
+             // 4509014: If a class method name begins with '<', it must be "<init>".
+-            assert(!name.is_null(), "method name in constant pool is null");
++            assert(name != NULL, "method name in constant pool is null");
+             unsigned int name_len = name->utf8_length();
+             assert(name_len > 0, "bad method name");  // already verified as legal name
+             if (name->byte_at(0) == '<') {
+-              if (name() != vmSymbols::object_initializer_name()) {
++              if (name != vmSymbols::object_initializer_name()) {
+                 classfile_parse_error(
+                   "Bad method name at constant pool index %u in class file %s",
+                   name_ref_index, CHECK_(nullHandle));
+@@ -616,15 +635,15 @@
+           {
+             int name_and_type_ref_index = cp->name_and_type_ref_index_at(ref_index);
+             int name_ref_index = cp->name_ref_index_at(name_and_type_ref_index);
+-            symbolHandle name(THREAD, cp->symbol_at(name_ref_index));
++            Symbol*  name = cp->symbol_at(name_ref_index);
+             if (ref_kind == JVM_REF_newInvokeSpecial) {
+-              if (name() != vmSymbols::object_initializer_name()) {
++              if (name != vmSymbols::object_initializer_name()) {
+                 classfile_parse_error(
+                   "Bad constructor name at constant pool index %u in class file %s",
+                   name_ref_index, CHECK_(nullHandle));
+               }
+             } else {
+-              if (name() == vmSymbols::object_initializer_name()) {
++              if (name == vmSymbols::object_initializer_name()) {
+                 classfile_parse_error(
+                   "Bad method name at constant pool index %u in class file %s",
+                   name_ref_index, CHECK_(nullHandle));
+@@ -637,14 +656,18 @@
+         break;
+       }
+       case JVM_CONSTANT_MethodType: {
+-        symbolHandle no_name = vmSymbolHandles::type_name(); // place holder
+-        symbolHandle signature(THREAD, cp->method_type_signature_at(index));
++        Symbol* no_name = vmSymbols::type_name(); // place holder
++        Symbol*  signature = cp->method_type_signature_at(index);
+         verify_legal_method_signature(no_name, signature, CHECK_(nullHandle));
+         break;
+       }
++      case JVM_CONSTANT_Utf8: {
++        assert(cp->symbol_at(index)->refcount() != 0, "count corrupted");
++      }
+     }  // end of switch
+   }  // end of for
+ 
++  cp_in_error.set_in_error(false);
+   return cp;
+ }
+ 
+@@ -666,8 +689,8 @@
+       guarantee_property(java_lang_String::is_instance(patch()),
+                          "Illegal class patch at %d in class file %s",
+                          index, CHECK);
+-      symbolHandle name = java_lang_String::as_symbol(patch(), CHECK);
+-      cp->unresolved_klass_at_put(index, name());
++      Symbol* name = java_lang_String::as_symbol(patch(), CHECK);
++      cp->unresolved_klass_at_put(index, name);
+     }
+     break;
+ 
+@@ -718,15 +741,15 @@
+ 
+ class NameSigHash: public ResourceObj {
+  public:
+-  symbolOop     _name;       // name
+-  symbolOop     _sig;        // signature
++  Symbol*       _name;       // name
++  Symbol*       _sig;        // signature
+   NameSigHash*  _next;       // Next entry in hash table
+ };
+ 
+ 
+ #define HASH_ROW_SIZE 256
+ 
+-unsigned int hash(symbolOop name, symbolOop sig) {
++unsigned int hash(Symbol* name, Symbol* sig) {
+   unsigned int raw_hash = 0;
+   raw_hash += ((unsigned int)(uintptr_t)name) >> (LogHeapWordSize + 2);
+   raw_hash += ((unsigned int)(uintptr_t)sig) >> LogHeapWordSize;
+@@ -743,8 +766,8 @@
+ // Return true if no duplicate is found. And name/sig is added as a new entry in table.
+ // The old format checker uses heap sort to find duplicates.
+ // NOTE: caller should guarantee that GC doesn't happen during the life cycle
+-// of table since we don't expect symbolOop's to move.
+-bool put_after_lookup(symbolOop name, symbolOop sig, NameSigHash** table) {
++// of table since we don't expect Symbol*'s to move.
++bool put_after_lookup(Symbol* name, Symbol* sig, NameSigHash** table) {
+   assert(name != NULL, "name in constant pool is NULL");
+ 
+   // First lookup for duplicates
+@@ -774,7 +797,7 @@
+                                                  int length,
+                                                  Handle class_loader,
+                                                  Handle protection_domain,
+-                                                 symbolHandle class_name,
++                                                 Symbol* class_name,
+                                                  TRAPS) {
+   ClassFileStream* cfs = stream();
+   assert(length > 0, "only called for length>0");
+@@ -794,7 +817,7 @@
+     if (cp->tag_at(interface_index).is_klass()) {
+       interf = KlassHandle(THREAD, cp->resolved_klass_at(interface_index));
+     } else {
+-      symbolHandle unresolved_klass (THREAD, cp->klass_name_at(interface_index));
++      Symbol*  unresolved_klass  = cp->klass_name_at(interface_index);
+ 
+       // Don't need to check legal name because it's checked when parsing constant pool.
+       // But need to make sure it's not an array type.
+@@ -831,7 +854,7 @@
+     debug_only(No_Safepoint_Verifier nsv;)
+     for (index = 0; index < length; index++) {
+       klassOop k = (klassOop)interfaces->obj_at(index);
+-      symbolOop name = instanceKlass::cast(k)->name();
++      Symbol* name = instanceKlass::cast(k)->name();
+       // If no duplicates, add (name, NULL) in hashtable interface_names.
+       if (!put_after_lookup(name, NULL, interface_names)) {
+         dup = true;
+@@ -909,7 +932,7 @@
+                    "Invalid field attribute index %u in class file %s",
+                    attribute_name_index,
+                    CHECK);
+-    symbolOop attribute_name = cp->symbol_at(attribute_name_index);
++    Symbol* attribute_name = cp->symbol_at(attribute_name_index);
+     if (is_static && attribute_name == vmSymbols::tag_constant_value()) {
+       // ignore if non-static
+       if (constantvalue_index != 0) {
+@@ -1032,7 +1055,7 @@
+       valid_cp_range(name_index, cp_size) && cp->tag_at(name_index).is_utf8(),
+       "Invalid constant pool index %u for field name in class file %s",
+       name_index, CHECK_(nullHandle));
+-    symbolHandle name(THREAD, cp->symbol_at(name_index));
++    Symbol*  name = cp->symbol_at(name_index);
+     verify_legal_field_name(name, CHECK_(nullHandle));
+ 
+     u2 signature_index = cfs->get_u2_fast();
+@@ -1041,7 +1064,7 @@
+         cp->tag_at(signature_index).is_utf8(),
+       "Invalid constant pool index %u for field signature in class file %s",
+       signature_index, CHECK_(nullHandle));
+-    symbolHandle sig(THREAD, cp->symbol_at(signature_index));
++    Symbol*  sig = cp->symbol_at(signature_index);
+     verify_legal_field_signature(name, sig, CHECK_(nullHandle));
+ 
+     u2 constantvalue_index = 0;
+@@ -1167,9 +1190,9 @@
+       debug_only(No_Safepoint_Verifier nsv;)
+       for (int i = 0; i < length*instanceKlass::next_offset; i += instanceKlass::next_offset) {
+         int name_index = fields->ushort_at(i + instanceKlass::name_index_offset);
+-        symbolOop name = cp->symbol_at(name_index);
++        Symbol* name = cp->symbol_at(name_index);
+         int sig_index = fields->ushort_at(i + instanceKlass::signature_index_offset);
+-        symbolOop sig = cp->symbol_at(sig_index);
++        Symbol* sig = cp->symbol_at(sig_index);
+         // If no duplicates, add name/signature in hashtable names_and_sigs.
+         if (!put_after_lookup(name, sig, names_and_sigs)) {
+           dup = true;
+@@ -1423,16 +1446,16 @@
+         "Signature index %u in %s has bad constant type in class file %s",
+         descriptor_index, tbl_name, CHECK_NULL);
+ 
+-      symbolHandle name(THREAD, cp->symbol_at(name_index));
+-      symbolHandle sig(THREAD, cp->symbol_at(descriptor_index));
++      Symbol*  name = cp->symbol_at(name_index);
++      Symbol*  sig = cp->symbol_at(descriptor_index);
+       verify_legal_field_name(name, CHECK_NULL);
+       u2 extra_slot = 0;
+       if (!isLVTT) {
+         verify_legal_field_signature(name, sig, CHECK_NULL);
+ 
+         // 4894874: check special cases for double and long local variables
+-        if (sig() == vmSymbols::type_signature(T_DOUBLE) ||
+-            sig() == vmSymbols::type_signature(T_LONG)) {
++        if (sig == vmSymbols::type_signature(T_DOUBLE) ||
++            sig == vmSymbols::type_signature(T_LONG)) {
+           extra_slot = 1;
+         }
+       }
+@@ -1540,7 +1563,7 @@
+ }
+ 
+ void ClassFileParser::throwIllegalSignature(
+-    const char* type, symbolHandle name, symbolHandle sig, TRAPS) {
++    const char* type, Symbol* name, Symbol* sig, TRAPS) {
+   ResourceMark rm(THREAD);
+   Exceptions::fthrow(THREAD_AND_LOCATION,
+       vmSymbols::java_lang_ClassFormatError(),
+@@ -1581,7 +1604,7 @@
+       cp->tag_at(name_index).is_utf8(),
+     "Illegal constant pool index %u for method name in class file %s",
+     name_index, CHECK_(nullHandle));
+-  symbolHandle name(THREAD, cp->symbol_at(name_index));
++  Symbol*  name = cp->symbol_at(name_index);
+   verify_legal_method_name(name, CHECK_(nullHandle));
+ 
+   u2 signature_index = cfs->get_u2_fast();
+@@ -1590,7 +1613,7 @@
+       cp->tag_at(signature_index).is_utf8(),
+     "Illegal constant pool index %u for method signature in class file %s",
+     signature_index, CHECK_(nullHandle));
+-  symbolHandle signature(THREAD, cp->symbol_at(signature_index));
++  Symbol*  signature = cp->symbol_at(signature_index);
+ 
+   AccessFlags access_flags;
+   if (name == vmSymbols::class_initializer_name()) {
+@@ -1661,7 +1684,7 @@
+       "Invalid method attribute name index %u in class file %s",
+       method_attribute_name_index, CHECK_(nullHandle));
+ 
+-    symbolOop method_attribute_name = cp->symbol_at(method_attribute_name_index);
++    Symbol* method_attribute_name = cp->symbol_at(method_attribute_name_index);
+     if (method_attribute_name == vmSymbols::tag_code()) {
+       // Parse Code attribute
+       if (_need_verify) {
+@@ -2058,16 +2081,16 @@
+                                                      0,
+                                                      CHECK_(nullHandle));
+ 
+-  if (name() == vmSymbols::finalize_method_name() &&
+-      signature() == vmSymbols::void_method_signature()) {
++  if (name == vmSymbols::finalize_method_name() &&
++      signature == vmSymbols::void_method_signature()) {
+     if (m->is_empty_method()) {
+       _has_empty_finalizer = true;
+     } else {
+       _has_finalizer = true;
+     }
+   }
+-  if (name() == vmSymbols::object_initializer_name() &&
+-      signature() == vmSymbols::void_method_signature() &&
++  if (name == vmSymbols::object_initializer_name() &&
++      signature == vmSymbols::void_method_signature() &&
+       m->is_vanilla_constructor()) {
+     _has_vanilla_constructor = true;
+   }
+@@ -2194,7 +2217,7 @@
+     }
+   }
+   // Sort method array by ascending method name (for faster lookups & vtable construction)
+-  // Note that the ordering is not alphabetical, see symbolOopDesc::fast_compare
++  // Note that the ordering is not alphabetical, see Symbol::fast_compare
+   methodOopDesc::sort_methods(methods(),
+                               methods_annotations(),
+                               methods_parameter_annotations(),
+@@ -2243,9 +2266,10 @@
+   if (JvmtiExport::can_get_source_debug_extension()) {
+     // Optimistically assume that only 1 byte UTF format is used
+     // (common case)
+-    symbolOop sde_symbol = oopFactory::new_symbol((char*)sde_buffer,
+-                                                  length, CHECK);
++    TempNewSymbol sde_symbol = SymbolTable::new_symbol((const char*)sde_buffer, length, CHECK);
+     k->set_source_debug_extension(sde_symbol);
++    // Note that set_source_debug_extension() increments the reference count
++    // for its copy of the Symbol*, so use a TempNewSymbol here.
+   }
+   // Got utf8 string, set stream position forward
+   cfs->skip_u1(length, CHECK);
+@@ -2441,7 +2465,7 @@
+         cp->tag_at(attribute_name_index).is_utf8(),
+       "Attribute name has bad constant pool index %u in class file %s",
+       attribute_name_index, CHECK);
+-    symbolOop tag = cp->symbol_at(attribute_name_index);
++    Symbol* tag = cp->symbol_at(attribute_name_index);
+     if (tag == vmSymbols::tag_source_file()) {
+       // Check for SourceFile tag
+       if (_need_verify) {
+@@ -2608,7 +2632,7 @@
+       case T_OBJECT:
+         {
+           #ifdef ASSERT
+-          symbolOop sym = oopFactory::new_symbol("Ljava/lang/String;", CHECK);
++          TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
+           assert(fd->signature() == sym, "just checking");
+           #endif
+           oop string = fd->string_initial_value(CHECK);
+@@ -2651,8 +2675,8 @@
+     (*fields_ptr)()->ushort_at(i + instanceKlass::name_index_offset);
+     int sig_index  =
+       (*fields_ptr)()->ushort_at(i + instanceKlass::signature_index_offset);
+-    symbolOop f_name = cp->symbol_at(name_index);
+-    symbolOop f_sig  = cp->symbol_at(sig_index);
++    Symbol* f_name = cp->symbol_at(name_index);
++    Symbol* f_sig  = cp->symbol_at(sig_index);
+     if (f_sig == vmSymbols::reference_signature() && reference_index == 0) {
+       // Save the index for reference signature for later use.
+       // The fake discovered field does not entries in the
+@@ -2809,9 +2833,8 @@
+     int name_index = fields->ushort_at(i + instanceKlass::name_index_offset);
+     int sig_index  = fields->ushort_at(i + instanceKlass::signature_index_offset);
+     int acc_flags  = fields->ushort_at(i + instanceKlass::access_flags_offset);
+-    symbolOop f_name = cp->symbol_at(name_index);
+-    symbolOop f_sig  = cp->symbol_at(sig_index);
+-
++    Symbol* f_name = cp->symbol_at(name_index);
++    Symbol* f_sig  = cp->symbol_at(sig_index);
+     if (f_name == vmSymbols::vmentry_name() && (acc_flags & JVM_ACC_STATIC) == 0) {
+       if (f_sig == vmSymbols::machine_word_signature()) {
+         // If the signature of vmentry is already changed, we're done.
+@@ -2845,12 +2868,12 @@
+ }
+ 
+ 
+-instanceKlassHandle ClassFileParser::parseClassFile(symbolHandle name,
++instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
+                                                     Handle class_loader,
+                                                     Handle protection_domain,
+                                                     KlassHandle host_klass,
+                                                     GrowableArray<Handle>* cp_patches,
+-                                                    symbolHandle& parsed_name,
++                                                    TempNewSymbol& parsed_name,
+                                                     bool verify,
+                                                     TRAPS) {
+   // So that JVMTI can cache class file in the state before retransformable agents
+@@ -2903,7 +2926,7 @@
+   cfs->set_verify(_need_verify);
+ 
+   // Save the class file name for easier error message printing.
+-  _class_name = name.not_null()? name : vmSymbolHandles::unknown_class_name();
++  _class_name = (name != NULL) ? name : vmSymbols::unknown_class_name();
+ 
+   cfs->guarantee_more(8, CHECK_(nullHandle));  // magic, major, minor
+   // Magic value
+@@ -2918,10 +2941,10 @@
+ 
+   // Check version numbers - we check this even with verifier off
+   if (!is_supported_version(major_version, minor_version)) {
+-    if (name.is_null()) {
++    if (name == NULL) {
+       Exceptions::fthrow(
+         THREAD_AND_LOCATION,
+-        vmSymbolHandles::java_lang_UnsupportedClassVersionError(),
++        vmSymbols::java_lang_UnsupportedClassVersionError(),
+         "Unsupported major.minor version %u.%u",
+         major_version,
+         minor_version);
+@@ -2929,7 +2952,7 @@
+       ResourceMark rm(THREAD);
+       Exceptions::fthrow(
+         THREAD_AND_LOCATION,
+-        vmSymbolHandles::java_lang_UnsupportedClassVersionError(),
++        vmSymbols::java_lang_UnsupportedClassVersionError(),
+         "%s : Unsupported major.minor version %u.%u",
+         name->as_C_string(),
+         major_version,
+@@ -2948,6 +2971,8 @@
+ 
+   // Constant pool
+   constantPoolHandle cp = parse_constant_pool(CHECK_(nullHandle));
++  ConstantPoolCleaner error_handler(cp); // set constant pool to be cleaned up.
++
+   int cp_size = cp->length();
+ 
+   cfs->guarantee_more(8, CHECK_(nullHandle));  // flags, this_class, super_class, infs_len
+@@ -2972,12 +2997,15 @@
+     "Invalid this class index %u in constant pool in class file %s",
+     this_class_index, CHECK_(nullHandle));
+ 
+-  symbolHandle class_name (THREAD, cp->unresolved_klass_at(this_class_index));
+-  assert(class_name.not_null(), "class_name can't be null");
++  Symbol*  class_name  = cp->unresolved_klass_at(this_class_index);
++  assert(class_name != NULL, "class_name can't be null");
+ 
+   // It's important to set parsed_name *before* resolving the super class.
+   // (it's used for cleanup by the caller if parsing fails)
+   parsed_name = class_name;
++  // parsed_name is returned and can be used if there's an error, so add to
++  // its reference count.  Caller will decrement the refcount.
++  parsed_name->increment_refcount();
+ 
+   // Update _class_name which could be null previously to be class_name
+   _class_name = class_name;
+@@ -2997,11 +3025,11 @@
+   { HandleMark hm(THREAD);
+ 
+     // Checks if name in class file matches requested name
+-    if (name.not_null() && class_name() != name()) {
++    if (name != NULL && class_name != name) {
+       ResourceMark rm(THREAD);
+       Exceptions::fthrow(
+         THREAD_AND_LOCATION,
+-        vmSymbolHandles::java_lang_NoClassDefFoundError(),
++        vmSymbols::java_lang_NoClassDefFoundError(),
+         "%s (wrong name: %s)",
+         name->as_C_string(),
+         class_name->as_C_string()
+@@ -3010,14 +3038,14 @@
+     }
+ 
+     if (TraceClassLoadingPreorder) {
+-      tty->print("[Loading %s", name()->as_klass_external_name());
++      tty->print("[Loading %s", name->as_klass_external_name());
+       if (cfs->source() != NULL) tty->print(" from %s", cfs->source());
+       tty->print_cr("]");
+     }
+ 
+     u2 super_class_index = cfs->get_u2_fast();
+     if (super_class_index == 0) {
+-      check_property(class_name() == vmSymbols::java_lang_Object(),
++      check_property(class_name == vmSymbols::java_lang_Object(),
+                      "Invalid superclass index %u in class file %s",
+                      super_class_index,
+                      CHECK_(nullHandle));
+@@ -3079,11 +3107,11 @@
+ 
+     // We check super class after class file is parsed and format is checked
+     if (super_class_index > 0 && super_klass.is_null()) {
+-      symbolHandle sk (THREAD, cp->klass_name_at(super_class_index));
++      Symbol*  sk  = cp->klass_name_at(super_class_index);
+       if (access_flags.is_interface()) {
+         // Before attempting to resolve the superclass, check for class format
+         // errors not checked yet.
+-        guarantee_property(sk() == vmSymbols::java_lang_Object(),
++        guarantee_property(sk == vmSymbols::java_lang_Object(),
+                            "Interfaces must have java.lang.Object as superclass in class file %s",
+                            CHECK_(nullHandle));
+       }
+@@ -3104,7 +3132,7 @@
+         ResourceMark rm(THREAD);
+         Exceptions::fthrow(
+           THREAD_AND_LOCATION,
+-          vmSymbolHandles::java_lang_IncompatibleClassChangeError(),
++          vmSymbols::java_lang_IncompatibleClassChangeError(),
+           "class %s has interface %s as super class",
+           class_name->as_klass_external_name(),
+           super_klass->external_name()
+@@ -3195,18 +3223,18 @@
+     next_nonstatic_field_offset = first_nonstatic_field_offset;
+ 
+     // Add fake fields for java.lang.Class instances (also see below)
+-    if (class_name() == vmSymbols::java_lang_Class() && class_loader.is_null()) {
++    if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
+       java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle));
+     }
+ 
+     // adjust the vmentry field declaration in java.dyn.MethodHandle
+-    if (EnableMethodHandles && class_name() == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
++    if (EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
+       java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
+     }
+ 
+     // Add a fake "discovered" field if it is not present
+     // for compatibility with earlier jdk's.
+-    if (class_name() == vmSymbols::java_lang_ref_Reference()
++    if (class_name == vmSymbols::java_lang_ref_Reference()
+       && class_loader.is_null()) {
+       java_lang_ref_Reference_fix_pre(&fields, cp, &fac, CHECK_(nullHandle));
+     }
+@@ -3238,7 +3266,7 @@
+ 
+     // Add fake fields for java.lang.Class instances (also see above).
+     // FieldsAllocationStyle and CompactFields values will be reset to default.
+-    if(class_name() == vmSymbols::java_lang_Class() && class_loader.is_null()) {
++    if(class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
+       java_lang_Class_fix_post(&next_nonstatic_field_offset);
+       nonstatic_oop_offsets[0] = first_nonstatic_field_offset;
+       const uint fake_oop_count = (next_nonstatic_field_offset -
+@@ -3281,22 +3309,22 @@
+     // (see in JavaClasses::compute_hard_coded_offsets()).
+     // Use default fields allocation order for them.
+     if( (allocation_style != 0 || compact_fields ) && class_loader.is_null() &&
+-        (class_name() == vmSymbols::java_lang_AssertionStatusDirectives() ||
+-         class_name() == vmSymbols::java_lang_Class() ||
+-         class_name() == vmSymbols::java_lang_ClassLoader() ||
+-         class_name() == vmSymbols::java_lang_ref_Reference() ||
+-         class_name() == vmSymbols::java_lang_ref_SoftReference() ||
+-         class_name() == vmSymbols::java_lang_StackTraceElement() ||
+-         class_name() == vmSymbols::java_lang_String() ||
+-         class_name() == vmSymbols::java_lang_Throwable() ||
+-         class_name() == vmSymbols::java_lang_Boolean() ||
+-         class_name() == vmSymbols::java_lang_Character() ||
+-         class_name() == vmSymbols::java_lang_Float() ||
+-         class_name() == vmSymbols::java_lang_Double() ||
+-         class_name() == vmSymbols::java_lang_Byte() ||
+-         class_name() == vmSymbols::java_lang_Short() ||
+-         class_name() == vmSymbols::java_lang_Integer() ||
+-         class_name() == vmSymbols::java_lang_Long())) {
++        (class_name == vmSymbols::java_lang_AssertionStatusDirectives() ||
++         class_name == vmSymbols::java_lang_Class() ||
++         class_name == vmSymbols::java_lang_ClassLoader() ||
++         class_name == vmSymbols::java_lang_ref_Reference() ||
++         class_name == vmSymbols::java_lang_ref_SoftReference() ||
++         class_name == vmSymbols::java_lang_StackTraceElement() ||
++         class_name == vmSymbols::java_lang_String() ||
++         class_name == vmSymbols::java_lang_Throwable() ||
++         class_name == vmSymbols::java_lang_Boolean() ||
++         class_name == vmSymbols::java_lang_Character() ||
++         class_name == vmSymbols::java_lang_Float() ||
++         class_name == vmSymbols::java_lang_Double() ||
++         class_name == vmSymbols::java_lang_Byte() ||
++         class_name == vmSymbols::java_lang_Short() ||
++         class_name == vmSymbols::java_lang_Integer() ||
++         class_name == vmSymbols::java_lang_Long())) {
+       allocation_style = 0;     // Allocate oops first
+       compact_fields   = false; // Don't compact fields
+     }
+@@ -3545,6 +3573,7 @@
+     this_klass->set_has_nonstatic_fields(has_nonstatic_fields);
+     this_klass->set_static_oop_field_count(fac.static_oop_count);
+     cp->set_pool_holder(this_klass());
++    error_handler.set_in_error(false);   // turn off error handler for cp
+     this_klass->set_constants(cp());
+     this_klass->set_local_interfaces(local_interfaces());
+     this_klass->set_fields(fields());
+@@ -3937,7 +3966,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_IllegalAccessError(),
++      vmSymbols::java_lang_IllegalAccessError(),
+       "class %s cannot access its superclass %s",
+       this_klass->external_name(),
+       instanceKlass::cast(super)->external_name()
+@@ -3957,7 +3986,7 @@
+       ResourceMark rm(THREAD);
+       Exceptions::fthrow(
+         THREAD_AND_LOCATION,
+-        vmSymbolHandles::java_lang_IllegalAccessError(),
++        vmSymbols::java_lang_IllegalAccessError(),
+         "class %s cannot access its superinterface %s",
+         this_klass->external_name(),
+         instanceKlass::cast(k)->external_name()
+@@ -3981,8 +4010,8 @@
+         (!m->is_static()) &&
+         (m->name() != vmSymbols::object_initializer_name())) {
+ 
+-      symbolOop name = m->name();
+-      symbolOop signature = m->signature();
++      Symbol* name = m->name();
++      Symbol* signature = m->signature();
+       klassOop k = this_klass->super();
+       methodOop super_m = NULL;
+       while (k != NULL) {
+@@ -4005,7 +4034,7 @@
+             ResourceMark rm(THREAD);
+             Exceptions::fthrow(
+               THREAD_AND_LOCATION,
+-              vmSymbolHandles::java_lang_VerifyError(),
++              vmSymbols::java_lang_VerifyError(),
+               "class %s overrides final method %s.%s",
+               this_klass->external_name(),
+               name->as_C_string(),
+@@ -4039,7 +4068,7 @@
+       ResourceMark rm(THREAD);
+       Exceptions::fthrow(
+         THREAD_AND_LOCATION,
+-        vmSymbolHandles::java_lang_VerifyError(),
++        vmSymbols::java_lang_VerifyError(),
+         "Illegal static method %s in interface %s",
+         m->name()->as_C_string(),
+         this_klass->external_name()
+@@ -4069,7 +4098,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_ClassFormatError(),
++      vmSymbols::java_lang_ClassFormatError(),
+       "Illegal class modifiers in class %s: 0x%X",
+       _class_name->as_C_string(), flags
+     );
+@@ -4129,7 +4158,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_ClassFormatError(),
++      vmSymbols::java_lang_ClassFormatError(),
+       "Illegal field modifiers in class %s: 0x%X",
+       _class_name->as_C_string(), flags);
+     return;
+@@ -4137,7 +4166,7 @@
+ }
+ 
+ void ClassFileParser::verify_legal_method_modifiers(
+-    jint flags, bool is_interface, symbolHandle name, TRAPS) {
++    jint flags, bool is_interface, Symbol* name, TRAPS) {
+   if (!_need_verify) { return; }
+ 
+   const bool is_public       = (flags & JVM_ACC_PUBLIC)       != 0;
+@@ -4182,7 +4211,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_ClassFormatError(),
++      vmSymbols::java_lang_ClassFormatError(),
+       "Method %s in class %s has illegal modifiers: 0x%X",
+       name->as_C_string(), _class_name->as_C_string(), flags);
+     return;
+@@ -4253,7 +4282,7 @@
+ }
+ 
+ // Checks if name is a legal class name.
+-void ClassFileParser::verify_legal_class_name(symbolHandle name, TRAPS) {
++void ClassFileParser::verify_legal_class_name(Symbol* name, TRAPS) {
+   if (!_need_verify || _relax_verify) { return; }
+ 
+   char buf[fixed_buffer_size];
+@@ -4283,7 +4312,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_ClassFormatError(),
++      vmSymbols::java_lang_ClassFormatError(),
+       "Illegal class name \"%s\" in class file %s", bytes,
+       _class_name->as_C_string()
+     );
+@@ -4292,7 +4321,7 @@
+ }
+ 
+ // Checks if name is a legal field name.
+-void ClassFileParser::verify_legal_field_name(symbolHandle name, TRAPS) {
++void ClassFileParser::verify_legal_field_name(Symbol* name, TRAPS) {
+   if (!_need_verify || _relax_verify) { return; }
+ 
+   char buf[fixed_buffer_size];
+@@ -4316,7 +4345,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_ClassFormatError(),
++      vmSymbols::java_lang_ClassFormatError(),
+       "Illegal field name \"%s\" in class %s", bytes,
+       _class_name->as_C_string()
+     );
+@@ -4325,10 +4354,10 @@
+ }
+ 
+ // Checks if name is a legal method name.
+-void ClassFileParser::verify_legal_method_name(symbolHandle name, TRAPS) {
++void ClassFileParser::verify_legal_method_name(Symbol* name, TRAPS) {
+   if (!_need_verify || _relax_verify) { return; }
+ 
+-  assert(!name.is_null(), "method name is null");
++  assert(name != NULL, "method name is null");
+   char buf[fixed_buffer_size];
+   char* bytes = name->as_utf8_flexible_buffer(THREAD, buf, fixed_buffer_size);
+   unsigned int length = name->utf8_length();
+@@ -4353,7 +4382,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_ClassFormatError(),
++      vmSymbols::java_lang_ClassFormatError(),
+       "Illegal method name \"%s\" in class %s", bytes,
+       _class_name->as_C_string()
+     );
+@@ -4363,7 +4392,7 @@
+ 
+ 
+ // Checks if signature is a legal field signature.
+-void ClassFileParser::verify_legal_field_signature(symbolHandle name, symbolHandle signature, TRAPS) {
++void ClassFileParser::verify_legal_field_signature(Symbol* name, Symbol* signature, TRAPS) {
+   if (!_need_verify) { return; }
+ 
+   char buf[fixed_buffer_size];
+@@ -4378,7 +4407,7 @@
+ 
+ // Checks if signature is a legal method signature.
+ // Returns number of parameters
+-int ClassFileParser::verify_legal_method_signature(symbolHandle name, symbolHandle signature, TRAPS) {
++int ClassFileParser::verify_legal_method_signature(Symbol* name, Symbol* signature, TRAPS) {
+   if (!_need_verify) {
+     // make sure caller's args_size will be less than 0 even for non-static
+     // method so it will be recomputed in compute_size_of_parameters().
+@@ -4510,8 +4539,8 @@
+       // public static boolean isJavaIdentifierStart(char ch);
+       JavaCalls::call_static(&result,
+                              klass,
+-                             vmSymbolHandles::isJavaIdentifierStart_name(),
+-                             vmSymbolHandles::int_bool_signature(),
++                             vmSymbols::isJavaIdentifierStart_name(),
++                             vmSymbols::int_bool_signature(),
+                              &args,
+                              THREAD);
+ 
+@@ -4527,8 +4556,8 @@
+         // public static boolean isJavaIdentifierPart(char ch);
+         JavaCalls::call_static(&result,
+                                klass,
+-                               vmSymbolHandles::isJavaIdentifierPart_name(),
+-                               vmSymbolHandles::int_bool_signature(),
++                               vmSymbols::isJavaIdentifierPart_name(),
++                               vmSymbols::int_bool_signature(),
+                                &args,
+                                THREAD);
+ 
+diff --git a/src/share/vm/classfile/classFileParser.hpp b/src/share/vm/classfile/classFileParser.hpp
+--- openjdk/hotspot/src/share/vm/classfile/classFileParser.hpp
++++ openjdk/hotspot/src/share/vm/classfile/classFileParser.hpp
+@@ -32,6 +32,7 @@
+ #include "runtime/handles.inline.hpp"
+ #include "utilities/accessFlags.hpp"
+ 
++class TempNewSymbol;
+ // Parser for for .class files
+ //
+ // The bytes describing the class file structure is read from a Stream object
+@@ -42,7 +43,7 @@
+   bool _relax_verify;
+   u2   _major_version;
+   u2   _minor_version;
+-  symbolHandle _class_name;
++  Symbol* _class_name;
+   KlassHandle _host_klass;
+   GrowableArray<Handle>* _cp_patches; // overrides for CP entries
+ 
+@@ -73,7 +74,7 @@
+                                   int length,
+                                   Handle class_loader,
+                                   Handle protection_domain,
+-                                  symbolHandle class_name,
++                                  Symbol* class_name,
+                                   TRAPS);
+ 
+   // Field parsing
+@@ -210,21 +211,21 @@
+   }
+ 
+   void throwIllegalSignature(
+-      const char* type, symbolHandle name, symbolHandle sig, TRAPS);
++      const char* type, Symbol* name, Symbol* sig, TRAPS);
+ 
+   bool is_supported_version(u2 major, u2 minor);
+   bool has_illegal_visibility(jint flags);
+ 
+   void verify_constantvalue(int constantvalue_index, int signature_index, constantPoolHandle cp, TRAPS);
+   void verify_legal_utf8(const unsigned char* buffer, int length, TRAPS);
+-  void verify_legal_class_name(symbolHandle name, TRAPS);
+-  void verify_legal_field_name(symbolHandle name, TRAPS);
+-  void verify_legal_method_name(symbolHandle name, TRAPS);
+-  void verify_legal_field_signature(symbolHandle fieldname, symbolHandle signature, TRAPS);
+-  int  verify_legal_method_signature(symbolHandle methodname, symbolHandle signature, TRAPS);
++  void verify_legal_class_name(Symbol* name, TRAPS);
++  void verify_legal_field_name(Symbol* name, TRAPS);
++  void verify_legal_method_name(Symbol* name, TRAPS);
++  void verify_legal_field_signature(Symbol* fieldname, Symbol* signature, TRAPS);
++  int  verify_legal_method_signature(Symbol* methodname, Symbol* signature, TRAPS);
+   void verify_legal_class_modifiers(jint flags, TRAPS);
+   void verify_legal_field_modifiers(jint flags, bool is_interface, TRAPS);
+-  void verify_legal_method_modifiers(jint flags, bool is_interface, symbolHandle name, TRAPS);
++  void verify_legal_method_modifiers(jint flags, bool is_interface, Symbol* name, TRAPS);
+   bool verify_unqualified_name(char* name, unsigned int length, int type);
+   char* skip_over_field_name(char* name, bool slash_ok, unsigned int length);
+   char* skip_over_field_signature(char* signature, bool void_ok, unsigned int length, TRAPS);
+@@ -273,21 +274,21 @@
+   //
+   // "parsed_name" is updated by this method, and is the name found
+   // while parsing the stream.
+-  instanceKlassHandle parseClassFile(symbolHandle name,
++  instanceKlassHandle parseClassFile(Symbol* name,
+                                      Handle class_loader,
+                                      Handle protection_domain,
+-                                     symbolHandle& parsed_name,
++                                     TempNewSymbol& parsed_name,
+                                      bool verify,
+                                      TRAPS) {
+     KlassHandle no_host_klass;
+     return parseClassFile(name, class_loader, protection_domain, no_host_klass, NULL, parsed_name, verify, THREAD);
+   }
+-  instanceKlassHandle parseClassFile(symbolHandle name,
++  instanceKlassHandle parseClassFile(Symbol* name,
+                                      Handle class_loader,
+                                      Handle protection_domain,
+                                      KlassHandle host_klass,
+                                      GrowableArray<Handle>* cp_patches,
+-                                     symbolHandle& parsed_name,
++                                     TempNewSymbol& parsed_name,
+                                      bool verify,
+                                      TRAPS);
+ 
+diff --git a/src/share/vm/classfile/classLoader.cpp b/src/share/vm/classfile/classLoader.cpp
+--- openjdk/hotspot/src/share/vm/classfile/classLoader.cpp
++++ openjdk/hotspot/src/share/vm/classfile/classLoader.cpp
+@@ -41,7 +41,7 @@
+ #include "oops/instanceKlass.hpp"
+ #include "oops/instanceRefKlass.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "prims/jvm_misc.hpp"
+ #include "runtime/arguments.hpp"
+ #include "runtime/compilationPolicy.hpp"
+@@ -752,11 +752,7 @@
+     }
+   }
+   if (*top + n + sizeof(intptr_t) >= end) {
+-    warning("\nThe shared miscellaneous data space is not large "
+-            "enough to \npreload requested classes.  Use "
+-            "-XX:SharedMiscDataSize= to increase \nthe initial "
+-            "size of the miscellaneous data space.\n");
+-    exit(2);
++    report_out_of_shared_space(SharedMiscData);
+   }
+ 
+   // Copy the table data (the strings) to the shared space.
+@@ -875,9 +871,9 @@
+ }
+ 
+ 
+-instanceKlassHandle ClassLoader::load_classfile(symbolHandle h_name, TRAPS) {
++instanceKlassHandle ClassLoader::load_classfile(Symbol* h_name, TRAPS) {
+   ResourceMark rm(THREAD);
+-  EventMark m("loading class " INTPTR_FORMAT, (address)h_name());
++  EventMark m("loading class " INTPTR_FORMAT, (address)h_name);
+   ThreadProfilerMark tpm(ThreadProfilerMark::classLoaderRegion);
+ 
+   stringStream st;
+@@ -912,7 +908,7 @@
+     ClassFileParser parser(stream);
+     Handle class_loader;
+     Handle protection_domain;
+-    symbolHandle parsed_name;
++    TempNewSymbol parsed_name = NULL;
+     instanceKlassHandle result = parser.parseClassFile(h_name,
+                                                        class_loader,
+                                                        protection_domain,
+@@ -1308,7 +1304,7 @@
+       if (_compile_the_world_counter > CompileTheWorldStopAt) return;
+ 
+       // Construct name without extension
+-      symbolHandle sym = oopFactory::new_symbol_handle(buffer, CHECK);
++      TempNewSymbol sym = SymbolTable::new_symbol(buffer, CHECK);
+       // Use loader to load and initialize class
+       klassOop ik = SystemDictionary::resolve_or_null(sym, loader, Handle(), THREAD);
+       instanceKlassHandle k (THREAD, ik);
+diff --git a/src/share/vm/classfile/classLoader.hpp b/src/share/vm/classfile/classLoader.hpp
+--- openjdk/hotspot/src/share/vm/classfile/classLoader.hpp
++++ openjdk/hotspot/src/share/vm/classfile/classLoader.hpp
+@@ -280,7 +280,7 @@
+   }
+ 
+   // Load individual .class file
+-  static instanceKlassHandle load_classfile(symbolHandle h_name, TRAPS);
++  static instanceKlassHandle load_classfile(Symbol* h_name, TRAPS);
+ 
+   // If the specified package has been loaded by the system, then returns
+   // the name of the directory or ZIP file that the package was loaded from.
+diff --git a/src/share/vm/classfile/dictionary.cpp b/src/share/vm/classfile/dictionary.cpp
+--- openjdk/hotspot/src/share/vm/classfile/dictionary.cpp
++++ openjdk/hotspot/src/share/vm/classfile/dictionary.cpp
+@@ -36,7 +36,7 @@
+ 
+ 
+ Dictionary::Dictionary(int table_size)
+-  : TwoOopHashtable(table_size, sizeof(DictionaryEntry)) {
++  : TwoOopHashtable<klassOop>(table_size, sizeof(DictionaryEntry)) {
+   _current_class_index = 0;
+   _current_class_entry = NULL;
+ };
+@@ -45,7 +45,7 @@
+ 
+ Dictionary::Dictionary(int table_size, HashtableBucket* t,
+                        int number_of_entries)
+-  : TwoOopHashtable(table_size, sizeof(DictionaryEntry), t, number_of_entries) {
++  : TwoOopHashtable<klassOop>(table_size, sizeof(DictionaryEntry), t, number_of_entries) {
+   _current_class_index = 0;
+   _current_class_entry = NULL;
+ };
+@@ -54,7 +54,7 @@
+ DictionaryEntry* Dictionary::new_entry(unsigned int hash, klassOop klass,
+                                        oop loader) {
+   DictionaryEntry* entry;
+-  entry = (DictionaryEntry*)Hashtable::new_entry(hash, klass);
++  entry = (DictionaryEntry*)Hashtable<klassOop>::new_entry(hash, klass);
+   entry->set_loader(loader);
+   entry->set_pd_set(NULL);
+   return entry;
+@@ -62,7 +62,7 @@
+ 
+ 
+ DictionaryEntry* Dictionary::new_entry() {
+-  DictionaryEntry* entry = (DictionaryEntry*)Hashtable::new_entry(0L, NULL);
++  DictionaryEntry* entry = (DictionaryEntry*)Hashtable<klassOop>::new_entry(0L, NULL);
+   entry->set_loader(NULL);
+   entry->set_pd_set(NULL);
+   return entry;
+@@ -76,7 +76,7 @@
+     entry->set_pd_set(to_delete->next());
+     delete to_delete;
+   }
+-  Hashtable::free_entry(entry);
++  Hashtable<klassOop>::free_entry(entry);
+ }
+ 
+ 
+@@ -298,7 +298,7 @@
+     for (DictionaryEntry *probe = bucket(index);
+                           probe != NULL;
+                           probe = probe->next()) {
+-      oop e = probe->klass();
++      klassOop e = probe->klass();
+       oop class_loader = probe->loader();
+       if (is_strongly_reachable(class_loader, e)) {
+         blk->do_oop((oop*)probe->klass_addr());
+@@ -421,11 +421,11 @@
+ // also cast to volatile;  we do this to ensure store order is maintained
+ // by the compilers.
+ 
+-void Dictionary::add_klass(symbolHandle class_name, Handle class_loader,
++void Dictionary::add_klass(Symbol* class_name, Handle class_loader,
+                            KlassHandle obj) {
+   assert_locked_or_safepoint(SystemDictionary_lock);
+   assert(obj() != NULL, "adding NULL obj");
+-  assert(Klass::cast(obj())->name() == class_name(), "sanity check on name");
++  assert(Klass::cast(obj())->name() == class_name, "sanity check on name");
+ 
+   unsigned int hash = compute_hash(class_name, class_loader);
+   int index = hash_to_index(hash);
+@@ -444,15 +444,14 @@
+ // Callers should be aware that an entry could be added just after
+ // _buckets[index] is read here, so the caller will not see the new entry.
+ DictionaryEntry* Dictionary::get_entry(int index, unsigned int hash,
+-                                       symbolHandle class_name,
++                                       Symbol* class_name,
+                                        Handle class_loader) {
+-  symbolOop name_ = class_name();
+-  oop loader_ = class_loader();
++  oop loader = class_loader();
+   debug_only(_lookup_count++);
+   for (DictionaryEntry* entry = bucket(index);
+                         entry != NULL;
+                         entry = entry->next()) {
+-    if (entry->hash() == hash && entry->equals(name_, loader_)) {
++    if (entry->hash() == hash && entry->equals(class_name, loader)) {
+       return entry;
+     }
+     debug_only(_lookup_length++);
+@@ -461,7 +460,7 @@
+ }
+ 
+ 
+-klassOop Dictionary::find(int index, unsigned int hash, symbolHandle name,
++klassOop Dictionary::find(int index, unsigned int hash, Symbol* name,
+                           Handle loader, Handle protection_domain, TRAPS) {
+   DictionaryEntry* entry = get_entry(index, hash, name, loader);
+   if (entry != NULL && entry->is_valid_protection_domain(protection_domain)) {
+@@ -473,7 +472,7 @@
+ 
+ 
+ klassOop Dictionary::find_class(int index, unsigned int hash,
+-                                symbolHandle name, Handle loader) {
++                                Symbol* name, Handle loader) {
+   assert_locked_or_safepoint(SystemDictionary_lock);
+   assert (index == index_for(name, loader), "incorrect index?");
+ 
+@@ -486,7 +485,7 @@
+ // that table is static.
+ 
+ klassOop Dictionary::find_shared_class(int index, unsigned int hash,
+-                                       symbolHandle name) {
++                                       Symbol* name) {
+   assert (index == index_for(name, Handle()), "incorrect index?");
+ 
+   DictionaryEntry* entry = get_entry(index, hash, name, Handle());
+@@ -498,7 +497,7 @@
+                                        instanceKlassHandle klass,
+                                        Handle loader, Handle protection_domain,
+                                        TRAPS) {
+-  symbolHandle klass_name(THREAD, klass->name());
++  Symbol*  klass_name = klass->name();
+   DictionaryEntry* entry = get_entry(index, hash, klass_name, loader);
+ 
+   assert(entry != NULL,"entry must be present, we just created it");
+@@ -513,7 +512,7 @@
+ 
+ 
+ bool Dictionary::is_valid_protection_domain(int index, unsigned int hash,
+-                                            symbolHandle name,
++                                            Symbol* name,
+                                             Handle loader,
+                                             Handle protection_domain) {
+   DictionaryEntry* entry = get_entry(index, hash, name, loader);
+@@ -545,7 +544,7 @@
+     DictionaryEntry* p = master_list;
+     master_list = master_list->next();
+     p->set_next(NULL);
+-    symbolHandle class_name (thread, instanceKlass::cast((klassOop)(p->klass()))->name());
++    Symbol* class_name = instanceKlass::cast((klassOop)(p->klass()))->name();
+     unsigned int hash = compute_hash(class_name, Handle(thread, p->loader()));
+     int index = hash_to_index(hash);
+     p->set_hash(hash);
+@@ -555,22 +554,22 @@
+ }
+ 
+ SymbolPropertyTable::SymbolPropertyTable(int table_size)
+-  : Hashtable(table_size, sizeof(SymbolPropertyEntry))
++  : Hashtable<Symbol*>(table_size, sizeof(SymbolPropertyEntry))
+ {
+ }
+ SymbolPropertyTable::SymbolPropertyTable(int table_size, HashtableBucket* t,
+                                          int number_of_entries)
+-  : Hashtable(table_size, sizeof(SymbolPropertyEntry), t, number_of_entries)
++  : Hashtable<Symbol*>(table_size, sizeof(SymbolPropertyEntry), t, number_of_entries)
+ {
+ }
+ 
+ 
+ SymbolPropertyEntry* SymbolPropertyTable::find_entry(int index, unsigned int hash,
+-                                                     symbolHandle sym,
++                                                     Symbol* sym,
+                                                      intptr_t sym_mode) {
+   assert(index == index_for(sym, sym_mode), "incorrect index?");
+   for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
+-    if (p->hash() == hash && p->symbol() == sym() && p->symbol_mode() == sym_mode) {
++    if (p->hash() == hash && p->symbol() == sym && p->symbol_mode() == sym_mode) {
+       return p;
+     }
+   }
+@@ -579,13 +578,13 @@
+ 
+ 
+ SymbolPropertyEntry* SymbolPropertyTable::add_entry(int index, unsigned int hash,
+-                                                    symbolHandle sym, intptr_t sym_mode) {
++                                                    Symbol* sym, intptr_t sym_mode) {
+   assert_locked_or_safepoint(SystemDictionary_lock);
+   assert(index == index_for(sym, sym_mode), "incorrect index?");
+   assert(find_entry(index, hash, sym, sym_mode) == NULL, "no double entry");
+ 
+-  SymbolPropertyEntry* p = new_entry(hash, sym(), sym_mode);
+-  Hashtable::add_entry(index, p);
++  SymbolPropertyEntry* p = new_entry(hash, sym, sym_mode);
++  Hashtable<Symbol*>::add_entry(index, p);
+   return p;
+ }
+ 
+@@ -593,7 +592,6 @@
+ void SymbolPropertyTable::oops_do(OopClosure* f) {
+   for (int index = 0; index < table_size(); index++) {
+     for (SymbolPropertyEntry* p = bucket(index); p != NULL; p = p->next()) {
+-      f->do_oop((oop*) p->symbol_addr());
+       if (p->property_oop() != NULL) {
+         f->do_oop(p->property_oop_addr());
+       }
+diff --git a/src/share/vm/classfile/dictionary.hpp b/src/share/vm/classfile/dictionary.hpp
+--- openjdk/hotspot/src/share/vm/classfile/dictionary.hpp
++++ openjdk/hotspot/src/share/vm/classfile/dictionary.hpp
+@@ -36,7 +36,7 @@
+ // The data structure for the system dictionary (and the shared system
+ // dictionary).
+ 
+-class Dictionary : public TwoOopHashtable {
++class Dictionary : public TwoOopHashtable<klassOop> {
+   friend class VMStructs;
+ private:
+   // current iteration index.
+@@ -45,19 +45,19 @@
+   static DictionaryEntry*       _current_class_entry;
+ 
+   DictionaryEntry* get_entry(int index, unsigned int hash,
+-                             symbolHandle name, Handle loader);
++                             Symbol* name, Handle loader);
+ 
+   DictionaryEntry* bucket(int i) {
+-    return (DictionaryEntry*)Hashtable::bucket(i);
++    return (DictionaryEntry*)Hashtable<klassOop>::bucket(i);
+   }
+ 
+   // The following method is not MT-safe and must be done under lock.
+   DictionaryEntry** bucket_addr(int i) {
+-    return (DictionaryEntry**)Hashtable::bucket_addr(i);
++    return (DictionaryEntry**)Hashtable<klassOop>::bucket_addr(i);
+   }
+ 
+   void add_entry(int index, DictionaryEntry* new_entry) {
+-    Hashtable::add_entry(index, (HashtableEntry*)new_entry);
++    Hashtable<klassOop>::add_entry(index, (HashtableEntry<oop>*)new_entry);
+   }
+ 
+ 
+@@ -71,12 +71,12 @@
+ 
+   void free_entry(DictionaryEntry* entry);
+ 
+-  void add_klass(symbolHandle class_name, Handle class_loader,KlassHandle obj);
++  void add_klass(Symbol* class_name, Handle class_loader,KlassHandle obj);
+ 
+   klassOop find_class(int index, unsigned int hash,
+-                      symbolHandle name, Handle loader);
++                      Symbol* name, Handle loader);
+ 
+-  klassOop find_shared_class(int index, unsigned int hash, symbolHandle name);
++  klassOop find_shared_class(int index, unsigned int hash, Symbol* name);
+ 
+   // Compiler support
+   klassOop try_get_next_class();
+@@ -95,7 +95,7 @@
+ 
+   // Classes loaded by the bootstrap loader are always strongly reachable.
+   // If we're not doing class unloading, all classes are strongly reachable.
+-  static bool is_strongly_reachable(oop class_loader, oop klass) {
++  static bool is_strongly_reachable(oop class_loader, klassOop klass) {
+     assert (klass != NULL, "should have non-null klass");
+     return (class_loader == NULL || !ClassUnloading);
+   }
+@@ -105,10 +105,10 @@
+   bool do_unloading(BoolObjectClosure* is_alive);
+ 
+   // Protection domains
+-  klassOop find(int index, unsigned int hash, symbolHandle name,
++  klassOop find(int index, unsigned int hash, Symbol* name,
+                 Handle loader, Handle protection_domain, TRAPS);
+   bool is_valid_protection_domain(int index, unsigned int hash,
+-                                  symbolHandle name, Handle class_loader,
++                                  Symbol* name, Handle class_loader,
+                                   Handle protection_domain);
+   void add_protection_domain(int index, unsigned int hash,
+                              instanceKlassHandle klass, Handle loader,
+@@ -147,7 +147,7 @@
+ // An entry in the system dictionary, this describes a class as
+ // { klassOop, loader, protection_domain }.
+ 
+-class DictionaryEntry : public HashtableEntry {
++class DictionaryEntry : public HashtableEntry<klassOop> {
+   friend class VMStructs;
+  private:
+   // Contains the set of approved protection domains that can access
+@@ -166,11 +166,11 @@
+   klassOop* klass_addr() { return (klassOop*)literal_addr(); }
+ 
+   DictionaryEntry* next() const {
+-    return (DictionaryEntry*)HashtableEntry::next();
++    return (DictionaryEntry*)HashtableEntry<klassOop>::next();
+   }
+ 
+   DictionaryEntry** next_addr() {
+-    return (DictionaryEntry**)HashtableEntry::next_addr();
++    return (DictionaryEntry**)HashtableEntry<klassOop>::next_addr();
+   }
+ 
+   oop loader() const { return _loader; }
+@@ -209,7 +209,7 @@
+     }
+   }
+ 
+-  bool equals(symbolOop class_name, oop class_loader) const {
++  bool equals(Symbol* class_name, oop class_loader) const {
+     klassOop klass = (klassOop)literal();
+     return (instanceKlass::cast(klass)->name() == class_name &&
+             _loader == class_loader);
+@@ -226,9 +226,9 @@
+   }
+ };
+ 
+-// Entry in a SymbolPropertyTable, mapping a single symbolOop
++// Entry in a SymbolPropertyTable, mapping a single Symbol*
+ // to a managed and an unmanaged pointer.
+-class SymbolPropertyEntry : public HashtableEntry {
++class SymbolPropertyEntry : public HashtableEntry<Symbol*> {
+   friend class VMStructs;
+  private:
+   intptr_t _symbol_mode;  // secondary key
+@@ -236,7 +236,7 @@
+   address _property_data;
+ 
+  public:
+-  symbolOop symbol() const          { return (symbolOop) literal(); }
++  Symbol* symbol() const            { return literal(); }
+ 
+   intptr_t symbol_mode() const      { return _symbol_mode; }
+   void set_symbol_mode(intptr_t m)  { _symbol_mode = m; }
+@@ -248,14 +248,13 @@
+   void set_property_data(address p) { _property_data = p; }
+ 
+   SymbolPropertyEntry* next() const {
+-    return (SymbolPropertyEntry*)HashtableEntry::next();
++    return (SymbolPropertyEntry*)HashtableEntry<Symbol*>::next();
+   }
+ 
+   SymbolPropertyEntry** next_addr() {
+-    return (SymbolPropertyEntry**)HashtableEntry::next_addr();
++    return (SymbolPropertyEntry**)HashtableEntry<Symbol*>::next_addr();
+   }
+ 
+-  oop* symbol_addr()                { return literal_addr(); }
+   oop* property_oop_addr()          { return &_property_oop; }
+ 
+   void print_on(outputStream* st) const {
+@@ -279,16 +278,16 @@
+ // A system-internal mapping of symbols to pointers, both managed
+ // and unmanaged.  Used to record the auto-generation of each method
+ // MethodHandle.invoke(S)T, for all signatures (S)T.
+-class SymbolPropertyTable : public Hashtable {
++class SymbolPropertyTable : public Hashtable<Symbol*> {
+   friend class VMStructs;
+ private:
+   SymbolPropertyEntry* bucket(int i) {
+-    return (SymbolPropertyEntry*) Hashtable::bucket(i);
++    return (SymbolPropertyEntry*) Hashtable<Symbol*>::bucket(i);
+   }
+ 
+   // The following method is not MT-safe and must be done under lock.
+   SymbolPropertyEntry** bucket_addr(int i) {
+-    return (SymbolPropertyEntry**) Hashtable::bucket_addr(i);
++    return (SymbolPropertyEntry**) Hashtable<Symbol*>::bucket_addr(i);
+   }
+ 
+   void add_entry(int index, SymbolPropertyEntry* new_entry) {
+@@ -298,8 +297,10 @@
+     ShouldNotReachHere();
+   }
+ 
+-  SymbolPropertyEntry* new_entry(unsigned int hash, symbolOop symbol, intptr_t symbol_mode) {
+-    SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable::new_entry(hash, symbol);
++  SymbolPropertyEntry* new_entry(unsigned int hash, Symbol* symbol, intptr_t symbol_mode) {
++    SymbolPropertyEntry* entry = (SymbolPropertyEntry*) Hashtable<Symbol*>::new_entry(hash, symbol);
++    // Hashtable with Symbol* literal must increment and decrement refcount.
++    symbol->increment_refcount();
+     entry->set_symbol_mode(symbol_mode);
+     entry->set_property_oop(NULL);
+     entry->set_property_data(NULL);
+@@ -311,23 +312,25 @@
+   SymbolPropertyTable(int table_size, HashtableBucket* t, int number_of_entries);
+ 
+   void free_entry(SymbolPropertyEntry* entry) {
+-    Hashtable::free_entry(entry);
++    // decrement Symbol refcount here because hashtable doesn't.
++    entry->literal()->decrement_refcount();
++    Hashtable<Symbol*>::free_entry(entry);
+   }
+ 
+-  unsigned int compute_hash(symbolHandle sym, intptr_t symbol_mode) {
++  unsigned int compute_hash(Symbol* sym, intptr_t symbol_mode) {
+     // Use the regular identity_hash.
+-    return Hashtable::compute_hash(sym) ^ symbol_mode;
++    return Hashtable<Symbol*>::compute_hash(sym) ^ symbol_mode;
+   }
+ 
+-  int index_for(symbolHandle name, intptr_t symbol_mode) {
++  int index_for(Symbol* name, intptr_t symbol_mode) {
+     return hash_to_index(compute_hash(name, symbol_mode));
+   }
+ 
+   // need not be locked; no state change
+-  SymbolPropertyEntry* find_entry(int index, unsigned int hash, symbolHandle name, intptr_t name_mode);
++  SymbolPropertyEntry* find_entry(int index, unsigned int hash, Symbol* name, intptr_t name_mode);
+ 
+   // must be done under SystemDictionary_lock
+-  SymbolPropertyEntry* add_entry(int index, unsigned int hash, symbolHandle name, intptr_t name_mode);
++  SymbolPropertyEntry* add_entry(int index, unsigned int hash, Symbol* name, intptr_t name_mode);
+ 
+   // GC support
+   void oops_do(OopClosure* f);
+@@ -343,6 +346,4 @@
+ #endif
+   void verify();
+ };
+-
+-
+ #endif // SHARE_VM_CLASSFILE_DICTIONARY_HPP
+diff --git a/src/share/vm/classfile/javaAssertions.cpp b/src/share/vm/classfile/javaAssertions.cpp
+--- openjdk/hotspot/src/share/vm/classfile/javaAssertions.cpp
++++ openjdk/hotspot/src/share/vm/classfile/javaAssertions.cpp
+@@ -93,7 +93,7 @@
+ }
+ 
+ oop JavaAssertions::createAssertionStatusDirectives(TRAPS) {
+-  symbolHandle asd_sym = vmSymbolHandles::java_lang_AssertionStatusDirectives();
++  Symbol* asd_sym = vmSymbols::java_lang_AssertionStatusDirectives();
+   klassOop k = SystemDictionary::resolve_or_fail(asd_sym, true, CHECK_NULL);
+   instanceKlassHandle asd_klass (THREAD, k);
+   asd_klass->initialize(CHECK_NULL);
+diff --git a/src/share/vm/classfile/javaClasses.cpp b/src/share/vm/classfile/javaClasses.cpp
+--- openjdk/hotspot/src/share/vm/classfile/javaClasses.cpp
++++ openjdk/hotspot/src/share/vm/classfile/javaClasses.cpp
+@@ -37,7 +37,7 @@
+ #include "oops/klass.hpp"
+ #include "oops/klassOop.hpp"
+ #include "oops/methodOop.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "oops/typeArrayOop.hpp"
+ #include "runtime/fieldDescriptor.hpp"
+ #include "runtime/handles.inline.hpp"
+@@ -58,7 +58,7 @@
+ #endif
+ 
+ static bool find_field(instanceKlass* ik,
+-                       symbolOop name_symbol, symbolOop signature_symbol,
++                       Symbol* name_symbol, Symbol* signature_symbol,
+                        fieldDescriptor* fd,
+                        bool allow_super = false) {
+   if (allow_super)
+@@ -70,7 +70,7 @@
+ // Helpful routine for computing field offsets at run time rather than hardcoding them
+ static void
+ compute_offset(int &dest_offset,
+-               klassOop klass_oop, symbolOop name_symbol, symbolOop signature_symbol,
++               klassOop klass_oop, Symbol* name_symbol, Symbol* signature_symbol,
+                bool allow_super = false) {
+   fieldDescriptor fd;
+   instanceKlass* ik = instanceKlass::cast(klass_oop);
+@@ -85,7 +85,7 @@
+ // Same as above but for "optional" offsets that might not be present in certain JDK versions
+ static void
+ compute_optional_offset(int& dest_offset,
+-                        klassOop klass_oop, symbolOop name_symbol, symbolOop signature_symbol,
++                        klassOop klass_oop, Symbol* name_symbol, Symbol* signature_symbol,
+                         bool allow_super = false) {
+   fieldDescriptor fd;
+   instanceKlass* ik = instanceKlass::cast(klass_oop);
+@@ -165,7 +165,7 @@
+   return h_obj();
+ }
+ 
+-Handle java_lang_String::create_from_symbol(symbolHandle symbol, TRAPS) {
++Handle java_lang_String::create_from_symbol(Symbol* symbol, TRAPS) {
+   int length = UTF8::unicode_length((char*)symbol->bytes(), symbol->utf8_length());
+   Handle h_obj = basic_create(length, false, CHECK_NH);
+   if (length > 0) {
+@@ -301,17 +301,17 @@
+   return StringTable::hash_string(value->char_at_addr(offset), length);
+ }
+ 
+-symbolHandle java_lang_String::as_symbol(Handle java_string, TRAPS) {
++Symbol* java_lang_String::as_symbol(Handle java_string, TRAPS) {
+   oop          obj    = java_string();
+   typeArrayOop value  = java_lang_String::value(obj);
+   int          offset = java_lang_String::offset(obj);
+   int          length = java_lang_String::length(obj);
+   jchar* base = (length == 0) ? NULL : value->char_at_addr(offset);
+-  symbolOop sym = SymbolTable::lookup_unicode(base, length, THREAD);
+-  return symbolHandle(THREAD, sym);
++  Symbol* sym = SymbolTable::lookup_unicode(base, length, THREAD);
++  return sym;
+ }
+ 
+-symbolOop java_lang_String::as_symbol_or_null(oop java_string) {
++Symbol* java_lang_String::as_symbol_or_null(oop java_string) {
+   typeArrayOop value  = java_lang_String::value(java_string);
+   int          offset = java_lang_String::offset(java_string);
+   int          length = java_lang_String::length(java_string);
+@@ -562,7 +562,7 @@
+ 
+ void java_lang_Class::print_signature(oop java_class, outputStream* st) {
+   assert(java_lang_Class::is_instance(java_class), "must be a Class object");
+-  symbolOop name = NULL;
++  Symbol* name = NULL;
+   bool is_instance = false;
+   if (is_primitive(java_class)) {
+     name = vmSymbols::type_signature(primitive_type(java_class));
+@@ -580,25 +580,32 @@
+   if (is_instance)  st->print(";");
+ }
+ 
+-symbolOop java_lang_Class::as_signature(oop java_class, bool intern_if_not_found, TRAPS) {
++Symbol* java_lang_Class::as_signature(oop java_class, bool intern_if_not_found, TRAPS) {
+   assert(java_lang_Class::is_instance(java_class), "must be a Class object");
+-  symbolOop name = NULL;
++  Symbol* name;
+   if (is_primitive(java_class)) {
+-    return vmSymbols::type_signature(primitive_type(java_class));
++    name = vmSymbols::type_signature(primitive_type(java_class));
++    // Because this can create a new symbol, the caller has to decrement
++    // the refcount, so make adjustment here and below for symbols returned
++    // that are not created or incremented due to a successful lookup.
++    name->increment_refcount();
+   } else {
+     klassOop k = as_klassOop(java_class);
+     if (!Klass::cast(k)->oop_is_instance()) {
+-      return Klass::cast(k)->name();
++      name = Klass::cast(k)->name();
++      name->increment_refcount();
+     } else {
+       ResourceMark rm;
+       const char* sigstr = Klass::cast(k)->signature_name();
+       int         siglen = (int) strlen(sigstr);
+-      if (!intern_if_not_found)
+-        return SymbolTable::probe(sigstr, siglen);
+-      else
+-        return oopFactory::new_symbol(sigstr, siglen, THREAD);
++      if (!intern_if_not_found) {
++        name = SymbolTable::probe(sigstr, siglen);
++      } else {
++        name = SymbolTable::new_symbol(sigstr, siglen, THREAD);
++      }
+     }
+   }
++  return name;
+ }
+ 
+ 
+@@ -1147,8 +1154,8 @@
+       JavaCalls::call_virtual(&result,
+                               stream,
+                               KlassHandle(THREAD, stream->klass()),
+-                              vmSymbolHandles::println_name(),
+-                              vmSymbolHandles::char_array_void_signature(),
++                              vmSymbols::println_name(),
++                              vmSymbols::char_array_void_signature(),
+                               arg,
+                               THREAD);
+     }
+@@ -1202,8 +1209,8 @@
+       JavaCalls::call_virtual(&result,
+                               h_throwable,
+                               KlassHandle(THREAD, h_throwable->klass()),
+-                              vmSymbolHandles::getCause_name(),
+-                              vmSymbolHandles::void_throwable_signature(),
++                              vmSymbols::getCause_name(),
++                              vmSymbols::void_throwable_signature(),
+                               THREAD);
+       // Ignore any exceptions. we are in the middle of exception handling. Same as classic VM.
+       if (HAS_PENDING_EXCEPTION) {
+@@ -1641,7 +1648,7 @@
+   oop methodname = StringTable::intern(method->name(), CHECK_0);
+   java_lang_StackTraceElement::set_methodName(element(), methodname);
+   // Fill in source file name
+-  symbolOop source = instanceKlass::cast(method->method_holder())->source_file_name();
++  Symbol* source = instanceKlass::cast(method->method_holder())->source_file_name();
+   oop filename = StringTable::intern(source, CHECK_0);
+   java_lang_StackTraceElement::set_fileName(element(), filename);
+   // File in source line number
+@@ -1857,7 +1864,7 @@
+ 
+ Handle java_lang_reflect_Constructor::create(TRAPS) {
+   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
+-  symbolHandle name = vmSymbolHandles::java_lang_reflect_Constructor();
++  Symbol* name = vmSymbols::java_lang_reflect_Constructor();
+   klassOop k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
+   instanceKlassHandle klass (THREAD, k);
+   // Ensure it is initialized
+@@ -1979,7 +1986,7 @@
+ 
+ Handle java_lang_reflect_Field::create(TRAPS) {
+   assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem");
+-  symbolHandle name = vmSymbolHandles::java_lang_reflect_Field();
++  Symbol* name = vmSymbols::java_lang_reflect_Field();
+   klassOop k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
+   instanceKlassHandle klass (THREAD, k);
+   // Ensure it is initialized
+@@ -2545,16 +2552,19 @@
+   java_lang_Class::print_signature(rtype(mt), st);
+ }
+ 
+-symbolOop java_dyn_MethodType::as_signature(oop mt, bool intern_if_not_found, TRAPS) {
++Symbol* java_dyn_MethodType::as_signature(oop mt, bool intern_if_not_found, TRAPS) {
+   ResourceMark rm;
+   stringStream buffer(128);
+   print_signature(mt, &buffer);
+   const char* sigstr =       buffer.base();
+   int         siglen = (int) buffer.size();
+-  if (!intern_if_not_found)
+-    return SymbolTable::probe(sigstr, siglen);
+-  else
+-    return oopFactory::new_symbol(sigstr, siglen, THREAD);
++  Symbol *name;
++  if (!intern_if_not_found) {
++    name = SymbolTable::probe(sigstr, siglen);
++  } else {
++    name = SymbolTable::new_symbol(sigstr, siglen, THREAD);
++  }
++  return name;
+ }
+ 
+ oop java_dyn_MethodType::rtype(oop mt) {
+@@ -3057,13 +3067,12 @@
+ bool JavaClasses::check_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) {
+   EXCEPTION_MARK;
+   fieldDescriptor fd;
+-  symbolHandle klass_sym = oopFactory::new_symbol_handle(klass_name, CATCH);
++  TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH);
+   klassOop k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH);
+   instanceKlassHandle h_klass (THREAD, k);
+-  //instanceKlassHandle h_klass(klass);
+-  symbolHandle f_name = oopFactory::new_symbol_handle(field_name, CATCH);
+-  symbolHandle f_sig  = oopFactory::new_symbol_handle(field_sig, CATCH);
+-  if (!h_klass->find_local_field(f_name(), f_sig(), &fd)) {
++  TempNewSymbol f_name = SymbolTable::new_symbol(field_name, CATCH);
++  TempNewSymbol f_sig  = SymbolTable::new_symbol(field_sig, CATCH);
++  if (!h_klass->find_local_field(f_name, f_sig, &fd)) {
+     tty->print_cr("Nonstatic field %s.%s not found", klass_name, field_name);
+     return false;
+   }
+@@ -3084,12 +3093,12 @@
+ bool JavaClasses::check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) {
+   EXCEPTION_MARK;
+   fieldDescriptor fd;
+-  symbolHandle klass_sym = oopFactory::new_symbol_handle(klass_name, CATCH);
++  TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH);
+   klassOop k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH);
+   instanceKlassHandle h_klass (THREAD, k);
+-  symbolHandle f_name = oopFactory::new_symbol_handle(field_name, CATCH);
+-  symbolHandle f_sig  = oopFactory::new_symbol_handle(field_sig, CATCH);
+-  if (!h_klass->find_local_field(f_name(), f_sig(), &fd)) {
++  TempNewSymbol f_name = SymbolTable::new_symbol(field_name, CATCH);
++  TempNewSymbol f_sig  = SymbolTable::new_symbol(field_sig, CATCH);
++  if (!h_klass->find_local_field(f_name, f_sig, &fd)) {
+     tty->print_cr("Static field %s.%s not found", klass_name, field_name);
+     return false;
+   }
+@@ -3109,12 +3118,12 @@
+ bool JavaClasses::check_constant(const char *klass_name, int hardcoded_constant, const char *field_name, const char* field_sig) {
+   EXCEPTION_MARK;
+   fieldDescriptor fd;
+-  symbolHandle klass_sym = oopFactory::new_symbol_handle(klass_name, CATCH);
++  TempNewSymbol klass_sym = SymbolTable::new_symbol(klass_name, CATCH);
+   klassOop k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH);
+   instanceKlassHandle h_klass (THREAD, k);
+-  symbolHandle f_name = oopFactory::new_symbol_handle(field_name, CATCH);
+-  symbolHandle f_sig  = oopFactory::new_symbol_handle(field_sig, CATCH);
+-  if (!h_klass->find_local_field(f_name(), f_sig(), &fd)) {
++  TempNewSymbol f_name = SymbolTable::new_symbol(field_name, CATCH);
++  TempNewSymbol f_sig  = SymbolTable::new_symbol(field_sig, CATCH);
++  if (!h_klass->find_local_field(f_name, f_sig, &fd)) {
+     tty->print_cr("Static field %s.%s not found", klass_name, field_name);
+     return false;
+   }
+diff --git a/src/share/vm/classfile/javaClasses.hpp b/src/share/vm/classfile/javaClasses.hpp
+--- openjdk/hotspot/src/share/vm/classfile/javaClasses.hpp
++++ openjdk/hotspot/src/share/vm/classfile/javaClasses.hpp
+@@ -78,7 +78,7 @@
+   static oop    create_oop_from_unicode(jchar* unicode, int len, TRAPS);
+   static Handle create_from_str(const char* utf8_str, TRAPS);
+   static oop    create_oop_from_str(const char* utf8_str, TRAPS);
+-  static Handle create_from_symbol(symbolHandle symbol, TRAPS);
++  static Handle create_from_symbol(Symbol* symbol, TRAPS);
+   static Handle create_from_platform_dependent_str(const char* str, TRAPS);
+   static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS);
+ 
+@@ -140,8 +140,8 @@
+   static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); }
+ 
+   // Conversion
+-  static symbolHandle as_symbol(Handle java_string, TRAPS);
+-  static symbolOop as_symbol_or_null(oop java_string);
++  static Symbol* as_symbol(Handle java_string, TRAPS);
++  static Symbol* as_symbol_or_null(oop java_string);
+ 
+   // Testers
+   static bool is_instance(oop obj) {
+@@ -193,7 +193,7 @@
+     (*reference_klass) = KlassHandle(refk_oop);
+     return result;
+   }
+-  static symbolOop as_signature(oop java_class, bool intern_if_not_found, TRAPS);
++  static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS);
+   static void print_signature(oop java_class, outputStream *st);
+   // Testing
+   static bool is_instance(oop obj) {
+@@ -1071,7 +1071,7 @@
+   static oop            ptype(oop mt, int index);
+   static int            ptype_count(oop mt);
+ 
+-  static symbolOop      as_signature(oop mt, bool intern_if_not_found, TRAPS);
++  static Symbol*        as_signature(oop mt, bool intern_if_not_found, TRAPS);
+   static void           print_signature(oop mt, outputStream* st);
+ 
+   static bool is_instance(oop obj) {
+diff --git a/src/share/vm/classfile/loaderConstraints.cpp b/src/share/vm/classfile/loaderConstraints.cpp
+--- openjdk/hotspot/src/share/vm/classfile/loaderConstraints.cpp
++++ openjdk/hotspot/src/share/vm/classfile/loaderConstraints.cpp
+@@ -31,28 +31,33 @@
+ #include "utilities/hashtable.inline.hpp"
+ 
+ LoaderConstraintTable::LoaderConstraintTable(int nof_buckets)
+-  : Hashtable(nof_buckets, sizeof(LoaderConstraintEntry)) {};
++  : Hashtable<klassOop>(nof_buckets, sizeof(LoaderConstraintEntry)) {};
+ 
+ 
+ LoaderConstraintEntry* LoaderConstraintTable::new_entry(
+-                                 unsigned int hash, symbolOop name,
++                                 unsigned int hash, Symbol* name,
+                                  klassOop klass, int num_loaders,
+                                  int max_loaders) {
+   LoaderConstraintEntry* entry;
+-  entry = (LoaderConstraintEntry*)Hashtable::new_entry(hash, klass);
++  entry = (LoaderConstraintEntry*)Hashtable<klassOop>::new_entry(hash, klass);
+   entry->set_name(name);
+   entry->set_num_loaders(num_loaders);
+   entry->set_max_loaders(max_loaders);
+   return entry;
+ }
+ 
++void LoaderConstraintTable::free_entry(LoaderConstraintEntry *entry) {
++  // decrement name refcount before freeing
++  entry->name()->decrement_refcount();
++  Hashtable<klassOop>::free_entry(entry);
++}
++
+ 
+ void LoaderConstraintTable::oops_do(OopClosure* f) {
+   for (int index = 0; index < table_size(); index++) {
+     for (LoaderConstraintEntry* probe = bucket(index);
+                                 probe != NULL;
+                                 probe = probe->next()) {
+-      f->do_oop((oop*)(probe->name_addr()));
+       if (probe->klass() != NULL) {
+         f->do_oop((oop*)probe->klass_addr());
+       }
+@@ -65,27 +70,13 @@
+   }
+ }
+ 
+-// We must keep the symbolOop used in the name alive.  We'll use the
+-// loaders to decide if a particular entry can be purged.
+-void LoaderConstraintTable::always_strong_classes_do(OopClosure* blk) {
+-  // We must keep the symbolOop used in the name alive.
+-  for (int cindex = 0; cindex < table_size(); cindex++) {
+-    for (LoaderConstraintEntry* lc_probe = bucket(cindex);
+-                                lc_probe != NULL;
+-                                lc_probe = lc_probe->next()) {
+-      assert (lc_probe->name() != NULL,  "corrupted loader constraint table");
+-      blk->do_oop((oop*)lc_probe->name_addr());
+-    }
+-  }
+-}
+-
+ 
+ // The loaderConstraintTable must always be accessed with the
+ // SystemDictionary lock held. This is true even for readers as
+ // entries in the table could be being dynamically resized.
+ 
+ LoaderConstraintEntry** LoaderConstraintTable::find_loader_constraint(
+-                                    symbolHandle name, Handle loader) {
++                                    Symbol* name, Handle loader) {
+ 
+   unsigned int hash = compute_hash(name);
+   int index = hash_to_index(hash);
+@@ -93,7 +84,7 @@
+   while (*pp) {
+     LoaderConstraintEntry* p = *pp;
+     if (p->hash() == hash) {
+-      if (p->name() == name()) {
++      if (p->name() == name) {
+         for (int i = p->num_loaders() - 1; i >= 0; i--) {
+           if (p->loader(i) == loader()) {
+             return pp;
+@@ -177,7 +168,6 @@
+         free_entry(probe);
+       } else {
+ #ifdef ASSERT
+-        assert(is_alive->do_object_b(probe->name()), "name should be live");
+         if (probe->klass() != NULL) {
+           assert(is_alive->do_object_b(probe->klass()), "klass should be live");
+         }
+@@ -194,7 +184,7 @@
+   }
+ }
+ 
+-bool LoaderConstraintTable::add_entry(symbolHandle class_name,
++bool LoaderConstraintTable::add_entry(Symbol* class_name,
+                                       klassOop klass1, Handle class_loader1,
+                                       klassOop klass2, Handle class_loader2) {
+   int failure_code = 0; // encode different reasons for failing
+@@ -233,7 +223,7 @@
+         unsigned int hash = compute_hash(class_name);
+         int index = hash_to_index(hash);
+         LoaderConstraintEntry* p;
+-        p = new_entry(hash, class_name(), klass, 2, 2);
++        p = new_entry(hash, class_name, klass, 2, 2);
+         p->set_loaders(NEW_C_HEAP_ARRAY(oop, 2));
+         p->set_loader(0, class_loader1());
+         p->set_loader(1, class_loader2());
+@@ -244,7 +234,7 @@
+           ResourceMark rm;
+           tty->print("[Adding new constraint for name: %s, loader[0]: %s,"
+                      " loader[1]: %s ]\n",
+-                     class_name()->as_C_string(),
++                     class_name->as_C_string(),
+                      SystemDictionary::loader_name(class_loader1()),
+                      SystemDictionary::loader_name(class_loader2())
+                      );
+@@ -257,7 +247,7 @@
+             ResourceMark rm;
+             tty->print("[Setting class object in existing constraint for"
+                        " name: %s and loader %s ]\n",
+-                       class_name()->as_C_string(),
++                       class_name->as_C_string(),
+                        SystemDictionary::loader_name(class_loader1())
+                        );
+           }
+@@ -288,7 +278,7 @@
+     }
+     tty->print("[Failed to add constraint for name: %s, loader[0]: %s,"
+                " loader[1]: %s, Reason: %s ]\n",
+-               class_name()->as_C_string(),
++               class_name->as_C_string(),
+                SystemDictionary::loader_name(class_loader1()),
+                SystemDictionary::loader_name(class_loader2()),
+                reason
+@@ -303,14 +293,14 @@
+ // violated
+ bool LoaderConstraintTable::check_or_update(instanceKlassHandle k,
+                                                    Handle loader,
+-                                                   symbolHandle name) {
++                                                   Symbol* name) {
+   LoaderConstraintEntry* p = *(find_loader_constraint(name, loader));
+   if (p && p->klass() != NULL && p->klass() != k()) {
+     if (TraceLoaderConstraints) {
+       ResourceMark rm;
+       tty->print("[Constraint check failed for name %s, loader %s: "
+                  "the presented class object differs from that stored ]\n",
+-                 name()->as_C_string(),
++                 name->as_C_string(),
+                  SystemDictionary::loader_name(loader()));
+     }
+     return false;
+@@ -321,7 +311,7 @@
+         ResourceMark rm;
+         tty->print("[Updating constraint for name %s, loader %s, "
+                    "by setting class object ]\n",
+-                   name()->as_C_string(),
++                   name->as_C_string(),
+                    SystemDictionary::loader_name(loader()));
+       }
+     }
+@@ -329,7 +319,7 @@
+   }
+ }
+ 
+-klassOop LoaderConstraintTable::find_constrained_klass(symbolHandle name,
++klassOop LoaderConstraintTable::find_constrained_klass(Symbol* name,
+                                                        Handle loader) {
+   LoaderConstraintEntry *p = *(find_loader_constraint(name, loader));
+   if (p != NULL && p->klass() != NULL)
+@@ -442,11 +432,10 @@
+     for (LoaderConstraintEntry* probe = bucket(cindex);
+                                 probe != NULL;
+                                 probe = probe->next()) {
+-      guarantee(probe->name()->is_symbol(), "should be symbol");
+       if (probe->klass() != NULL) {
+         instanceKlass* ik = instanceKlass::cast(probe->klass());
+         guarantee(ik->name() == probe->name(), "name should match");
+-        symbolHandle name (thread, ik->name());
++        Symbol* name = ik->name();
+         Handle loader(thread, ik->class_loader());
+         unsigned int d_hash = dictionary->compute_hash(name, loader);
+         int d_index = dictionary->hash_to_index(d_hash);
+diff --git a/src/share/vm/classfile/loaderConstraints.hpp b/src/share/vm/classfile/loaderConstraints.hpp
+--- openjdk/hotspot/src/share/vm/classfile/loaderConstraints.hpp
++++ openjdk/hotspot/src/share/vm/classfile/loaderConstraints.hpp
+@@ -31,7 +31,7 @@
+ 
+ class LoaderConstraintEntry;
+ 
+-class LoaderConstraintTable : public Hashtable {
++class LoaderConstraintTable : public Hashtable<klassOop> {
+   friend class VMStructs;
+ private:
+ 
+@@ -40,39 +40,39 @@
+     _nof_buckets            = 1009                     // number of buckets in hash table
+   };
+ 
+-  LoaderConstraintEntry** find_loader_constraint(symbolHandle name,
++  LoaderConstraintEntry** find_loader_constraint(Symbol* name,
+                                                  Handle loader);
+ 
+ public:
+ 
+   LoaderConstraintTable(int nof_buckets);
+ 
+-  LoaderConstraintEntry* new_entry(unsigned int hash, symbolOop name,
++  LoaderConstraintEntry* new_entry(unsigned int hash, Symbol* name,
+                                    klassOop klass, int num_loaders,
+                                    int max_loaders);
++  void free_entry(LoaderConstraintEntry *entry);
+ 
+   LoaderConstraintEntry* bucket(int i) {
+-    return (LoaderConstraintEntry*)Hashtable::bucket(i);
++    return (LoaderConstraintEntry*)Hashtable<klassOop>::bucket(i);
+   }
+ 
+   LoaderConstraintEntry** bucket_addr(int i) {
+-    return (LoaderConstraintEntry**)Hashtable::bucket_addr(i);
++    return (LoaderConstraintEntry**)Hashtable<klassOop>::bucket_addr(i);
+   }
+ 
+   // GC support
+   void oops_do(OopClosure* f);
+-  void always_strong_classes_do(OopClosure* blk);
+ 
+   // Check class loader constraints
+-  bool add_entry(symbolHandle name, klassOop klass1, Handle loader1,
++  bool add_entry(Symbol* name, klassOop klass1, Handle loader1,
+                                     klassOop klass2, Handle loader2);
+ 
+   // Note:  The main entry point for this module is via SystemDictionary.
+-  // SystemDictionary::check_signature_loaders(symbolHandle signature,
++  // SystemDictionary::check_signature_loaders(Symbol* signature,
+   //                                           Handle loader1, Handle loader2,
+   //                                           bool is_method, TRAPS)
+ 
+-  klassOop find_constrained_klass(symbolHandle name, Handle loader);
++  klassOop find_constrained_klass(Symbol* name, Handle loader);
+ 
+   // Class loader constraints
+ 
+@@ -83,7 +83,7 @@
+                                 LoaderConstraintEntry** pp2, klassOop klass);
+ 
+   bool check_or_update(instanceKlassHandle k, Handle loader,
+-                              symbolHandle name);
++                              Symbol* name);
+ 
+ 
+   void purge_loader_constraints(BoolObjectClosure* is_alive);
+@@ -94,34 +94,36 @@
+ #endif
+ };
+ 
+-class LoaderConstraintEntry : public HashtableEntry {
++class LoaderConstraintEntry : public HashtableEntry<klassOop> {
+   friend class VMStructs;
+ private:
+-  symbolOop              _name;                   // class name
++  Symbol*                _name;                   // class name
+   int                    _num_loaders;
+   int                    _max_loaders;
+   oop*                   _loaders;                // initiating loaders
+ 
+ public:
+ 
+-  klassOop klass() { return (klassOop)literal(); }
+-  klassOop* klass_addr() { return (klassOop*)literal_addr(); }
++  klassOop klass() { return literal(); }
++  klassOop* klass_addr() { return literal_addr(); }
+   void set_klass(klassOop k) { set_literal(k); }
+ 
+   LoaderConstraintEntry* next() {
+-    return (LoaderConstraintEntry*)HashtableEntry::next();
++    return (LoaderConstraintEntry*)HashtableEntry<klassOop>::next();
+   }
+ 
+   LoaderConstraintEntry** next_addr() {
+-    return (LoaderConstraintEntry**)HashtableEntry::next_addr();
++    return (LoaderConstraintEntry**)HashtableEntry<klassOop>::next_addr();
+   }
+   void set_next(LoaderConstraintEntry* next) {
+-    HashtableEntry::set_next(next);
++    HashtableEntry<klassOop>::set_next(next);
+   }
+ 
+-  symbolOop name() { return _name; }
+-  symbolOop* name_addr() { return &_name; }
+-  void set_name(symbolOop name) { _name = name; }
++  Symbol* name() { return _name; }
++  void set_name(Symbol* name) {
++    _name = name;
++    if (name != NULL) name->increment_refcount();
++  }
+ 
+   int num_loaders() { return _num_loaders; }
+   void set_num_loaders(int i) { _num_loaders = i; }
+diff --git a/src/share/vm/classfile/placeholders.cpp b/src/share/vm/classfile/placeholders.cpp
+--- openjdk/hotspot/src/share/vm/classfile/placeholders.cpp
++++ openjdk/hotspot/src/share/vm/classfile/placeholders.cpp
+@@ -31,10 +31,12 @@
+ 
+ // Placeholder methods
+ 
+-PlaceholderEntry* PlaceholderTable::new_entry(int hash, symbolOop name,
++PlaceholderEntry* PlaceholderTable::new_entry(int hash, Symbol* name,
+                                               oop loader, bool havesupername,
+-                                              symbolOop supername) {
+-  PlaceholderEntry* entry = (PlaceholderEntry*)Hashtable::new_entry(hash, name);
++                                              Symbol* supername) {
++  PlaceholderEntry* entry = (PlaceholderEntry*)Hashtable<Symbol*>::new_entry(hash, name);
++  // Hashtable with Symbol* literal must increment and decrement refcount.
++  name->increment_refcount();
+   entry->set_loader(loader);
+   entry->set_havesupername(havesupername);
+   entry->set_supername(supername);
+@@ -46,33 +48,40 @@
+   return entry;
+ }
+ 
++void PlaceholderTable::free_entry(PlaceholderEntry* entry) {
++  // decrement Symbol refcount here because Hashtable doesn't.
++  entry->literal()->decrement_refcount();
++  if (entry->supername() != NULL) entry->supername()->decrement_refcount();
++  Hashtable<Symbol*>::free_entry(entry);
++}
++
+ 
+ // Placeholder objects represent classes currently being loaded.
+ // All threads examining the placeholder table must hold the
+ // SystemDictionary_lock, so we don't need special precautions
+ // on store ordering here.
+ void PlaceholderTable::add_entry(int index, unsigned int hash,
+-                                 symbolHandle class_name, Handle class_loader,
+-                                 bool havesupername, symbolHandle supername){
++                                 Symbol* class_name, Handle class_loader,
++                                 bool havesupername, Symbol* supername){
+   assert_locked_or_safepoint(SystemDictionary_lock);
+-  assert(!class_name.is_null(), "adding NULL obj");
++  assert(class_name != NULL, "adding NULL obj");
+ 
+   // Both readers and writers are locked so it's safe to just
+   // create the placeholder and insert it in the list without a membar.
+-  PlaceholderEntry* entry = new_entry(hash, class_name(), class_loader(), havesupername, supername());
++  PlaceholderEntry* entry = new_entry(hash, class_name, class_loader(), havesupername, supername);
+   add_entry(index, entry);
+ }
+ 
+ 
+ // Remove a placeholder object.
+ void PlaceholderTable::remove_entry(int index, unsigned int hash,
+-                                    symbolHandle class_name,
++                                    Symbol* class_name,
+                                     Handle class_loader) {
+   assert_locked_or_safepoint(SystemDictionary_lock);
+   PlaceholderEntry** p = bucket_addr(index);
+   while (*p) {
+     PlaceholderEntry *probe = *p;
+-    if (probe->hash() == hash && probe->equals(class_name(), class_loader())) {
++    if (probe->hash() == hash && probe->equals(class_name, class_loader())) {
+       // Delete entry
+       *p = probe->next();
+       free_entry(probe);
+@@ -83,29 +92,28 @@
+ }
+ 
+ PlaceholderEntry* PlaceholderTable::get_entry(int index, unsigned int hash,
+-                                       symbolHandle class_name,
++                                       Symbol* class_name,
+                                        Handle class_loader) {
+   assert_locked_or_safepoint(SystemDictionary_lock);
+ 
+-  symbolOop class_name_ = class_name();
+   oop class_loader_ = class_loader();
+ 
+   for (PlaceholderEntry *place_probe = bucket(index);
+                          place_probe != NULL;
+                          place_probe = place_probe->next()) {
+     if (place_probe->hash() == hash &&
+-        place_probe->equals(class_name_, class_loader_)) {
++        place_probe->equals(class_name, class_loader_)) {
+       return place_probe;
+     }
+   }
+   return NULL;
+ }
+ 
+-symbolOop PlaceholderTable::find_entry(int index, unsigned int hash,
+-                                       symbolHandle class_name,
++Symbol* PlaceholderTable::find_entry(int index, unsigned int hash,
++                                       Symbol* class_name,
+                                        Handle class_loader) {
+   PlaceholderEntry* probe = get_entry(index, hash, class_name, class_loader);
+-  return (probe? probe->klass(): symbolOop(NULL));
++  return (probe? probe->klassname(): (Symbol*)NULL);
+ }
+ 
+   // find_and_add returns probe pointer - old or new
+@@ -113,7 +121,7 @@
+   // If entry exists, reuse entry
+   // For both, push SeenThread for classloadAction
+   // if havesupername: this is used for circularity for instanceklass loading
+-PlaceholderEntry* PlaceholderTable::find_and_add(int index, unsigned int hash, symbolHandle name, Handle loader, classloadAction action, symbolHandle supername, Thread* thread) {
++PlaceholderEntry* PlaceholderTable::find_and_add(int index, unsigned int hash, Symbol* name, Handle loader, classloadAction action, Symbol* supername, Thread* thread) {
+   PlaceholderEntry* probe = get_entry(index, hash, name, loader);
+   if (probe == NULL) {
+     // Nothing found, add place holder
+@@ -122,7 +130,7 @@
+   } else {
+     if (action == LOAD_SUPER) {
+       probe->set_havesupername(true);
+-      probe->set_supername(supername());
++      probe->set_supername(supername);
+     }
+   }
+   if (probe) probe->add_seen_thread(thread, action);
+@@ -145,7 +153,7 @@
+ // Therefore - must always check SD first
+ // Ignores the case where entry is not found
+ void PlaceholderTable::find_and_remove(int index, unsigned int hash,
+-                       symbolHandle name, Handle loader, Thread* thread) {
++                       Symbol* name, Handle loader, Thread* thread) {
+     assert_locked_or_safepoint(SystemDictionary_lock);
+     PlaceholderEntry *probe = get_entry(index, hash, name, loader);
+     if (probe != NULL) {
+@@ -158,7 +166,7 @@
+   }
+ 
+ PlaceholderTable::PlaceholderTable(int table_size)
+-    : TwoOopHashtable(table_size, sizeof(PlaceholderEntry)) {
++    : TwoOopHashtable<Symbol*>(table_size, sizeof(PlaceholderEntry)) {
+ }
+ 
+ 
+@@ -174,26 +182,22 @@
+ 
+ 
+ void PlaceholderEntry::oops_do(OopClosure* blk) {
+-  assert(klass() != NULL, "should have a non-null klass");
+-  blk->do_oop((oop*)klass_addr());
++  assert(klassname() != NULL, "should have a non-null klass");
+   if (_loader != NULL) {
+     blk->do_oop(loader_addr());
+   }
+-  if (_supername != NULL) {
+-    blk->do_oop((oop*)supername_addr());
+-  }
+   if (_instanceKlass != NULL) {
+     blk->do_oop((oop*)instanceKlass_addr());
+   }
+ }
+ 
+ // do all entries in the placeholder table
+-void PlaceholderTable::entries_do(void f(symbolOop, oop)) {
++void PlaceholderTable::entries_do(void f(Symbol*, oop)) {
+   for (int index = 0; index < table_size(); index++) {
+     for (PlaceholderEntry* probe = bucket(index);
+                            probe != NULL;
+                            probe = probe->next()) {
+-      f(probe->klass(), probe->loader());
++      f(probe->klassname(), probe->loader());
+     }
+   }
+ }
+@@ -202,7 +206,7 @@
+ #ifndef PRODUCT
+ // Note, doesn't append a cr
+ void PlaceholderEntry::print() const {
+-  klass()->print_value();
++  klassname()->print_value();
+   if (loader() != NULL) {
+     tty->print(", loader ");
+     loader()->print_value();
+@@ -238,7 +242,6 @@
+   guarantee(instanceKlass() == NULL
+             || Klass::cast(instanceKlass())->oop_is_instance(),
+             "checking type of instanceKlass result");
+-  klass()->verify();
+ }
+ 
+ void PlaceholderTable::verify() {
+diff --git a/src/share/vm/classfile/placeholders.hpp b/src/share/vm/classfile/placeholders.hpp
+--- openjdk/hotspot/src/share/vm/classfile/placeholders.hpp
++++ openjdk/hotspot/src/share/vm/classfile/placeholders.hpp
+@@ -34,35 +34,36 @@
+ // being loaded, as well as arrays of primitives.
+ //
+ 
+-class PlaceholderTable : public TwoOopHashtable {
++class PlaceholderTable : public TwoOopHashtable<Symbol*> {
+   friend class VMStructs;
+ 
+ public:
+   PlaceholderTable(int table_size);
+ 
+-  PlaceholderEntry* new_entry(int hash, symbolOop name, oop loader, bool havesupername, symbolOop supername);
++  PlaceholderEntry* new_entry(int hash, Symbol* name, oop loader, bool havesupername, Symbol* supername);
++  void free_entry(PlaceholderEntry* entry);
+ 
+   PlaceholderEntry* bucket(int i) {
+-    return (PlaceholderEntry*)Hashtable::bucket(i);
++    return (PlaceholderEntry*)Hashtable<Symbol*>::bucket(i);
+   }
+ 
+   PlaceholderEntry** bucket_addr(int i) {
+-    return (PlaceholderEntry**)Hashtable::bucket_addr(i);
++    return (PlaceholderEntry**)Hashtable<Symbol*>::bucket_addr(i);
+   }
+ 
+   void add_entry(int index, PlaceholderEntry* new_entry) {
+-    Hashtable::add_entry(index, (HashtableEntry*)new_entry);
++    Hashtable<Symbol*>::add_entry(index, (HashtableEntry<Symbol*>*)new_entry);
+   }
+ 
+-  void add_entry(int index, unsigned int hash, symbolHandle name,
+-                Handle loader, bool havesupername, symbolHandle supername);
++  void add_entry(int index, unsigned int hash, Symbol* name,
++                Handle loader, bool havesupername, Symbol* supername);
+ 
+-// This returns a symbolOop to match type for SystemDictionary
+-  symbolOop find_entry(int index, unsigned int hash,
+-                       symbolHandle name, Handle loader);
++  // This returns a Symbol* to match type for SystemDictionary
++  Symbol* find_entry(int index, unsigned int hash,
++                       Symbol* name, Handle loader);
+ 
+   PlaceholderEntry* get_entry(int index, unsigned int hash,
+-                       symbolHandle name, Handle loader);
++                       Symbol* name, Handle loader);
+ 
+ // caller to create a placeholder entry must enumerate an action
+ // caller claims ownership of that action
+@@ -84,22 +85,22 @@
+   // If no entry exists, add a placeholder entry and push SeenThread
+   // If entry exists, reuse entry and push SeenThread for classloadAction
+   PlaceholderEntry* find_and_add(int index, unsigned int hash,
+-                                 symbolHandle name, Handle loader,
+-                                 classloadAction action, symbolHandle supername,
++                                 Symbol* name, Handle loader,
++                                 classloadAction action, Symbol* supername,
+                                  Thread* thread);
+ 
+   void remove_entry(int index, unsigned int hash,
+-                    symbolHandle name, Handle loader);
++                    Symbol* name, Handle loader);
+ 
+ // Remove placeholder information
+   void find_and_remove(int index, unsigned int hash,
+-                       symbolHandle name, Handle loader, Thread* thread);
++                       Symbol* name, Handle loader, Thread* thread);
+ 
+   // GC support.
+   void oops_do(OopClosure* f);
+ 
+   // JVMTI support
+-  void entries_do(void f(symbolOop, oop));
++  void entries_do(void f(Symbol*, oop));
+ 
+ #ifndef PRODUCT
+   void print();
+@@ -151,14 +152,14 @@
+ // on store ordering here.
+ // The system dictionary is the only user of this class.
+ 
+-class PlaceholderEntry : public HashtableEntry {
++class PlaceholderEntry : public HashtableEntry<Symbol*> {
+   friend class VMStructs;
+ 
+ 
+  private:
+   oop               _loader;        // initiating loader
+   bool              _havesupername; // distinguish between null supername, and unknown
+-  symbolOop         _supername;
++  Symbol*           _supername;
+   Thread*           _definer;       // owner of define token
+   klassOop          _instanceKlass; // instanceKlass from successful define
+   SeenThread*       _superThreadQ;  // doubly-linked queue of Threads loading a superclass for this class
+@@ -173,8 +174,7 @@
+ 
+  public:
+   // Simple accessors, used only by SystemDictionary
+-  symbolOop          klass()               const { return (symbolOop)literal(); }
+-  symbolOop*         klass_addr()          { return (symbolOop*)literal_addr(); }
++  Symbol*            klassname()           const { return literal(); }
+ 
+   oop                loader()              const { return _loader; }
+   void               set_loader(oop loader) { _loader = loader; }
+@@ -183,9 +183,11 @@
+   bool               havesupername()       const { return _havesupername; }
+   void               set_havesupername(bool havesupername) { _havesupername = havesupername; }
+ 
+-  symbolOop          supername()           const { return _supername; }
+-  void               set_supername(symbolOop supername) { _supername = supername; }
+-  symbolOop*         supername_addr()      { return &_supername; }
++  Symbol*            supername()           const { return _supername; }
++  void               set_supername(Symbol* supername) {
++    _supername = supername;
++    if (_supername != NULL) _supername->increment_refcount();
++  }
+ 
+   Thread*            definer()             const {return _definer; }
+   void               set_definer(Thread* definer) { _definer = definer; }
+@@ -204,17 +206,17 @@
+   void               set_defineThreadQ(SeenThread* SeenThread) { _defineThreadQ = SeenThread; }
+ 
+   PlaceholderEntry* next() const {
+-    return (PlaceholderEntry*)HashtableEntry::next();
++    return (PlaceholderEntry*)HashtableEntry<Symbol*>::next();
+   }
+ 
+   PlaceholderEntry** next_addr() {
+-    return (PlaceholderEntry**)HashtableEntry::next_addr();
++    return (PlaceholderEntry**)HashtableEntry<Symbol*>::next_addr();
+   }
+ 
+   // Test for equality
+   // Entries are unique for class/classloader name pair
+-  bool equals(symbolOop class_name, oop class_loader) const {
+-    return (klass() == class_name && loader() == class_loader);
++  bool equals(Symbol* class_name, oop class_loader) const {
++    return (klassname() == class_name && loader() == class_loader);
+   }
+ 
+   SeenThread* actionToQueue(PlaceholderTable::classloadAction action) {
+diff --git a/src/share/vm/classfile/resolutionErrors.cpp b/src/share/vm/classfile/resolutionErrors.cpp
+--- openjdk/hotspot/src/share/vm/classfile/resolutionErrors.cpp
++++ openjdk/hotspot/src/share/vm/classfile/resolutionErrors.cpp
+@@ -32,12 +32,12 @@
+ 
+ // add new entry to the table
+ void ResolutionErrorTable::add_entry(int index, unsigned int hash,
+-                                     constantPoolHandle pool, int cp_index, symbolHandle error)
++                                     constantPoolHandle pool, int cp_index, Symbol* error)
+ {
+   assert_locked_or_safepoint(SystemDictionary_lock);
+-  assert(!pool.is_null() && !error.is_null(), "adding NULL obj");
++  assert(!pool.is_null() && error != NULL, "adding NULL obj");
+ 
+-  ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error());
++  ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error);
+   add_entry(index, entry);
+ }
+ 
+@@ -57,20 +57,35 @@
+   return NULL;
+ }
+ 
++void ResolutionErrorEntry::set_error(Symbol* e) {
++  assert(e == NULL || _error == NULL, "cannot reset error");
++  _error = e;
++  if (_error != NULL) _error->increment_refcount();
++}
++
+ // create new error entry
+ ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, constantPoolOop pool,
+-                                                      int cp_index, symbolOop error)
++                                                      int cp_index, Symbol* error)
+ {
+-  ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable::new_entry(hash, pool);
++  ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<constantPoolOop>::new_entry(hash, pool);
+   entry->set_cp_index(cp_index);
++  NOT_PRODUCT(entry->set_error(NULL);)
+   entry->set_error(error);
+ 
+   return entry;
+ }
+ 
++void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) {
++  // decrement error refcount
++  assert(entry->error() != NULL, "error should be set");
++  entry->error()->decrement_refcount();
++  Hashtable<constantPoolOop>::free_entry(entry);
++}
++
++
+ // create resolution error table
+ ResolutionErrorTable::ResolutionErrorTable(int table_size)
+-    : Hashtable(table_size, sizeof(ResolutionErrorEntry)) {
++    : Hashtable<constantPoolOop>(table_size, sizeof(ResolutionErrorEntry)) {
+ }
+ 
+ // GC support
+@@ -80,7 +95,7 @@
+                            probe != NULL;
+                            probe = probe->next()) {
+       assert(probe->pool() != (constantPoolOop)NULL, "resolution error table is corrupt");
+-      assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt");
++      assert(probe->error() != (Symbol*)NULL, "resolution error table is corrupt");
+       probe->oops_do(f);
+     }
+   }
+@@ -89,20 +104,6 @@
+ // GC support
+ void ResolutionErrorEntry::oops_do(OopClosure* blk) {
+   blk->do_oop((oop*)pool_addr());
+-  blk->do_oop((oop*)error_addr());
+-}
+-
+-// We must keep the symbolOop used in the error alive. The constantPoolOop will
+-// decide when the entry can be purged.
+-void ResolutionErrorTable::always_strong_classes_do(OopClosure* blk) {
+-  for (int i = 0; i < table_size(); i++) {
+-    for (ResolutionErrorEntry* probe = bucket(i);
+-                           probe != NULL;
+-                           probe = probe->next()) {
+-      assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt");
+-      blk->do_oop((oop*)probe->error_addr());
+-    }
+-  }
+ }
+ 
+ // Remove unloaded entries from the table
+diff --git a/src/share/vm/classfile/resolutionErrors.hpp b/src/share/vm/classfile/resolutionErrors.hpp
+--- openjdk/hotspot/src/share/vm/classfile/resolutionErrors.hpp
++++ openjdk/hotspot/src/share/vm/classfile/resolutionErrors.hpp
+@@ -33,27 +33,28 @@
+ // ResolutionError objects are used to record errors encountered during
+ // constant pool resolution (JVMS 5.4.3).
+ 
+-class ResolutionErrorTable : public Hashtable {
++class ResolutionErrorTable : public Hashtable<constantPoolOop> {
+ 
+ public:
+   ResolutionErrorTable(int table_size);
+ 
+-  ResolutionErrorEntry* new_entry(int hash, constantPoolOop pool, int cp_index, symbolOop error);
++  ResolutionErrorEntry* new_entry(int hash, constantPoolOop pool, int cp_index, Symbol* error);
++  void free_entry(ResolutionErrorEntry *entry);
+ 
+   ResolutionErrorEntry* bucket(int i) {
+-    return (ResolutionErrorEntry*)Hashtable::bucket(i);
++    return (ResolutionErrorEntry*)Hashtable<constantPoolOop>::bucket(i);
+   }
+ 
+   ResolutionErrorEntry** bucket_addr(int i) {
+-    return (ResolutionErrorEntry**)Hashtable::bucket_addr(i);
++    return (ResolutionErrorEntry**)Hashtable<constantPoolOop>::bucket_addr(i);
+   }
+ 
+   void add_entry(int index, ResolutionErrorEntry* new_entry) {
+-    Hashtable::add_entry(index, (HashtableEntry*)new_entry);
++    Hashtable<constantPoolOop>::add_entry(index, (HashtableEntry<constantPoolOop>*)new_entry);
+   }
+ 
+   void add_entry(int index, unsigned int hash,
+-                 constantPoolHandle pool, int which, symbolHandle error);
++                 constantPoolHandle pool, int which, Symbol* error);
+ 
+ 
+   // find error given the constant pool and constant pool index
+@@ -68,18 +69,15 @@
+   // purges unloaded entries from the table
+   void purge_resolution_errors(BoolObjectClosure* is_alive);
+ 
+-  // this table keeps symbolOops alive
+-  void always_strong_classes_do(OopClosure* blk);
+-
+   // GC support.
+   void oops_do(OopClosure* f);
+ };
+ 
+ 
+-class ResolutionErrorEntry : public HashtableEntry {
++class ResolutionErrorEntry : public HashtableEntry<constantPoolOop> {
+  private:
+   int               _cp_index;
+-  symbolOop         _error;
++  Symbol*           _error;
+ 
+  public:
+   constantPoolOop    pool() const               { return (constantPoolOop)literal(); }
+@@ -88,16 +86,15 @@
+   int                cp_index() const           { return _cp_index; }
+   void               set_cp_index(int cp_index) { _cp_index = cp_index; }
+ 
+-  symbolOop          error() const              { return _error; }
+-  void               set_error(symbolOop e)     { _error = e; }
+-  symbolOop*         error_addr()               { return &_error; }
++  Symbol*            error() const              { return _error; }
++  void               set_error(Symbol* e);
+ 
+   ResolutionErrorEntry* next() const {
+-    return (ResolutionErrorEntry*)HashtableEntry::next();
++    return (ResolutionErrorEntry*)HashtableEntry<constantPoolOop>::next();
+   }
+ 
+   ResolutionErrorEntry** next_addr() {
+-    return (ResolutionErrorEntry**)HashtableEntry::next_addr();
++    return (ResolutionErrorEntry**)HashtableEntry<constantPoolOop>::next_addr();
+   }
+ 
+   // GC support
+diff --git a/src/share/vm/classfile/stackMapFrame.cpp b/src/share/vm/classfile/stackMapFrame.cpp
+--- openjdk/hotspot/src/share/vm/classfile/stackMapFrame.cpp
++++ openjdk/hotspot/src/share/vm/classfile/stackMapFrame.cpp
+@@ -27,7 +27,7 @@
+ #include "classfile/verifier.hpp"
+ #include "memory/resourceArea.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/handles.inline.hpp"
+ #include "utilities/globalDefinitions.hpp"
+ 
+@@ -90,8 +90,7 @@
+ 
+ VerificationType StackMapFrame::set_locals_from_arg(
+     const methodHandle m, VerificationType thisKlass, TRAPS) {
+-  symbolHandle signature(THREAD, m->signature());
+-  SignatureStream ss(signature);
++  SignatureStream ss(m->signature());
+   int init_local_num = 0;
+   if (!m->is_static()) {
+     init_local_num++;
+@@ -118,8 +117,14 @@
+     case T_OBJECT:
+     case T_ARRAY:
+     {
+-      symbolOop sig = ss.as_symbol(CHECK_(VerificationType::bogus_type()));
+-      return VerificationType::reference_type(symbolHandle(THREAD, sig));
++      Symbol* sig = ss.as_symbol(CHECK_(VerificationType::bogus_type()));
++      // Create another symbol to save as signature stream unreferences
++      // this symbol.
++      Symbol* sig_copy =
++        verifier()->create_temporary_symbol(sig, 0, sig->utf8_length(),
++                                 CHECK_(VerificationType::bogus_type()));
++      assert(sig_copy == sig, "symbols don't match");
++      return VerificationType::reference_type(sig_copy);
+     }
+     case T_INT:     return VerificationType::integer_type();
+     case T_BYTE:    return VerificationType::byte_type();
+@@ -157,7 +162,7 @@
+     VerificationType* from, VerificationType* to, int32_t len, TRAPS) const {
+   for (int32_t i = 0; i < len; i++) {
+     bool subtype = to[i].is_assignable_from(
+-      from[i], verifier()->current_class(), THREAD);
++      from[i], verifier(), THREAD);
+     if (!subtype) {
+       return false;
+     }
+@@ -187,7 +192,7 @@
+   }
+   VerificationType top = _stack[--_stack_size];
+   bool subtype = type.is_assignable_from(
+-    top, verifier()->current_class(), CHECK_(VerificationType::bogus_type()));
++    top, verifier(), CHECK_(VerificationType::bogus_type()));
+   if (!subtype) {
+     verifier()->verify_error(_offset, "Bad type on operand stack");
+     return VerificationType::bogus_type();
+@@ -203,7 +208,7 @@
+     return VerificationType::bogus_type();
+   }
+   bool subtype = type.is_assignable_from(_locals[index],
+-    verifier()->current_class(), CHECK_(VerificationType::bogus_type()));
++    verifier(), CHECK_(VerificationType::bogus_type()));
+   if (!subtype) {
+     verifier()->verify_error(_offset, "Bad local variable type");
+     return VerificationType::bogus_type();
+@@ -221,9 +226,9 @@
+     return;
+   }
+   bool subtype1 = type1.is_assignable_from(
+-    _locals[index], verifier()->current_class(), CHECK);
++    _locals[index], verifier(), CHECK);
+   bool subtype2 = type2.is_assignable_from(
+-    _locals[index+1], verifier()->current_class(), CHECK);
++    _locals[index+1], verifier(), CHECK);
+   if (!subtype1 || !subtype2) {
+     verifier()->verify_error(_offset, "Bad local variable type");
+     return;
+diff --git a/src/share/vm/classfile/stackMapFrame.hpp b/src/share/vm/classfile/stackMapFrame.hpp
+--- openjdk/hotspot/src/share/vm/classfile/stackMapFrame.hpp
++++ openjdk/hotspot/src/share/vm/classfile/stackMapFrame.hpp
+@@ -177,8 +177,7 @@
+     if (_stack_size != 0) {
+       VerificationType top = _stack[_stack_size - 1];
+       bool subtype = type.is_assignable_from(
+-        top, verifier()->current_class(),
+-        CHECK_(VerificationType::bogus_type()));
++        top, verifier(), CHECK_(VerificationType::bogus_type()));
+       if (subtype) {
+         _stack_size --;
+         NOT_PRODUCT( _stack[_stack_size] = VerificationType::bogus_type(); )
+@@ -194,11 +193,9 @@
+     assert(type2.is_long() || type2.is_double(), "must be long/double_2");
+     if (_stack_size >= 2) {
+       VerificationType top1 = _stack[_stack_size - 1];
+-      bool subtype1 = type1.is_assignable_from(
+-        top1, verifier()->current_class(), CHECK);
++      bool subtype1 = type1.is_assignable_from(top1, verifier(), CHECK);
+       VerificationType top2 = _stack[_stack_size - 2];
+-      bool subtype2 = type2.is_assignable_from(
+-        top2, verifier()->current_class(), CHECK);
++      bool subtype2 = type2.is_assignable_from(top2, verifier(), CHECK);
+       if (subtype1 && subtype2) {
+         _stack_size -= 2;
+         NOT_PRODUCT( _stack[_stack_size] = VerificationType::bogus_type(); )
+diff --git a/src/share/vm/classfile/stackMapTable.cpp b/src/share/vm/classfile/stackMapTable.cpp
+--- openjdk/hotspot/src/share/vm/classfile/stackMapTable.cpp
++++ openjdk/hotspot/src/share/vm/classfile/stackMapTable.cpp
+@@ -184,8 +184,7 @@
+       _stream->stackmap_format_error("bad class index", THREAD);
+       return VerificationType::bogus_type();
+     }
+-    return VerificationType::reference_type(
+-      symbolHandle(THREAD, _cp->klass_name_at(class_index)));
++    return VerificationType::reference_type(_cp->klass_name_at(class_index));
+   }
+   if (tag == ITEM_UninitializedThis) {
+     if (flags != NULL) {
+diff --git a/src/share/vm/classfile/symbolTable.cpp b/src/share/vm/classfile/symbolTable.cpp
+--- openjdk/hotspot/src/share/vm/classfile/symbolTable.cpp
++++ openjdk/hotspot/src/share/vm/classfile/symbolTable.cpp
+@@ -32,7 +32,6 @@
+ #include "memory/gcLocker.inline.hpp"
+ #include "oops/oop.inline.hpp"
+ #include "oops/oop.inline2.hpp"
+-#include "oops/symbolKlass.hpp"
+ #include "runtime/mutexLocker.hpp"
+ #include "utilities/hashtable.inline.hpp"
+ #include "utilities/numberSeq.hpp"
+@@ -42,6 +41,87 @@
+ SymbolTable* SymbolTable::_the_table = NULL;
+ bool SymbolTable::_needs_rehashing = false;
+ 
++Symbol* SymbolTable::allocate_symbol(const u1* name, int len, TRAPS) {
++  // Don't allow symbols to be created which cannot fit in a Symbol*.
++  if (len > Symbol::max_length()) {
++    THROW_MSG_0(vmSymbols::java_lang_InternalError(),
++                "name is too long to represent");
++  }
++  Symbol* sym = new (len) Symbol(name, len);
++  assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted");
++  return sym;
++}
++
++bool SymbolTable::allocate_symbols(int names_count, const u1** names,
++                                   int* lengths, Symbol** syms, TRAPS) {
++  for (int i = 0; i< names_count; i++) {
++    if (lengths[i] > Symbol::max_length()) {
++      THROW_MSG_0(vmSymbols::java_lang_InternalError(),
++                  "name is too long to represent");
++    }
++  }
++
++  for (int i = 0; i< names_count; i++) {
++    int len = lengths[i];
++    syms[i] = new (len) Symbol(names[i], len);
++    assert(syms[i] != NULL, "new should call vm_exit_out_of_memory if "
++                            "C_HEAP is exhausted");
++  }
++  return true;
++}
++
++// Call function for all symbols in the symbol table.
++void SymbolTable::symbols_do(SymbolClosure *cl) {
++  const int n = the_table()->table_size();
++  for (int i = 0; i < n; i++) {
++    for (HashtableEntry<Symbol*>* p = the_table()->bucket(i);
++         p != NULL;
++         p = p->next()) {
++      cl->do_symbol(p->literal_addr());
++    }
++  }
++}
++
++int SymbolTable::symbols_removed = 0;
++int SymbolTable::symbols_counted = 0;
++
++// Remove unreferenced symbols from the symbol table
++// This is done late during GC.  This doesn't use the hash table unlink because
++// it assumes that the literals are oops.
++void SymbolTable::unlink() {
++  int removed = 0;
++  int total = 0;
++  int memory_total = 0;
++  for (int i = 0; i < the_table()->table_size(); ++i) {
++    for (HashtableEntry<Symbol*>** p = the_table()->bucket_addr(i); *p != NULL; ) {
++      HashtableEntry<Symbol*>* entry = *p;
++      if (entry->is_shared()) {
++        break;
++      }
++      Symbol* s = entry->literal();
++      memory_total += s->object_size();
++      total++;
++      assert(s != NULL, "just checking");
++      // If reference count is zero, remove.
++      if (s->refcount() == 0) {
++        delete s;
++        removed++;
++        *p = entry->next();
++        the_table()->free_entry(entry);
++      } else {
++        p = entry->next_addr();
++      }
++    }
++  }
++  symbols_removed += removed;
++  symbols_counted += total;
++  if (PrintGCDetails) {
++    gclog_or_tty->print(" [Symbols=%d size=%dK] ", total,
++                        (memory_total*HeapWordSize)/1024);
++  }
++}
++
++
+ // Create a new table and using alternate hash code, populate the new table
+ // with the existing strings.   Set flag to use the alternate hash code afterwards.
+ void SymbolTable::rehash_table() {
+@@ -64,14 +144,16 @@
+ 
+ // Lookup a symbol in a bucket.
+ 
+-symbolOop SymbolTable::lookup(int index, const char* name,
++Symbol* SymbolTable::lookup(int index, const char* name,
+                               int len, unsigned int hash) {
+   int count = 0;
+-  for (HashtableEntry* e = bucket(index); e != NULL; e = e->next()) {
++  for (HashtableEntry<Symbol*>* e = bucket(index); e != NULL; e = e->next()) {
+     count++;
+     if (e->hash() == hash) {
+-      symbolOop sym = symbolOop(e->literal());
++      Symbol* sym = e->literal();
+       if (sym->equals(name, len)) {
++        // something is referencing this symbol now.
++        sym->increment_refcount();
+         return sym;
+       }
+     }
+@@ -98,29 +180,21 @@
+ // entries in the symbol table during normal execution (only during
+ // safepoints).
+ 
+-symbolOop SymbolTable::lookup(const char* name, int len, TRAPS) {
++Symbol* SymbolTable::lookup(const char* name, int len, TRAPS) {
+   unsigned int hashValue = hash_symbol(name, len);
+   int index = the_table()->hash_to_index(hashValue);
+ 
+-  symbolOop s = the_table()->lookup(index, name, len, hashValue);
++  Symbol* s = the_table()->lookup(index, name, len, hashValue);
+ 
+   // Found
+   if (s != NULL) return s;
+ 
+-  // We assume that lookup() has been called already, that it failed,
+-  // and symbol was not found.  We create the symbol here.
+-  symbolKlass* sk  = (symbolKlass*) Universe::symbolKlassObj()->klass_part();
+-  symbolOop s_oop = sk->allocate_symbol((u1*)name, len, CHECK_NULL);
+-  symbolHandle sym (THREAD, s_oop);
+-
+-  // Allocation must be done before grabbing the SymbolTable_lock lock
+-  MutexLocker ml(SymbolTable_lock, THREAD);
+-
+   // Otherwise, add to symbol to table
+-  return the_table()->basic_add(sym, index, (u1*)name, len, hashValue, CHECK_NULL);
++  return the_table()->basic_add(index, (u1*)name, len, hashValue, CHECK_NULL);
++;
+ }
+ 
+-symbolOop SymbolTable::lookup(symbolHandle sym, int begin, int end, TRAPS) {
++Symbol* SymbolTable::lookup(const Symbol* sym, int begin, int end, TRAPS) {
+   char* buffer;
+   int index, len;
+   unsigned int hashValue;
+@@ -132,7 +206,7 @@
+     len = end - begin;
+     hashValue = hash_symbol(name, len);
+     index = the_table()->hash_to_index(hashValue);
+-    symbolOop s = the_table()->lookup(index, name, len, hashValue);
++    Symbol* s = the_table()->lookup(index, name, len, hashValue);
+ 
+     // Found
+     if (s != NULL) return s;
+@@ -153,30 +227,22 @@
+   // We can't include the code in No_Safepoint_Verifier because of the
+   // ResourceMark.
+ 
+-  // We assume that lookup() has been called already, that it failed,
+-  // and symbol was not found.  We create the symbol here.
+-  symbolKlass* sk  = (symbolKlass*) Universe::symbolKlassObj()->klass_part();
+-  symbolOop s_oop = sk->allocate_symbol((u1*)buffer, len, CHECK_NULL);
+-  symbolHandle newsym (THREAD, s_oop);
+-
+-  // Allocation must be done before grabbing the SymbolTable_lock lock
+-  MutexLocker ml(SymbolTable_lock, THREAD);
+-
+-  return the_table()->basic_add(newsym, index, (u1*)buffer, len, hashValue, CHECK_NULL);
++  return the_table()->basic_add(index, (u1*)buffer, len, hashValue, CHECK_NULL);
+ }
+ 
+-symbolOop SymbolTable::lookup_only(const char* name, int len,
++Symbol* SymbolTable::lookup_only(const char* name, int len,
+                                    unsigned int& hash) {
+   hash = hash_symbol(name, len);
+   int index = the_table()->hash_to_index(hash);
+ 
+-  return the_table()->lookup(index, name, len, hash);
++  Symbol* s = the_table()->lookup(index, name, len, hash);
++  return s;
+ }
+ 
+ // Suggestion: Push unicode-based lookup all the way into the hashing
+ // and probing logic, so there is no need for convert_to_utf8 until
+-// an actual new symbolOop is created.
+-symbolOop SymbolTable::lookup_unicode(const jchar* name, int utf16_length, TRAPS) {
++// an actual new Symbol* is created.
++Symbol* SymbolTable::lookup_unicode(const jchar* name, int utf16_length, TRAPS) {
+   int utf8_length = UNICODE::utf8_length((jchar*) name, utf16_length);
+   char stack_buf[128];
+   if (utf8_length < (int) sizeof(stack_buf)) {
+@@ -191,7 +257,7 @@
+   }
+ }
+ 
+-symbolOop SymbolTable::lookup_only_unicode(const jchar* name, int utf16_length,
++Symbol* SymbolTable::lookup_only_unicode(const jchar* name, int utf16_length,
+                                            unsigned int& hash) {
+   int utf8_length = UNICODE::utf8_length((jchar*) name, utf16_length);
+   char stack_buf[128];
+@@ -210,54 +276,33 @@
+ void SymbolTable::add(constantPoolHandle cp, int names_count,
+                       const char** names, int* lengths, int* cp_indices,
+                       unsigned int* hashValues, TRAPS) {
+-
+-  symbolKlass* sk  = (symbolKlass*) Universe::symbolKlassObj()->klass_part();
+-  symbolOop sym_oops[symbol_alloc_batch_size];
+-  bool allocated = sk->allocate_symbols(names_count, names, lengths,
+-                                        sym_oops, CHECK);
+-  if (!allocated) {
++  SymbolTable* table = the_table();
++  bool added = table->basic_add(cp, names_count, names, lengths,
++                                cp_indices, hashValues, CHECK);
++  if (!added) {
+     // do it the hard way
+     for (int i=0; i<names_count; i++) {
+       assert(!Universe::heap()->is_in_reserved(names[i]) || GC_locker::is_active(),
++      int index = table->hash_to_index(hashValues[i]);
++      Symbol* sym = table->basic_add(index, (u1*)names[i], lengths[i],
++                                       hashValues[i], CHECK);
++      cp->symbol_at_put(cp_indices[i], sym);
++    }
++  }
++}
++
++Symbol* SymbolTable::basic_add(int index, u1 *name, int len,
++                                 unsigned int hashValue_arg, TRAPS) {
++  assert(!Universe::heap()->is_in_reserved(name) || GC_locker::is_active(),
+          "proposed name of symbol must be stable");
+ 
+-      // We assume that lookup() has been called already, that it failed,
+-      // and symbol was not found.  We create the symbol here.
+-      symbolKlass* sk  = (symbolKlass*) Universe::symbolKlassObj()->klass_part();
+-      symbolOop s_oop = sk->allocate_symbol((u1*)names[i], lengths[i], CHECK);
+-      symbolHandle sym (THREAD, s_oop);
+-
+-      // Allocation must be done before grabbing the SymbolTable_lock lock
+-      MutexLocker ml(SymbolTable_lock, THREAD);
+-
+-      SymbolTable* table = the_table();
+-      int index = table->hash_to_index(hashValues[i]);
+-      symbolOop s = table->basic_add(sym, index, (u1*)names[i], lengths[i],
+-                                       hashValues[i], CHECK);
+-      cp->symbol_at_put(cp_indices[i], s);
+-    }
+-    return;
+-  }
+-
+-  symbolHandle syms[symbol_alloc_batch_size];
+-  for (int i=0; i<names_count; i++) {
+-    syms[i] = symbolHandle(THREAD, sym_oops[i]);
+-  }
++  // We assume that lookup() has been called already, that it failed,
++  // and symbol was not found.  We create the symbol here.
++  Symbol* sym = allocate_symbol(name, len, CHECK_NULL);
+ 
+   // Allocation must be done before grabbing the SymbolTable_lock lock
+   MutexLocker ml(SymbolTable_lock, THREAD);
+ 
+-  SymbolTable* table = the_table();
+-  bool added = table->basic_add(syms, cp, names_count, names, lengths,
+-                                cp_indices, hashValues, CHECK);
+-  assert(added, "should always return true");
+-}
+-
+-symbolOop SymbolTable::basic_add(symbolHandle sym, int index_arg, u1 *name, int len,
+-                                 unsigned int hashValue_arg, TRAPS) {
+-  // Cannot hit a safepoint in this function because the "this" pointer can move.
+-  No_Safepoint_Verifier nsv;
+-
+   assert(sym->equals((char*)name, len), "symbol must be properly initialized");
+ 
+   // Check if the symbol table has been rehashed, if so, need to recalculate
+@@ -275,25 +320,34 @@
+   // Since look-up was done lock-free, we need to check if another
+   // thread beat us in the race to insert the symbol.
+ 
+-  symbolOop test = lookup(index, (char*)name, len, hashValue);
++  Symbol* test = lookup(index, (char*)name, len, hashValue);
+   if (test != NULL) {
+     // A race occurred and another thread introduced the symbol, this one
+     // will be dropped and collected.
++    delete sym;
++    assert(test->refcount() != 0, "lookup should have incremented the count");
+     return test;
+   }
+ 
+-  HashtableEntry* entry = new_entry(hashValue, sym());
++  HashtableEntry<Symbol*>* entry = new_entry(hashValue, sym);
++  sym->increment_refcount();
+   add_entry(index, entry);
+-  return sym();
++  return sym;
+ }
+ 
+-bool SymbolTable::basic_add(symbolHandle* syms,
+-                            constantPoolHandle cp, int names_count,
++bool SymbolTable::basic_add(constantPoolHandle cp, int names_count,
+                             const char** names, int* lengths,
+                             int* cp_indices, unsigned int* hashValues,
+                             TRAPS) {
+-  // Cannot hit a safepoint in this function because the "this" pointer can move.
+-  No_Safepoint_Verifier nsv;
++  Symbol* syms[symbol_alloc_batch_size];
++  bool allocated = allocate_symbols(names_count, (const u1**)names, lengths,
++                                    syms, CHECK_false);
++  if (!allocated) {
++    return false;
++  }
++
++  // Allocation must be done before grabbing the SymbolTable_lock lock
++  MutexLocker ml(SymbolTable_lock, THREAD);
+ 
+   for (int i=0; i<names_count; i++) {
+     assert(syms[i]->equals(names[i], lengths[i]), "symbol must be properly initialized");
+@@ -308,29 +362,31 @@
+     // Since look-up was done lock-free, we need to check if another
+     // thread beat us in the race to insert the symbol.
+     int index = hash_to_index(hashValue);
+-    symbolOop test = lookup(index, names[i], lengths[i], hashValue);
++    Symbol* test = lookup(index, names[i], lengths[i], hashValue);
+     if (test != NULL) {
+       // A race occurred and another thread introduced the symbol, this one
+       // will be dropped and collected. Use test instead.
+       cp->symbol_at_put(cp_indices[i], test);
++      assert(test->refcount() != 0, "lookup should have incremented the count");
++      delete syms[i];
+     } else {
+-      symbolOop sym = syms[i]();
+-      HashtableEntry* entry = new_entry(hashValue, sym);
++      Symbol* sym = syms[i];
++      HashtableEntry<Symbol*>* entry = new_entry(hashValue, sym);
++      sym->increment_refcount();  // increment refcount in external hashtable
+       add_entry(index, entry);
+       cp->symbol_at_put(cp_indices[i], sym);
+     }
+   }
+-  return true;  // always returns true
++
++  return true;
+ }
+ 
+ void SymbolTable::verify() {
+   for (int i = 0; i < the_table()->table_size(); ++i) {
+-    HashtableEntry* p = the_table()->bucket(i);
++    HashtableEntry<Symbol*>* p = the_table()->bucket(i);
+     for ( ; p != NULL; p = p->next()) {
+-      symbolOop s = symbolOop(p->literal());
++      Symbol* s = (Symbol*)(p->literal());
+       guarantee(s != NULL, "symbol is NULL");
+-      s->verify();
+-      guarantee(s->is_perm(), "symbol not in permspace");
+       unsigned int h = hash_symbol((const char*)s->bytes(), s->utf8_length());
+       guarantee(p->hash() == h, "broken hash in symbol table entry");
+       guarantee(the_table()->hash_to_index(h) == i,
+@@ -343,7 +399,7 @@
+   NumberSeq summary;
+   for (int i = 0; i < the_table()->table_size(); ++i) {
+     int count = 0;
+-    for (HashtableEntry* e = the_table()->bucket(i);
++    for (HashtableEntry<Symbol*>* e = the_table()->bucket(i);
+        e != NULL; e = e->next()) {
+       count++;
+     }
+@@ -376,10 +432,14 @@
+   int total = 0;
+   int max_symbols = 0;
+   int out_of_range = 0;
++  int memory_total = 0;
++  int count = 0;
+   for (i = 0; i < the_table()->table_size(); i++) {
+-    HashtableEntry* p = the_table()->bucket(i);
++    HashtableEntry<Symbol*>* p = the_table()->bucket(i);
+     for ( ; p != NULL; p = p->next()) {
+-      int counter = symbolOop(p->literal())->utf8_length();
++      memory_total += p->literal()->object_size();
++      count++;
++      int counter = p->literal()->utf8_length();
+       total += counter;
+       if (counter < results_length) {
+         results[counter]++;
+@@ -390,6 +450,17 @@
+     }
+   }
+   tty->print_cr("Symbol Table:");
++  tty->print_cr("Total number of symbols  %5d", count);
++  tty->print_cr("Total size in memory     %5dK",
++          (memory_total*HeapWordSize)/1024);
++  tty->print_cr("Total counted            %5d", symbols_counted);
++  tty->print_cr("Total removed            %5d", symbols_removed);
++  if (symbols_counted > 0) {
++    tty->print_cr("Percent removed          %3.2f",
++          ((float)symbols_removed/(float)symbols_counted)* 100);
++  }
++  tty->print_cr("Reference counts         %5d", Symbol::_total_count);
++  tty->print_cr("Histogram of symbol length:");
+   tty->print_cr("%8s %5d", "Total  ", total);
+   tty->print_cr("%8s %5d", "Maximum", max_symbols);
+   tty->print_cr("%8s %3.2f", "Average",
+@@ -401,22 +472,41 @@
+       tty->print_cr("%6d %10d", i, results[i]);
+     }
+   }
+-  int line_length = 70;
+-  tty->print_cr("%s %30s", " Length", "Number chains that length");
+-  for (i = 0; i < results_length; i++) {
+-    if (results[i] > 0) {
+-      tty->print("%4d", i);
+-      for (j = 0; (j < results[i]) && (j < line_length);  j++) {
+-        tty->print("%1s", "*");
++  if (Verbose) {
++    int line_length = 70;
++    tty->print_cr("%s %30s", " Length", "Number chains that length");
++    for (i = 0; i < results_length; i++) {
++      if (results[i] > 0) {
++        tty->print("%4d", i);
++        for (j = 0; (j < results[i]) && (j < line_length);  j++) {
++          tty->print("%1s", "*");
++        }
++        if (j == line_length) {
++          tty->print("%1s", "+");
++        }
++        tty->cr();
+       }
+-      if (j == line_length) {
+-        tty->print("%1s", "+");
++    }
++  }
++  tty->print_cr(" %s %d: %d\n", "Number chains longer than",
++                    results_length, out_of_range);
++}
++
++void SymbolTable::print() {
++  for (int i = 0; i < the_table()->table_size(); ++i) {
++    HashtableEntry<Symbol*>** p = the_table()->bucket_addr(i);
++    HashtableEntry<Symbol*>* entry = the_table()->bucket(i);
++    if (entry != NULL) {
++      while (entry != NULL) {
++        tty->print(PTR_FORMAT " ", entry->literal());
++        entry->literal()->print();
++        tty->print(" %d", entry->literal()->refcount());
++        p = entry->next_addr();
++        entry = (HashtableEntry<Symbol*>*)HashtableEntry<Symbol*>::make_ptr(*p);
+       }
+       tty->cr();
+     }
+   }
+-  tty->print_cr(" %s %d: %d\n", "Number chains longer than",
+-                    results_length, out_of_range);
+ }
+ #endif // PRODUCT
+ 
+@@ -476,7 +566,7 @@
+ oop StringTable::lookup(int index, jchar* name,
+                         int len, unsigned int hash) {
+   int count = 0;
+-  for (HashtableEntry* l = bucket(index); l != NULL; l = l->next()) {
++  for (HashtableEntry<oop>* l = bucket(index); l != NULL; l = l->next()) {
+     count++;
+     if (l->hash() == hash) {
+       if (java_lang_String::equals(l->literal(), name, len)) {
+@@ -492,11 +582,22 @@
+ }
+ 
+ 
+-oop StringTable::basic_add(int index_arg, Handle string, jchar* name,
++oop StringTable::basic_add(int index, Handle string_or_null, jchar* name,
+                            int len, unsigned int hashValue_arg, TRAPS) {
++  debug_only(StableMemoryChecker smc(name, len * sizeof(name[0])));
++  assert(!Universe::heap()->is_in_reserved(name) || GC_locker::is_active(),
++         "proposed name of symbol must be stable");
+ 
+-  // Cannot hit a safepoint in this function because the "this" pointer can move.
+-  No_Safepoint_Verifier nsv;
++  Handle string;
++  // try to reuse the string if possible
++  if (!string_or_null.is_null() && (!JavaObjectsInPerm || string_or_null()->is_perm())) {
++    string = string_or_null;
++  } else {
++    string = java_lang_String::create_tenured_from_unicode(name, len, CHECK_NULL);
++  }
++
++  // Allocation must be done before grapping the SymbolTable_lock lock
++  MutexLocker ml(StringTable_lock, THREAD);
+ 
+   assert(java_lang_String::equals(string(), name, len),
+          "string must be properly initialized");
+@@ -522,13 +623,13 @@
+     return test;
+   }
+ 
+-  HashtableEntry* entry = new_entry(hashValue, string());
++  HashtableEntry<oop>* entry = new_entry(hashValue, string());
+   add_entry(index, entry);
+   return string();
+ }
+ 
+ 
+-oop StringTable::lookup(symbolOop symbol) {
++oop StringTable::lookup(Symbol* symbol) {
+   ResourceMark rm;
+   int length;
+   jchar* chars = symbol->as_unicode(length);
+@@ -542,32 +643,17 @@
+                         int len, TRAPS) {
+   unsigned int hashValue = hash_string(name, len);
+   int index = the_table()->hash_to_index(hashValue);
+-  oop found_string = the_table()->lookup(index, name, len, hashValue);
++  oop string = the_table()->lookup(index, name, len, hashValue);
+ 
+   // Found
+-  if (found_string != NULL) return found_string;
+-
+-  debug_only(StableMemoryChecker smc(name, len * sizeof(name[0])));
+-  assert(!Universe::heap()->is_in_reserved(name) || GC_locker::is_active(),
+-         "proposed name of symbol must be stable");
+-
+-  Handle string;
+-  // try to reuse the string if possible
+-  if (!string_or_null.is_null() && string_or_null()->is_perm()) {
+-    string = string_or_null;
+-  } else {
+-    string = java_lang_String::create_tenured_from_unicode(name, len, CHECK_NULL);
+-  }
+-
+-  // Allocation must be done before grabbing the StringTable_lock lock
+-  MutexLocker ml(StringTable_lock, THREAD);
++  if (string != NULL) return string;
+ 
+   // Otherwise, add to symbol to table
+-  return the_table()->basic_add(index, string, name, len,
++  return the_table()->basic_add(index, string_or_null, name, len,
+                                 hashValue, CHECK_NULL);
+ }
+ 
+-oop StringTable::intern(symbolOop symbol, TRAPS) {
++oop StringTable::intern(Symbol* symbol, TRAPS) {
+   if (symbol == NULL) return NULL;
+   ResourceMark rm(THREAD);
+   int length;
+@@ -601,17 +687,55 @@
+   return result;
+ }
+ 
++void StringTable::unlink(BoolObjectClosure* is_alive) {
++  // Readers of the table are unlocked, so we should only be removing
++  // entries at a safepoint.
++  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
++  for (int i = 0; i < the_table()->table_size(); ++i) {
++    for (HashtableEntry<oop>** p = the_table()->bucket_addr(i); *p != NULL; ) {
++      HashtableEntry<oop>* entry = *p;
++      if (entry->is_shared()) {
++        break;
++      }
++      assert(entry->literal() != NULL, "just checking");
++      if (is_alive->do_object_b(entry->literal())) {
++        p = entry->next_addr();
++      } else {
++        *p = entry->next();
++        the_table()->free_entry(entry);
++      }
++    }
++  }
++}
++
++void StringTable::oops_do(OopClosure* f) {
++  for (int i = 0; i < the_table()->table_size(); ++i) {
++    HashtableEntry<oop>** p = the_table()->bucket_addr(i);
++    HashtableEntry<oop>* entry = the_table()->bucket(i);
++    while (entry != NULL) {
++      f->do_oop((oop*)entry->literal_addr());
++
++      // Did the closure remove the literal from the table?
++      if (entry->literal() == NULL) {
++        assert(!entry->is_shared(), "immutable hashtable entry?");
++        *p = entry->next();
++        the_table()->free_entry(entry);
++      } else {
++        p = entry->next_addr();
++      }
++      entry = (HashtableEntry<oop>*)HashtableEntry<oop>::make_ptr(*p);
++    }
++  }
++}
++
+ void StringTable::verify() {
+   for (int i = 0; i < the_table()->table_size(); ++i) {
+-    HashtableEntry* p = the_table()->bucket(i);
++    HashtableEntry<oop>* p = the_table()->bucket(i);
+     for ( ; p != NULL; p = p->next()) {
+       oop s = p->literal();
+       guarantee(s != NULL, "interned string is NULL");
+-      guarantee(s->is_perm(), "interned string not in permspace");
+-
+-      int length;
+-      jchar* chars = java_lang_String::as_unicode_string(s, length);
+-      unsigned int h = hash_string(chars, length);
++      guarantee(s->is_perm() || !JavaObjectsInPerm, "interned string not in permspace");
++      unsigned int h = java_lang_String::hash_string(s);
+       guarantee(p->hash() == h, "broken hash in string table entry");
+       guarantee(the_table()->hash_to_index(h) == i,
+                 "wrong index in string table");
+@@ -622,7 +746,7 @@
+ void StringTable::dump(outputStream* st) {
+   NumberSeq summary;
+   for (int i = 0; i < the_table()->table_size(); ++i) {
+-    HashtableEntry* p = the_table()->bucket(i);
++    HashtableEntry<oop>* p = the_table()->bucket(i);
+     int count = 0;
+     for ( ; p != NULL; p = p->next()) {
+       count++;
+diff --git a/src/share/vm/classfile/symbolTable.hpp b/src/share/vm/classfile/symbolTable.hpp
+--- openjdk/hotspot/src/share/vm/classfile/symbolTable.hpp
++++ openjdk/hotspot/src/share/vm/classfile/symbolTable.hpp
+@@ -26,11 +26,11 @@
+ #define SHARE_VM_CLASSFILE_SYMBOLTABLE_HPP
+ 
+ #include "memory/allocation.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "utilities/hashtable.hpp"
+ 
+-// The symbol table holds all symbolOops and corresponding interned strings.
+-// symbolOops and literal strings should be canonicalized.
++// The symbol table holds all Symbol*s and corresponding interned strings.
++// Symbol*s and literal strings should be canonicalized.
+ //
+ // The interned strings are created lazily.
+ //
+@@ -43,23 +43,67 @@
+ class outputStream;
+ 
+ 
+-class SymbolTable : public Hashtable {
++// Class to hold a newly created or referenced Symbol* temporarily in scope.
++// new_symbol() and lookup() will create a Symbol* if not already in the
++// symbol table and add to the symbol's reference count.
++// probe() and lookup_only() will increment the refcount if symbol is found.
++class TempNewSymbol : public StackObj {
++  Symbol* _temp;
++
++ public:
++  TempNewSymbol() : _temp(NULL) {}
++  // Creating or looking up a symbol increments the symbol's reference count
++  TempNewSymbol(Symbol *s) : _temp(s) {}
++
++  // Operator= increments reference count.
++  void operator=(const TempNewSymbol &s) {
++    _temp = s._temp;
++    if (_temp !=NULL) _temp->increment_refcount();
++  }
++
++  // Decrement reference counter so it can go away if it's unique
++  ~TempNewSymbol() { if (_temp != NULL) _temp->decrement_refcount(); }
++
++  // Operators so they can be used like Symbols
++  Symbol* operator -> () const                   { return _temp; }
++  bool    operator == (Symbol* o) const          { return _temp == o; }
++  // Sneaky conversion function
++  operator Symbol*()                             { return _temp; }
++};
++
++class SymbolTable : public Hashtable<Symbol*> {
+   friend class VMStructs;
++  friend class ClassFileParser;
+ 
+ private:
+   // The symbol table
+   static SymbolTable* _the_table;
+ 
++  // For statistics
++  static int symbols_removed;
++  static int symbols_counted;
++
++  Symbol* allocate_symbol(const u1* name, int len, TRAPS);   // Assumes no characters larger than 0x7F
++  bool allocate_symbols(int names_count, const u1** names, int* lengths, Symbol** syms, TRAPS);
++
+   // Set if one bucket is out of balance due to hash algorithm deficiency
+   static bool _needs_rehashing;
+ 
+   // Adding elements
+-  symbolOop basic_add(symbolHandle sym, int index, u1* name, int len,
++  Symbol* basic_add(int index, u1* name, int len,
+                       unsigned int hashValue, TRAPS);
+-  bool basic_add(symbolHandle* syms, constantPoolHandle cp, int names_count,
++  bool basic_add(constantPoolHandle cp, int names_count,
+                  const char** names, int* lengths, int* cp_indices,
+                  unsigned int* hashValues, TRAPS);
+ 
++  static void new_symbols(constantPoolHandle cp, int names_count,
++                          const char** name, int* lengths,
++                          int* cp_indices, unsigned int* hashValues,
++                          TRAPS) {
++    add(cp, names_count, name, lengths, cp_indices, hashValues, THREAD);
++  }
++
++
+   // Table size
+   enum {
+     symbol_table_size = 20011
+@@ -67,13 +111,13 @@
+ 
+   static unsigned int hash_symbol(const char* s, int len);
+ 
+-  symbolOop lookup(int index, const char* name, int len, unsigned int hash);
++  Symbol* lookup(int index, const char* name, int len, unsigned int hash);
+ 
+   SymbolTable()
+-    : Hashtable(symbol_table_size, sizeof (HashtableEntry)) {}
++    : Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>)) {}
+ 
+   SymbolTable(HashtableBucket* t, int number_of_entries)
+-    : Hashtable(symbol_table_size, sizeof (HashtableEntry), t,
++    : Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>), t,
+                 number_of_entries) {}
+ 
+ public:
+@@ -97,48 +141,60 @@
+     _the_table = new SymbolTable(t, number_of_entries);
+   }
+ 
+-  static symbolOop lookup(const char* name, int len, TRAPS);
++  static Symbol* lookup(const char* name, int len, TRAPS);
+   // lookup only, won't add. Also calculate hash.
+-  static symbolOop lookup_only(const char* name, int len, unsigned int& hash);
++  static Symbol* lookup_only(const char* name, int len, unsigned int& hash);
+   // Only copy to C string to be added if lookup failed.
+-  static symbolOop lookup(symbolHandle sym, int begin, int end, TRAPS);
++  static Symbol* lookup(const Symbol* sym, int begin, int end, TRAPS);
++
++  static void release(Symbol* sym);
+ 
+   // jchar (utf16) version of lookups
+-  static symbolOop lookup_unicode(const jchar* name, int len, TRAPS);
+-  static symbolOop lookup_only_unicode(const jchar* name, int len, unsigned int& hash);
++  static Symbol* lookup_unicode(const jchar* name, int len, TRAPS);
++  static Symbol* lookup_only_unicode(const jchar* name, int len, unsigned int& hash);
+ 
+   static void add(constantPoolHandle cp, int names_count,
+                   const char** names, int* lengths, int* cp_indices,
+                   unsigned int* hashValues, TRAPS);
+ 
+-  // GC support
+-  //   Delete pointers to otherwise-unreachable objects.
+-  static void unlink(BoolObjectClosure* cl) {
+-    the_table()->Hashtable::unlink(cl);
++  // Release any dead symbols
++  static void unlink();
++
++  // iterate over symbols
++  static void symbols_do(SymbolClosure *cl);
++
++  // Symbol creation
++  static Symbol* new_symbol(const char* utf8_buffer, int length, TRAPS) {
++    assert(utf8_buffer != NULL, "just checking");
++    return lookup(utf8_buffer, length, THREAD);
+   }
+ 
+-  // Invoke "f->do_oop" on the locations of all oops in the table.
+-  static void oops_do(OopClosure* f) {
+-    the_table()->Hashtable::oops_do(f);
++  static Symbol*       new_symbol(const char* name, TRAPS) {
++    return new_symbol(name, (int)strlen(name), THREAD);
++  }
++  static Symbol*       new_symbol(const Symbol* sym, int begin, int end, TRAPS) {
++    assert(begin <= end && end <= sym->utf8_length(), "just checking");
++    return lookup(sym, begin, end, THREAD);
+   }
+ 
+   // Symbol lookup
+-  static symbolOop lookup(int index, const char* name, int len, TRAPS);
++  static Symbol* lookup(int index, const char* name, int len, TRAPS);
+ 
+   // Needed for preloading classes in signatures when compiling.
+   // Returns the symbol is already present in symbol table, otherwise
+   // NULL.  NO ALLOCATION IS GUARANTEED!
+-  static symbolOop probe(const char* name, int len) {
++  static Symbol* probe(const char* name, int len) {
+     unsigned int ignore_hash;
+     return lookup_only(name, len, ignore_hash);
+   }
+-  static symbolOop probe_unicode(const jchar* name, int len) {
++  static Symbol* probe_unicode(const jchar* name, int len) {
+     unsigned int ignore_hash;
+     return lookup_only_unicode(name, len, ignore_hash);
+   }
+ 
+   // Histogram
+   static void print_histogram()     PRODUCT_RETURN;
++  static void print()     PRODUCT_RETURN;
+ 
+   // Debugging
+   static void verify();
+@@ -146,13 +202,13 @@
+ 
+   // Sharing
+   static void copy_buckets(char** top, char*end) {
+-    the_table()->Hashtable::copy_buckets(top, end);
++    the_table()->Hashtable<Symbol*>::copy_buckets(top, end);
+   }
+   static void copy_table(char** top, char*end) {
+-    the_table()->Hashtable::copy_table(top, end);
++    the_table()->Hashtable<Symbol*>::copy_table(top, end);
+   }
+   static void reverse(void* boundary = NULL) {
+-    ((Hashtable*)the_table())->reverse(boundary);
++    the_table()->Hashtable<Symbol*>::reverse(boundary);
+   }
+ 
+   // Rehash the symbol table if it gets out of balance
+@@ -160,8 +216,7 @@
+   static bool needs_rehashing()         { return _needs_rehashing; }
+ };
+ 
+-
+-class StringTable : public Hashtable {
++class StringTable : public Hashtable<oop> {
+   friend class VMStructs;
+ 
+ private:
+@@ -172,7 +227,7 @@
+   static bool _needs_rehashing;
+ 
+   static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS);
+-  oop basic_add(int index, Handle string, jchar* name, int len,
++  oop basic_add(int index, Handle string_or_null, jchar* name, int len,
+                 unsigned int hashValue, TRAPS);
+ 
+   // Table size
+@@ -182,10 +237,10 @@
+ 
+   oop lookup(int index, jchar* chars, int length, unsigned int hashValue);
+ 
+-  StringTable() : Hashtable(string_table_size, sizeof (HashtableEntry)) {}
++  StringTable() : Hashtable<oop>(string_table_size, sizeof (HashtableEntry<oop>)) {}
+ 
+   StringTable(HashtableBucket* t, int number_of_entries)
+-    : Hashtable(string_table_size, sizeof (HashtableEntry), t,
++    : Hashtable<oop>(string_table_size, sizeof (HashtableEntry<oop>), t,
+                 number_of_entries) {}
+ 
+ public:
+@@ -207,14 +262,10 @@
+ 
+   // GC support
+   //   Delete pointers to otherwise-unreachable objects.
+-  static void unlink(BoolObjectClosure* cl) {
+-    the_table()->Hashtable::unlink(cl);
+-  }
++  static void unlink(BoolObjectClosure* cl);
+ 
+   // Invoke "f->do_oop" on the locations of all oops in the table.
+-  static void oops_do(OopClosure* f) {
+-    the_table()->Hashtable::oops_do(f);
+-  }
++  static void oops_do(OopClosure* f);
+ 
+   // Hashing algorithm, used as the hash value used by the
+   //     StringTable for bucket selection and comparison (stored in the
+@@ -225,10 +276,10 @@
+   static void test_alt_hash() PRODUCT_RETURN;
+ 
+   // Probing
+-  static oop lookup(symbolOop symbol);
++  static oop lookup(Symbol* symbol);
+ 
+   // Interning
+-  static oop intern(symbolOop symbol, TRAPS);
++  static oop intern(Symbol* symbol, TRAPS);
+   static oop intern(oop string, TRAPS);
+   static oop intern(const char *utf8_string, TRAPS);
+ 
+@@ -238,13 +289,13 @@
+ 
+   // Sharing
+   static void copy_buckets(char** top, char*end) {
+-    the_table()->Hashtable::copy_buckets(top, end);
++    the_table()->Hashtable<oop>::copy_buckets(top, end);
+   }
+   static void copy_table(char** top, char*end) {
+-    the_table()->Hashtable::copy_table(top, end);
++    the_table()->Hashtable<oop>::copy_table(top, end);
+   }
+   static void reverse() {
+-    ((BasicHashtable*)the_table())->reverse();
++    the_table()->Hashtable<oop>::reverse();
+   }
+ 
+   // Rehash the symbol table if it gets out of balance
+diff --git a/src/share/vm/classfile/systemDictionary.cpp b/src/share/vm/classfile/systemDictionary.cpp
+--- openjdk/hotspot/src/share/vm/classfile/systemDictionary.cpp
++++ openjdk/hotspot/src/share/vm/classfile/systemDictionary.cpp
+@@ -93,8 +93,8 @@
+   JavaValue result(T_OBJECT);
+   JavaCalls::call_static(&result,
+                          KlassHandle(THREAD, WK_KLASS(ClassLoader_klass)),
+-                         vmSymbolHandles::getSystemClassLoader_name(),
+-                         vmSymbolHandles::void_classloader_signature(),
++                         vmSymbols::getSystemClassLoader_name(),
++                         vmSymbols::void_classloader_signature(),
+                          CHECK);
+ 
+   _java_system_loader = (oop)result.get_jobject();
+@@ -107,8 +107,8 @@
+ #ifdef ASSERT
+ 
+ // return true if class_name contains no '.' (internal format is '/')
+-bool SystemDictionary::is_internal_format(symbolHandle class_name) {
+-  if (class_name.not_null()) {
++bool SystemDictionary::is_internal_format(Symbol* class_name) {
++  if (class_name != NULL) {
+     ResourceMark rm;
+     char* name = class_name->as_C_string();
+     return strchr(name, '.') == NULL;
+@@ -141,7 +141,7 @@
+ 
+ // Forwards to resolve_or_null
+ 
+-klassOop SystemDictionary::resolve_or_fail(symbolHandle class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) {
++klassOop SystemDictionary::resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS) {
+   klassOop klass = resolve_or_null(class_name, class_loader, protection_domain, THREAD);
+   if (HAS_PENDING_EXCEPTION || klass == NULL) {
+     KlassHandle k_h(THREAD, klass);
+@@ -151,7 +151,7 @@
+   return klass;
+ }
+ 
+-klassOop SystemDictionary::handle_resolution_exception(symbolHandle class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS) {
++klassOop SystemDictionary::handle_resolution_exception(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS) {
+   if (HAS_PENDING_EXCEPTION) {
+     // If we have a pending exception we forward it to the caller, unless throw_error is true,
+     // in which case we have to check whether the pending exception is a ClassNotFoundException,
+@@ -180,7 +180,7 @@
+ }
+ 
+ 
+-klassOop SystemDictionary::resolve_or_fail(symbolHandle class_name,
++klassOop SystemDictionary::resolve_or_fail(Symbol* class_name,
+                                            bool throw_error, TRAPS)
+ {
+   return resolve_or_fail(class_name, Handle(), Handle(), throw_error, THREAD);
+@@ -189,48 +189,49 @@
+ 
+ // Forwards to resolve_instance_class_or_null
+ 
+-klassOop SystemDictionary::resolve_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS) {
++klassOop SystemDictionary::resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS) {
+   assert(!THREAD->is_Compiler_thread(), "Can not load classes with the Compiler thread");
+-  if (FieldType::is_array(class_name())) {
++  if (FieldType::is_array(class_name)) {
+     return resolve_array_class_or_null(class_name, class_loader, protection_domain, CHECK_NULL);
++  } else if (FieldType::is_obj(class_name)) {
++    ResourceMark rm(THREAD);
++    // Ignore wrapping L and ;.
++    TempNewSymbol name = SymbolTable::new_symbol(class_name->as_C_string() + 1,
++                                   class_name->utf8_length() - 2, CHECK_NULL);
++    return resolve_instance_class_or_null(name, class_loader, protection_domain, CHECK_NULL);
+   } else {
+     return resolve_instance_class_or_null(class_name, class_loader, protection_domain, CHECK_NULL);
+   }
+ }
+ 
+-klassOop SystemDictionary::resolve_or_null(symbolHandle class_name, TRAPS) {
++klassOop SystemDictionary::resolve_or_null(Symbol* class_name, TRAPS) {
+   return resolve_or_null(class_name, Handle(), Handle(), THREAD);
+ }
+ 
+ // Forwards to resolve_instance_class_or_null
+ 
+-klassOop SystemDictionary::resolve_array_class_or_null(symbolHandle class_name,
++klassOop SystemDictionary::resolve_array_class_or_null(Symbol* class_name,
+                                                        Handle class_loader,
+                                                        Handle protection_domain,
+                                                        TRAPS) {
+-  assert(FieldType::is_array(class_name()), "must be array");
+-  jint dimension;
+-  symbolOop object_key;
++  assert(FieldType::is_array(class_name), "must be array");
+   klassOop k = NULL;
+-  // dimension and object_key are assigned as a side-effect of this call
+-  BasicType t = FieldType::get_array_info(class_name(),
+-                                          &dimension,
+-                                          &object_key,
+-                                          CHECK_NULL);
+-
++  FieldArrayInfo fd;
++  // dimension and object_key in FieldArrayInfo are assigned as a side-effect
++  // of this call
++  BasicType t = FieldType::get_array_info(class_name, fd, CHECK_NULL);
+   if (t == T_OBJECT) {
+-    symbolHandle h_key(THREAD, object_key);
+     // naked oop "k" is OK here -- we assign back into it
+-    k = SystemDictionary::resolve_instance_class_or_null(h_key,
++    k = SystemDictionary::resolve_instance_class_or_null(fd.object_key(),
+                                                          class_loader,
+                                                          protection_domain,
+                                                          CHECK_NULL);
+     if (k != NULL) {
+-      k = Klass::cast(k)->array_klass(dimension, CHECK_NULL);
++      k = Klass::cast(k)->array_klass(fd.dimension(), CHECK_NULL);
+     }
+   } else {
+     k = Universe::typeArrayKlassObj(t);
+-    k = typeArrayKlass::cast(k)->array_klass(dimension, CHECK_NULL);
++    k = typeArrayKlass::cast(k)->array_klass(fd.dimension(), CHECK_NULL);
+   }
+   return k;
+ }
+@@ -271,8 +272,8 @@
+ // Must be called, even if superclass is null, since this is
+ // where the placeholder entry is created which claims this
+ // thread is loading this class/classloader.
+-klassOop SystemDictionary::resolve_super_or_fail(symbolHandle child_name,
+-                                                 symbolHandle class_name,
++klassOop SystemDictionary::resolve_super_or_fail(Symbol* child_name,
++                                                 Symbol* class_name,
+                                                  Handle class_loader,
+                                                  Handle protection_domain,
+                                                  bool is_superclass,
+@@ -281,7 +282,7 @@
+   // Try to get one of the well-known klasses.
+   // They are trusted, and do not participate in circularities.
+   if (LinkWellKnownClasses) {
+-    klassOop k = find_well_known_klass(class_name());
++    klassOop k = find_well_known_klass(class_name);
+     if (k != NULL) {
+       return k;
+     }
+@@ -323,7 +324,7 @@
+     if ((childk != NULL ) && (is_superclass) &&
+        ((quicksuperk = instanceKlass::cast(childk)->super()) != NULL) &&
+ 
+-         ((Klass::cast(quicksuperk)->name() == class_name()) &&
++         ((Klass::cast(quicksuperk)->name() == class_name) &&
+             (Klass::cast(quicksuperk)->class_loader()  == class_loader()))) {
+            return quicksuperk;
+     } else {
+@@ -342,7 +343,7 @@
+   }
+ 
+ // java.lang.Object should have been found above
+-  assert(class_name() != NULL, "null super class for resolving");
++  assert(class_name != NULL, "null super class for resolving");
+   // Resolve the super class or interface, check results on return
+   klassOop superk = NULL;
+   superk = SystemDictionary::resolve_or_null(class_name,
+@@ -392,8 +393,8 @@
+   JavaCalls::call_special(&result,
+                          class_loader,
+                          system_loader,
+-                         vmSymbolHandles::checkPackageAccess_name(),
+-                         vmSymbolHandles::class_protectiondomain_signature(),
++                         vmSymbols::checkPackageAccess_name(),
++                         vmSymbols::class_protectiondomain_signature(),
+                          Handle(THREAD, klass->java_mirror()),
+                          protection_domain,
+                          THREAD);
+@@ -414,7 +415,7 @@
+   {
+     // We recalculate the entry here -- we've called out to java since
+     // the last time it was calculated.
+-    symbolHandle kn(THREAD, klass->name());
++    Symbol*  kn = klass->name();
+     unsigned int d_hash = dictionary()->compute_hash(kn, class_loader);
+     int d_index = dictionary()->hash_to_index(d_hash);
+ 
+@@ -489,7 +490,7 @@
+ // and we are done,
+ // If return null klassOop and no pending exception, the caller must load the class
+ instanceKlassHandle SystemDictionary::handle_parallel_super_load(
+-    symbolHandle name, symbolHandle superclassname, Handle class_loader,
++    Symbol* name, Symbol* superclassname, Handle class_loader,
+     Handle protection_domain, Handle lockObject, TRAPS) {
+ 
+   instanceKlassHandle nh = instanceKlassHandle(); // null Handle
+@@ -578,17 +579,9 @@
+ }
+ 
+ 
+-klassOop SystemDictionary::resolve_instance_class_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS) {
+-  assert(class_name.not_null() && !FieldType::is_array(class_name()), "invalid class name");
+-  // First check to see if we should remove wrapping L and ;
+-  symbolHandle name;
+-  if (FieldType::is_obj(class_name())) {
+-    ResourceMark rm(THREAD);
+-    // Ignore wrapping L and ;.
+-    name = oopFactory::new_symbol_handle(class_name()->as_C_string() + 1, class_name()->utf8_length() - 2, CHECK_NULL);
+-  } else {
+-    name = class_name;
+-  }
++klassOop SystemDictionary::resolve_instance_class_or_null(Symbol* name, Handle class_loader, Handle protection_domain, TRAPS) {
++  assert(name != NULL && !FieldType::is_array(name) &&
++         !FieldType::is_obj(name), "invalid class name");
+ 
+   // UseNewReflection
+   // Fix for 4474172; see evaluation for more details
+@@ -632,7 +625,7 @@
+   bool havesupername = false;
+   instanceKlassHandle k;
+   PlaceholderEntry* placeholder;
+-  symbolHandle superclassname;
++  Symbol* superclassname = NULL;
+ 
+   {
+     MutexLocker mu(SystemDictionary_lock, THREAD);
+@@ -646,7 +639,7 @@
+       if (placeholder && placeholder->super_load_in_progress()) {
+          super_load_in_progress = true;
+          if (placeholder->havesupername() == true) {
+-           superclassname = symbolHandle(THREAD, placeholder->supername());
++           superclassname = placeholder->supername();
+            havesupername = true;
+          }
+       }
+@@ -691,7 +684,6 @@
+     //    No performance benefit and no deadlock issues.
+     // case 5. parallelCapable user level classloaders - without objectLocker
+     //    Allow parallel classloading of a class/classloader pair
+-    symbolHandle nullsymbolHandle;
+     bool throw_circularity_error = false;
+     {
+       MutexLocker mu(SystemDictionary_lock, THREAD);
+@@ -733,7 +725,7 @@
+       // LOAD_INSTANCE in parallel
+       // add placeholder entry even if error - callers will remove on error
+       if (!throw_circularity_error && !class_has_been_loaded) {
+-        PlaceholderEntry* newprobe = placeholders()->find_and_add(p_index, p_hash, name, class_loader, PlaceholderTable::LOAD_INSTANCE, nullsymbolHandle, THREAD);
++        PlaceholderEntry* newprobe = placeholders()->find_and_add(p_index, p_hash, name, class_loader, PlaceholderTable::LOAD_INSTANCE, NULL, THREAD);
+         // For class loaders that do not acquire the classloader object lock,
+         // if they did not catch another thread holding LOAD_INSTANCE,
+         // need a check analogous to the acquire ObjectLocker/find_class
+@@ -837,7 +829,7 @@
+   {
+     Handle loader (THREAD, k->class_loader());
+     MutexLocker mu(SystemDictionary_lock, THREAD);
+-    oop kk = find_class_or_placeholder(name, loader);
++    oop kk = find_class(name, loader);
+     assert(kk == k(), "should be present in dictionary");
+   }
+ #endif
+@@ -880,7 +872,7 @@
+ // _dictionary->bucket(index) is read here, so the caller will not see
+ // the new entry.
+ 
+-klassOop SystemDictionary::find(symbolHandle class_name,
++klassOop SystemDictionary::find(Symbol* class_name,
+                                 Handle class_loader,
+                                 Handle protection_domain,
+                                 TRAPS) {
+@@ -910,37 +902,34 @@
+ 
+ // Look for a loaded instance or array klass by name.  Do not do any loading.
+ // return NULL in case of error.
+-klassOop SystemDictionary::find_instance_or_array_klass(symbolHandle class_name,
++klassOop SystemDictionary::find_instance_or_array_klass(Symbol* class_name,
+                                                         Handle class_loader,
+                                                         Handle protection_domain,
+                                                         TRAPS) {
+   klassOop k = NULL;
+-  assert(class_name() != NULL, "class name must be non NULL");
++  assert(class_name != NULL, "class name must be non NULL");
+ 
+   // Try to get one of the well-known klasses.
+   if (LinkWellKnownClasses) {
+-    k = find_well_known_klass(class_name());
++    k = find_well_known_klass(class_name);
+     if (k != NULL) {
+       return k;
+     }
+   }
+ 
+-  if (FieldType::is_array(class_name())) {
++  if (FieldType::is_array(class_name)) {
+     // The name refers to an array.  Parse the name.
+-    jint dimension;
+-    symbolOop object_key;
+-
+-    // dimension and object_key are assigned as a side-effect of this call
+-    BasicType t = FieldType::get_array_info(class_name(), &dimension,
+-                                            &object_key, CHECK_(NULL));
++    // dimension and object_key in FieldArrayInfo are assigned as a
++    // side-effect of this call
++    FieldArrayInfo fd;
++    BasicType t = FieldType::get_array_info(class_name, fd, CHECK_(NULL));
+     if (t != T_OBJECT) {
+       k = Universe::typeArrayKlassObj(t);
+     } else {
+-      symbolHandle h_key(THREAD, object_key);
+-      k = SystemDictionary::find(h_key, class_loader, protection_domain, THREAD);
++      k = SystemDictionary::find(fd.object_key(), class_loader, protection_domain, THREAD);
+     }
+     if (k != NULL) {
+-      k = Klass::cast(k)->array_klass_or_null(dimension);
++      k = Klass::cast(k)->array_klass_or_null(fd.dimension());
+     }
+   } else {
+     k = find(class_name, class_loader, protection_domain, THREAD);
+@@ -949,7 +938,7 @@
+ }
+ 
+ // Quick range check for names of well-known classes:
+-static symbolOop wk_klass_name_limits[2] = {NULL, NULL};
++static Symbol* wk_klass_name_limits[2] = {NULL, NULL};
+ 
+ #ifndef PRODUCT
+ static int find_wkk_calls, find_wkk_probes, find_wkk_wins;
+@@ -957,7 +946,7 @@
+ //  => 60% hit after limit guard, 25% total win rate
+ #endif
+ 
+-klassOop SystemDictionary::find_well_known_klass(symbolOop class_name) {
++klassOop SystemDictionary::find_well_known_klass(Symbol* class_name) {
+   // A bounds-check on class_name will quickly get a negative result.
+   NOT_PRODUCT(find_wkk_calls++);
+   if (class_name >= wk_klass_name_limits[0] &&
+@@ -983,14 +972,14 @@
+ // Note: this method is much like resolve_from_stream, but
+ // updates no supplemental data structures.
+ // TODO consolidate the two methods with a helper routine?
+-klassOop SystemDictionary::parse_stream(symbolHandle class_name,
++klassOop SystemDictionary::parse_stream(Symbol* class_name,
+                                         Handle class_loader,
+                                         Handle protection_domain,
+                                         ClassFileStream* st,
+                                         KlassHandle host_klass,
+                                         GrowableArray<Handle>* cp_patches,
+                                         TRAPS) {
+-  symbolHandle parsed_name;
++  TempNewSymbol parsed_name = NULL;
+ 
+   // Parse the stream. Note that we do this even though this klass might
+   // already be present in the SystemDictionary, otherwise we would not
+@@ -1011,13 +1000,12 @@
+                                                              true,
+                                                              THREAD);
+ 
+-
+   // We don't redefine the class, so we just need to clean up whether there
+   // was an error or not (don't want to modify any system dictionary
+   // data structures).
+   // Parsed name could be null if we threw an error before we got far
+   // enough along to parse it -- in that case, there is nothing to clean up.
+-  if (!parsed_name.is_null()) {
++  if (parsed_name != NULL) {
+     unsigned int p_hash = placeholders()->compute_hash(parsed_name,
+                                                        class_loader);
+     int p_index = placeholders()->hash_to_index(p_hash);
+@@ -1060,7 +1048,7 @@
+ // Note: class_name can be NULL. In that case we do not know the name of
+ // the class until we have parsed the stream.
+ 
+-klassOop SystemDictionary::resolve_from_stream(symbolHandle class_name,
++klassOop SystemDictionary::resolve_from_stream(Symbol* class_name,
+                                                Handle class_loader,
+                                                Handle protection_domain,
+                                                ClassFileStream* st,
+@@ -1079,7 +1067,7 @@
+   check_loader_lock_contention(lockObject, THREAD);
+   ObjectLocker ol(lockObject, THREAD, DoObjectLock);
+ 
+-  symbolHandle parsed_name;
++  TempNewSymbol parsed_name = NULL;
+ 
+   // Parse the stream. Note that we do this even though this klass might
+   // already be present in the SystemDictionary, otherwise we would not
+@@ -1101,7 +1089,7 @@
+   const char* pkg = "java/";
+   if (!HAS_PENDING_EXCEPTION &&
+       !class_loader.is_null() &&
+-      !parsed_name.is_null() &&
++      parsed_name != NULL &&
+       !strncmp((const char*)parsed_name->bytes(), pkg, strlen(pkg))) {
+     // It is illegal to define classes in the "java." package from
+     // JVM_DefineClass or jni_DefineClass unless you're the bootclassloader
+@@ -1121,9 +1109,8 @@
+   }
+ 
+   if (!HAS_PENDING_EXCEPTION) {
+-    assert(!parsed_name.is_null(), "Sanity");
+-    assert(class_name.is_null() || class_name() == parsed_name(),
+-           "name mismatch");
++    assert(parsed_name != NULL, "Sanity");
++    assert(class_name == NULL || class_name == parsed_name, "name mismatch");
+     // Verification prevents us from creating names with dots in them, this
+     // asserts that that's the case.
+     assert(is_internal_format(parsed_name),
+@@ -1144,7 +1131,7 @@
+   // must make sure parsed_name is valid first (it won't be if we had
+   // a format error before the class was parsed far enough to
+   // find the name).
+-  if (HAS_PENDING_EXCEPTION && !parsed_name.is_null()) {
++  if (HAS_PENDING_EXCEPTION && parsed_name != NULL) {
+     unsigned int p_hash = placeholders()->compute_hash(parsed_name,
+                                                        class_loader);
+     int p_index = placeholders()->hash_to_index(p_hash);
+@@ -1160,16 +1147,16 @@
+   // SystemDictionary; this is only done on success
+   debug_only( {
+     if (!HAS_PENDING_EXCEPTION) {
+-      assert(!parsed_name.is_null(), "parsed_name is still null?");
+-      symbolHandle h_name   (THREAD, k->name());
++      assert(parsed_name != NULL, "parsed_name is still null?");
++      Symbol*  h_name    = k->name();
+       Handle h_loader (THREAD, k->class_loader());
+ 
+       MutexLocker mu(SystemDictionary_lock, THREAD);
+ 
+-      oop check = find_class_or_placeholder(parsed_name, class_loader);
++      klassOop check = find_class(parsed_name, class_loader);
+       assert(check == k(), "should be present in the dictionary");
+ 
+-      oop check2 = find_class_or_placeholder(h_name, h_loader);
++      klassOop check2 = find_class(h_name, h_loader);
+       assert(check == check2, "name inconsistancy in SystemDictionary");
+     }
+   } );
+@@ -1189,7 +1176,7 @@
+ // If there is a shared dictionary, then find the entry for the
+ // given shared system class, if any.
+ 
+-klassOop SystemDictionary::find_shared_class(symbolHandle class_name) {
++klassOop SystemDictionary::find_shared_class(Symbol* class_name) {
+   if (shared_dictionary() != NULL) {
+     unsigned int d_hash = dictionary()->compute_hash(class_name, Handle());
+     int d_index = dictionary()->hash_to_index(d_hash);
+@@ -1207,7 +1194,7 @@
+ // object hierarchy until loaded.]
+ 
+ instanceKlassHandle SystemDictionary::load_shared_class(
+-                 symbolHandle class_name, Handle class_loader, TRAPS) {
++                 Symbol* class_name, Handle class_loader, TRAPS) {
+   instanceKlassHandle ik (THREAD, find_shared_class(class_name));
+   return load_shared_class(ik, class_loader, THREAD);
+ }
+@@ -1222,14 +1209,14 @@
+   assert(class_loader.is_null(), "non-null classloader for shared class?");
+   if (ik.not_null()) {
+     instanceKlassHandle nh = instanceKlassHandle(); // null Handle
+-    symbolHandle class_name(THREAD, ik->name());
++    Symbol*  class_name = ik->name();
+ 
+     // Found the class, now load the superclass and interfaces.  If they
+     // are shared, add them to the main system dictionary and reset
+     // their hierarchy references (supers, subs, and interfaces).
+ 
+     if (ik->super() != NULL) {
+-      symbolHandle cn(THREAD, ik->super()->klass_part()->name());
++      Symbol*  cn = ik->super()->klass_part()->name();
+       resolve_super_or_fail(class_name, cn,
+                             class_loader, Handle(), true, CHECK_(nh));
+     }
+@@ -1243,7 +1230,7 @@
+       // interfaces' instanceKlass's C++ vtbls haven't been
+       // reinitialized yet (they will be once the interface classes
+       // are loaded)
+-      symbolHandle name (THREAD, k->klass_part()->name());
++      Symbol*  name  = k->klass_part()->name();
+       resolve_super_or_fail(class_name, name, class_loader, Handle(), false, CHECK_(nh));
+     }
+ 
+@@ -1290,7 +1277,7 @@
+ // Note that with delegation class loaders all classes in another loader will
+ // first try to call this so it'd better be fast!!
+ static instanceKlassHandle download_and_retry_class_load(
+-                                                    symbolHandle class_name,
++                                                    Symbol* class_name,
+                                                     TRAPS) {
+ 
+   klassOop dlm = SystemDictionary::sun_jkernel_DownloadManager_klass();
+@@ -1313,8 +1300,8 @@
+     // public static String getBootClassPathEntryForClass(String className);
+     JavaCalls::call_static(&result,
+                        KlassHandle(THREAD, dlm),
+-                       vmSymbolHandles::getBootClassPathEntryForClass_name(),
+-                       vmSymbolHandles::string_string_signature(),
++                       vmSymbols::getBootClassPathEntryForClass_name(),
++                       vmSymbols::string_string_signature(),
+                        class_string,
+                        CHECK_(nk));
+ 
+@@ -1344,7 +1331,7 @@
+ #endif // KERNEL
+ 
+ 
+-instanceKlassHandle SystemDictionary::load_instance_class(symbolHandle class_name, Handle class_loader, TRAPS) {
++instanceKlassHandle SystemDictionary::load_instance_class(Symbol* class_name, Handle class_loader, TRAPS) {
+   instanceKlassHandle nh = instanceKlassHandle(); // null Handle
+   if (class_loader.is_null()) {
+ 
+@@ -1419,16 +1406,16 @@
+       JavaCalls::call_special(&result,
+                               class_loader,
+                               spec_klass,
+-                              vmSymbolHandles::loadClassInternal_name(),
+-                              vmSymbolHandles::string_class_signature(),
++                              vmSymbols::loadClassInternal_name(),
++                              vmSymbols::string_class_signature(),
+                               string,
+                               CHECK_(nh));
+     } else {
+       JavaCalls::call_virtual(&result,
+                               class_loader,
+                               spec_klass,
+-                              vmSymbolHandles::loadClass_name(),
+-                              vmSymbolHandles::string_class_signature(),
++                              vmSymbols::loadClass_name(),
++                              vmSymbols::string_class_signature(),
+                               string,
+                               CHECK_(nh));
+     }
+@@ -1444,7 +1431,7 @@
+       // For user defined Java class loaders, check that the name returned is
+       // the same as that requested.  This check is done for the bootstrap
+       // loader when parsing the class file.
+-      if (class_name() == k->name()) {
++      if (class_name == k->name()) {
+         return k;
+       }
+     }
+@@ -1477,7 +1464,7 @@
+   // classloader lock held
+   // Parallel classloaders will call find_or_define_instance_class
+   // which will require a token to perform the define class
+-  symbolHandle name_h(THREAD, k->name());
++  Symbol*  name_h = k->name();
+   unsigned int d_hash = dictionary()->compute_hash(name_h, class_loader_h);
+   int d_index = dictionary()->hash_to_index(d_hash);
+   check_constraints(d_index, d_hash, k, class_loader_h, true, CHECK);
+@@ -1536,10 +1523,10 @@
+ // findClass(), i.e. FindLoadedClass/DefineClassIfAbsent or they
+ // potentially waste time reading and parsing the bytestream.
+ // Note: VM callers should ensure consistency of k/class_name,class_loader
+-instanceKlassHandle SystemDictionary::find_or_define_instance_class(symbolHandle class_name, Handle class_loader, instanceKlassHandle k, TRAPS) {
++instanceKlassHandle SystemDictionary::find_or_define_instance_class(Symbol* class_name, Handle class_loader, instanceKlassHandle k, TRAPS) {
+ 
+   instanceKlassHandle nh = instanceKlassHandle(); // null Handle
+-  symbolHandle name_h(THREAD, k->name()); // passed in class_name may be null
++  Symbol*  name_h = k->name(); // passed in class_name may be null
+ 
+   unsigned int d_hash = dictionary()->compute_hash(name_h, class_loader);
+   int d_index = dictionary()->hash_to_index(d_hash);
+@@ -1560,8 +1547,7 @@
+     }
+ 
+     // Acquire define token for this class/classloader
+-    symbolHandle nullsymbolHandle;
+-    probe = placeholders()->find_and_add(p_index, p_hash, name_h, class_loader, PlaceholderTable::DEFINE_CLASS, nullsymbolHandle, THREAD);
++    probe = placeholders()->find_and_add(p_index, p_hash, name_h, class_loader, PlaceholderTable::DEFINE_CLASS, NULL, THREAD);
+     // Wait if another thread defining in parallel
+     // All threads wait - even those that will throw duplicate class: otherwise
+     // caller is surprised by LinkageError: duplicate, but findLoadedClass fails
+@@ -1653,7 +1639,7 @@
+ // Lookup
+ 
+ klassOop SystemDictionary::find_class(int index, unsigned int hash,
+-                                      symbolHandle class_name,
++                                      Symbol* class_name,
+                                       Handle class_loader) {
+   assert_locked_or_safepoint(SystemDictionary_lock);
+   assert (index == dictionary()->index_for(class_name, class_loader),
+@@ -1665,18 +1651,17 @@
+ 
+ 
+ // Basic find on classes in the midst of being loaded
+-symbolOop SystemDictionary::find_placeholder(int index, unsigned int hash,
+-                                             symbolHandle class_name,
+-                                             Handle class_loader) {
++Symbol* SystemDictionary::find_placeholder(Symbol* class_name,
++                                           Handle class_loader) {
+   assert_locked_or_safepoint(SystemDictionary_lock);
+-
+-  return placeholders()->find_entry(index, hash, class_name, class_loader);
++  unsigned int p_hash = placeholders()->compute_hash(class_name, class_loader);
++  int p_index = placeholders()->hash_to_index(p_hash);
++  return placeholders()->find_entry(p_index, p_hash, class_name, class_loader);
+ }
+ 
+ 
+ // Used for assertions and verification only
+-oop SystemDictionary::find_class_or_placeholder(symbolHandle class_name,
+-                                                Handle class_loader) {
++klassOop SystemDictionary::find_class(Symbol* class_name, Handle class_loader) {
+   #ifndef ASSERT
+   guarantee(VerifyBeforeGC   ||
+             VerifyDuringGC   ||
+@@ -1684,22 +1669,11 @@
+             VerifyAfterGC, "too expensive");
+   #endif
+   assert_locked_or_safepoint(SystemDictionary_lock);
+-  symbolOop class_name_ = class_name();
+-  oop class_loader_ = class_loader();
+ 
+   // First look in the loaded class array
+   unsigned int d_hash = dictionary()->compute_hash(class_name, class_loader);
+   int d_index = dictionary()->hash_to_index(d_hash);
+-  oop lookup = find_class(d_index, d_hash, class_name, class_loader);
+-
+-  if (lookup == NULL) {
+-    // Next try the placeholders
+-    unsigned int p_hash = placeholders()->compute_hash(class_name,class_loader);
+-    int p_index = placeholders()->hash_to_index(p_hash);
+-    lookup = find_placeholder(p_index, p_hash, class_name, class_loader);
+-  }
+-
+-  return lookup;
++  return find_class(d_index, d_hash, class_name, class_loader);
+ }
+ 
+ 
+@@ -1757,12 +1731,6 @@
+ 
+   // Visit extra methods
+   invoke_method_table()->oops_do(blk);
+-
+-  // Loader constraints. We must keep the symbolOop used in the name alive.
+-  constraints()->always_strong_classes_do(blk);
+-
+-  // Resolution errors keep the symbolOop for the error alive
+-  resolution_errors()->always_strong_classes_do(blk);
+ }
+ 
+ 
+@@ -1808,9 +1776,6 @@
+ 
+ 
+ void SystemDictionary::preloaded_oops_do(OopClosure* f) {
+-  f->do_oop((oop*) &wk_klass_name_limits[0]);
+-  f->do_oop((oop*) &wk_klass_name_limits[1]);
+-
+   for (int k = (int)FIRST_WKID; k < (int)WKID_LIMIT; k++) {
+     f->do_oop((oop*) &_well_known_klasses[k]);
+   }
+@@ -1862,7 +1827,7 @@
+   dictionary()->classes_do(f, CHECK);
+ }
+ 
+-void SystemDictionary::placeholders_do(void f(symbolOop, oop)) {
++void SystemDictionary::placeholders_do(void f(Symbol*, oop)) {
+   placeholders()->entries_do(f);
+ }
+ 
+@@ -1882,7 +1847,7 @@
+   // class is loaded.
+   klassOop aos = _abstract_ownable_synchronizer_klass;
+   if (aos == NULL) {
+-    klassOop k = resolve_or_fail(vmSymbolHandles::java_util_concurrent_locks_AbstractOwnableSynchronizer(), true, CHECK);
++    klassOop k = resolve_or_fail(vmSymbols::java_util_concurrent_locks_AbstractOwnableSynchronizer(), true, CHECK);
+     // Force a fence to prevent any read before the write completes
+     OrderAccess::fence();
+     _abstract_ownable_synchronizer_klass = k;
+@@ -1924,7 +1889,7 @@
+   assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
+   int  info = wk_init_info[id - FIRST_WKID];
+   int  sid  = (info >> CEIL_LG_OPTION_LIMIT);
+-  symbolHandle symbol = vmSymbolHandles::symbol_handle_at((vmSymbols::SID)sid);
++  Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
+   klassOop*    klassp = &_well_known_klasses[id];
+   bool must_load = (init_opt < SystemDictionary::Opt);
+   bool try_load  = true;
+@@ -1954,7 +1919,7 @@
+     initialize_wk_klass((WKID)id, opt, CHECK);
+ 
+     // Update limits, so find_well_known_klass can be very fast:
+-    symbolOop s = vmSymbols::symbol_at((vmSymbols::SID)sid);
++    Symbol* s = vmSymbols::symbol_at((vmSymbols::SID)sid);
+     if (wk_klass_name_limits[1] == NULL) {
+       wk_klass_name_limits[0] = wk_klass_name_limits[1] = s;
+     } else if (wk_klass_name_limits[1] < s) {
+@@ -2081,7 +2046,7 @@
+                                          TRAPS) {
+   const char *linkage_error = NULL;
+   {
+-    symbolHandle name (THREAD, k->name());
++    Symbol*  name  = k->name();
+     MutexLocker mu(SystemDictionary_lock, THREAD);
+ 
+     klassOop check = find_class(d_index, d_hash, name, class_loader);
+@@ -2102,10 +2067,8 @@
+     }
+ 
+ #ifdef ASSERT
+-    unsigned int p_hash = placeholders()->compute_hash(name, class_loader);
+-    int p_index = placeholders()->hash_to_index(p_hash);
+-    symbolOop ph_check = find_placeholder(p_index, p_hash, name, class_loader);
+-    assert(ph_check == NULL || ph_check == name(), "invalid symbol");
++    Symbol* ph_check = find_placeholder(name, class_loader);
++    assert(ph_check == NULL || ph_check == name, "invalid symbol");
+ #endif
+ 
+     if (linkage_error == NULL) {
+@@ -2141,7 +2104,7 @@
+                                          TRAPS) {
+   // Compile_lock prevents systemDictionary updates during compilations
+   assert_locked_or_safepoint(Compile_lock);
+-  symbolHandle name (THREAD, k->name());
++  Symbol*  name  = k->name();
+ 
+   {
+   MutexLocker mu1(SystemDictionary_lock, THREAD);
+@@ -2181,7 +2144,7 @@
+ // while only one thread can define a class at one time, multiple
+ // classes can resolve the superclass for a class at one time,
+ // and the placeholder is used to track that
+-//  symbolOop ph_check = find_placeholder(p_index, p_hash, name, class_loader);
++//  Symbol* ph_check = find_placeholder(name, class_loader);
+ //  assert (ph_check == NULL, "should not have a placeholder entry");
+ #endif
+     SystemDictionary_lock->notify_all();
+@@ -2190,7 +2153,7 @@
+ 
+ 
+ klassOop SystemDictionary::find_constrained_instance_or_array_klass(
+-                    symbolHandle class_name, Handle class_loader, TRAPS) {
++                    Symbol* class_name, Handle class_loader, TRAPS) {
+ 
+   // First see if it has been loaded directly.
+   // Force the protection domain to be null.  (This removes protection checks.)
+@@ -2203,23 +2166,20 @@
+   // Now look to see if it has been loaded elsewhere, and is subject to
+   // a loader constraint that would require this loader to return the
+   // klass that is already loaded.
+-  if (FieldType::is_array(class_name())) {
++  if (FieldType::is_array(class_name)) {
+     // For array classes, their klassOops are not kept in the
+     // constraint table. The element klassOops are.
+-    jint dimension;
+-    symbolOop object_key;
+-    BasicType t = FieldType::get_array_info(class_name(), &dimension,
+-                                            &object_key, CHECK_(NULL));
++    FieldArrayInfo fd;
++    BasicType t = FieldType::get_array_info(class_name, fd, CHECK_(NULL));
+     if (t != T_OBJECT) {
+       klass = Universe::typeArrayKlassObj(t);
+     } else {
+-      symbolHandle elem_name(THREAD, object_key);
+       MutexLocker mu(SystemDictionary_lock, THREAD);
+-      klass = constraints()->find_constrained_klass(elem_name, class_loader);
++      klass = constraints()->find_constrained_klass(fd.object_key(), class_loader);
+     }
+     // If element class already loaded, allocate array klass
+     if (klass != NULL) {
+-      klass = Klass::cast(klass)->array_klass_or_null(dimension);
++      klass = Klass::cast(klass)->array_klass_or_null(fd.dimension());
+     }
+   } else {
+     MutexLocker mu(SystemDictionary_lock, THREAD);
+@@ -2231,25 +2191,23 @@
+ }
+ 
+ 
+-bool SystemDictionary::add_loader_constraint(symbolHandle class_name,
++bool SystemDictionary::add_loader_constraint(Symbol* class_name,
+                                              Handle class_loader1,
+                                              Handle class_loader2,
+                                              Thread* THREAD) {
+-  symbolHandle constraint_name;
+-  if (!FieldType::is_array(class_name())) {
++  Symbol* constraint_name = NULL;
++  if (!FieldType::is_array(class_name)) {
+     constraint_name = class_name;
+   } else {
+     // For array classes, their klassOops are not kept in the
+     // constraint table. The element classes are.
+-    jint dimension;
+-    symbolOop object_key;
+-    BasicType t = FieldType::get_array_info(class_name(), &dimension,
+-                                            &object_key, CHECK_(false));
++    FieldArrayInfo fd;
++    BasicType t = FieldType::get_array_info(class_name, fd, CHECK_(false));
+     // primitive types always pass
+     if (t != T_OBJECT) {
+       return true;
+     } else {
+-      constraint_name = symbolHandle(THREAD, object_key);
++      constraint_name = fd.object_key();
+     }
+   }
+   unsigned int d_hash1 = dictionary()->compute_hash(constraint_name, class_loader1);
+@@ -2272,7 +2230,7 @@
+ 
+ // Add entry to resolution error table to record the error when the first
+ // attempt to resolve a reference to a class has failed.
+-void SystemDictionary::add_resolution_error(constantPoolHandle pool, int which, symbolHandle error) {
++void SystemDictionary::add_resolution_error(constantPoolHandle pool, int which, Symbol* error) {
+   unsigned int hash = resolution_errors()->compute_hash(pool, which);
+   int index = resolution_errors()->hash_to_index(hash);
+   {
+@@ -2282,13 +2240,13 @@
+ }
+ 
+ // Lookup resolution error table. Returns error if found, otherwise NULL.
+-symbolOop SystemDictionary::find_resolution_error(constantPoolHandle pool, int which) {
++Symbol* SystemDictionary::find_resolution_error(constantPoolHandle pool, int which) {
+   unsigned int hash = resolution_errors()->compute_hash(pool, which);
+   int index = resolution_errors()->hash_to_index(hash);
+   {
+     MutexLocker ml(SystemDictionary_lock, Thread::current());
+     ResolutionErrorEntry* entry = resolution_errors()->find_entry(index, hash, pool, which);
+-    return (entry != NULL) ? entry->error() : (symbolOop)NULL;
++    return (entry != NULL) ? entry->error() : (Symbol*)NULL;
+   }
+ }
+ 
+@@ -2344,7 +2302,7 @@
+ // NULL if no constraint failed. The returned C string needs cleaning up
+ // with a ResourceMark in the caller.  No exception except OOME is thrown.
+ // Arrays are not added to the loader constraint table, their elements are.
+-char* SystemDictionary::check_signature_loaders(symbolHandle signature,
++char* SystemDictionary::check_signature_loaders(Symbol* signature,
+                                                Handle loader1, Handle loader2,
+                                                bool is_method, TRAPS)  {
+   // Nothing to do if loaders are the same.
+@@ -2352,13 +2310,14 @@
+     return NULL;
+   }
+ 
++  ResourceMark rm(THREAD);
+   SignatureStream sig_strm(signature, is_method);
+   while (!sig_strm.is_done()) {
+     if (sig_strm.is_object()) {
+-      symbolOop s = sig_strm.as_symbol(CHECK_NULL);
+-      symbolHandle sig (THREAD, s);
++      Symbol* s = sig_strm.as_symbol(CHECK_NULL);
++      Symbol*  sig  = s;
+       if (!add_loader_constraint(sig, loader1, loader2, THREAD)) {
+-        return sig()->as_C_string();
++        return sig->as_C_string();
+       }
+     }
+     sig_strm.next();
+@@ -2367,12 +2326,12 @@
+ }
+ 
+ 
+-methodOop SystemDictionary::find_method_handle_invoke(symbolHandle name,
+-                                                      symbolHandle signature,
++methodOop SystemDictionary::find_method_handle_invoke(Symbol* name,
++                                                      Symbol* signature,
+                                                       KlassHandle accessing_klass,
+                                                       TRAPS) {
+   if (!EnableMethodHandles)  return NULL;
+-  vmSymbols::SID name_id = vmSymbols::find_sid(name());
++  vmSymbols::SID name_id = vmSymbols::find_sid(name);
+   assert(name_id != vmSymbols::NO_SID, "must be a known name");
+   unsigned int hash  = invoke_method_table()->compute_hash(signature, name_id);
+   int          index = invoke_method_table()->hash_to_index(hash);
+@@ -2385,7 +2344,7 @@
+       return NULL;              // do not attempt from within compiler
+     bool for_invokeGeneric = (name_id == vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name));
+     bool found_on_bcp = false;
+-    Handle mt = find_method_handle_type(signature(), accessing_klass,
++    Handle mt = find_method_handle_type(signature, accessing_klass,
+                                         for_invokeGeneric,
+                                         found_on_bcp, CHECK_NULL);
+     KlassHandle  mh_klass = SystemDictionaryHandles::MethodHandle_klass();
+@@ -2416,7 +2375,7 @@
+ // signature, as interpreted relative to the given class loader.
+ // Because of class loader constraints, all method handle usage must be
+ // consistent with this loader.
+-Handle SystemDictionary::find_method_handle_type(symbolHandle signature,
++Handle SystemDictionary::find_method_handle_type(Symbol* signature,
+                                                  KlassHandle accessing_klass,
+                                                  bool for_invokeGeneric,
+                                                  bool& return_bcp_flag,
+@@ -2424,11 +2383,12 @@
+   Handle class_loader, protection_domain;
+   bool is_on_bcp = true;  // keep this true as long as we can materialize from the boot classloader
+   Handle empty;
+-  int npts = ArgumentCount(signature()).size();
++  int npts = ArgumentCount(signature).size();
+   objArrayHandle pts = oopFactory::new_objArray(SystemDictionary::Class_klass(), npts, CHECK_(empty));
+   int arg = 0;
+   Handle rt;                            // the return type from the signature
+-  for (SignatureStream ss(signature()); !ss.is_done(); ss.next()) {
++  ResourceMark rm(THREAD);
++  for (SignatureStream ss(signature); !ss.is_done(); ss.next()) {
+     oop mirror = NULL;
+     if (is_on_bcp) {
+       mirror = ss.as_java_mirror(class_loader, protection_domain,
+@@ -2500,17 +2460,18 @@
+ Handle SystemDictionary::link_method_handle_constant(KlassHandle caller,
+                                                      int ref_kind, //e.g., JVM_REF_invokeVirtual
+                                                      KlassHandle callee,
+-                                                     symbolHandle name_sym,
+-                                                     symbolHandle signature,
++                                                     Symbol* name_sym,
++                                                     Symbol* signature,
+                                                      TRAPS) {
+   Handle empty;
+-  Handle name = java_lang_String::create_from_symbol(name_sym(), CHECK_(empty));
++  Handle name = java_lang_String::create_from_symbol(name_sym, CHECK_(empty));
+   Handle type;
+   if (signature->utf8_length() > 0 && signature->byte_at(0) == '(') {
+     bool ignore_is_on_bcp = false;
+     type = find_method_handle_type(signature, caller, false, ignore_is_on_bcp, CHECK_(empty));
+   } else {
+-    SignatureStream ss(signature(), false);
++    ResourceMark rm(THREAD);
++    SignatureStream ss(signature, false);
+     if (!ss.is_done()) {
+       oop mirror = ss.as_java_mirror(caller->class_loader(), caller->protection_domain(),
+                                      SignatureStream::NCDFError, CHECK_(empty));
+@@ -2542,7 +2503,7 @@
+ // Ask Java code to find or construct a java.dyn.CallSite for the given
+ // name and signature, as interpreted relative to the given class loader.
+ Handle SystemDictionary::make_dynamic_call_site(Handle bootstrap_method,
+-                                                symbolHandle name,
++                                                Symbol* name,
+                                                 methodHandle signature_invoker,
+                                                 Handle info,
+                                                 methodHandle caller_method,
+@@ -2557,7 +2518,7 @@
+   MethodHandles::init_MemberName(caller_mname(), caller_method());
+ 
+   // call sun.dyn.MethodHandleNatives::makeDynamicCallSite(bootm, name, mtype, info, caller_mname, caller_pos)
+-  oop name_str_oop = StringTable::intern(name(), CHECK_(empty)); // not a handle!
++  oop name_str_oop = StringTable::intern(name, CHECK_(empty)); // not a handle!
+   JavaCallArguments args(Handle(THREAD, bootstrap_method()));
+   args.push_oop(name_str_oop);
+   args.push_oop(signature_invoker->method_handle_type());
+@@ -2740,16 +2701,20 @@
+ 
+ 
+ void SystemDictionary::verify_obj_klass_present(Handle obj,
+-                                                symbolHandle class_name,
++                                                Symbol* class_name,
+                                                 Handle class_loader) {
+   GCMutexLocker mu(SystemDictionary_lock);
+-  oop probe = find_class_or_placeholder(class_name, class_loader);
++  Symbol* name;
++
++  klassOop probe = find_class(class_name, class_loader);
+   if (probe == NULL) {
+     probe = SystemDictionary::find_shared_class(class_name);
++    if (probe == NULL) {
++      name = find_placeholder(class_name, class_loader);
++    }
+   }
+-  guarantee(probe != NULL &&
+-            (!probe->is_klass() || probe == obj()),
+-                     "Loaded klasses should be in SystemDictionary");
++  guarantee(probe != NULL || name != NULL,
++            "Loaded klasses should be in SystemDictionary");
+ }
+ 
+ #ifndef PRODUCT
+diff --git a/src/share/vm/classfile/systemDictionary.hpp b/src/share/vm/classfile/systemDictionary.hpp
+--- openjdk/hotspot/src/share/vm/classfile/systemDictionary.hpp
++++ openjdk/hotspot/src/share/vm/classfile/systemDictionary.hpp
+@@ -28,14 +28,14 @@
+ #include "classfile/classFileStream.hpp"
+ #include "classfile/classLoader.hpp"
+ #include "oops/objArrayOop.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/java.hpp"
+ #include "runtime/reflectionUtils.hpp"
+ #include "utilities/hashtable.hpp"
+ 
+ // The system dictionary stores all loaded classes and maps:
+ //
+-//   [class name,class loader] -> class   i.e.  [symbolOop,oop] -> klassOop
++//   [class name,class loader] -> class   i.e.  [Symbol*,oop] -> klassOop
+ //
+ // Classes are loaded lazily. The default VM class loader is
+ // represented as NULL.
+@@ -226,26 +226,26 @@
+   // throw_error flag.  For most uses the throw_error argument should be set
+   // to true.
+ 
+-  static klassOop resolve_or_fail(symbolHandle class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
++  static klassOop resolve_or_fail(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, TRAPS);
+   // Convenient call for null loader and protection domain.
+-  static klassOop resolve_or_fail(symbolHandle class_name, bool throw_error, TRAPS);
++  static klassOop resolve_or_fail(Symbol* class_name, bool throw_error, TRAPS);
+ private:
+   // handle error translation for resolve_or_null results
+-  static klassOop handle_resolution_exception(symbolHandle class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS);
++  static klassOop handle_resolution_exception(Symbol* class_name, Handle class_loader, Handle protection_domain, bool throw_error, KlassHandle klass_h, TRAPS);
+ 
+ public:
+ 
+   // Returns a class with a given class name and class loader.
+   // Loads the class if needed. If not found NULL is returned.
+-  static klassOop resolve_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS);
++  static klassOop resolve_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
+   // Version with null loader and protection domain
+-  static klassOop resolve_or_null(symbolHandle class_name, TRAPS);
++  static klassOop resolve_or_null(Symbol* class_name, TRAPS);
+ 
+   // Resolve a superclass or superinterface. Called from ClassFileParser,
+   // parse_interfaces, resolve_instance_class_or_null, load_shared_class
+   // "child_name" is the class whose super class or interface is being resolved.
+-  static klassOop resolve_super_or_fail(symbolHandle child_name,
+-                                        symbolHandle class_name,
++  static klassOop resolve_super_or_fail(Symbol* child_name,
++                                        Symbol* class_name,
+                                         Handle class_loader,
+                                         Handle protection_domain,
+                                         bool is_superclass,
+@@ -253,7 +253,7 @@
+ 
+   // Parse new stream. This won't update the system dictionary or
+   // class hierarchy, simply parse the stream. Used by JVMTI RedefineClasses.
+-  static klassOop parse_stream(symbolHandle class_name,
++  static klassOop parse_stream(Symbol* class_name,
+                                Handle class_loader,
+                                Handle protection_domain,
+                                ClassFileStream* st,
+@@ -261,7 +261,7 @@
+     KlassHandle nullHandle;
+     return parse_stream(class_name, class_loader, protection_domain, st, nullHandle, NULL, THREAD);
+   }
+-  static klassOop parse_stream(symbolHandle class_name,
++  static klassOop parse_stream(Symbol* class_name,
+                                Handle class_loader,
+                                Handle protection_domain,
+                                ClassFileStream* st,
+@@ -270,23 +270,23 @@
+                                TRAPS);
+ 
+   // Resolve from stream (called by jni_DefineClass and JVM_DefineClass)
+-  static klassOop resolve_from_stream(symbolHandle class_name, Handle class_loader,
++  static klassOop resolve_from_stream(Symbol* class_name, Handle class_loader,
+                                       Handle protection_domain,
+                                       ClassFileStream* st, bool verify, TRAPS);
+ 
+   // Lookup an already loaded class. If not found NULL is returned.
+-  static klassOop find(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS);
++  static klassOop find(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
+ 
+   // Lookup an already loaded instance or array class.
+   // Do not make any queries to class loaders; consult only the cache.
+   // If not found NULL is returned.
+-  static klassOop find_instance_or_array_klass(symbolHandle class_name,
++  static klassOop find_instance_or_array_klass(Symbol* class_name,
+                                                Handle class_loader,
+                                                Handle protection_domain,
+                                                TRAPS);
+ 
+   // If the given name is known to vmSymbols, return the well-know klass:
+-  static klassOop find_well_known_klass(symbolOop class_name);
++  static klassOop find_well_known_klass(Symbol* class_name);
+ 
+   // Lookup an instance or array class that has already been loaded
+   // either into the given class loader, or else into another class
+@@ -309,7 +309,7 @@
+   // satisfied, and it is safe for classes in the given class loader
+   // to manipulate strongly-typed values of the found class, subject
+   // to local linkage and access checks.
+-  static klassOop find_constrained_instance_or_array_klass(symbolHandle class_name,
++  static klassOop find_constrained_instance_or_array_klass(Symbol* class_name,
+                                                            Handle class_loader,
+                                                            TRAPS);
+ 
+@@ -324,7 +324,7 @@
+   //   (added for helpers that use HandleMarks and ResourceMarks)
+   static void classes_do(void f(klassOop, oop, TRAPS), TRAPS);
+   // All entries in the placeholder table and their class loaders
+-  static void placeholders_do(void f(symbolOop, oop));
++  static void placeholders_do(void f(Symbol*, oop));
+ 
+   // Iterate over all methods in all klasses in dictionary
+   static void methods_do(void f(methodOop));
+@@ -383,12 +383,12 @@
+   static void verify();
+ 
+ #ifdef ASSERT
+-  static bool is_internal_format(symbolHandle class_name);
++  static bool is_internal_format(Symbol* class_name);
+ #endif
+ 
+   // Verify class is in dictionary
+   static void verify_obj_klass_present(Handle obj,
+-                                       symbolHandle class_name,
++                                       Symbol* class_name,
+                                        Handle class_loader);
+ 
+   // Initialization
+@@ -469,19 +469,19 @@
+   // Note:  java_lang_Class::primitive_type is the inverse of java_mirror
+ 
+   // Check class loader constraints
+-  static bool add_loader_constraint(symbolHandle name, Handle loader1,
++  static bool add_loader_constraint(Symbol* name, Handle loader1,
+                                     Handle loader2, TRAPS);
+-  static char* check_signature_loaders(symbolHandle signature, Handle loader1,
++  static char* check_signature_loaders(Symbol* signature, Handle loader1,
+                                        Handle loader2, bool is_method, TRAPS);
+ 
+   // JSR 292
+   // find the java.dyn.MethodHandles::invoke method for a given signature
+-  static methodOop find_method_handle_invoke(symbolHandle name,
+-                                             symbolHandle signature,
++  static methodOop find_method_handle_invoke(Symbol* name,
++                                             Symbol* signature,
+                                              KlassHandle accessing_klass,
+                                              TRAPS);
+   // ask Java to compute a java.dyn.MethodType object for a given signature
+-  static Handle    find_method_handle_type(symbolHandle signature,
++  static Handle    find_method_handle_type(Symbol* signature,
+                                            KlassHandle accessing_klass,
+                                            bool for_invokeGeneric,
+                                            bool& return_bcp_flag,
+@@ -490,13 +490,13 @@
+   static Handle    link_method_handle_constant(KlassHandle caller,
+                                                int ref_kind, //e.g., JVM_REF_invokeVirtual
+                                                KlassHandle callee,
+-                                               symbolHandle name,
+-                                               symbolHandle signature,
++                                               Symbol* name,
++                                               Symbol* signature,
+                                                TRAPS);
+   // ask Java to create a dynamic call site, while linking an invokedynamic op
+   static Handle    make_dynamic_call_site(Handle bootstrap_method,
+                                           // Callee information:
+-                                          symbolHandle name,
++                                          Symbol* name,
+                                           methodHandle signature_invoker,
+                                           Handle info,
+                                           // Caller information:
+@@ -519,8 +519,8 @@
+ 
+   // Record the error when the first attempt to resolve a reference from a constant
+   // pool entry to a class fails.
+-  static void add_resolution_error(constantPoolHandle pool, int which, symbolHandle error);
+-  static symbolOop find_resolution_error(constantPoolHandle pool, int which);
++  static void add_resolution_error(constantPoolHandle pool, int which, Symbol* error);
++  static Symbol* find_resolution_error(constantPoolHandle pool, int which);
+ 
+  private:
+ 
+@@ -580,29 +580,29 @@
+   static SymbolPropertyTable* invoke_method_table() { return _invoke_method_table; }
+ 
+   // Basic loading operations
+-  static klassOop resolve_instance_class_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS);
+-  static klassOop resolve_array_class_or_null(symbolHandle class_name, Handle class_loader, Handle protection_domain, TRAPS);
+-  static instanceKlassHandle handle_parallel_super_load(symbolHandle class_name, symbolHandle supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);
++  static klassOop resolve_instance_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
++  static klassOop resolve_array_class_or_null(Symbol* class_name, Handle class_loader, Handle protection_domain, TRAPS);
++  static instanceKlassHandle handle_parallel_super_load(Symbol* class_name, Symbol* supername, Handle class_loader, Handle protection_domain, Handle lockObject, TRAPS);
+   // Wait on SystemDictionary_lock; unlocks lockObject before
+   // waiting; relocks lockObject with correct recursion count
+   // after waiting, but before reentering SystemDictionary_lock
+   // to preserve lock order semantics.
+   static void double_lock_wait(Handle lockObject, TRAPS);
+   static void define_instance_class(instanceKlassHandle k, TRAPS);
+-  static instanceKlassHandle find_or_define_instance_class(symbolHandle class_name,
++  static instanceKlassHandle find_or_define_instance_class(Symbol* class_name,
+                                                 Handle class_loader,
+                                                 instanceKlassHandle k, TRAPS);
+-  static instanceKlassHandle load_shared_class(symbolHandle class_name,
++  static instanceKlassHandle load_shared_class(Symbol* class_name,
+                                                Handle class_loader, TRAPS);
+   static instanceKlassHandle load_shared_class(instanceKlassHandle ik,
+                                                Handle class_loader, TRAPS);
+-  static instanceKlassHandle load_instance_class(symbolHandle class_name, Handle class_loader, TRAPS);
++  static instanceKlassHandle load_instance_class(Symbol* class_name, Handle class_loader, TRAPS);
+   static Handle compute_loader_lock_object(Handle class_loader, TRAPS);
+   static void check_loader_lock_contention(Handle loader_lock, TRAPS);
+   static bool is_parallelCapable(Handle class_loader);
+   static bool is_parallelDefine(Handle class_loader);
+ 
+-  static klassOop find_shared_class(symbolHandle class_name);
++  static klassOop find_shared_class(Symbol* class_name);
+ 
+   // Setup link to hierarchy
+   static void add_to_hierarchy(instanceKlassHandle k, TRAPS);
+@@ -613,34 +613,29 @@
+ 
+   // Basic find on loaded classes
+   static klassOop find_class(int index, unsigned int hash,
+-                             symbolHandle name, Handle loader);
++                             Symbol* name, Handle loader);
++  static klassOop find_class(Symbol* class_name, Handle class_loader);
+ 
+   // Basic find on classes in the midst of being loaded
+-  static symbolOop find_placeholder(int index, unsigned int hash,
+-                                    symbolHandle name, Handle loader);
+-
+-  // Basic find operation of loaded classes and classes in the midst
+-  // of loading;  used for assertions and verification only.
+-  static oop find_class_or_placeholder(symbolHandle class_name,
+-                                       Handle class_loader);
++  static Symbol* find_placeholder(Symbol* name, Handle loader);
+ 
+   // Updating entry in dictionary
+   // Add a completely loaded class
+-  static void add_klass(int index, symbolHandle class_name,
++  static void add_klass(int index, Symbol* class_name,
+                         Handle class_loader, KlassHandle obj);
+ 
+   // Add a placeholder for a class being loaded
+   static void add_placeholder(int index,
+-                              symbolHandle class_name,
++                              Symbol* class_name,
+                               Handle class_loader);
+   static void remove_placeholder(int index,
+-                                 symbolHandle class_name,
++                                 Symbol* class_name,
+                                  Handle class_loader);
+ 
+   // Performs cleanups after resolve_super_or_fail. This typically needs
+   // to be called on failure.
+   // Won't throw, but can block.
+-  static void resolution_cleanups(symbolHandle class_name,
++  static void resolution_cleanups(Symbol* class_name,
+                                   Handle class_loader,
+                                   TRAPS);
+ 
+@@ -670,7 +665,6 @@
+   static bool _has_checkPackageAccess;
+ };
+ 
+-// Cf. vmSymbols vs. vmSymbolHandles
+ class SystemDictionaryHandles : AllStatic {
+ public:
+   #define WK_KLASS_HANDLE_DECLARE(name, ignore_symbol, option) \
+diff --git a/src/share/vm/classfile/verificationType.cpp b/src/share/vm/classfile/verificationType.cpp
+--- openjdk/hotspot/src/share/vm/classfile/verificationType.cpp
++++ openjdk/hotspot/src/share/vm/classfile/verificationType.cpp
+@@ -25,6 +25,7 @@
+ #include "precompiled.hpp"
+ #include "classfile/symbolTable.hpp"
+ #include "classfile/verificationType.hpp"
++#include "classfile/verifier.hpp"
+ 
+ VerificationType VerificationType::from_tag(u1 tag) {
+   switch (tag) {
+@@ -41,7 +42,8 @@
+ }
+ 
+ bool VerificationType::is_reference_assignable_from(
+-    const VerificationType& from, instanceKlassHandle context, TRAPS) const {
++    const VerificationType& from, ClassVerifier* context, TRAPS) const {
++  instanceKlassHandle klass = context->current_class();
+   if (from.is_null()) {
+     // null is assignable to any reference
+     return true;
+@@ -56,8 +58,8 @@
+       return true;
+     }
+     klassOop obj = SystemDictionary::resolve_or_fail(
+-        name_handle(), Handle(THREAD, context->class_loader()),
+-        Handle(THREAD, context->protection_domain()), true, CHECK_false);
++        name(), Handle(THREAD, klass->class_loader()),
++        Handle(THREAD, klass->protection_domain()), true, CHECK_false);
+     KlassHandle this_class(THREAD, obj);
+ 
+     if (this_class->is_interface()) {
+@@ -66,13 +68,13 @@
+       return true;
+     } else if (from.is_object()) {
+       klassOop from_class = SystemDictionary::resolve_or_fail(
+-          from.name_handle(), Handle(THREAD, context->class_loader()),
+-          Handle(THREAD, context->protection_domain()), true, CHECK_false);
++          from.name(), Handle(THREAD, klass->class_loader()),
++          Handle(THREAD, klass->protection_domain()), true, CHECK_false);
+       return instanceKlass::cast(from_class)->is_subclass_of(this_class());
+     }
+   } else if (is_array() && from.is_array()) {
+-    VerificationType comp_this = get_component(CHECK_false);
+-    VerificationType comp_from = from.get_component(CHECK_false);
++    VerificationType comp_this = get_component(context, CHECK_false);
++    VerificationType comp_from = from.get_component(context, CHECK_false);
+     if (!comp_this.is_bogus() && !comp_from.is_bogus()) {
+       return comp_this.is_assignable_from(comp_from, context, CHECK_false);
+     }
+@@ -80,9 +82,9 @@
+   return false;
+ }
+ 
+-VerificationType VerificationType::get_component(TRAPS) const {
++VerificationType VerificationType::get_component(ClassVerifier *context, TRAPS) const {
+   assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array");
+-  symbolOop component;
++  Symbol* component;
+   switch (name()->byte_at(1)) {
+     case 'Z': return VerificationType(Boolean);
+     case 'B': return VerificationType(Byte);
+@@ -93,12 +95,12 @@
+     case 'F': return VerificationType(Float);
+     case 'D': return VerificationType(Double);
+     case '[':
+-      component = SymbolTable::lookup(
++      component = context->create_temporary_symbol(
+         name(), 1, name()->utf8_length(),
+         CHECK_(VerificationType::bogus_type()));
+       return VerificationType::reference_type(component);
+     case 'L':
+-      component = SymbolTable::lookup(
++      component = context->create_temporary_symbol(
+         name(), 2, name()->utf8_length() - 1,
+         CHECK_(VerificationType::bogus_type()));
+       return VerificationType::reference_type(component);
+diff --git a/src/share/vm/classfile/verificationType.hpp b/src/share/vm/classfile/verificationType.hpp
+--- openjdk/hotspot/src/share/vm/classfile/verificationType.hpp
++++ openjdk/hotspot/src/share/vm/classfile/verificationType.hpp
+@@ -29,7 +29,7 @@
+ #include "memory/allocation.hpp"
+ #include "oops/instanceKlass.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/handles.hpp"
+ #include "runtime/signature.hpp"
+ 
+@@ -47,6 +47,8 @@
+   ITEM_Bogus = (uint)-1
+ };
+ 
++class ClassVerifier;
++
+ class VerificationType VALUE_OBJ_CLASS_SPEC {
+   private:
+     // Least significant bits of _handle are always 0, so we use these as
+@@ -56,7 +58,7 @@
+     // will catch this and we'll have to add a descriminator tag to this
+     // structure.
+     union {
+-      symbolOop* _handle;
++      Symbol*   _sym;
+       uintptr_t _data;
+     } _u;
+ 
+@@ -73,7 +75,7 @@
+       TypeMask           = 0x00000003,
+ 
+       // Topmost types encoding
+-      Reference          = 0x0,        // _handle contains the name
++      Reference          = 0x0,        // _sym contains the name
+       Primitive          = 0x1,        // see below for primitive list
+       Uninitialized      = 0x2,        // 0x00ffff00 contains bci
+       TypeQuery          = 0x3,        // Meta-types used for category testing
+@@ -85,7 +87,7 @@
+       Category2_2ndFlag  = 0x04,       // Second word of a two-word value
+ 
+       // special reference values
+-      Null               = 0x00000000, // A reference with a 0 handle is null
++      Null               = 0x00000000, // A reference with a 0 sym is null
+ 
+       // Primitives categories (the second byte determines the category)
+       Category1          = (Category1Flag     << 1 * BitsPerByte) | Primitive,
+@@ -152,17 +154,14 @@
+   static VerificationType category2_2nd_check()
+     { return VerificationType(Category2_2ndQuery); }
+ 
+-  // For reference types, store the actual oop* handle
+-  static VerificationType reference_type(symbolHandle sh) {
+-      assert(((uintptr_t)sh.raw_value() & 0x3) == 0, "Oops must be aligned");
++  // For reference types, store the actual Symbol
++  static VerificationType reference_type(Symbol* sh) {
++      assert(((uintptr_t)sh & 0x3) == 0, "Oops must be aligned");
+       // If the above assert fails in the future because oop* isn't aligned,
+       // then this type encoding system will have to change to have a tag value
+       // to descriminate between oops and primitives.
+-      return VerificationType((uintptr_t)((symbolOop*)sh.raw_value()));
++      return VerificationType((uintptr_t)sh);
+   }
+-  static VerificationType reference_type(symbolOop s, TRAPS)
+-    { return reference_type(symbolHandle(THREAD, s)); }
+-
+   static VerificationType uninitialized_type(u2 bci)
+     { return VerificationType(bci << 1 * BitsPerByte | Uninitialized); }
+   static VerificationType uninitialized_this_type()
+@@ -242,13 +241,9 @@
+     return ((_u._data & BciMask) >> 1 * BitsPerByte);
+   }
+ 
+-  symbolHandle name_handle() const {
++  Symbol* name() const {
+     assert(is_reference() && !is_null(), "Must be a non-null reference");
+-    return symbolHandle(_u._handle, true);
+-  }
+-  symbolOop name() const {
+-    assert(is_reference() && !is_null(), "Must be a non-null reference");
+-    return *(_u._handle);
++    return _u._sym;
+   }
+ 
+   bool equals(const VerificationType& t) const {
+@@ -269,7 +264,7 @@
+   // is assignable to another.  Returns true if one can assign 'from' to
+   // this.
+   bool is_assignable_from(
+-      const VerificationType& from, instanceKlassHandle context, TRAPS) const {
++      const VerificationType& from, ClassVerifier* context, TRAPS) const {
+     if (equals(from) || is_bogus()) {
+       return true;
+     } else {
+@@ -298,7 +293,7 @@
+     }
+   }
+ 
+-  VerificationType get_component(TRAPS) const;
++  VerificationType get_component(ClassVerifier* context, TRAPS) const;
+ 
+   int dimensions() const {
+     assert(is_array(), "Must be an array");
+@@ -312,7 +307,7 @@
+  private:
+ 
+   bool is_reference_assignable_from(
+-    const VerificationType&, instanceKlassHandle, TRAPS) const;
++    const VerificationType&, ClassVerifier*, TRAPS) const;
+ };
+ 
+ #endif // SHARE_VM_CLASSFILE_VERIFICATIONTYPE_HPP
+diff --git a/src/share/vm/classfile/verifier.cpp b/src/share/vm/classfile/verifier.cpp
+--- openjdk/hotspot/src/share/vm/classfile/verifier.cpp
++++ openjdk/hotspot/src/share/vm/classfile/verifier.cpp
+@@ -98,10 +98,10 @@
+ }
+ 
+ bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool should_verify_class, TRAPS) {
++  HandleMark hm;
+   ResourceMark rm(THREAD);
+-  HandleMark hm;
+ 
+-  symbolHandle exception_name;
++  Symbol* exception_name = NULL;
+   const size_t message_buffer_len = klass->name()->utf8_length() + 1024;
+   char* message_buffer = NEW_RESOURCE_ARRAY(char, message_buffer_len);
+ 
+@@ -141,7 +141,7 @@
+         tty->print("Verification for %s has", klassName);
+         tty->print_cr(" exception pending %s ",
+           instanceKlass::cast(PENDING_EXCEPTION->klass())->external_name());
+-      } else if (!exception_name.is_null()) {
++      } else if (exception_name != NULL) {
+         tty->print_cr("Verification for %s failed", klassName);
+       }
+       tty->print_cr("End class verification for: %s", klassName);
+@@ -150,7 +150,7 @@
+ 
+   if (HAS_PENDING_EXCEPTION) {
+     return false; // use the existing exception
+-  } else if (exception_name.is_null()) {
++  } else if (exception_name == NULL) {
+     return true; // verifcation succeeded
+   } else { // VerifyError or ClassFormatError to be created and thrown
+     ResourceMark rm(THREAD);
+@@ -172,7 +172,7 @@
+ }
+ 
+ bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) {
+-  symbolOop name = klass->name();
++  Symbol* name = klass->name();
+   klassOop refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass();
+ 
+   return (should_verify_for(klass->class_loader(), should_verify_class) &&
+@@ -202,7 +202,7 @@
+   );
+ }
+ 
+-symbolHandle Verifier::inference_verify(
++Symbol* Verifier::inference_verify(
+     instanceKlassHandle klass, char* message, size_t message_len, TRAPS) {
+   JavaThread* thread = (JavaThread*)THREAD;
+   JNIEnv *env = thread->jni_environment();
+@@ -245,18 +245,17 @@
+   // These numbers are chosen so that VerifyClassCodes interface doesn't need
+   // to be changed (still return jboolean (unsigned char)), and result is
+   // 1 when verification is passed.
+-  symbolHandle nh(NULL);
+   if (result == 0) {
+     return vmSymbols::java_lang_VerifyError();
+   } else if (result == 1) {
+-    return nh; // verified.
++    return NULL; // verified.
+   } else if (result == 2) {
+-    THROW_MSG_(vmSymbols::java_lang_OutOfMemoryError(), message, nh);
++    THROW_MSG_(vmSymbols::java_lang_OutOfMemoryError(), message, NULL);
+   } else if (result == 3) {
+     return vmSymbols::java_lang_ClassFormatError();
+   } else {
+     ShouldNotReachHere();
+-    return nh;
++    return NULL;
+   }
+ }
+ 
+@@ -266,12 +265,19 @@
+ 
+ ClassVerifier::ClassVerifier(
+     instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS)
+-    : _thread(THREAD), _exception_type(symbolHandle()), _message(msg),
++    : _thread(THREAD), _exception_type(NULL), _message(msg),
+       _message_buffer_len(msg_len), _klass(klass) {
+   _this_type = VerificationType::reference_type(klass->name());
++  // Create list to hold symbols in reference area.
++  _symbols = new GrowableArray<Symbol*>(100, 0, NULL);
+ }
+ 
+ ClassVerifier::~ClassVerifier() {
++  // Decrement the reference count for any symbols created.
++  for (int i = 0; i < _symbols->length(); i++) {
++    Symbol* s = _symbols->at(i);
++    s->decrement_refcount();
++  }
+ }
+ 
+ VerificationType ClassVerifier::object_type() const {
+@@ -308,7 +314,6 @@
+ }
+ 
+ void ClassVerifier::verify_method(methodHandle m, TRAPS) {
+-  ResourceMark rm(THREAD);
+   _method = m;   // initialize _method
+   if (_verify_verbose) {
+     tty->print_cr("Verifying method %s", m->name_and_sig_as_C_string());
+@@ -615,7 +620,7 @@
+               VerificationType::null_type(), CHECK_VERIFY(this));
+           } else {
+             VerificationType component =
+-              atype.get_component(CHECK_VERIFY(this));
++              atype.get_component(this, CHECK_VERIFY(this));
+             current_frame.push_stack(component, CHECK_VERIFY(this));
+           }
+           no_control_flow = false; break;
+@@ -1386,7 +1391,7 @@
+         VerificationType throwable =
+           VerificationType::reference_type(vmSymbols::java_lang_Throwable());
+         bool is_subclass = throwable.is_assignable_from(
+-          catch_type, current_class(), CHECK_VERIFY(this));
++          catch_type, this, CHECK_VERIFY(this));
+         if (!is_subclass) {
+           // 4286534: should throw VerifyError according to recent spec change
+           verify_error(
+@@ -1473,8 +1478,6 @@
+       if(bci >= start_pc && bci < end_pc) {
+         u1 flags = current_frame->flags();
+         if (this_uninit) {  flags |= FLAG_THIS_UNINIT; }
+-
+-        ResourceMark rm(THREAD);
+         StackMapFrame* new_frame = current_frame->frame_in_exception_handler(flags);
+         if (catch_type_index != 0) {
+           // We know that this index refers to a subclass of Throwable
+@@ -1575,7 +1578,7 @@
+   va_end(va);
+ }
+ 
+-klassOop ClassVerifier::load_class(symbolHandle name, TRAPS) {
++klassOop ClassVerifier::load_class(Symbol* name, TRAPS) {
+   // Get current loader and protection domain first.
+   oop loader = current_class()->class_loader();
+   oop protection_domain = current_class()->protection_domain();
+@@ -1587,8 +1590,8 @@
+ 
+ bool ClassVerifier::is_protected_access(instanceKlassHandle this_class,
+                                         klassOop target_class,
+-                                        symbolOop field_name,
+-                                        symbolOop field_sig,
++                                        Symbol* field_name,
++                                        Symbol* field_sig,
+                                         bool is_method) {
+   No_Safepoint_Verifier nosafepoint;
+ 
+@@ -1736,7 +1739,7 @@
+ }
+ 
+ bool ClassVerifier::name_in_supers(
+-    symbolOop ref_name, instanceKlassHandle current) {
++    Symbol* ref_name, instanceKlassHandle current) {
+   klassOop super = current->super();
+   while (super != NULL) {
+     if (super->klass_part()->name() == ref_name) {
+@@ -1755,8 +1758,8 @@
+   verify_cp_type(index, cp, 1 << JVM_CONSTANT_Fieldref, CHECK_VERIFY(this));
+ 
+   // Get field name and signature
+-  symbolHandle field_name = symbolHandle(THREAD, cp->name_ref_at(index));
+-  symbolHandle field_sig = symbolHandle(THREAD, cp->signature_ref_at(index));
++  Symbol* field_name = cp->name_ref_at(index);
++  Symbol* field_sig = cp->signature_ref_at(index);
+ 
+   if (!SignatureVerifier::is_valid_type_signature(field_sig)) {
+     class_format_error(
+@@ -1823,11 +1826,11 @@
+       fieldDescriptor fd;
+       if (stack_object_type == VerificationType::uninitialized_this_type() &&
+           target_class_type.equals(current_type()) &&
+-          _klass->find_local_field(field_name(), field_sig(), &fd)) {
++          _klass->find_local_field(field_name, field_sig, &fd)) {
+         stack_object_type = current_type();
+       }
+       is_assignable = target_class_type.is_assignable_from(
+-        stack_object_type, current_class(), CHECK_VERIFY(this));
++        stack_object_type, this, CHECK_VERIFY(this));
+       if (!is_assignable) {
+         verify_error(bci, "Bad type on operand stack in putfield");
+         return;
+@@ -1836,9 +1839,9 @@
+     check_protected: {
+       if (_this_type == stack_object_type)
+         break; // stack_object_type must be assignable to _current_class_type
+-      symbolHandle ref_class_name = symbolHandle(THREAD,
+-        cp->klass_name_at(cp->klass_ref_index_at(index)));
+-      if (!name_in_supers(ref_class_name(), current_class()))
++      Symbol* ref_class_name =
++        cp->klass_name_at(cp->klass_ref_index_at(index));
++      if (!name_in_supers(ref_class_name, current_class()))
+         // stack_object_type must be assignable to _current_class_type since:
+         // 1. stack_object_type must be assignable to ref_class.
+         // 2. ref_class must be _current_class or a subclass of it. It can't
+@@ -1846,12 +1849,12 @@
+         break;
+ 
+       klassOop ref_class_oop = load_class(ref_class_name, CHECK);
+-      if (is_protected_access(current_class(), ref_class_oop, field_name(),
+-                              field_sig(), false)) {
++      if (is_protected_access(current_class(), ref_class_oop, field_name,
++                              field_sig, false)) {
+         // It's protected access, check if stack object is assignable to
+         // current class.
+         is_assignable = current_type().is_assignable_from(
+-          stack_object_type, current_class(), CHECK_VERIFY(this));
++          stack_object_type, this, CHECK_VERIFY(this));
+         if (!is_assignable) {
+           verify_error(bci, "Bad access to protected data in getfield");
+           return;
+@@ -1911,7 +1914,7 @@
+       instanceKlassHandle mh(THREAD, m->method_holder());
+       if (m->is_protected() && !mh->is_same_class_package(_klass())) {
+         bool assignable = current_type().is_assignable_from(
+-          objectref_type, current_class(), CHECK_VERIFY(this));
++          objectref_type, this, CHECK_VERIFY(this));
+         if (!assignable) {
+           verify_error(bci, "Bad access to protected <init> method");
+           return;
+@@ -1941,8 +1944,8 @@
+   verify_cp_type(index, cp, types, CHECK_VERIFY(this));
+ 
+   // Get method name and signature
+-  symbolHandle method_name(THREAD, cp->name_ref_at(index));
+-  symbolHandle method_sig(THREAD, cp->signature_ref_at(index));
++  Symbol* method_name = cp->name_ref_at(index);
++  Symbol* method_sig = cp->signature_ref_at(index);
+ 
+   if (!SignatureVerifier::is_valid_method_signature(method_sig)) {
+     class_format_error(
+@@ -2035,7 +2038,7 @@
+   if (method_name->byte_at(0) == '<') {
+     // Make sure <init> can only be invoked by invokespecial
+     if (opcode != Bytecodes::_invokespecial ||
+-        method_name() != vmSymbols::object_initializer_name()) {
++        method_name != vmSymbols::object_initializer_name()) {
+       verify_error(bci, "Illegal call to internal method");
+       return;
+     }
+@@ -2044,7 +2047,7 @@
+              && !ref_class_type.equals(VerificationType::reference_type(
+                   current_class()->super()->klass_part()->name()))) {
+     bool subtype = ref_class_type.is_assignable_from(
+-      current_type(), current_class(), CHECK_VERIFY(this));
++      current_type(), this, CHECK_VERIFY(this));
+     if (!subtype) {
+       verify_error(bci, "Bad invokespecial instruction: "
+           "current class isn't assignable to reference class.");
+@@ -2058,7 +2061,7 @@
+   // Check objectref on operand stack
+   if (opcode != Bytecodes::_invokestatic &&
+       opcode != Bytecodes::_invokedynamic) {
+-    if (method_name() == vmSymbols::object_initializer_name()) {  // <init> method
++    if (method_name == vmSymbols::object_initializer_name()) {  // <init> method
+       verify_invoke_init(bcs, ref_class_type, current_frame,
+         code_length, this_uninit, cp, CHECK_VERIFY(this));
+     } else {   // other methods
+@@ -2070,22 +2073,22 @@
+           current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this));
+         if (current_type() != stack_object_type) {
+           assert(cp->cache() == NULL, "not rewritten yet");
+-          symbolHandle ref_class_name = symbolHandle(THREAD,
+-            cp->klass_name_at(cp->klass_ref_index_at(index)));
++          Symbol* ref_class_name =
++            cp->klass_name_at(cp->klass_ref_index_at(index));
+           // See the comments in verify_field_instructions() for
+           // the rationale behind this.
+-          if (name_in_supers(ref_class_name(), current_class())) {
++          if (name_in_supers(ref_class_name, current_class())) {
+             klassOop ref_class = load_class(ref_class_name, CHECK);
+             if (is_protected_access(
+-                  _klass, ref_class, method_name(), method_sig(), true)) {
++                  _klass, ref_class, method_name, method_sig, true)) {
+               // It's protected access, check if stack object is
+               // assignable to current class.
+               bool is_assignable = current_type().is_assignable_from(
+-                stack_object_type, current_class(), CHECK_VERIFY(this));
++                stack_object_type, this, CHECK_VERIFY(this));
+               if (!is_assignable) {
+                 if (ref_class_type.name() == vmSymbols::java_lang_Object()
+                     && stack_object_type.is_array()
+-                    && method_name() == vmSymbols::clone_name()) {
++                    && method_name == vmSymbols::clone_name()) {
+                   // Special case: arrays pretend to implement public Object
+                   // clone().
+                 } else {
+@@ -2105,7 +2108,7 @@
+   }
+   // Push the result type.
+   if (sig_stream.type() != T_VOID) {
+-    if (method_name() == vmSymbols::object_initializer_name()) {
++    if (method_name == vmSymbols::object_initializer_name()) {
+       // <init> method must have a void return type
+       verify_error(bci, "Return type must be void in <init> method");
+       return;
+@@ -2130,7 +2133,7 @@
+   }
+ 
+   // from_bt[index] contains the array signature which has a length of 2
+-  symbolHandle sig = oopFactory::new_symbol_handle(
++  Symbol* sig = create_temporary_symbol(
+     from_bt[index], 2, CHECK_(VerificationType::bogus_type()));
+   return VerificationType::reference_type(sig);
+ }
+@@ -2143,7 +2146,6 @@
+ 
+   VerificationType component_type =
+     cp_index_to_type(index, cp, CHECK_VERIFY(this));
+-  ResourceMark rm(THREAD);
+   int length;
+   char* arr_sig_str;
+   if (component_type.is_array()) {     // it's an array
+@@ -2163,7 +2165,7 @@
+     strncpy(&arr_sig_str[2], component_name, length - 2);
+     arr_sig_str[length - 1] = ';';
+   }
+-  symbolHandle arr_sig = oopFactory::new_symbol_handle(
++  Symbol* arr_sig = create_temporary_symbol(
+     arr_sig_str, length, CHECK_VERIFY(this));
+   VerificationType new_array_type = VerificationType::reference_type(arr_sig);
+   current_frame->push_stack(new_array_type, CHECK_VERIFY(this));
+@@ -2256,9 +2258,25 @@
+     verify_error(bci, "Method expects a return value");
+     return;
+   }
+-  bool match = return_type.is_assignable_from(type, _klass, CHECK_VERIFY(this));
++  bool match = return_type.is_assignable_from(type, this, CHECK_VERIFY(this));
+   if (!match) {
+     verify_error(bci, "Bad return type");
+     return;
+   }
+ }
++
++// The verifier creates symbols which are substrings of Symbols.
++// These are stored in the verifier until the end of verification so that
++// they can be reference counted.
++Symbol* ClassVerifier::create_temporary_symbol(const Symbol *s, int begin,
++                                               int end, TRAPS) {
++  Symbol* sym = SymbolTable::new_symbol(s, begin, end, CHECK_NULL);
++  _symbols->push(sym);
++  return sym;
++}
++
++Symbol* ClassVerifier::create_temporary_symbol(const char *s, int length, TRAPS) {
++  Symbol* sym = SymbolTable::new_symbol(s, length, CHECK_NULL);
++  _symbols->push(sym);
++  return sym;
++}
+diff --git a/src/share/vm/classfile/verifier.hpp b/src/share/vm/classfile/verifier.hpp
+--- openjdk/hotspot/src/share/vm/classfile/verifier.hpp
++++ openjdk/hotspot/src/share/vm/classfile/verifier.hpp
+@@ -59,7 +59,7 @@
+ 
+  private:
+   static bool is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class);
+-  static symbolHandle inference_verify(
++  static Symbol* inference_verify(
+     instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS);
+ };
+ 
+@@ -69,8 +69,8 @@
+ 
+ // Summary of verifier's memory usage:
+ // StackMapTable is stack allocated.
+-// StackMapFrame are resource allocated. There is one ResourceMark
+-// for each method.
++// StackMapFrame are resource allocated. There is only one ResourceMark
++// for each class verification, which is created at the top level.
+ // There is one mutable StackMapFrame (current_frame) which is updated
+ // by abstract bytecode interpretation. frame_in_exception_handler() returns
+ // a frame that has a mutable one-item stack (ready for pushing the
+@@ -80,8 +80,6 @@
+ // locals/stack arrays in StackMapFrame are resource allocated.
+ // locals/stack arrays can be shared between StackMapFrame's, except
+ // the mutable StackMapFrame (current_frame).
+-// Care needs to be taken to make sure resource objects don't outlive
+-// the lifetime of their ResourceMark.
+ 
+ // These macros are used similarly to CHECK macros but also check
+ // the status of the verifier and return if that has an error.
+@@ -94,9 +92,10 @@
+ class ClassVerifier : public StackObj {
+  private:
+   Thread* _thread;
+-  symbolHandle _exception_type;
++  Symbol* _exception_type;
+   char* _message;
+   size_t _message_buffer_len;
++  GrowableArray<Symbol*>* _symbols;  // keep a list of symbols created
+ 
+   void verify_method(methodHandle method, TRAPS);
+   char* generate_code_data(methodHandle m, u4 code_length, TRAPS);
+@@ -110,7 +109,7 @@
+ 
+   bool is_protected_access(
+     instanceKlassHandle this_class, klassOop target_class,
+-    symbolOop field_name, symbolOop field_sig, bool is_method);
++    Symbol* field_name, Symbol* field_sig, bool is_method);
+ 
+   void verify_cp_index(constantPoolHandle cp, int index, TRAPS);
+   void verify_cp_type(
+@@ -165,7 +164,7 @@
+   void verify_astore(u2 index, StackMapFrame* current_frame, TRAPS);
+   void verify_iinc  (u2 index, StackMapFrame* current_frame, TRAPS);
+ 
+-  bool name_in_supers(symbolOop ref_name, instanceKlassHandle current);
++  bool name_in_supers(Symbol* ref_name, instanceKlassHandle current);
+ 
+   VerificationType object_type() const;
+ 
+@@ -206,8 +205,8 @@
+   void verify_class(TRAPS);
+ 
+   // Return status modes
+-  symbolHandle result() const { return _exception_type; }
+-  bool has_error() const { return !(result().is_null()); }
++  Symbol* result() const { return _exception_type; }
++  bool has_error() const { return result() != NULL; }
+ 
+   // Called when verify or class format errors are encountered.
+   // May throw an exception based upon the mode.
+@@ -216,16 +215,22 @@
+   void class_format_error(const char* fmt, ...);
+   void format_error_message(const char* fmt, int offset, va_list args);
+ 
+-  klassOop load_class(symbolHandle name, TRAPS);
++  klassOop load_class(Symbol* name, TRAPS);
+ 
+   int change_sig_to_verificationType(
+     SignatureStream* sig_type, VerificationType* inference_type, TRAPS);
+ 
+   VerificationType cp_index_to_type(int index, constantPoolHandle cp, TRAPS) {
+-    return VerificationType::reference_type(
+-      symbolHandle(THREAD, cp->klass_name_at(index)));
++    return VerificationType::reference_type(cp->klass_name_at(index));
+   }
+ 
++  // Keep a list of temporary symbols created during verification because
++  // their reference counts need to be decrememented when the verifier object
++  // goes out of scope.  Since these symbols escape the scope in which they're
++  // created, we can't use a TempNewSymbol.
++  Symbol* create_temporary_symbol(const Symbol* s, int begin, int end, TRAPS);
++  Symbol* create_temporary_symbol(const char *s, int length, TRAPS);
++
+   static bool _verify_verbose;  // for debugging
+ };
+ 
+@@ -236,9 +241,14 @@
+     case T_OBJECT:
+     case T_ARRAY:
+       {
+-        symbolOop name = sig_type->as_symbol(CHECK_0);
++        Symbol* name = sig_type->as_symbol(CHECK_0);
++        // Create another symbol to save as signature stream unreferences
++        // this symbol.
++        Symbol* name_copy =
++          create_temporary_symbol(name, 0, name->utf8_length(), CHECK_0);
++        assert(name_copy == name, "symbols don't match");
+         *inference_type =
+-          VerificationType::reference_type(symbolHandle(THREAD, name));
++          VerificationType::reference_type(name_copy);
+         return 1;
+       }
+     case T_LONG:
+diff --git a/src/share/vm/classfile/vmSymbols.cpp b/src/share/vm/classfile/vmSymbols.cpp
+--- openjdk/hotspot/src/share/vm/classfile/vmSymbols.cpp
++++ openjdk/hotspot/src/share/vm/classfile/vmSymbols.cpp
+@@ -30,11 +30,11 @@
+ #include "utilities/xmlstream.hpp"
+ 
+ 
+-symbolOop vmSymbols::_symbols[vmSymbols::SID_LIMIT];
++Symbol* vmSymbols::_symbols[vmSymbols::SID_LIMIT];
+ 
+-symbolOop vmSymbols::_type_signatures[T_VOID+1] = { NULL /*, NULL...*/ };
++Symbol* vmSymbols::_type_signatures[T_VOID+1] = { NULL /*, NULL...*/ };
+ 
+-inline int compare_symbol(symbolOop a, symbolOop b) {
++inline int compare_symbol(Symbol* a, Symbol* b) {
+   if (a == b)  return 0;
+   // follow the natural address order:
+   return (address)a > (address)b ? +1 : -1;
+@@ -43,8 +43,8 @@
+ static vmSymbols::SID vm_symbol_index[vmSymbols::SID_LIMIT];
+ extern "C" {
+   static int compare_vmsymbol_sid(const void* void_a, const void* void_b) {
+-    symbolOop a = vmSymbols::symbol_at(*((vmSymbols::SID*) void_a));
+-    symbolOop b = vmSymbols::symbol_at(*((vmSymbols::SID*) void_b));
++    Symbol* a = vmSymbols::symbol_at(*((vmSymbols::SID*) void_a));
++    Symbol* b = vmSymbols::symbol_at(*((vmSymbols::SID*) void_b));
+     return compare_symbol(a, b);
+   }
+ }
+@@ -79,7 +79,7 @@
+   if (!UseSharedSpaces) {
+     const char* string = &vm_symbol_bodies[0];
+     for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
+-      symbolOop sym = oopFactory::new_symbol(string, CHECK);
++      Symbol* sym = SymbolTable::new_symbol(string, CHECK);
+       _symbols[index] = sym;
+       string += strlen(string); // skip string body
+       string += 1;              // skip trailing null
+@@ -100,7 +100,7 @@
+ #ifdef ASSERT
+   // Check for duplicates:
+   for (int i1 = (int)FIRST_SID; i1 < (int)SID_LIMIT; i1++) {
+-    symbolOop sym = symbol_at((SID)i1);
++    Symbol* sym = symbol_at((SID)i1);
+     for (int i2 = (int)FIRST_SID; i2 < i1; i2++) {
+       if (symbol_at((SID)i2) == sym) {
+         tty->print("*** Duplicate VM symbol SIDs %s(%d) and %s(%d): \"",
+@@ -128,16 +128,16 @@
+     // Spot-check correspondence between strings, symbols, and enums:
+     assert(_symbols[NO_SID] == NULL, "must be");
+     const char* str = "java/lang/Object";
+-    symbolOop sym = oopFactory::new_symbol(str, CHECK);
+-    assert(strcmp(str, (char*)sym->base()) == 0, "");
+-    assert(sym == java_lang_Object(), "");
++    TempNewSymbol jlo = SymbolTable::new_symbol(str, CHECK);
++    assert(strncmp(str, (char*)jlo->base(), jlo->utf8_length()) == 0, "");
++    assert(jlo == java_lang_Object(), "");
+     SID sid = VM_SYMBOL_ENUM_NAME(java_lang_Object);
+-    assert(find_sid(sym) == sid, "");
+-    assert(symbol_at(sid) == sym, "");
++    assert(find_sid(jlo) == sid, "");
++    assert(symbol_at(sid) == jlo, "");
+ 
+     // Make sure find_sid produces the right answer in each case.
+     for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
+-      sym = symbol_at((SID)index);
++      Symbol* sym = symbol_at((SID)index);
+       sid = find_sid(sym);
+       assert(sid == (SID)index, "symbol index works");
+       // Note:  If there are duplicates, this assert will fail.
+@@ -147,8 +147,8 @@
+     // The string "format" happens (at the moment) not to be a vmSymbol,
+     // though it is a method name in java.lang.String.
+     str = "format";
+-    sym = oopFactory::new_symbol(str, CHECK);
+-    sid = find_sid(sym);
++    TempNewSymbol fmt = SymbolTable::new_symbol(str, CHECK);
++    sid = find_sid(fmt);
+     assert(sid == NO_SID, "symbol index works (negative test)");
+   }
+ #endif
+@@ -172,22 +172,23 @@
+ 
+ 
+ 
+-void vmSymbols::oops_do(OopClosure* f, bool do_all) {
++void vmSymbols::symbols_do(SymbolClosure* f) {
+   for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
+-    f->do_oop((oop*) &_symbols[index]);
++    f->do_symbol(&_symbols[index]);
+   }
+   for (int i = 0; i < T_VOID+1; i++) {
+-    if (_type_signatures[i] != NULL) {
+-      assert(i >= T_BOOLEAN, "checking");
+-      f->do_oop((oop*)&_type_signatures[i]);
+-    } else if (do_all) {
+-      f->do_oop((oop*)&_type_signatures[i]);
+-    }
++    f->do_symbol(&_type_signatures[i]);
+   }
+ }
+ 
++void vmSymbols::serialize(SerializeOopClosure* soc) {
++  soc->do_region((u_char*)&_symbols[FIRST_SID],
++                 (SID_LIMIT - FIRST_SID) * sizeof(_symbols[0]));
++  soc->do_region((u_char*)_type_signatures, sizeof(_type_signatures));
++}
+ 
+-BasicType vmSymbols::signature_type(symbolOop s) {
++
++BasicType vmSymbols::signature_type(Symbol* s) {
+   assert(s != NULL, "checking");
+   for (int i = T_BOOLEAN; i < T_VOID+1; i++) {
+     if (s == _type_signatures[i]) {
+@@ -205,7 +206,7 @@
+ // (Typical counts are calls=7000 and probes=17000.)
+ #endif
+ 
+-vmSymbols::SID vmSymbols::find_sid(symbolOop symbol) {
++vmSymbols::SID vmSymbols::find_sid(Symbol* symbol) {
+   // Handle the majority of misses by a bounds check.
+   // Then, use a binary search over the index.
+   // Expected trip count is less than log2_SID_LIMIT, about eight.
+@@ -260,7 +261,7 @@
+     // (We have already proven that there are no duplicates in the list.)
+     SID sid2 = NO_SID;
+     for (int index = (int)FIRST_SID; index < (int)SID_LIMIT; index++) {
+-      symbolOop sym2 = symbol_at((SID)index);
++      Symbol* sym2 = symbol_at((SID)index);
+       if (sym2 == symbol) {
+         sid2 = (SID)index;
+         break;
+@@ -319,9 +320,9 @@
+ 
+ methodOop vmIntrinsics::method_for(vmIntrinsics::ID id) {
+   if (id == _none)  return NULL;
+-  symbolOop cname = vmSymbols::symbol_at(class_for(id));
+-  symbolOop mname = vmSymbols::symbol_at(name_for(id));
+-  symbolOop msig  = vmSymbols::symbol_at(signature_for(id));
++  Symbol* cname = vmSymbols::symbol_at(class_for(id));
++  Symbol* mname = vmSymbols::symbol_at(name_for(id));
++  Symbol* msig  = vmSymbols::symbol_at(signature_for(id));
+   if (cname == NULL || mname == NULL || msig == NULL)  return NULL;
+   klassOop k = SystemDictionary::find_well_known_klass(cname);
+   if (k == NULL)  return NULL;
+@@ -490,17 +491,17 @@
+ #ifndef PRODUCT
+ // verify_method performs an extra check on a matched intrinsic method
+ 
+-static bool match_method(methodOop m, symbolOop n, symbolOop s) {
++static bool match_method(methodOop m, Symbol* n, Symbol* s) {
+   return (m->name() == n &&
+           m->signature() == s);
+ }
+ 
+-static vmIntrinsics::ID match_method_with_klass(methodOop m, symbolOop mk) {
++static vmIntrinsics::ID match_method_with_klass(methodOop m, Symbol* mk) {
+ #define VM_INTRINSIC_MATCH(id, klassname, namepart, sigpart, flags) \
+-  { symbolOop k = vmSymbols::klassname(); \
++  { Symbol* k = vmSymbols::klassname(); \
+     if (mk == k) { \
+-      symbolOop n = vmSymbols::namepart(); \
+-      symbolOop s = vmSymbols::sigpart(); \
++      Symbol* n = vmSymbols::namepart(); \
++      Symbol* s = vmSymbols::sigpart(); \
+       if (match_method(m, n, s)) \
+         return vmIntrinsics::id; \
+     } }
+@@ -511,7 +512,7 @@
+ }
+ 
+ void vmIntrinsics::verify_method(ID actual_id, methodOop m) {
+-  symbolOop mk = Klass::cast(m->method_holder())->name();
++  Symbol* mk = Klass::cast(m->method_holder())->name();
+   ID declared_id = match_method_with_klass(m, mk);
+ 
+   if (declared_id == actual_id)  return; // success
+diff --git a/src/share/vm/classfile/vmSymbols.hpp b/src/share/vm/classfile/vmSymbols.hpp
+--- openjdk/hotspot/src/share/vm/classfile/vmSymbols.hpp
++++ openjdk/hotspot/src/share/vm/classfile/vmSymbols.hpp
+@@ -25,17 +25,15 @@
+ #ifndef SHARE_VM_CLASSFILE_VMSYMBOLS_HPP
+ #define SHARE_VM_CLASSFILE_VMSYMBOLS_HPP
+ 
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
++#include "memory/iterator.hpp"
+ 
+-// The classes vmSymbols and vmSymbolHandles are a name spaces for fast lookup of
+-// symbols commonly used in the VM. The first class return a symbolOop, while the
+-// second class returns a SymbolHandle. The underlying data structure is shared
+-// between the two classes.
++// The class vmSymbols is a name space for fast lookup of
++// symbols commonly used in the VM.
+ //
+ // Sample usage:
+ //
+-//   symbolOop obj       = vmSymbols::java_lang_Object()();
+-//   SymbolHandle handle = vmSymbolHandles::java_lang_Object();
++//   Symbol* obj       = vmSymbols::java_lang_Object();
+ 
+ 
+ // Useful sub-macros exported by this header file:
+@@ -461,7 +459,7 @@
+   VM_INTRINSICS_DO(VM_INTRINSIC_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, VM_SYMBOL_IGNORE, do_alias)           \
+                                                                                                                   \
+   /* returned by the C1 compiler in case there's not enough memory to allocate a new symbol*/                     \
+-  template(dummy_symbol_oop,                          "illegal symbol")                                           \
++  template(dummy_symbol,                              "illegal symbol")                                           \
+                                                                                                                   \
+   /* used by ClassFormatError when class name is not known yet */                                                 \
+   template(unknown_class_name,                        "<Unknown>")                                                \
+@@ -940,10 +938,9 @@
+ // Class vmSymbols
+ 
+ class vmSymbols: AllStatic {
+- friend class vmSymbolHandles;
+  friend class vmIntrinsics;
+  public:
+-  // enum for figuring positions and size of array holding symbolOops
++  // enum for figuring positions and size of array holding Symbol*s
+   enum SID {
+     NO_SID = 0,
+ 
+@@ -965,39 +962,42 @@
+ 
+  private:
+   // The symbol array
+-  static symbolOop _symbols[];
++  static Symbol* _symbols[];
+ 
+   // Field signatures indexed by BasicType.
+-  static symbolOop _type_signatures[T_VOID+1];
++  static Symbol* _type_signatures[T_VOID+1];
+ 
+  public:
+   // Initialization
+   static void initialize(TRAPS);
+   // Accessing
+-  #define VM_SYMBOL_DECLARE(name, ignore) \
+-    static symbolOop name() { return _symbols[VM_SYMBOL_ENUM_NAME(name)]; }
++  #define VM_SYMBOL_DECLARE(name, ignore)                 \
++    static Symbol* name() {                               \
++      return _symbols[VM_SYMBOL_ENUM_NAME(name)];         \
++    }
+   VM_SYMBOLS_DO(VM_SYMBOL_DECLARE, VM_SYMBOL_DECLARE)
+   #undef VM_SYMBOL_DECLARE
+ 
+-  // GC support
+-  static void oops_do(OopClosure* f, bool do_all = false);
++  // Sharing support
++  static void symbols_do(SymbolClosure* f);
++  static void serialize(SerializeOopClosure* soc);
+ 
+-  static symbolOop type_signature(BasicType t) {
++  static Symbol* type_signature(BasicType t) {
+     assert((uint)t < T_VOID+1, "range check");
+     assert(_type_signatures[t] != NULL, "domain check");
+     return _type_signatures[t];
+   }
+   // inverse of type_signature; returns T_OBJECT if s is not recognized
+-  static BasicType signature_type(symbolOop s);
++  static BasicType signature_type(Symbol* s);
+ 
+-  static symbolOop symbol_at(SID id) {
++  static Symbol* symbol_at(SID id) {
+     assert(id >= FIRST_SID && id < SID_LIMIT, "oob");
+     assert(_symbols[id] != NULL, "init");
+     return _symbols[id];
+   }
+ 
+   // Returns symbol's SID if one is assigned, else NO_SID.
+-  static SID find_sid(symbolOop symbol);
++  static SID find_sid(Symbol* symbol);
+ 
+ #ifndef PRODUCT
+   // No need for this in the product:
+@@ -1005,34 +1005,6 @@
+ #endif //PRODUCT
+ };
+ 
+-
+-// Class vmSymbolHandles
+-
+-class vmSymbolHandles: AllStatic {
+-  friend class vmIntrinsics;
+-  friend class ciObjectFactory;
+-
+- public:
+-  // Accessing
+-  #define VM_SYMBOL_HANDLE_DECLARE(name, ignore) \
+-    static symbolHandle name() { return symbol_handle_at(vmSymbols::VM_SYMBOL_ENUM_NAME(name)); }
+-  VM_SYMBOLS_DO(VM_SYMBOL_HANDLE_DECLARE, VM_SYMBOL_HANDLE_DECLARE)
+-  #undef VM_SYMBOL_HANDLE_DECLARE
+-
+-  static symbolHandle symbol_handle_at(vmSymbols::SID id) {
+-    return symbolHandle(&vmSymbols::_symbols[(int)id], false);
+-  }
+-
+-  static symbolHandle type_signature(BasicType t) {
+-    assert(vmSymbols::type_signature(t) != NULL, "domain check");
+-    return symbolHandle(&vmSymbols::_type_signatures[t], false);
+-  }
+-  // inverse of type_signature; returns T_OBJECT if s is not recognized
+-  static BasicType signature_type(symbolHandle s) {
+-    return vmSymbols::signature_type(s());
+-  }
+-};
+-
+ // VM Intrinsic ID's uniquely identify some very special methods
+ class vmIntrinsics: AllStatic {
+   friend class vmSymbols;
+diff --git a/src/share/vm/code/compiledIC.cpp b/src/share/vm/code/compiledIC.cpp
+--- openjdk/hotspot/src/share/vm/code/compiledIC.cpp
++++ openjdk/hotspot/src/share/vm/code/compiledIC.cpp
+@@ -34,7 +34,7 @@
+ #include "memory/oopFactory.hpp"
+ #include "oops/methodOop.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/icache.hpp"
+ #include "runtime/sharedRuntime.hpp"
+ #include "runtime/stubRoutines.hpp"
+diff --git a/src/share/vm/code/dependencies.cpp b/src/share/vm/code/dependencies.cpp
+--- openjdk/hotspot/src/share/vm/code/dependencies.cpp
++++ openjdk/hotspot/src/share/vm/code/dependencies.cpp
+@@ -628,8 +628,8 @@
+ 
+  private:
+   // optional method descriptor to check for:
+-  symbolOop _name;
+-  symbolOop _signature;
++  Symbol* _name;
++  Symbol* _signature;
+ 
+   // special classes which are not allowed to be witnesses:
+   klassOop  _participants[PARTICIPANT_LIMIT+1];
+diff --git a/src/share/vm/code/nmethod.cpp b/src/share/vm/code/nmethod.cpp
+--- openjdk/hotspot/src/share/vm/code/nmethod.cpp
++++ openjdk/hotspot/src/share/vm/code/nmethod.cpp
+@@ -57,9 +57,9 @@
+   {                                                                       \
+     methodOop m = (method);                                               \
+     if (m != NULL) {                                                      \
+-      symbolOop klass_name = m->klass_name();                             \
+-      symbolOop name = m->name();                                         \
+-      symbolOop signature = m->signature();                               \
++      Symbol* klass_name = m->klass_name();                               \
++      Symbol* name = m->name();                                           \
++      Symbol* signature = m->signature();                                 \
+       HS_DTRACE_PROBE6(hotspot, compiled__method__unload,                 \
+         klass_name->bytes(), klass_name->utf8_length(),                   \
+         name->bytes(), name->utf8_length(),                               \
+@@ -1868,7 +1868,7 @@
+     SimpleScopeDesc ssd(this, fr.pc());
+     Bytecode_invoke call(ssd.method(), ssd.bci());
+     bool has_receiver = call.has_receiver();
+-    symbolOop signature = call.signature();
++    Symbol* signature = call.signature();
+     fr.oops_compiled_arguments_do(signature, has_receiver, reg_map, f);
+   }
+ #endif // !SHARK
+@@ -2639,7 +2639,7 @@
+         } else {
+           bool did_name = false;
+           if (!at_this && ss.is_object()) {
+-            symbolOop name = ss.as_symbol_or_null();
++            Symbol* name = ss.as_symbol_or_null();
+             if (name != NULL) {
+               name->print_value_on(stream);
+               did_name = true;
+diff --git a/src/share/vm/compiler/compileBroker.cpp b/src/share/vm/compiler/compileBroker.cpp
+--- openjdk/hotspot/src/share/vm/compiler/compileBroker.cpp
++++ openjdk/hotspot/src/share/vm/compiler/compileBroker.cpp
+@@ -66,9 +66,9 @@
+ #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(compiler, method)              \
+   {                                                                      \
+     char* comp_name = (char*)(compiler)->name();                         \
+-    symbolOop klass_name = (method)->klass_name();                       \
+-    symbolOop name = (method)->name();                                   \
+-    symbolOop signature = (method)->signature();                         \
++    Symbol* klass_name = (method)->klass_name();                         \
++    Symbol* name = (method)->name();                                     \
++    Symbol* signature = (method)->signature();                           \
+     HS_DTRACE_PROBE8(hotspot, method__compile__begin,                    \
+       comp_name, strlen(comp_name),                                      \
+       klass_name->bytes(), klass_name->utf8_length(),                    \
+@@ -79,9 +79,9 @@
+ #define DTRACE_METHOD_COMPILE_END_PROBE(compiler, method, success)       \
+   {                                                                      \
+     char* comp_name = (char*)(compiler)->name();                         \
+-    symbolOop klass_name = (method)->klass_name();                       \
+-    symbolOop name = (method)->name();                                   \
+-    symbolOop signature = (method)->signature();                         \
++    Symbol* klass_name = (method)->klass_name();                         \
++    Symbol* name = (method)->name();                                     \
++    Symbol* signature = (method)->signature();                           \
+     HS_DTRACE_PROBE9(hotspot, method__compile__end,                      \
+       comp_name, strlen(comp_name),                                      \
+       klass_name->bytes(), klass_name->utf8_length(),                    \
+@@ -689,7 +689,7 @@
+   CompilerThread* compiler_thread = NULL;
+ 
+   klassOop k =
+-    SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_Thread(),
++    SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(),
+                                       true, CHECK_0);
+   instanceKlassHandle klass (THREAD, k);
+   instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_0);
+@@ -700,8 +700,8 @@
+   JavaValue result(T_VOID);
+   JavaCalls::call_special(&result, thread_oop,
+                        klass,
+-                       vmSymbolHandles::object_initializer_name(),
+-                       vmSymbolHandles::threadgroup_string_void_signature(),
++                       vmSymbols::object_initializer_name(),
++                       vmSymbols::threadgroup_string_void_signature(),
+                        thread_group,
+                        string,
+                        CHECK_0);
+diff --git a/src/share/vm/compiler/compileLog.hpp b/src/share/vm/compiler/compileLog.hpp
+--- openjdk/hotspot/src/share/vm/compiler/compileLog.hpp
++++ openjdk/hotspot/src/share/vm/compiler/compileLog.hpp
+@@ -63,7 +63,7 @@
+   stringStream* context()                        { return &_context; }
+ 
+   void          name(ciSymbol* s);               // name='s'
+-  void          name(symbolHandle s)             { xmlStream::name(s); }
++  void          name(Symbol* s)                  { xmlStream::name(s); }
+ 
+   // Output an object description, return obj->ident().
+   int           identify(ciObject* obj);
+diff --git a/src/share/vm/compiler/compilerOracle.cpp b/src/share/vm/compiler/compilerOracle.cpp
+--- openjdk/hotspot/src/share/vm/compiler/compilerOracle.cpp
++++ openjdk/hotspot/src/share/vm/compiler/compilerOracle.cpp
+@@ -30,7 +30,7 @@
+ #include "oops/klass.hpp"
+ #include "oops/methodOop.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/handles.inline.hpp"
+ #include "runtime/jniHandles.hpp"
+ 
+@@ -46,33 +46,33 @@
+   };
+ 
+  protected:
+-  jobject        _class_name;
++  Symbol*        _class_name;
++  Symbol*        _method_name;
++  Symbol*        _signature;
+   Mode           _class_mode;
+-  jobject        _method_name;
+   Mode           _method_mode;
+-  jobject        _signature;
+   MethodMatcher* _next;
+ 
+-  static bool match(symbolHandle candidate, symbolHandle match, Mode match_mode);
++  static bool match(Symbol* candidate, Symbol* match, Mode match_mode);
+ 
+-  symbolHandle class_name() const { return (symbolOop)JNIHandles::resolve_non_null(_class_name); }
+-  symbolHandle method_name() const { return (symbolOop)JNIHandles::resolve_non_null(_method_name); }
+-  symbolHandle signature() const { return (symbolOop)JNIHandles::resolve(_signature); }
++  Symbol* class_name() const { return _class_name; }
++  Symbol* method_name() const { return _method_name; }
++  Symbol* signature() const { return _signature; }
+ 
+  public:
+-  MethodMatcher(symbolHandle class_name, Mode class_mode,
+-                symbolHandle method_name, Mode method_mode,
+-                symbolHandle signature, MethodMatcher* next);
+-  MethodMatcher(symbolHandle class_name, symbolHandle method_name, MethodMatcher* next);
++  MethodMatcher(Symbol* class_name, Mode class_mode,
++                Symbol* method_name, Mode method_mode,
++                Symbol* signature, MethodMatcher* next);
++  MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next);
+ 
+   // utility method
+   MethodMatcher* find(methodHandle method) {
+-    symbolHandle class_name  = Klass::cast(method->method_holder())->name();
+-    symbolHandle method_name = method->name();
++    Symbol* class_name  = Klass::cast(method->method_holder())->name();
++    Symbol* method_name = method->name();
+     for (MethodMatcher* current = this; current != NULL; current = current->_next) {
+       if (match(class_name, current->class_name(), current->_class_mode) &&
+           match(method_name, current->method_name(), current->_method_mode) &&
+-          (current->signature().is_null() || current->signature()() == method->signature())) {
++          (current->signature() == NULL || current->signature() == method->signature())) {
+         return current;
+       }
+     }
+@@ -85,14 +85,14 @@
+ 
+   MethodMatcher* next() const { return _next; }
+ 
+-  static void print_symbol(symbolHandle h, Mode mode) {
++  static void print_symbol(Symbol* h, Mode mode) {
+     ResourceMark rm;
+ 
+     if (mode == Suffix || mode == Substring || mode == Any) {
+       tty->print("*");
+     }
+     if (mode != Any) {
+-      h()->print_symbol_on(tty);
++      h->print_symbol_on(tty);
+     }
+     if (mode == Prefix || mode == Substring) {
+       tty->print("*");
+@@ -103,7 +103,7 @@
+     print_symbol(class_name(), _class_mode);
+     tty->print(".");
+     print_symbol(method_name(), _method_mode);
+-    if (!signature().is_null()) {
++    if (signature() != NULL) {
+       tty->print(" ");
+       signature()->print_symbol_on(tty);
+     }
+@@ -115,9 +115,9 @@
+   }
+ };
+ 
+-MethodMatcher::MethodMatcher(symbolHandle class_name, symbolHandle method_name, MethodMatcher* next) {
+-  _class_name  = JNIHandles::make_global(class_name);
+-  _method_name = JNIHandles::make_global(method_name);
++MethodMatcher::MethodMatcher(Symbol* class_name, Symbol* method_name, MethodMatcher* next) {
++  _class_name  = class_name;
++  _method_name = method_name;
+   _next        = next;
+   _class_mode  = MethodMatcher::Exact;
+   _method_mode = MethodMatcher::Exact;
+@@ -125,24 +125,24 @@
+ }
+ 
+ 
+-MethodMatcher::MethodMatcher(symbolHandle class_name, Mode class_mode,
+-                             symbolHandle method_name, Mode method_mode,
+-                             symbolHandle signature, MethodMatcher* next):
++MethodMatcher::MethodMatcher(Symbol* class_name, Mode class_mode,
++                             Symbol* method_name, Mode method_mode,
++                             Symbol* signature, MethodMatcher* next):
+     _class_mode(class_mode)
+   , _method_mode(method_mode)
+   , _next(next)
+-  , _class_name(JNIHandles::make_global(class_name()))
+-  , _method_name(JNIHandles::make_global(method_name()))
+-  , _signature(JNIHandles::make_global(signature())) {
++  , _class_name(class_name)
++  , _method_name(method_name)
++  , _signature(signature) {
+ }
+ 
+-bool MethodMatcher::match(symbolHandle candidate, symbolHandle match, Mode match_mode) {
++bool MethodMatcher::match(Symbol* candidate, Symbol* match, Mode match_mode) {
+   if (match_mode == Any) {
+     return true;
+   }
+ 
+   if (match_mode == Exact) {
+-    return candidate() == match();
++    return candidate == match;
+   }
+ 
+   ResourceMark rm;
+@@ -171,9 +171,9 @@
+ class MethodOptionMatcher: public MethodMatcher {
+   const char * option;
+  public:
+-  MethodOptionMatcher(symbolHandle class_name, Mode class_mode,
+-                             symbolHandle method_name, Mode method_mode,
+-                             symbolHandle signature, const char * opt, MethodMatcher* next):
++  MethodOptionMatcher(Symbol* class_name, Mode class_mode,
++                             Symbol* method_name, Mode method_mode,
++                             Symbol* signature, const char * opt, MethodMatcher* next):
+     MethodMatcher(class_name, class_mode, method_name, method_mode, signature, next) {
+     option = opt;
+   }
+@@ -256,9 +256,9 @@
+ 
+ 
+ static MethodMatcher* add_predicate(OracleCommand command,
+-                                    symbolHandle class_name, MethodMatcher::Mode c_mode,
+-                                    symbolHandle method_name, MethodMatcher::Mode m_mode,
+-                                    symbolHandle signature) {
++                                    Symbol* class_name, MethodMatcher::Mode c_mode,
++                                    Symbol* method_name, MethodMatcher::Mode m_mode,
++                                    Symbol* signature) {
+   assert(command != OptionCommand, "must use add_option_string");
+   if (command == LogCommand && !LogCompilation && lists[LogCommand] == NULL)
+     tty->print_cr("Warning:  +LogCompilation must be enabled in order for individual methods to be logged.");
+@@ -268,9 +268,9 @@
+ 
+ 
+ 
+-static MethodMatcher* add_option_string(symbolHandle class_name, MethodMatcher::Mode c_mode,
+-                                        symbolHandle method_name, MethodMatcher::Mode m_mode,
+-                                        symbolHandle signature,
++static MethodMatcher* add_option_string(Symbol* class_name, MethodMatcher::Mode c_mode,
++                                        Symbol* method_name, MethodMatcher::Mode m_mode,
++                                        Symbol* signature,
+                                         const char* option) {
+   lists[OptionCommand] = new MethodOptionMatcher(class_name, c_mode, method_name, m_mode,
+                                                  signature, option, lists[OptionCommand]);
+@@ -497,9 +497,9 @@
+ 
+   if (scan_line(line, class_name, &c_match, method_name, &m_match, &bytes_read, error_msg)) {
+     EXCEPTION_MARK;
+-    symbolHandle c_name = oopFactory::new_symbol_handle(class_name, CHECK);
+-    symbolHandle m_name = oopFactory::new_symbol_handle(method_name, CHECK);
+-    symbolHandle signature;
++    Symbol* c_name = SymbolTable::new_symbol(class_name, CHECK);
++    Symbol* m_name = SymbolTable::new_symbol(method_name, CHECK);
++    Symbol* signature = NULL;
+ 
+     line += bytes_read;
+     // there might be a signature following the method.
+@@ -507,7 +507,7 @@
+     if (1 == sscanf(line, "%*[ \t](%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
+       sig[0] = '(';
+       line += bytes_read;
+-      signature = oopFactory::new_symbol_handle(sig, CHECK);
++      signature = SymbolTable::new_symbol(sig, CHECK);
+     }
+ 
+     if (command == OptionCommand) {
+@@ -727,9 +727,9 @@
+       }
+ 
+       EXCEPTION_MARK;
+-      symbolHandle c_name = oopFactory::new_symbol_handle(className, CHECK);
+-      symbolHandle m_name = oopFactory::new_symbol_handle(methodName, CHECK);
+-      symbolHandle signature;
++      Symbol* c_name = SymbolTable::new_symbol(className, CHECK);
++      Symbol* m_name = SymbolTable::new_symbol(methodName, CHECK);
++      Symbol* signature = NULL;
+ 
+       add_predicate(CompileOnlyCommand, c_name, c_match, m_name, m_match, signature);
+       if (PrintVMOptions) {
+diff --git a/src/share/vm/compiler/compilerOracle.hpp b/src/share/vm/compiler/compilerOracle.hpp
+--- openjdk/hotspot/src/share/vm/compiler/compilerOracle.hpp
++++ openjdk/hotspot/src/share/vm/compiler/compilerOracle.hpp
+@@ -31,8 +31,6 @@
+ // CompilerOracle is an interface for turning on and off compilation
+ // for some methods
+ 
+-class symbolHandle;
+-
+ class CompilerOracle : AllStatic {
+  private:
+   static bool _quiet;
+diff --git a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
+--- openjdk/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
++++ openjdk/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
+@@ -5921,9 +5921,10 @@
+ 
+     {
+       TraceTime t("scrub symbol & string tables", PrintGCDetails, false, gclog_or_tty);
+-      // Now clean up stale oops in SymbolTable and StringTable
+-      SymbolTable::unlink(&_is_alive_closure);
++      // Now clean up stale oops in StringTable
+       StringTable::unlink(&_is_alive_closure);
++      // Clean up unreferenced symbols in symbol table.
++      SymbolTable::unlink();
+     }
+   }
+ 
+diff --git a/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/src/share/vm/gc_implementation/g1/concurrentMark.cpp
+--- openjdk/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp
++++ openjdk/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp
+@@ -1944,9 +1944,10 @@
+   rp->verify_no_references_recorded();
+   assert(!rp->discovery_enabled(), "should have been disabled");
+ 
+-  // Now clean up stale oops in SymbolTable and StringTable
+-  SymbolTable::unlink(&g1_is_alive);
++  // Now clean up stale oops in StringTable
+   StringTable::unlink(&g1_is_alive);
++  // Clean up unreferenced symbols in symbol table.
++  SymbolTable::unlink();
+ }
+ 
+ void ConcurrentMark::swapMarkBitMaps() {
+diff --git a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp
+--- openjdk/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp
++++ openjdk/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp
+@@ -172,9 +172,10 @@
+   assert(GenMarkSweep::_marking_stack.is_empty(), "just drained");
+ 
+ 
+-  // Visit symbol and interned string tables and delete unmarked oops
+-  SymbolTable::unlink(&GenMarkSweep::is_alive);
++  // Visit interned string tables and delete unmarked oops
+   StringTable::unlink(&GenMarkSweep::is_alive);
++  // Clean up unreferenced symbols in symbol table.
++  SymbolTable::unlink();
+ 
+   assert(GenMarkSweep::_marking_stack.is_empty(),
+          "stack should be empty by now");
+diff --git a/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp b/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp
+--- openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp
++++ openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp
+@@ -116,10 +116,6 @@
+       SystemDictionary::always_strong_oops_do(&mark_and_push_closure);
+       break;
+ 
+-    case vm_symbols:
+-      vmSymbols::oops_do(&mark_and_push_closure);
+-      break;
+-
+     case code_cache:
+       // Do not treat nmethods as strong roots for mark/sweep, since we can unload them.
+       //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(&mark_and_push_closure));
+diff --git a/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp b/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp
+--- openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp
++++ openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/pcTasks.hpp
+@@ -98,9 +98,8 @@
+     management            = 6,
+     jvmti                 = 7,
+     system_dictionary     = 8,
+-    vm_symbols            = 9,
+-    reference_processing  = 10,
+-    code_cache            = 11
++    reference_processing  = 9,
++    code_cache            = 10
+   };
+  private:
+   RootType _root_type;
+diff --git a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp
+--- openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp
++++ openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp
+@@ -527,7 +527,6 @@
+     Management::oops_do(mark_and_push_closure());
+     JvmtiExport::oops_do(mark_and_push_closure());
+     SystemDictionary::always_strong_oops_do(mark_and_push_closure());
+-    vmSymbols::oops_do(mark_and_push_closure());
+     // Do not treat nmethods as strong roots for mark/sweep, since we can unload them.
+     //CodeCache::scavenge_root_nmethods_do(CodeBlobToOopClosure(mark_and_push_closure()));
+   }
+@@ -558,9 +557,10 @@
+   follow_mdo_weak_refs();
+   assert(_marking_stack.is_empty(), "just drained");
+ 
+-  // Visit symbol and interned string tables and delete unmarked oops
+-  SymbolTable::unlink(is_alive_closure());
++  // Visit interned string tables and delete unmarked oops
+   StringTable::unlink(is_alive_closure());
++  // Clean up unreferenced symbols in symbol table.
++  SymbolTable::unlink();
+ 
+   assert(_marking_stack.is_empty(), "stack should be empty by now");
+ }
+@@ -634,7 +634,6 @@
+   JvmtiExport::oops_do(adjust_root_pointer_closure());
+   // SO_AllClasses
+   SystemDictionary::oops_do(adjust_root_pointer_closure());
+-  vmSymbols::oops_do(adjust_root_pointer_closure());
+   //CodeCache::scavenge_root_nmethods_oops_do(adjust_root_pointer_closure());
+ 
+   // Now adjust pointers in remaining weak roots.  (All of which should
+@@ -643,7 +642,6 @@
+   JNIHandles::weak_oops_do(&always_true, adjust_root_pointer_closure());
+ 
+   CodeCache::oops_do(adjust_pointer_closure());
+-  SymbolTable::oops_do(adjust_root_pointer_closure());
+   StringTable::oops_do(adjust_root_pointer_closure());
+   ref_processor()->weak_oops_do(adjust_root_pointer_closure());
+   PSScavenge::reference_processor()->weak_oops_do(adjust_root_pointer_closure());
+diff --git a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
+--- openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
++++ openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
+@@ -2375,7 +2375,6 @@
+     q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::management));
+     q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::system_dictionary));
+     q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::jvmti));
+-    q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::vm_symbols));
+     q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::code_cache));
+ 
+     if (parallel_gc_threads > 1) {
+@@ -2425,9 +2424,10 @@
+   // Revisit memoized MDO's and clear any unmarked weak refs
+   follow_mdo_weak_refs();
+ 
+-  // Visit symbol and interned string tables and delete unmarked oops
+-  SymbolTable::unlink(is_alive_closure());
++  // Visit interned string tables and delete unmarked oops
+   StringTable::unlink(is_alive_closure());
++  // Clean up unreferenced symbols in symbol table.
++  SymbolTable::unlink();
+ 
+   assert(cm->marking_stacks_empty(), "marking stacks should be empty");
+ }
+@@ -2456,7 +2456,6 @@
+   JvmtiExport::oops_do(adjust_root_pointer_closure());
+   // SO_AllClasses
+   SystemDictionary::oops_do(adjust_root_pointer_closure());
+-  vmSymbols::oops_do(adjust_root_pointer_closure());
+ 
+   // Now adjust pointers in remaining weak roots.  (All of which should
+   // have been cleared if they pointed to non-surviving objects.)
+@@ -2464,7 +2463,6 @@
+   JNIHandles::weak_oops_do(&always_true, adjust_root_pointer_closure());
+ 
+   CodeCache::oops_do(adjust_pointer_closure());
+-  SymbolTable::oops_do(adjust_root_pointer_closure());
+   StringTable::oops_do(adjust_root_pointer_closure());
+   ref_processor()->weak_oops_do(adjust_root_pointer_closure());
+   // Roots were visited so references into the young gen in roots
+diff --git a/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp b/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp
+--- openjdk/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp
++++ openjdk/hotspot/src/share/vm/gc_implementation/shared/concurrentGCThread.cpp
+@@ -187,7 +187,7 @@
+ 
+ SurrogateLockerThread* SurrogateLockerThread::make(TRAPS) {
+   klassOop k =
+-    SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_Thread(),
++    SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(),
+                                       true, CHECK_NULL);
+   instanceKlassHandle klass (THREAD, k);
+   instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_NULL);
+@@ -200,8 +200,8 @@
+   JavaValue result(T_VOID);
+   JavaCalls::call_special(&result, thread_oop,
+                           klass,
+-                          vmSymbolHandles::object_initializer_name(),
+-                          vmSymbolHandles::threadgroup_string_void_signature(),
++                          vmSymbols::object_initializer_name(),
++                          vmSymbols::threadgroup_string_void_signature(),
+                           thread_group,
+                           string,
+                           CHECK_NULL);
+diff --git a/src/share/vm/gc_implementation/shared/markSweep.cpp b/src/share/vm/gc_implementation/shared/markSweep.cpp
+--- openjdk/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp
++++ openjdk/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp
+@@ -111,7 +111,7 @@
+ 
+ MarkSweep::MarkAndPushClosure MarkSweep::mark_and_push_closure;
+ 
+-void MarkSweep::MarkAndPushClosure::do_oop(oop* p)       { mark_and_push(p); }
++void MarkSweep::MarkAndPushClosure::do_oop(oop* p)       { assert(*p == NULL || (*p)->is_oop(), ""); mark_and_push(p); }
+ void MarkSweep::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(p); }
+ 
+ void MarkSweep::follow_stack() {
+diff --git a/src/share/vm/interpreter/bytecode.cpp b/src/share/vm/interpreter/bytecode.cpp
+--- openjdk/hotspot/src/share/vm/interpreter/bytecode.cpp
++++ openjdk/hotspot/src/share/vm/interpreter/bytecode.cpp
+@@ -124,21 +124,20 @@
+ }
+ 
+ 
+-symbolOop Bytecode_member_ref::signature() const {
++Symbol* Bytecode_member_ref::signature() const {
+   constantPoolOop constants = method()->constants();
+   return constants->signature_ref_at(index());
+ }
+ 
+ 
+-symbolOop Bytecode_member_ref::name() const {
++Symbol* Bytecode_member_ref::name() const {
+   constantPoolOop constants = method()->constants();
+   return constants->name_ref_at(index());
+ }
+ 
+ 
+-BasicType Bytecode_member_ref::result_type(Thread *thread) const {
+-  symbolHandle sh(thread, signature());
+-  ResultTypeFinder rts(sh);
++BasicType Bytecode_member_ref::result_type() const {
++  ResultTypeFinder rts(signature());
+   rts.iterate();
+   return rts.type();
+ }
+diff --git a/src/share/vm/interpreter/bytecode.hpp b/src/share/vm/interpreter/bytecode.hpp
+--- openjdk/hotspot/src/share/vm/interpreter/bytecode.hpp
++++ openjdk/hotspot/src/share/vm/interpreter/bytecode.hpp
+@@ -193,10 +193,10 @@
+  public:
+   int          index() const;                    // cache index (loaded from instruction)
+   int          pool_index() const;               // constant pool index
+-  symbolOop    name() const;                     // returns the name of the method or field
+-  symbolOop    signature() const;                // returns the signature of the method or field
++  Symbol*      name() const;                     // returns the name of the method or field
++  Symbol*      signature() const;                // returns the signature of the method or field
+ 
+-  BasicType    result_type(Thread* thread) const; // returns the result type of the getfield or invoke
++  BasicType    result_type() const;              // returns the result type of the getfield or invoke
+ };
+ 
+ // Abstraction for invoke_{virtual, static, interface, special}
+diff --git a/src/share/vm/interpreter/bytecodeTracer.cpp b/src/share/vm/interpreter/bytecodeTracer.cpp
+--- openjdk/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp
++++ openjdk/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp
+@@ -188,7 +188,7 @@
+   _closure->trace(method, bcp, st);
+ }
+ 
+-void print_symbol(symbolOop sym, outputStream* st) {
++void print_symbol(Symbol* sym, outputStream* st) {
+   char buf[40];
+   int len = sym->utf8_length();
+   if (len >= (int)sizeof(buf)) {
+@@ -205,10 +205,9 @@
+   } else if (java_lang_String::is_instance(value)) {
+     EXCEPTION_MARK;
+     Handle h_value (THREAD, value);
+-    symbolHandle sym = java_lang_String::as_symbol(h_value, CATCH);
+-    print_symbol(sym(), st);
+-  } else if (value->is_symbol()) {
+-    print_symbol(symbolOop(value), st);
++    Symbol* sym = java_lang_String::as_symbol(h_value, CATCH);
++    print_symbol(sym, st);
++    sym->decrement_refcount();
+   } else {
+     st->print_cr(" " PTR_FORMAT, (intptr_t) value);
+   }
+@@ -316,7 +315,7 @@
+   } else if (tag.is_method_type()) {
+     int i2 = constants->method_type_index_at(i);
+     st->print(" <MethodType> %d", i2);
+-    print_oop(constants->symbol_at(i2), st);
++    print_symbol(constants->symbol_at(i2), st);
+   } else if (tag.is_method_handle()) {
+     int kind = constants->method_handle_ref_kind_at(i);
+     int i2 = constants->method_handle_index_at(i);
+@@ -354,11 +353,11 @@
+     return;
+   }
+ 
+-  symbolOop name = constants->uncached_name_ref_at(i);
+-  symbolOop signature = constants->uncached_signature_ref_at(i);
++  Symbol* name = constants->uncached_name_ref_at(i);
++  Symbol* signature = constants->uncached_signature_ref_at(i);
+   const char* sep = (tag.is_field() ? "/" : "");
+   if (has_klass) {
+-    symbolOop klass = constants->klass_name_at(constants->uncached_klass_ref_index_at(i));
++    Symbol* klass = constants->klass_name_at(constants->uncached_klass_ref_index_at(i));
+     st->print_cr(" %d <%s.%s%s%s> ", i, klass->as_C_string(), name->as_C_string(), sep, signature->as_C_string());
+   } else {
+     if (tag.is_invoke_dynamic()) {
+@@ -438,7 +437,7 @@
+     case Bytecodes::_anewarray: {
+         int klass_index = get_index_u2();
+         constantPoolOop constants = method()->constants();
+-        symbolOop name = constants->klass_name_at(klass_index);
++        Symbol* name = constants->klass_name_at(klass_index);
+         st->print_cr(" %s ", name->as_C_string());
+       }
+       break;
+@@ -446,7 +445,7 @@
+         int klass_index = get_index_u2();
+         int nof_dims = get_index_u1();
+         constantPoolOop constants = method()->constants();
+-        symbolOop name = constants->klass_name_at(klass_index);
++        Symbol* name = constants->klass_name_at(klass_index);
+         st->print_cr(" %s %d", name->as_C_string(), nof_dims);
+       }
+       break;
+@@ -552,7 +551,7 @@
+     case Bytecodes::_instanceof:
+       { int i = get_index_u2();
+         constantPoolOop constants = method()->constants();
+-        symbolOop name = constants->klass_name_at(i);
++        Symbol* name = constants->klass_name_at(i);
+         st->print_cr(" %d <%s>", i, name->as_C_string());
+       }
+       break;
+diff --git a/src/share/vm/interpreter/interpreter.cpp b/src/share/vm/interpreter/interpreter.cpp
+--- openjdk/hotspot/src/share/vm/interpreter/interpreter.cpp
++++ openjdk/hotspot/src/share/vm/interpreter/interpreter.cpp
+@@ -302,7 +302,7 @@
+       Thread *thread = Thread::current();
+       ResourceMark rm(thread);
+       methodHandle mh(thread, method);
+-      type = Bytecode_invoke(mh, bci).result_type(thread);
++      type = Bytecode_invoke(mh, bci).result_type();
+       // since the cache entry might not be initialized:
+       // (NOT needed for the old calling convension)
+       if (!is_top_frame) {
+@@ -316,7 +316,7 @@
+       Thread *thread = Thread::current();
+       ResourceMark rm(thread);
+       methodHandle mh(thread, method);
+-      type = Bytecode_invoke(mh, bci).result_type(thread);
++      type = Bytecode_invoke(mh, bci).result_type();
+       // since the cache entry might not be initialized:
+       // (NOT needed for the old calling convension)
+       if (!is_top_frame) {
+diff --git a/src/share/vm/interpreter/interpreterRuntime.cpp b/src/share/vm/interpreter/interpreterRuntime.cpp
+--- openjdk/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
++++ openjdk/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
+@@ -39,7 +39,7 @@
+ #include "oops/methodDataOop.hpp"
+ #include "oops/objArrayKlass.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "prims/jvmtiExport.hpp"
+ #include "prims/nativeLookup.hpp"
+ #include "runtime/biasedLocking.hpp"
+@@ -295,7 +295,7 @@
+ 
+ IRT_ENTRY(void, InterpreterRuntime::create_exception(JavaThread* thread, char* name, char* message))
+   // lookup exception klass
+-  symbolHandle s = oopFactory::new_symbol_handle(name, CHECK);
++  TempNewSymbol s = SymbolTable::new_symbol(name, CHECK);
+   if (ProfileTraps) {
+     if (s == vmSymbols::java_lang_ArithmeticException()) {
+       note_trap(thread, Deoptimization::Reason_div0_check, CHECK);
+@@ -304,7 +304,7 @@
+     }
+   }
+   // create exception
+-  Handle exception = Exceptions::new_exception(thread, s(), message);
++  Handle exception = Exceptions::new_exception(thread, s, message);
+   thread->set_vm_result(exception());
+ IRT_END
+ 
+@@ -313,12 +313,12 @@
+   ResourceMark rm(thread);
+   const char* klass_name = Klass::cast(obj->klass())->external_name();
+   // lookup exception klass
+-  symbolHandle s = oopFactory::new_symbol_handle(name, CHECK);
++  TempNewSymbol s = SymbolTable::new_symbol(name, CHECK);
+   if (ProfileTraps) {
+     note_trap(thread, Deoptimization::Reason_class_check, CHECK);
+   }
+   // create exception, with klass name as detail message
+-  Handle exception = Exceptions::new_exception(thread, s(), klass_name);
++  Handle exception = Exceptions::new_exception(thread, s, klass_name);
+   thread->set_vm_result(exception());
+ IRT_END
+ 
+@@ -326,13 +326,13 @@
+ IRT_ENTRY(void, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException(JavaThread* thread, char* name, jint index))
+   char message[jintAsStringSize];
+   // lookup exception klass
+-  symbolHandle s = oopFactory::new_symbol_handle(name, CHECK);
++  TempNewSymbol s = SymbolTable::new_symbol(name, CHECK);
+   if (ProfileTraps) {
+     note_trap(thread, Deoptimization::Reason_range_check, CHECK);
+   }
+   // create exception
+   sprintf(message, "%d", index);
+-  THROW_MSG(s(), message);
++  THROW_MSG(s, message);
+ IRT_END
+ 
+ IRT_ENTRY(void, InterpreterRuntime::throw_ClassCastException(
+@@ -673,7 +673,7 @@
+     ResourceMark rm(thread);
+     methodHandle m (thread, method(thread));
+     Bytecode_invoke call(m, bci(thread));
+-    symbolHandle signature (thread, call.signature());
++    Symbol* signature = call.signature();
+     receiver = Handle(thread,
+                   thread->last_frame().interpreter_callee_receiver(signature));
+     assert(Universe::heap()->is_in_reserved_or_null(receiver()),
+@@ -797,7 +797,7 @@
+   if (!pool->cache()->secondary_entry_at(site_index)->is_f1_null())
+     return;
+ 
+-  symbolHandle call_site_name(THREAD, pool->name_ref_at(site_index));
++  Symbol*  call_site_name = pool->name_ref_at(site_index);
+ 
+   Handle call_site
+     = SystemDictionary::make_dynamic_call_site(bootm,
+diff --git a/src/share/vm/interpreter/linkResolver.cpp b/src/share/vm/interpreter/linkResolver.cpp
+--- openjdk/hotspot/src/share/vm/interpreter/linkResolver.cpp
++++ openjdk/hotspot/src/share/vm/interpreter/linkResolver.cpp
+@@ -56,7 +56,7 @@
+ //------------------------------------------------------------------------------------------------------------------------
+ // Implementation of FieldAccessInfo
+ 
+-void FieldAccessInfo::set(KlassHandle klass, symbolHandle name, int field_index, int field_offset,
++void FieldAccessInfo::set(KlassHandle klass, Symbol* name, int field_index, int field_offset,
+ BasicType field_type, AccessFlags access_flags) {
+   _klass        = klass;
+   _name         = name;
+@@ -148,7 +148,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_IllegalAccessError(),
++      vmSymbols::java_lang_IllegalAccessError(),
+       "tried to access class %s from class %s",
+       sel_klass->external_name(),
+       ref_klass->external_name()
+@@ -174,8 +174,8 @@
+ //
+ // According to JVM spec. $5.4.3c & $5.4.3d
+ 
+-void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
+-  methodOop result_oop = klass->uncached_lookup_method(name(), signature());
++void LinkResolver::lookup_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
++  methodOop result_oop = klass->uncached_lookup_method(name, signature);
+   if (EnableMethodHandles && result_oop != NULL) {
+     switch (result_oop->intrinsic_id()) {
+     case vmIntrinsics::_invokeExact:
+@@ -189,39 +189,39 @@
+ }
+ 
+ // returns first instance method
+-void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
+-  methodOop result_oop = klass->uncached_lookup_method(name(), signature());
++void LinkResolver::lookup_instance_method_in_klasses(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
++  methodOop result_oop = klass->uncached_lookup_method(name, signature);
+   result = methodHandle(THREAD, result_oop);
+   while (!result.is_null() && result->is_static()) {
+     klass = KlassHandle(THREAD, Klass::cast(result->method_holder())->super());
+-    result = methodHandle(THREAD, klass->uncached_lookup_method(name(), signature()));
++    result = methodHandle(THREAD, klass->uncached_lookup_method(name, signature));
+   }
+ }
+ 
+ 
+-int LinkResolver::vtable_index_of_miranda_method(KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
++int LinkResolver::vtable_index_of_miranda_method(KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
+   ResourceMark rm(THREAD);
+   klassVtable *vt = instanceKlass::cast(klass())->vtable();
+-  return vt->index_of_miranda(name(), signature());
++  return vt->index_of_miranda(name, signature);
+ }
+ 
+-void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
++void LinkResolver::lookup_method_in_interfaces(methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
+   instanceKlass *ik = instanceKlass::cast(klass());
+-  result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name(), signature()));
++  result = methodHandle(THREAD, ik->lookup_method_in_all_interfaces(name, signature));
+ }
+ 
+ void LinkResolver::lookup_implicit_method(methodHandle& result,
+-                                          KlassHandle klass, symbolHandle name, symbolHandle signature,
++                                          KlassHandle klass, Symbol* name, Symbol* signature,
+                                           KlassHandle current_klass,
+                                           TRAPS) {
+   if (EnableMethodHandles &&
+       klass() == SystemDictionary::MethodHandle_klass() &&
+-      methodOopDesc::is_method_handle_invoke_name(name())) {
++      methodOopDesc::is_method_handle_invoke_name(name)) {
+     if (!MethodHandles::enabled()) {
+       // Make sure the Java part of the runtime has been booted up.
+       klassOop natives = SystemDictionary::MethodHandleNatives_klass();
+       if (natives == NULL || instanceKlass::cast(natives)->is_not_initialized()) {
+-        SystemDictionary::resolve_or_fail(vmSymbolHandles::sun_dyn_MethodHandleNatives(),
++        SystemDictionary::resolve_or_fail(vmSymbols::sun_dyn_MethodHandleNatives(),
+                                           Handle(),
+                                           Handle(),
+                                           true,
+@@ -233,7 +233,7 @@
+                                                                        current_klass,
+                                                                        CHECK);
+     if (result_oop != NULL) {
+-      assert(result_oop->is_method_handle_invoke() && result_oop->signature() == signature(), "consistent");
++      assert(result_oop->is_method_handle_invoke() && result_oop->signature() == signature, "consistent");
+       result = methodHandle(THREAD, result_oop);
+     }
+   }
+@@ -273,7 +273,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_IllegalAccessError(),
++      vmSymbols::java_lang_IllegalAccessError(),
+       "tried to access method %s.%s%s from class %s",
+       sel_klass->external_name(),
+       sel_method->name()->as_C_string(),
+@@ -290,8 +290,8 @@
+   // resolve klass
+   resolve_klass(resolved_klass, pool, index, CHECK);
+ 
+-  symbolHandle method_name      (THREAD, pool->name_ref_at(index));
+-  symbolHandle method_signature (THREAD, pool->signature_ref_at(index));
++  Symbol*  method_name       = pool->name_ref_at(index);
++  Symbol*  method_signature  = pool->signature_ref_at(index);
+   KlassHandle  current_klass(THREAD, pool->pool_holder());
+ 
+   resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
+@@ -301,9 +301,9 @@
+   // The class is java.dyn.MethodHandle
+   resolved_klass = SystemDictionaryHandles::MethodHandle_klass();
+ 
+-  symbolHandle method_name = vmSymbolHandles::invokeExact_name();
++  Symbol* method_name = vmSymbols::invokeExact_name();
+ 
+-  symbolHandle method_signature(THREAD, pool->signature_ref_at(index));
++  Symbol*  method_signature = pool->signature_ref_at(index);
+   KlassHandle  current_klass   (THREAD, pool->pool_holder());
+ 
+   resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
+@@ -313,8 +313,8 @@
+ 
+   // resolve klass
+   resolve_klass(resolved_klass, pool, index, CHECK);
+-  symbolHandle method_name      (THREAD, pool->name_ref_at(index));
+-  symbolHandle method_signature (THREAD, pool->signature_ref_at(index));
++  Symbol*  method_name       = pool->name_ref_at(index);
++  Symbol*  method_signature  = pool->signature_ref_at(index);
+   KlassHandle  current_klass(THREAD, pool->pool_holder());
+ 
+   resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
+@@ -322,7 +322,7 @@
+ 
+ 
+ void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle resolved_klass,
+-                                  symbolHandle method_name, symbolHandle method_signature,
++                                  Symbol* method_name, Symbol* method_signature,
+                                   KlassHandle current_klass, bool check_access, TRAPS) {
+ 
+   // 1. check if klass is not interface
+@@ -349,8 +349,8 @@
+       ResourceMark rm(THREAD);
+       THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(),
+                 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+-                                                        method_name(),
+-                                                        method_signature()));
++                                                        method_name,
++                                                        method_signature));
+     }
+   }
+ 
+@@ -359,8 +359,8 @@
+     ResourceMark rm(THREAD);
+     THROW_MSG(vmSymbols::java_lang_AbstractMethodError(),
+               methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+-                                                      method_name(),
+-                                                      method_signature()));
++                                                      method_name,
++                                                      method_signature));
+   }
+ 
+   // 6. access checks, access checking may be turned off when calling from within the VM.
+@@ -387,7 +387,7 @@
+           " \"%s\" the class loader (instance of %s) of the current class, %s,"
+           " and the class loader (instance of %s) for resolved class, %s, have"
+           " different Class objects for the type %s used in the signature";
+-        char* sig = methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name(),method_signature());
++        char* sig = methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name,method_signature);
+         const char* loader1 = SystemDictionary::loader_name(loader());
+         char* current = instanceKlass::cast(current_klass())->name()->as_C_string();
+         const char* loader2 = SystemDictionary::loader_name(class_loader());
+@@ -406,8 +406,8 @@
+ 
+ void LinkResolver::resolve_interface_method(methodHandle& resolved_method,
+                                             KlassHandle resolved_klass,
+-                                            symbolHandle method_name,
+-                                            symbolHandle method_signature,
++                                            Symbol* method_name,
++                                            Symbol* method_signature,
+                                             KlassHandle current_klass,
+                                             bool check_access, TRAPS) {
+ 
+@@ -429,8 +429,8 @@
+       ResourceMark rm(THREAD);
+       THROW_MSG(vmSymbols::java_lang_NoSuchMethodError(),
+                 methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),
+-                                                        method_name(),
+-                                                        method_signature()));
++                                                        method_name,
++                                                        method_signature));
+     }
+   }
+ 
+@@ -449,7 +449,7 @@
+           "current class, %s, and the class loader (instance of %s) for "
+           "resolved class, %s, have different Class objects for the type %s "
+           "used in the signature";
+-        char* sig = methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name(),method_signature());
++        char* sig = methodOopDesc::name_and_sig_as_C_string(Klass::cast(resolved_klass()),method_name,method_signature);
+         const char* loader1 = SystemDictionary::loader_name(loader());
+         char* current = instanceKlass::cast(current_klass())->name()->as_C_string();
+         const char* loader2 = SystemDictionary::loader_name(class_loader());
+@@ -482,7 +482,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_IllegalAccessError(),
++      vmSymbols::java_lang_IllegalAccessError(),
+       "tried to access field %s.%s from class %s",
+       sel_klass->external_name(),
+       fd.name()->as_C_string(),
+@@ -511,9 +511,8 @@
+     resolve_klass_no_update(resolved_klass, pool, index, CHECK);
+   }
+   // Load these early in case the resolve of the containing klass fails
+-  symbolOop field = pool->name_ref_at(index);
+-  symbolHandle field_h (THREAD, field); // preserve in case we need the name
+-  symbolOop sig   = pool->signature_ref_at(index);
++  Symbol* field = pool->name_ref_at(index);
++  Symbol* sig   = pool->signature_ref_at(index);
+   // Check if there's a resolved klass containing the field
+   if( resolved_klass.is_null() ) {
+     ResourceMark rm(THREAD);
+@@ -559,7 +558,7 @@
+     HandleMark hm(THREAD);
+     Handle ref_loader (THREAD, instanceKlass::cast(ref_klass())->class_loader());
+     Handle sel_loader (THREAD, instanceKlass::cast(sel_klass())->class_loader());
+-    symbolHandle signature_ref (THREAD, pool->signature_ref_at(index));
++    Symbol*  signature_ref  = pool->signature_ref_at(index);
+     {
+       ResourceMark rm(THREAD);
+       char* failed_type_name =
+@@ -572,7 +571,7 @@
+           " \"%s\" the class loader (instance of %s) of the referring class, "
+           "%s, and the class loader (instance of %s) for the field's resolved "
+           "type, %s, have different Class objects for that type";
+-        char* field_name = field_h()->as_C_string();
++        char* field_name = field->as_C_string();
+         const char* loader1 = SystemDictionary::loader_name(ref_loader());
+         char* sel = instanceKlass::cast(sel_klass())->name()->as_C_string();
+         const char* loader2 = SystemDictionary::loader_name(sel_loader());
+@@ -589,7 +588,7 @@
+   // return information. note that the klass is set to the actual klass containing the
+   // field, otherwise access of static fields in superclasses will not work.
+   KlassHandle holder (THREAD, fd.field_holder());
+-  symbolHandle name  (THREAD, fd.name());
++  Symbol*  name   = fd.name();
+   result.set(holder, name, fd.index(), fd.offset(), fd.field_type(), fd.access_flags());
+ }
+ 
+@@ -605,8 +604,8 @@
+ // recv_klass         the receiver klass
+ 
+ 
+-void LinkResolver::resolve_static_call(CallInfo& result, KlassHandle& resolved_klass, symbolHandle method_name,
+-                                       symbolHandle method_signature, KlassHandle current_klass,
++void LinkResolver::resolve_static_call(CallInfo& result, KlassHandle& resolved_klass, Symbol* method_name,
++                                       Symbol* method_signature, KlassHandle current_klass,
+                                        bool check_access, bool initialize_class, TRAPS) {
+   methodHandle resolved_method;
+   linktime_resolve_static_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
+@@ -624,7 +623,7 @@
+ 
+ // throws linktime exceptions
+ void LinkResolver::linktime_resolve_static_method(methodHandle& resolved_method, KlassHandle resolved_klass,
+-                                                  symbolHandle method_name, symbolHandle method_signature,
++                                                  Symbol* method_name, Symbol* method_signature,
+                                                   KlassHandle current_klass, bool check_access, TRAPS) {
+ 
+   resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
+@@ -641,8 +640,8 @@
+ }
+ 
+ 
+-void LinkResolver::resolve_special_call(CallInfo& result, KlassHandle resolved_klass, symbolHandle method_name,
+-                                        symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
++void LinkResolver::resolve_special_call(CallInfo& result, KlassHandle resolved_klass, Symbol* method_name,
++                                        Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
+   methodHandle resolved_method;
+   linktime_resolve_special_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
+   runtime_resolve_special_method(result, resolved_method, resolved_klass, current_klass, check_access, CHECK);
+@@ -650,7 +649,7 @@
+ 
+ // throws linktime exceptions
+ void LinkResolver::linktime_resolve_special_method(methodHandle& resolved_method, KlassHandle resolved_klass,
+-                                                   symbolHandle method_name, symbolHandle method_signature,
++                                                   Symbol* method_name, Symbol* method_signature,
+                                                    KlassHandle current_klass, bool check_access, TRAPS) {
+ 
+   resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
+@@ -661,7 +660,7 @@
+     ResourceMark rm(THREAD);
+     Exceptions::fthrow(
+       THREAD_AND_LOCATION,
+-      vmSymbolHandles::java_lang_NoSuchMethodError(),
++      vmSymbols::java_lang_NoSuchMethodError(),
+       "%s: method %s%s not found",
+       resolved_klass->external_name(),
+       resolved_method->name()->as_C_string(),
+@@ -703,8 +702,8 @@
+       // Lookup super method
+       KlassHandle super_klass(THREAD, current_klass->super());
+       lookup_instance_method_in_klasses(sel_method, super_klass,
+-                           symbolHandle(THREAD, resolved_method->name()),
+-                           symbolHandle(THREAD, resolved_method->signature()), CHECK);
++                           resolved_method->name(),
++                           resolved_method->signature(), CHECK);
+       // check if found
+       if (sel_method.is_null()) {
+         ResourceMark rm(THREAD);
+@@ -739,7 +738,7 @@
+ }
+ 
+ void LinkResolver::resolve_virtual_call(CallInfo& result, Handle recv, KlassHandle receiver_klass, KlassHandle resolved_klass,
+-                                        symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass,
++                                        Symbol* method_name, Symbol* method_signature, KlassHandle current_klass,
+                                         bool check_access, bool check_null_and_abstract, TRAPS) {
+   methodHandle resolved_method;
+   linktime_resolve_virtual_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
+@@ -748,7 +747,7 @@
+ 
+ // throws linktime exceptions
+ void LinkResolver::linktime_resolve_virtual_method(methodHandle &resolved_method, KlassHandle resolved_klass,
+-                                                   symbolHandle method_name, symbolHandle method_signature,
++                                                   Symbol* method_name, Symbol* method_signature,
+                                                    KlassHandle current_klass, bool check_access, TRAPS) {
+   // normal method resolution
+   resolve_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
+@@ -798,8 +797,8 @@
+   // do lookup based on receiver klass using the vtable index
+   if (resolved_method->method_holder()->klass_part()->is_interface()) { // miranda method
+     vtable_index = vtable_index_of_miranda_method(resolved_klass,
+-                           symbolHandle(THREAD, resolved_method->name()),
+-                           symbolHandle(THREAD, resolved_method->signature()), CHECK);
++                           resolved_method->name(),
++                           resolved_method->signature(), CHECK);
+     assert(vtable_index >= 0 , "we should have valid vtable index at this point");
+ 
+     instanceKlass* inst = instanceKlass::cast(recv_klass());
+@@ -847,7 +846,7 @@
+ }
+ 
+ void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass,
+-                                          symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass,
++                                          Symbol* method_name, Symbol* method_signature, KlassHandle current_klass,
+                                           bool check_access, bool check_null_and_abstract, TRAPS) {
+   methodHandle resolved_method;
+   linktime_resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
+@@ -855,8 +854,8 @@
+ }
+ 
+ // throws linktime exceptions
+-void LinkResolver::linktime_resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, symbolHandle method_name,
+-                                                     symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
++void LinkResolver::linktime_resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name,
++                                                     Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS) {
+   // normal interface method resolution
+   resolve_interface_method(resolved_method, resolved_klass, method_name, method_signature, current_klass, check_access, CHECK);
+ 
+@@ -883,8 +882,8 @@
+   // do lookup based on receiver klass
+   methodHandle sel_method;
+   lookup_instance_method_in_klasses(sel_method, recv_klass,
+-            symbolHandle(THREAD, resolved_method->name()),
+-            symbolHandle(THREAD, resolved_method->signature()), CHECK);
++            resolved_method->name(),
++            resolved_method->signature(), CHECK);
+   // check if method exists
+   if (sel_method.is_null()) {
+     ResourceMark rm(THREAD);
+@@ -916,8 +915,8 @@
+ 
+ methodHandle LinkResolver::linktime_resolve_interface_method_or_null(
+                                                  KlassHandle resolved_klass,
+-                                                 symbolHandle method_name,
+-                                                 symbolHandle method_signature,
++                                                 Symbol* method_name,
++                                                 Symbol* method_signature,
+                                                  KlassHandle current_klass,
+                                                  bool check_access) {
+   EXCEPTION_MARK;
+@@ -933,8 +932,8 @@
+ 
+ methodHandle LinkResolver::linktime_resolve_virtual_method_or_null(
+                                                  KlassHandle resolved_klass,
+-                                                 symbolHandle method_name,
+-                                                 symbolHandle method_signature,
++                                                 Symbol* method_name,
++                                                 Symbol* method_signature,
+                                                  KlassHandle current_klass,
+                                                  bool check_access) {
+   EXCEPTION_MARK;
+@@ -951,8 +950,8 @@
+ methodHandle LinkResolver::resolve_virtual_call_or_null(
+                                                  KlassHandle receiver_klass,
+                                                  KlassHandle resolved_klass,
+-                                                 symbolHandle name,
+-                                                 symbolHandle signature,
++                                                 Symbol* name,
++                                                 Symbol* signature,
+                                                  KlassHandle current_klass) {
+   EXCEPTION_MARK;
+   CallInfo info;
+@@ -967,8 +966,8 @@
+ methodHandle LinkResolver::resolve_interface_call_or_null(
+                                                  KlassHandle receiver_klass,
+                                                  KlassHandle resolved_klass,
+-                                                 symbolHandle name,
+-                                                 symbolHandle signature,
++                                                 Symbol* name,
++                                                 Symbol* signature,
+                                                  KlassHandle current_klass) {
+   EXCEPTION_MARK;
+   CallInfo info;
+@@ -983,8 +982,8 @@
+ int LinkResolver::resolve_virtual_vtable_index(
+                                                KlassHandle receiver_klass,
+                                                KlassHandle resolved_klass,
+-                                               symbolHandle name,
+-                                               symbolHandle signature,
++                                               Symbol* name,
++                                               Symbol* signature,
+                                                KlassHandle current_klass) {
+   EXCEPTION_MARK;
+   CallInfo info;
+@@ -998,8 +997,8 @@
+ 
+ methodHandle LinkResolver::resolve_static_call_or_null(
+                                                   KlassHandle resolved_klass,
+-                                                  symbolHandle name,
+-                                                  symbolHandle signature,
++                                                  Symbol* name,
++                                                  Symbol* signature,
+                                                   KlassHandle current_klass) {
+   EXCEPTION_MARK;
+   CallInfo info;
+@@ -1011,7 +1010,7 @@
+   return info.selected_method();
+ }
+ 
+-methodHandle LinkResolver::resolve_special_call_or_null(KlassHandle resolved_klass, symbolHandle name, symbolHandle signature,
++methodHandle LinkResolver::resolve_special_call_or_null(KlassHandle resolved_klass, Symbol* name, Symbol* signature,
+                                                         KlassHandle current_klass) {
+   EXCEPTION_MARK;
+   CallInfo info;
+@@ -1039,22 +1038,22 @@
+   return;
+ }
+ 
+-void LinkResolver::resolve_pool(KlassHandle& resolved_klass, symbolHandle& method_name, symbolHandle& method_signature,
++void LinkResolver::resolve_pool(KlassHandle& resolved_klass, Symbol*& method_name, Symbol*& method_signature,
+                                 KlassHandle& current_klass, constantPoolHandle pool, int index, TRAPS) {
+    // resolve klass
+   resolve_klass(resolved_klass, pool, index, CHECK);
+ 
+   // Get name, signature, and static klass
+-  method_name      = symbolHandle(THREAD, pool->name_ref_at(index));
+-  method_signature = symbolHandle(THREAD, pool->signature_ref_at(index));
++  method_name      = pool->name_ref_at(index);
++  method_signature = pool->signature_ref_at(index);
+   current_klass    = KlassHandle(THREAD, pool->pool_holder());
+ }
+ 
+ 
+ void LinkResolver::resolve_invokestatic(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
+   KlassHandle  resolved_klass;
+-  symbolHandle method_name;
+-  symbolHandle method_signature;
++  Symbol* method_name = NULL;
++  Symbol* method_signature = NULL;
+   KlassHandle  current_klass;
+   resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
+   resolve_static_call(result, resolved_klass, method_name, method_signature, current_klass, true, true, CHECK);
+@@ -1063,8 +1062,8 @@
+ 
+ void LinkResolver::resolve_invokespecial(CallInfo& result, constantPoolHandle pool, int index, TRAPS) {
+   KlassHandle  resolved_klass;
+-  symbolHandle method_name;
+-  symbolHandle method_signature;
++  Symbol* method_name = NULL;
++  Symbol* method_signature = NULL;
+   KlassHandle  current_klass;
+   resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
+   resolve_special_call(result, resolved_klass, method_name, method_signature, current_klass, true, CHECK);
+@@ -1076,8 +1075,8 @@
+                                           TRAPS) {
+ 
+   KlassHandle  resolved_klass;
+-  symbolHandle method_name;
+-  symbolHandle method_signature;
++  Symbol* method_name = NULL;
++  Symbol* method_signature = NULL;
+   KlassHandle  current_klass;
+   resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
+   KlassHandle recvrKlass (THREAD, recv.is_null() ? (klassOop)NULL : recv->klass());
+@@ -1087,8 +1086,8 @@
+ 
+ void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, constantPoolHandle pool, int index, TRAPS) {
+   KlassHandle  resolved_klass;
+-  symbolHandle method_name;
+-  symbolHandle method_signature;
++  Symbol* method_name = NULL;
++  Symbol* method_signature = NULL;
+   KlassHandle  current_klass;
+   resolve_pool(resolved_klass, method_name,  method_signature, current_klass, pool, index, CHECK);
+   KlassHandle recvrKlass (THREAD, recv.is_null() ? (klassOop)NULL : recv->klass());
+@@ -1102,8 +1101,8 @@
+   // This guy is reached from InterpreterRuntime::resolve_invokedynamic.
+ 
+   // At this point, we only need the signature, and can ignore the name.
+-  symbolHandle method_signature(THREAD, pool->signature_ref_at(raw_index));  // raw_index works directly
+-  symbolHandle method_name = vmSymbolHandles::invokeExact_name();
++  Symbol*  method_signature = pool->signature_ref_at(raw_index);  // raw_index works directly
++  Symbol* method_name = vmSymbols::invokeExact_name();
+   KlassHandle resolved_klass = SystemDictionaryHandles::MethodHandle_klass();
+ 
+   // JSR 292:  this must be an implicitly generated method MethodHandle.invokeExact(*...)
+diff --git a/src/share/vm/interpreter/linkResolver.hpp b/src/share/vm/interpreter/linkResolver.hpp
+--- openjdk/hotspot/src/share/vm/interpreter/linkResolver.hpp
++++ openjdk/hotspot/src/share/vm/interpreter/linkResolver.hpp
+@@ -45,17 +45,17 @@
+ class FieldAccessInfo: public LinkInfo {
+  protected:
+   KlassHandle  _klass;
+-  symbolHandle _name;
++  Symbol*      _name;
+   AccessFlags  _access_flags;
+   int          _field_index;  // original index in the klass
+   int          _field_offset;
+   BasicType    _field_type;
+ 
+  public:
+-  void         set(KlassHandle klass, symbolHandle name, int field_index, int field_offset,
++  void         set(KlassHandle klass, Symbol* name, int field_index, int field_offset,
+                  BasicType field_type, AccessFlags access_flags);
+   KlassHandle  klass() const                     { return _klass; }
+-  symbolHandle name() const                      { return _name; }
++  Symbol* name() const                           { return _name; }
+   int          field_index() const               { return _field_index; }
+   int          field_offset() const              { return _field_offset; }
+   BasicType    field_type() const                { return _field_type; }
+@@ -107,26 +107,26 @@
+ 
+ class LinkResolver: AllStatic {
+  private:
+-  static void lookup_method_in_klasses          (methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS);
+-  static void lookup_instance_method_in_klasses (methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS);
+-  static void lookup_method_in_interfaces       (methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS);
+-  static void lookup_implicit_method            (methodHandle& result, KlassHandle klass, symbolHandle name, symbolHandle signature,
++  static void lookup_method_in_klasses          (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS);
++  static void lookup_instance_method_in_klasses (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS);
++  static void lookup_method_in_interfaces       (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS);
++  static void lookup_implicit_method            (methodHandle& result, KlassHandle klass, Symbol* name, Symbol* signature,
+                                                  KlassHandle current_klass, TRAPS);
+ 
+-  static int vtable_index_of_miranda_method(KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS);
++  static int vtable_index_of_miranda_method(KlassHandle klass, Symbol* name, Symbol* signature, TRAPS);
+ 
+   static void resolve_klass           (KlassHandle& result, constantPoolHandle  pool, int index, TRAPS);
+   static void resolve_klass_no_update (KlassHandle& result, constantPoolHandle pool, int index, TRAPS); // no update of constantPool entry
+ 
+-  static void resolve_pool  (KlassHandle& resolved_klass, symbolHandle& method_name, symbolHandle& method_signature, KlassHandle& current_klass, constantPoolHandle pool, int index, TRAPS);
++  static void resolve_pool  (KlassHandle& resolved_klass, Symbol*& method_name, Symbol*& method_signature, KlassHandle& current_klass, constantPoolHandle pool, int index, TRAPS);
+ 
+-  static void resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS);
+-  static void resolve_method          (methodHandle& resolved_method, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS);
++  static void resolve_interface_method(methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS);
++  static void resolve_method          (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS);
+ 
+-  static void linktime_resolve_static_method    (methodHandle& resolved_method, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS);
+-  static void linktime_resolve_special_method   (methodHandle& resolved_method, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS);
+-  static void linktime_resolve_virtual_method   (methodHandle &resolved_method, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature,KlassHandle current_klass, bool check_access, TRAPS);
+-  static void linktime_resolve_interface_method (methodHandle& resolved_method, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS);
++  static void linktime_resolve_static_method    (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS);
++  static void linktime_resolve_special_method   (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS);
++  static void linktime_resolve_virtual_method   (methodHandle &resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature,KlassHandle current_klass, bool check_access, TRAPS);
++  static void linktime_resolve_interface_method (methodHandle& resolved_method, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS);
+ 
+   static void runtime_resolve_special_method    (CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, KlassHandle current_klass, bool check_access, TRAPS);
+   static void runtime_resolve_virtual_method    (CallInfo& result, methodHandle resolved_method, KlassHandle resolved_klass, Handle recv, KlassHandle recv_klass, bool check_null_and_abstract, TRAPS);
+@@ -152,24 +152,24 @@
+   // runtime resolving:
+   //   resolved_klass = specified class (i.e., static receiver class)
+   //   current_klass  = sending method holder (i.e., class containing the method containing the call being resolved)
+-  static void resolve_static_call   (CallInfo& result,              KlassHandle& resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access, bool initialize_klass, TRAPS);
+-  static void resolve_special_call  (CallInfo& result,              KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access, TRAPS);
+-  static void resolve_virtual_call  (CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access, bool check_null_and_abstract, TRAPS);
+-  static void resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access, bool check_null_and_abstract, TRAPS);
++  static void resolve_static_call   (CallInfo& result,              KlassHandle& resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool initialize_klass, TRAPS);
++  static void resolve_special_call  (CallInfo& result,              KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, TRAPS);
++  static void resolve_virtual_call  (CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool check_null_and_abstract, TRAPS);
++  static void resolve_interface_call(CallInfo& result, Handle recv, KlassHandle recv_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access, bool check_null_and_abstract, TRAPS);
+ 
+   // same as above for compile-time resolution; but returns null handle instead of throwing an exception on error
+   // also, does not initialize klass (i.e., no side effects)
+-  static methodHandle resolve_virtual_call_or_null  (KlassHandle receiver_klass, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass);
+-  static methodHandle resolve_interface_call_or_null(KlassHandle receiver_klass, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass);
+-  static methodHandle resolve_static_call_or_null   (KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass);
+-  static methodHandle resolve_special_call_or_null  (KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass);
++  static methodHandle resolve_virtual_call_or_null  (KlassHandle receiver_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass);
++  static methodHandle resolve_interface_call_or_null(KlassHandle receiver_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass);
++  static methodHandle resolve_static_call_or_null   (KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass);
++  static methodHandle resolve_special_call_or_null  (KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass);
+ 
+   // same as above for compile-time resolution; returns vtable_index if current_klass if linked
+-  static int resolve_virtual_vtable_index  (KlassHandle receiver_klass, KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass);
++  static int resolve_virtual_vtable_index  (KlassHandle receiver_klass, KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass);
+ 
+   // static resolving for compiler (does not throw exceptions, returns null handle if unsuccessful)
+-  static methodHandle linktime_resolve_virtual_method_or_null  (KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access);
+-  static methodHandle linktime_resolve_interface_method_or_null(KlassHandle resolved_klass, symbolHandle method_name, symbolHandle method_signature, KlassHandle current_klass, bool check_access);
++  static methodHandle linktime_resolve_virtual_method_or_null  (KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access);
++  static methodHandle linktime_resolve_interface_method_or_null(KlassHandle resolved_klass, Symbol* method_name, Symbol* method_signature, KlassHandle current_klass, bool check_access);
+ 
+   // runtime resolving from constant pool
+   static void resolve_invokestatic   (CallInfo& result,              constantPoolHandle pool, int index, TRAPS);
+diff --git a/src/share/vm/memory/classify.cpp b/src/share/vm/memory/classify.cpp
+--- openjdk/hotspot/src/share/vm/memory/classify.cpp
++++ openjdk/hotspot/src/share/vm/memory/classify.cpp
+@@ -68,8 +68,6 @@
+     type = typeArray_type;
+   } else if (obj->is_objArray()) {
+     type = objArray_type;
+-  } else if (obj->is_symbol()) {
+-    type = symbol_type;
+   } else if (obj->is_klass()) {
+     Klass* k = ((klassOop)obj)->klass_part();
+     if (k->oop_is_instance()) {
+@@ -158,8 +156,6 @@
+           name = "_typeArrayKlassKlassObj";
+         } else if (obj == Universe::instanceKlassKlassObj()) {
+           name = "_instanceKlassKlassObj";
+-        } else if (obj == Universe::symbolKlassObj()) {
+-          name = "_symbolKlassObj";
+         } else if (obj == Universe::methodKlassObj()) {
+           name = "_methodKlassObj";
+         } else if (obj == Universe::constMethodKlassObj()) {
+diff --git a/src/share/vm/memory/compactingPermGenGen.cpp b/src/share/vm/memory/compactingPermGenGen.cpp
+--- openjdk/hotspot/src/share/vm/memory/compactingPermGenGen.cpp
++++ openjdk/hotspot/src/share/vm/memory/compactingPermGenGen.cpp
+@@ -95,17 +95,11 @@
+ // their stack to the class without having added the class to the
+ // dictionary yet. This means the class will be marked during phase 1
+ // but will not be unmarked during the application of the
+-// RecursiveAdjustSharedObjectClosure to the SystemDictionary. Note
+-// that we must not call find_shared_class with non-read-only symbols
+-// as doing so can cause hash codes to be computed, destroying
+-// forwarding pointers.
+-class TraversePlaceholdersClosure : public OopClosure {
+- protected:
+-  template <class T> inline void do_oop_work(T* p) {
+-    oop obj = oopDesc::load_decode_heap_oop_not_null(p);
+-    if (obj->klass() == Universe::symbolKlassObj() &&
+-        obj->is_shared_readonly()) {
+-      symbolHandle sym((symbolOop) obj);
++// RecursiveAdjustSharedObjectClosure to the SystemDictionary.
++class TraversePlaceholdersClosure {
++ public:
++  static void placeholders_do(Symbol* sym, oop loader) {
++    if (CompactingPermGenGen::is_shared(sym)) {
+       oop k = SystemDictionary::find_shared_class(sym);
+       if (k != NULL) {
+         RecursiveAdjustSharedObjectClosure clo;
+@@ -113,13 +107,8 @@
+       }
+     }
+   }
+- public:
+-  virtual void do_oop(oop* p)       { TraversePlaceholdersClosure::do_oop_work(p); }
+-  virtual void do_oop(narrowOop* p) { TraversePlaceholdersClosure::do_oop_work(p); }
+-
+ };
+ 
+-
+ void CompactingPermGenGen::initialize_performance_counters() {
+ 
+   const char* gen_name = "perm";
+@@ -335,8 +324,7 @@
+       Universe::oops_do(&blk);
+       StringTable::oops_do(&blk);
+       SystemDictionary::always_strong_classes_do(&blk);
+-      TraversePlaceholdersClosure tpc;
+-      SystemDictionary::placeholders_do(&tpc);
++      SystemDictionary::placeholders_do(TraversePlaceholdersClosure::placeholders_do);
+     }
+   }
+ }
+@@ -490,5 +478,3 @@
+   }
+   return true;
+ }
+-
+-void** CompactingPermGenGen::_vtbl_list;
+diff --git a/src/share/vm/memory/compactingPermGenGen.hpp b/src/share/vm/memory/compactingPermGenGen.hpp
+--- openjdk/hotspot/src/share/vm/memory/compactingPermGenGen.hpp
++++ openjdk/hotspot/src/share/vm/memory/compactingPermGenGen.hpp
+@@ -96,9 +96,6 @@
+   static HeapWord* misccode_end;
+   static HeapWord* shared_end;
+ 
+-  // List of klassOops whose vtbl entries are used to patch others.
+-  static void**        _vtbl_list;
+-
+   // Performance Counters
+   GenerationCounters*  _gen_counters;
+   CSpaceCounters*      _space_counters;
+@@ -153,32 +150,25 @@
+   VirtualSpace*           mc_space()       { return &_mc_vs; }
+   ContiguousSpace* unshared_space() const { return _the_space; }
+ 
+-  static bool inline is_shared(const oopDesc* p) {
+-    return (HeapWord*)p >= shared_bottom && (HeapWord*)p < shared_end;
++  static bool inline is_shared(const void* p) {
++    return p >= shared_bottom && p < shared_end;
+   }
+   // RedefineClasses note: this tester is used to check residence of
+   // the specified oop in the shared readonly space and not whether
+   // the oop is readonly.
+-  static bool inline is_shared_readonly(const oopDesc* p) {
+-    return (HeapWord*)p >= readonly_bottom && (HeapWord*)p < readonly_end;
++  static bool inline is_shared_readonly(const void* p) {
++    return p >= readonly_bottom && p < readonly_end;
+   }
+   // RedefineClasses note: this tester is used to check residence of
+   // the specified oop in the shared readwrite space and not whether
+   // the oop is readwrite.
+-  static bool inline is_shared_readwrite(const oopDesc* p) {
+-    return (HeapWord*)p >= readwrite_bottom && (HeapWord*)p < readwrite_end;
++  static bool inline is_shared_readwrite(const void* p) {
++    return p >= readwrite_bottom && p < readwrite_end;
+   }
+ 
+-  bool is_in_unshared(const void* p) const {
+-    return OneContigSpaceCardGeneration::is_in(p);
+-  }
+-
+-  bool is_in_shared(const void* p) const {
+-   return p >= shared_bottom && p < shared_end;
+-   }
+-
++  // Checks if the pointer is either in unshared space or in shared space
+   inline bool is_in(const void* p) const {
+-    return is_in_unshared(p) || is_in_shared(p);
++    return OneContigSpaceCardGeneration::is_in(p) || is_shared(p);
+   }
+ 
+   inline PermanentGenerationSpec* spec() const { return _spec; }
+@@ -236,6 +226,9 @@
+                                       void** vtable,
+                                       char** md_top, char* md_end,
+                                       char** mc_top, char* mc_end);
++  static void* find_matching_vtbl_ptr(void** vtbl_list,
++                                      void* new_vtable_start,
++                                      void* obj);
+ 
+   void verify(bool allow_dirty);
+ 
+diff --git a/src/share/vm/memory/dump.cpp b/src/share/vm/memory/dump.cpp
+--- openjdk/hotspot/src/share/vm/memory/dump.cpp
++++ openjdk/hotspot/src/share/vm/memory/dump.cpp
+@@ -133,6 +133,69 @@
+   return false;
+ }
+ 
++
++class MoveSymbols : public SymbolClosure {
++private:
++  char* _start;
++  char* _end;
++  char* _top;
++  int _count;
++
++  bool in_shared_space(Symbol* sym) const {
++    return (char*)sym >= _start && (char*)sym < _end;
++  }
++
++  Symbol* get_shared_copy(Symbol* sym) {
++    return sym->refcount() > 0 ? NULL : (Symbol*)(_start - sym->refcount());
++  }
++
++  Symbol* make_shared_copy(Symbol* sym) {
++    Symbol* new_sym = (Symbol*)_top;
++    int size = sym->object_size();
++    _top += size * HeapWordSize;
++    if (_top <= _end) {
++      Copy::disjoint_words((HeapWord*)sym, (HeapWord*)new_sym, size);
++      // Encode a reference to the copy as a negative distance from _start
++      // When a symbol is being copied to a shared space
++      // during CDS archive creation, the original symbol is marked
++      // as relocated by putting a negative value to its _refcount field,
++      // This value is also used to find where exactly the shared copy is
++      // (see MoveSymbols::get_shared_copy), so that the other references
++      // to this symbol could be changed to point to the shared copy.
++      sym->_refcount = (int)(_start - (char*)new_sym);
++      // Mark the symbol in the shared archive as immortal so it is read only
++      // and not refcounted.
++      new_sym->_refcount = -1;
++      _count++;
++    } else {
++      report_out_of_shared_space(SharedMiscData);
++    }
++    return new_sym;
++  }
++
++public:
++  MoveSymbols(char* top, char* end) :
++    _start(top), _end(end), _top(top), _count(0) { }
++
++  char* get_top() const { return _top; }
++  int count()     const { return _count; }
++
++  void do_symbol(Symbol** p) {
++    Symbol* sym = load_symbol(p);
++    if (sym != NULL && !in_shared_space(sym)) {
++      Symbol* new_sym = get_shared_copy(sym);
++      if (new_sym == NULL) {
++        // The symbol has not been relocated yet; copy it to _top address
++        assert(sym->refcount() > 0, "should have positive reference count");
++        new_sym = make_shared_copy(sym);
++      }
++      // Make the reference point to the shared copy of the symbol
++      store_symbol(p, new_sym);
++    }
++  }
++};
++
++
+ // Closure:  mark objects closure.
+ 
+ class MarkObjectsOopClosure : public OopClosure {
+@@ -164,7 +227,7 @@
+ }
+ 
+ 
+-// Closure:  mark common read-only objects, excluding symbols
++// Closure:  mark common read-only objects
+ 
+ class MarkCommonReadOnly : public ObjectClosure {
+ private:
+@@ -216,54 +279,52 @@
+ };
+ 
+ 
+-// Closure:  mark common symbols
++// Closure:  find symbol references in Java Heap objects
+ 
+-class MarkCommonSymbols : public ObjectClosure {
++class CommonSymbolsClosure : public ObjectClosure {
+ private:
+-  MarkObjectsOopClosure mark_all;
++  SymbolClosure* _closure;
+ public:
++  CommonSymbolsClosure(SymbolClosure* closure) : _closure(closure) { }
++
+   void do_object(oop obj) {
+ 
+-    // Mark symbols refered to by method objects.
++    // Traverse symbols referenced by method objects.
+ 
+     if (obj->is_method()) {
+       methodOop m = methodOop(obj);
+-      mark_object(m->name());
+-      mark_object(m->signature());
++      constantPoolOop constants = m->constants();
++      _closure->do_symbol(constants->symbol_at_addr(m->name_index()));
++      _closure->do_symbol(constants->symbol_at_addr(m->signature_index()));
+     }
+ 
+-    // Mark symbols referenced by klass objects which are read-only.
++    // Traverse symbols referenced by klass objects which are read-only.
+ 
+     else if (obj->is_klass()) {
++      Klass* k = Klass::cast((klassOop)obj);
++      k->shared_symbols_iterate(_closure);
+ 
+       if (obj->blueprint()->oop_is_instanceKlass()) {
+         instanceKlass* ik = instanceKlass::cast((klassOop)obj);
+-        mark_object(ik->name());
+-        mark_object(ik->generic_signature());
+-        mark_object(ik->source_file_name());
+-        mark_object(ik->source_debug_extension());
+-
+         typeArrayOop inner_classes = ik->inner_classes();
+         if (inner_classes != NULL) {
+-          int length = inner_classes->length();
+-          for (int i = 0;
+-                   i < length;
+-                   i += instanceKlass::inner_class_next_offset) {
++          constantPoolOop constants = ik->constants();
++          int n = inner_classes->length();
++          for (int i = 0; i < n; i += instanceKlass::inner_class_next_offset) {
+             int ioff = i + instanceKlass::inner_class_inner_name_offset;
+             int index = inner_classes->ushort_at(ioff);
+             if (index != 0) {
+-              mark_object(ik->constants()->symbol_at(index));
++              _closure->do_symbol(constants->symbol_at_addr(index));
+             }
+           }
+         }
+-        ik->field_names_and_sigs_iterate(&mark_all);
+       }
+     }
+ 
+-    // Mark symbols referenced by other constantpool entries.
++    // Traverse symbols referenced by other constantpool entries.
+ 
+-    if (obj->is_constantPool()) {
+-      constantPoolOop(obj)->shared_symbols_iterate(&mark_all);
++    else if (obj->is_constantPool()) {
++      constantPoolOop(obj)->shared_symbols_iterate(_closure);
+     }
+   }
+ };
+@@ -404,18 +465,7 @@
+       int s = obj->size();
+       oop sh_obj = (oop)_space->allocate(s);
+       if (sh_obj == NULL) {
+-        if (_read_only) {
+-          warning("\nThe permanent generation read only space is not large "
+-                  "enough to \npreload requested classes.  Use "
+-                  "-XX:SharedReadOnlySize= to increase \nthe initial "
+-                  "size of the read only space.\n");
+-        } else {
+-          warning("\nThe permanent generation read write space is not large "
+-                  "enough to \npreload requested classes.  Use "
+-                  "-XX:SharedReadWriteSize= to increase \nthe initial "
+-                  "size of the read write space.\n");
+-        }
+-        exit(2);
++        report_out_of_shared_space(_read_only ? SharedReadOnly : SharedReadWrite);
+       }
+       if (PrintSharedSpaces && Verbose && WizardMode) {
+         tty->print_cr("\nMoveMarkedObjects: " PTR_FORMAT " -> " PTR_FORMAT " %s", obj, sh_obj,
+@@ -459,8 +509,6 @@
+       instanceKlass* ik = instanceKlass::cast((klassOop)obj);
+       int i;
+ 
+-      mark_and_move_for_policy(OP_favor_startup, ik->name(), _move_ro);
+-
+       if (ik->super() != NULL) {
+         do_object(ik->super());
+       }
+@@ -469,7 +517,6 @@
+       mark_and_move_for_policy(OP_favor_startup, interfaces, _move_ro);
+       for(i = 0; i < interfaces->length(); i++) {
+         klassOop k = klassOop(interfaces->obj_at(i));
+-        mark_and_move_for_policy(OP_favor_startup, k->klass_part()->name(), _move_ro);
+         do_object(k);
+       }
+ 
+@@ -479,14 +526,6 @@
+         mark_and_move_for_policy(OP_favor_startup, m->constMethod(), _move_ro);
+         mark_and_move_for_policy(OP_favor_runtime, m->constMethod()->exception_table(), _move_ro);
+         mark_and_move_for_policy(OP_favor_runtime, m->constMethod()->stackmap_data(), _move_ro);
+-
+-        // We don't move the name symbolOop here because it may invalidate
+-        // method ordering, which is dependent on the address of the name
+-        // symbolOop.  It will get promoted later with the other symbols.
+-        // Method name is rarely accessed during classloading anyway.
+-        // mark_and_move_for_policy(OP_balanced, m->name(), _move_ro);
+-
+-        mark_and_move_for_policy(OP_favor_startup, m->signature(), _move_ro);
+       }
+ 
+       mark_and_move_for_policy(OP_favor_startup, ik->transitive_interfaces(), _move_ro);
+@@ -574,45 +613,43 @@
+ };
+ 
+ 
+-void sort_methods(instanceKlass* ik, TRAPS) {
+-  klassOop super = ik->super();
+-  if (super != NULL) {
+-    sort_methods(instanceKlass::cast(super), THREAD);
+-  }
+-
+-  // The methods array must be ordered by symbolOop address. (See
+-  // classFileParser.cpp where methods in a class are originally
+-  // sorted.)  Since objects have just be reordered, this must be
+-  // corrected.
+-  methodOopDesc::sort_methods(ik->methods(),
+-                              ik->methods_annotations(),
+-                              ik->methods_parameter_annotations(),
+-                              ik->methods_default_annotations(),
+-                              true /* idempotent, slow */);
+-
+-  // Itable indices are calculated based on methods array order
+-  // (see klassItable::compute_itable_index()).  Must reinitialize.
+-  // We assume that since checkconstraints is false, this method
+-  // cannot throw an exception.  An exception here would be
+-  // problematic since this is the VMThread, not a JavaThread.
+-  ik->itable()->initialize_itable(false, THREAD);
+-}
+-
+-// Sort methods if the oop is an instanceKlass.
++// The methods array must be reordered by Symbol* address.
++// (See classFileParser.cpp where methods in a class are originally
++// sorted). The addresses of symbols have been changed as a result
++// of moving to the shared space.
+ 
+ class SortMethodsClosure: public ObjectClosure {
++public:
++  void do_object(oop obj) {
++    if (obj->blueprint()->oop_is_instanceKlass()) {
++      instanceKlass* ik = instanceKlass::cast((klassOop)obj);
++      methodOopDesc::sort_methods(ik->methods(),
++                                  ik->methods_annotations(),
++                                  ik->methods_parameter_annotations(),
++                                  ik->methods_default_annotations(),
++                                  true /* idempotent, slow */);
++    }
++  }
++};
++
++// Itable indices are calculated based on methods array order
++// (see klassItable::compute_itable_index()).  Must reinitialize
++// after ALL methods of ALL classes have been reordered.
++// We assume that since checkconstraints is false, this method
++// cannot throw an exception.  An exception here would be
++// problematic since this is the VMThread, not a JavaThread.
++
++class ReinitializeItables: public ObjectClosure {
+ private:
+   Thread* _thread;
+ 
+ public:
+-  SortMethodsClosure(Thread* thread) : _thread(thread) {}
++  ReinitializeItables(Thread* thread) : _thread(thread) {}
+ 
+   void do_object(oop obj) {
+-    // instanceKlass objects need some adjustment.
+     if (obj->blueprint()->oop_is_instanceKlass()) {
+       instanceKlass* ik = instanceKlass::cast((klassOop)obj);
+-
+-      sort_methods(ik, _thread);
++      ik->itable()->initialize_itable(false, _thread);
+     }
+   }
+ };
+@@ -673,18 +710,9 @@
+   oop* top;
+   char* end;
+ 
+-  void out_of_space() {
+-    warning("\nThe shared miscellaneous data space is not large "
+-            "enough to \npreload requested classes.  Use "
+-            "-XX:SharedMiscDataSize= to increase \nthe initial "
+-            "size of the miscellaneous data space.\n");
+-    exit(2);
+-  }
+-
+-
+   inline void check_space() {
+     if ((char*)top + sizeof(oop) > end) {
+-      out_of_space();
++      report_out_of_shared_space(SharedMiscData);
+     }
+   }
+ 
+@@ -737,7 +765,7 @@
+ 
+   void do_region(u_char* start, size_t size) {
+     if ((char*)top + size > end) {
+-      out_of_space();
++      report_out_of_shared_space(SharedMiscData);
+     }
+     assert((intptr_t)start % sizeof(oop) == 0, "bad alignment");
+     assert(size % sizeof(oop) == 0, "bad size");
+@@ -870,46 +898,53 @@
+ 
+ class PatchKlassVtables: public ObjectClosure {
+ private:
+-  void*         _vtbl_ptr;
+-  VirtualSpace* _md_vs;
+   GrowableArray<klassOop>* _klass_objects;
+ 
+ public:
+-
+-  PatchKlassVtables(void* vtbl_ptr, VirtualSpace* md_vs) {
+-    _vtbl_ptr = vtbl_ptr;
+-    _md_vs = md_vs;
++  PatchKlassVtables() {
+     _klass_objects = new GrowableArray<klassOop>();
+   }
+ 
+-
+   void do_object(oop obj) {
+     if (obj->is_klass()) {
+       _klass_objects->append(klassOop(obj));
+     }
+   }
+ 
+-
+-  void patch(void** vtbl_list, int vtbl_list_size) {
+-    for (int i = 0; i < _klass_objects->length(); ++i) {
++  void patch(void** vtbl_list, void* new_vtable_start) {
++    int n = _klass_objects->length();
++    for (int i = 0; i < n; i++) {
+       klassOop obj = (klassOop)_klass_objects->at(i);
+       Klass* k = obj->klass_part();
+-      void* v =  *(void**)k;
+-
+-      int n;
+-      for (n = 0; n < vtbl_list_size; ++n) {
+-        *(void**)k = NULL;
+-        if (vtbl_list[n] == v) {
+-          *(void**)k = (void**)_vtbl_ptr +
+-                                 (n * CompactingPermGenGen::num_virtuals);
+-          break;
+-        }
+-      }
+-      guarantee(n < vtbl_list_size, "unable to find matching vtbl pointer");
++      *(void**)k = CompactingPermGenGen::find_matching_vtbl_ptr(
++                     vtbl_list, new_vtable_start, k);
+     }
+   }
+ };
+ 
++// Walk through all symbols and patch their vtable pointers.
++// Note that symbols have vtable pointers only in non-product builds
++// (see allocation.hpp).
++
++#ifndef PRODUCT
++class PatchSymbolVtables: public SymbolClosure {
++private:
++  void* _new_vtbl_ptr;
++
++public:
++  PatchSymbolVtables(void** vtbl_list, void* new_vtable_start) {
++    Symbol s;
++    _new_vtbl_ptr = CompactingPermGenGen::find_matching_vtbl_ptr(
++                      vtbl_list, new_vtable_start, &s);
++  }
++
++  void do_symbol(Symbol** p) {
++    Symbol* sym = load_symbol(p);
++    *(void**)sym = _new_vtbl_ptr;
++  }
++};
++#endif
++
+ 
+ // Populate the shared space.
+ 
+@@ -969,7 +1004,6 @@
+ 
+     MarkObjectsOopClosure mark_all;
+     MarkCommonReadOnly mark_common_ro;
+-    MarkCommonSymbols mark_common_symbols;
+     MarkStringValues mark_string_values;
+     MarkReadWriteObjects mark_rw;
+     MarkStringObjects mark_strings;
+@@ -1013,112 +1047,6 @@
+     MarkAndMoveOrderedReadOnly  mark_and_move_ordered_ro(&move_ro);
+     MarkAndMoveOrderedReadWrite mark_and_move_ordered_rw(&move_rw);
+ 
+-    // Phase 1a: move commonly used read-only objects to the read-only space.
+-
+-    if (SharedOptimizeColdStart) {
+-      tty->print("Moving pre-ordered read-only objects to shared space at " PTR_FORMAT " ... ",
+-                 _ro_space->top());
+-      for (int i = 0; i < _class_promote_order->length(); i++) {
+-        oop obj = _class_promote_order->at(i);
+-        mark_and_move_ordered_ro.do_object(obj);
+-      }
+-      tty->print_cr("done. ");
+-    }
+-
+-    tty->print("Moving read-only objects to shared space at " PTR_FORMAT " ... ",
+-               _ro_space->top());
+-    gch->object_iterate(&mark_common_ro);
+-    gch->object_iterate(&move_ro);
+-    tty->print_cr("done. ");
+-
+-    // Phase 1b: move commonly used symbols to the read-only space.
+-
+-    tty->print("Moving common symbols to shared space at " PTR_FORMAT " ... ",
+-               _ro_space->top());
+-    gch->object_iterate(&mark_common_symbols);
+-    gch->object_iterate(&move_ro);
+-    tty->print_cr("done. ");
+-
+-    // Phase 1c: move remaining symbols to the read-only space
+-    // (e.g. String initializers).
+-
+-    tty->print("Moving remaining symbols to shared space at " PTR_FORMAT " ... ",
+-               _ro_space->top());
+-    vmSymbols::oops_do(&mark_all, true);
+-    gch->object_iterate(&move_ro);
+-    tty->print_cr("done. ");
+-
+-    // Phase 1d: move String character arrays to the read-only space.
+-
+-    tty->print("Moving string char arrays to shared space at " PTR_FORMAT " ... ",
+-               _ro_space->top());
+-    gch->object_iterate(&mark_string_values);
+-    gch->object_iterate(&move_ro);
+-    tty->print_cr("done. ");
+-
+-    // Phase 2: move all remaining symbols to the read-only space.  The
+-    // remaining symbols are assumed to be string initializers no longer
+-    // referenced.
+-
+-    void* extra_symbols = _ro_space->top();
+-    tty->print("Moving additional symbols to shared space at " PTR_FORMAT " ... ",
+-               _ro_space->top());
+-    SymbolTable::oops_do(&mark_all);
+-    gch->object_iterate(&move_ro);
+-    tty->print_cr("done. ");
+-    tty->print_cr("Read-only space ends at " PTR_FORMAT ", %d bytes.",
+-                  _ro_space->top(), _ro_space->used());
+-
+-    // Phase 3: move read-write objects to the read-write space, except
+-    // Strings.
+-
+-    if (SharedOptimizeColdStart) {
+-      tty->print("Moving pre-ordered read-write objects to shared space at " PTR_FORMAT " ... ",
+-                 _rw_space->top());
+-      for (int i = 0; i < _class_promote_order->length(); i++) {
+-        oop obj = _class_promote_order->at(i);
+-        mark_and_move_ordered_rw.do_object(obj);
+-      }
+-      tty->print_cr("done. ");
+-    }
+-    tty->print("Moving read-write objects to shared space at " PTR_FORMAT " ... ",
+-               _rw_space->top());
+-    Universe::oops_do(&mark_all, true);
+-    SystemDictionary::oops_do(&mark_all);
+-    oop tmp = Universe::arithmetic_exception_instance();
+-    mark_object(java_lang_Throwable::message(tmp));
+-    gch->object_iterate(&mark_rw);
+-    gch->object_iterate(&move_rw);
+-    tty->print_cr("done. ");
+-
+-    // Phase 4: move String objects to the read-write space.
+-
+-    tty->print("Moving String objects to shared space at " PTR_FORMAT " ... ",
+-               _rw_space->top());
+-    StringTable::oops_do(&mark_all);
+-    gch->object_iterate(&mark_strings);
+-    gch->object_iterate(&move_rw);
+-    tty->print_cr("done. ");
+-    tty->print_cr("Read-write space ends at " PTR_FORMAT ", %d bytes.",
+-                  _rw_space->top(), _rw_space->used());
+-
+-#ifdef DEBUG
+-    // Check: scan for objects which were not moved.
+-
+-    CheckRemainingObjects check_objects;
+-    gch->object_iterate(&check_objects);
+-    check_objects.status();
+-#endif
+-
+-    // Resolve forwarding in objects and saved C++ structures
+-    tty->print("Updating references to shared objects ... ");
+-    ResolveForwardingClosure resolve;
+-    Universe::oops_do(&resolve);
+-    SystemDictionary::oops_do(&resolve);
+-    StringTable::oops_do(&resolve);
+-    SymbolTable::oops_do(&resolve);
+-    vmSymbols::oops_do(&resolve);
+-
+     // Set up the share data and shared code segments.
+ 
+     char* md_top = _md_vs->low();
+@@ -1144,6 +1072,122 @@
+                                                   &md_top, md_end,
+                                                   &mc_top, mc_end);
+ 
++    // Reserve space for the total size and the number of stored symbols.
++
++    md_top += sizeof(intptr_t) * 2;
++
++    MoveSymbols move_symbols(md_top, md_end);
++    CommonSymbolsClosure traverse_common_symbols(&move_symbols);
++
++    // Phase 1a: remove symbols with _refcount == 0
++
++    SymbolTable::unlink();
++
++    // Phase 1b: move commonly used symbols referenced by oop fields.
++
++    tty->print("Moving common symbols to metadata section at " PTR_FORMAT " ... ",
++               move_symbols.get_top());
++    gch->object_iterate(&traverse_common_symbols);
++    tty->print_cr("done. ");
++
++    // Phase 1c: move known names and signatures.
++
++    tty->print("Moving vmSymbols to metadata section at " PTR_FORMAT " ... ",
++               move_symbols.get_top());
++    vmSymbols::symbols_do(&move_symbols);
++    tty->print_cr("done. ");
++
++    // Phase 1d: move the remaining symbols by scanning the whole SymbolTable.
++
++    void* extra_symbols = move_symbols.get_top();
++    tty->print("Moving the remaining symbols to metadata section at " PTR_FORMAT " ... ",
++               move_symbols.get_top());
++    SymbolTable::symbols_do(&move_symbols);
++    tty->print_cr("done. ");
++
++    // Record the total length of all symbols at the beginning of the block.
++    ((intptr_t*)md_top)[-2] = move_symbols.get_top() - md_top;
++    ((intptr_t*)md_top)[-1] = move_symbols.count();
++    tty->print_cr("Moved %d symbols, %d bytes.",
++                  move_symbols.count(), move_symbols.get_top() - md_top);
++    // Advance the pointer to the end of symbol store.
++    md_top = move_symbols.get_top();
++
++
++    // Phase 2: move commonly used read-only objects to the read-only space.
++
++    if (SharedOptimizeColdStart) {
++      tty->print("Moving pre-ordered read-only objects to shared space at " PTR_FORMAT " ... ",
++                 _ro_space->top());
++      for (int i = 0; i < _class_promote_order->length(); i++) {
++        oop obj = _class_promote_order->at(i);
++        mark_and_move_ordered_ro.do_object(obj);
++      }
++      tty->print_cr("done. ");
++    }
++
++    tty->print("Moving read-only objects to shared space at " PTR_FORMAT " ... ",
++               _ro_space->top());
++    gch->object_iterate(&mark_common_ro);
++    gch->object_iterate(&move_ro);
++    tty->print_cr("done. ");
++
++    // Phase 3: move String character arrays to the read-only space.
++
++    tty->print("Moving string char arrays to shared space at " PTR_FORMAT " ... ",
++               _ro_space->top());
++    gch->object_iterate(&mark_string_values);
++    gch->object_iterate(&move_ro);
++    tty->print_cr("done. ");
++
++    // Phase 4: move read-write objects to the read-write space, except
++    // Strings.
++
++    if (SharedOptimizeColdStart) {
++      tty->print("Moving pre-ordered read-write objects to shared space at " PTR_FORMAT " ... ",
++                 _rw_space->top());
++      for (int i = 0; i < _class_promote_order->length(); i++) {
++        oop obj = _class_promote_order->at(i);
++        mark_and_move_ordered_rw.do_object(obj);
++      }
++      tty->print_cr("done. ");
++    }
++    tty->print("Moving read-write objects to shared space at " PTR_FORMAT " ... ",
++               _rw_space->top());
++    Universe::oops_do(&mark_all, true);
++    SystemDictionary::oops_do(&mark_all);
++    oop tmp = Universe::arithmetic_exception_instance();
++    mark_object(java_lang_Throwable::message(tmp));
++    gch->object_iterate(&mark_rw);
++    gch->object_iterate(&move_rw);
++    tty->print_cr("done. ");
++
++    // Phase 5: move String objects to the read-write space.
++
++    tty->print("Moving String objects to shared space at " PTR_FORMAT " ... ",
++               _rw_space->top());
++    StringTable::oops_do(&mark_all);
++    gch->object_iterate(&mark_strings);
++    gch->object_iterate(&move_rw);
++    tty->print_cr("done. ");
++    tty->print_cr("Read-write space ends at " PTR_FORMAT ", %d bytes.",
++                  _rw_space->top(), _rw_space->used());
++
++#ifdef DEBUG
++    // Check: scan for objects which were not moved.
++
++    CheckRemainingObjects check_objects;
++    gch->object_iterate(&check_objects);
++    check_objects.status();
++#endif
++
++    // Resolve forwarding in objects and saved C++ structures
++    tty->print("Updating references to shared objects ... ");
++    ResolveForwardingClosure resolve;
++    Universe::oops_do(&resolve);
++    SystemDictionary::oops_do(&resolve);
++    StringTable::oops_do(&resolve);
++
+     // Fix (forward) all of the references in these shared objects (which
+     // are required to point ONLY to objects in the shared spaces).
+     // Also, create a list of all objects which might later contain a
+@@ -1166,9 +1210,13 @@
+     // pointer resolution, so that methods can be promoted in any order
+     // with respect to their holder classes.
+ 
+-    SortMethodsClosure sort(THREAD);
++    SortMethodsClosure sort;
+     gen->ro_space()->object_iterate(&sort);
+     gen->rw_space()->object_iterate(&sort);
++
++    ReinitializeItables reinit_itables(THREAD);
++    gen->ro_space()->object_iterate(&reinit_itables);
++    gen->rw_space()->object_iterate(&reinit_itables);
+     tty->print_cr("done. ");
+     tty->cr();
+ 
+@@ -1233,9 +1281,16 @@
+     // Update the vtable pointers in all of the Klass objects in the
+     // heap. They should point to newly generated vtable.
+ 
+-    PatchKlassVtables pkvt(vtable, _md_vs);
++    PatchKlassVtables pkvt;
+     _rw_space->object_iterate(&pkvt);
+-    pkvt.patch(vtbl_list, vtbl_list_size);
++    pkvt.patch(vtbl_list, vtable);
++
++#ifndef PRODUCT
++    // Update the vtable pointers in all symbols,
++    // but only in non-product builds where symbols DO have virtual methods.
++    PatchSymbolVtables psvt(vtbl_list, vtable);
++    SymbolTable::symbols_do(&psvt);
++#endif
+ 
+     char* saved_vtbl = (char*)malloc(vtbl_list_size * sizeof(void*));
+     memmove(saved_vtbl, vtbl_list, vtbl_list_size * sizeof(void*));
+@@ -1304,6 +1359,19 @@
+   return JNI_OK;
+ }
+ 
++void* CompactingPermGenGen::find_matching_vtbl_ptr(void** vtbl_list,
++                                                   void* new_vtable_start,
++                                                   void* obj) {
++  void* old_vtbl_ptr = *(void**)obj;
++  for (int i = 0; i < vtbl_list_size; i++) {
++    if (vtbl_list[i] == old_vtbl_ptr) {
++      return (void**)new_vtable_start + i * num_virtuals;
++    }
++  }
++  ShouldNotReachHere();
++  return NULL;
++}
++
+ 
+ class LinkClassesClosure : public ObjectClosure {
+  private:
+@@ -1431,8 +1499,7 @@
+       computed_jsum = jsum(computed_jsum, class_name, (const int)name_len - 1);
+ 
+       // Got a class name - load it.
+-      symbolHandle class_name_symbol = oopFactory::new_symbol(class_name,
+-                                                              THREAD);
++      TempNewSymbol class_name_symbol = SymbolTable::new_symbol(class_name, THREAD);
+       guarantee(!HAS_PENDING_EXCEPTION, "Exception creating a symbol.");
+       klassOop klass = SystemDictionary::resolve_or_null(class_name_symbol,
+                                                          THREAD);
+diff --git a/src/share/vm/memory/genCollectedHeap.cpp b/src/share/vm/memory/genCollectedHeap.cpp
+--- openjdk/hotspot/src/share/vm/memory/genCollectedHeap.cpp
++++ openjdk/hotspot/src/share/vm/memory/genCollectedHeap.cpp
+@@ -875,10 +875,7 @@
+ 
+ void GenCollectedHeap::collect_locked(GCCause::Cause cause, int max_level) {
+   if (_preloading_shared_classes) {
+-    warning("\nThe permanent generation is not large enough to preload "
+-            "requested classes.\nUse -XX:PermSize= to increase the initial "
+-            "size of the permanent generation.\n");
+-    vm_exit(2);
++    report_out_of_shared_space(SharedPermGen);
+   }
+   // Read the GC count while holding the Heap_lock
+   unsigned int gc_count_before      = total_collections();
+diff --git a/src/share/vm/memory/genMarkSweep.cpp b/src/share/vm/memory/genMarkSweep.cpp
+--- openjdk/hotspot/src/share/vm/memory/genMarkSweep.cpp
++++ openjdk/hotspot/src/share/vm/memory/genMarkSweep.cpp
+@@ -296,9 +296,10 @@
+   follow_mdo_weak_refs();
+   assert(_marking_stack.is_empty(), "just drained");
+ 
+-  // Visit symbol and interned string tables and delete unmarked oops
+-  SymbolTable::unlink(&is_alive);
++  // Visit interned string tables and delete unmarked oops
+   StringTable::unlink(&is_alive);
++  // Clean up unreferenced symbols in symbol table.
++  SymbolTable::unlink();
+ 
+   assert(_marking_stack.is_empty(), "stack should be empty by now");
+ }
+diff --git a/src/share/vm/memory/heapInspection.cpp b/src/share/vm/memory/heapInspection.cpp
+--- openjdk/hotspot/src/share/vm/memory/heapInspection.cpp
++++ openjdk/hotspot/src/share/vm/memory/heapInspection.cpp
+@@ -56,7 +56,6 @@
+     if (_klass == Universe::objArrayKlassKlassObj())     name = "<objArrayKlassKlass>";     else
+     if (_klass == Universe::instanceKlassKlassObj())     name = "<instanceKlassKlass>";     else
+     if (_klass == Universe::typeArrayKlassKlassObj())    name = "<typeArrayKlassKlass>";    else
+-    if (_klass == Universe::symbolKlassObj())            name = "<symbolKlass>";            else
+     if (_klass == Universe::boolArrayKlassObj())         name = "<boolArrayKlass>";         else
+     if (_klass == Universe::charArrayKlassObj())         name = "<charArrayKlass>";         else
+     if (_klass == Universe::singleArrayKlassObj())       name = "<singleArrayKlass>";       else
+diff --git a/src/share/vm/memory/iterator.hpp b/src/share/vm/memory/iterator.hpp
+--- openjdk/hotspot/src/share/vm/memory/iterator.hpp
++++ openjdk/hotspot/src/share/vm/memory/iterator.hpp
+@@ -290,6 +290,22 @@
+   virtual void do_tag(int tag) = 0;
+ };
+ 
++class SymbolClosure : public StackObj {
++ public:
++  virtual void do_symbol(Symbol**) = 0;
++
++  // Clear LSB in symbol address; it can be set by CPSlot.
++  static Symbol* load_symbol(Symbol** p) {
++    return (Symbol*)(intptr_t(*p) & ~1);
++  }
++
++  // Store symbol, adjusting new pointer if the original pointer was adjusted
++  // (symbol references in constant pool slots have their LSB set to 1).
++  static void store_symbol(Symbol** p, Symbol* sym) {
++    *p = (Symbol*)(intptr_t(sym) | (intptr_t(*p) & 1));
++  }
++};
++
+ #ifdef ASSERT
+ // This class is used to flag phases of a collection that
+ // can unload classes and which should override the
+diff --git a/src/share/vm/memory/oopFactory.hpp b/src/share/vm/memory/oopFactory.hpp
+--- openjdk/hotspot/src/share/vm/memory/oopFactory.hpp
++++ openjdk/hotspot/src/share/vm/memory/oopFactory.hpp
+@@ -64,34 +64,6 @@
+ 
+   static typeArrayOop    new_typeArray(BasicType type, int length, TRAPS);
+ 
+-  // Symbols
+-  static symbolOop new_symbol(const char* utf8_buffer, int length, TRAPS) {
+-    assert(utf8_buffer != NULL, "just checking");
+-    return SymbolTable::lookup(utf8_buffer, length, CHECK_NULL);
+-  }
+-  static void new_symbols(constantPoolHandle cp, int names_count,
+-                          const char** name, int* lengths,
+-                          int* cp_indices, unsigned int* hashValues,
+-                          TRAPS) {
+-    SymbolTable::add(cp, names_count, name, lengths, cp_indices,
+-                     hashValues, CHECK);
+-  }
+-
+-  static symbolOop       new_symbol(char* name, TRAPS) { return new_symbol(name, (int)strlen(name), CHECK_NULL); }
+-  static symbolOop       new_symbol(const char* name, TRAPS) { return new_symbol(name, (int)strlen(name), CHECK_NULL); }
+-  static symbolOop       new_symbol(symbolHandle sym, int begin, int end, TRAPS) {
+-    assert(begin <= end && end <= sym->utf8_length(), "just checking");
+-    return SymbolTable::lookup(sym, begin, end, CHECK_NULL);
+-  }
+-
+-  // Create symbols as above but return a handle
+-  static symbolHandle    new_symbol_handle(const char* name, int length, TRAPS) {
+-    symbolOop sym = new_symbol(name, length, THREAD);
+-    return symbolHandle(THREAD, sym);
+-  }
+-  static symbolHandle    new_symbol_handle(char* name, TRAPS) { return new_symbol_handle(name, (int)strlen(name), CHECK_(symbolHandle())); }
+-  static symbolHandle    new_symbol_handle(const char* name, TRAPS) { return new_symbol_handle(name, (int)strlen(name), CHECK_(symbolHandle())); }
+-
+   // Constant pools
+   static constantPoolOop      new_constantPool     (int length,
+                                                     bool is_conc_safe,
+diff --git a/src/share/vm/memory/restore.cpp b/src/share/vm/memory/restore.cpp
+--- openjdk/hotspot/src/share/vm/memory/restore.cpp
++++ openjdk/hotspot/src/share/vm/memory/restore.cpp
+@@ -107,15 +107,23 @@
+   // Skip over (reserve space for) a list of addresses of C++ vtables
+   // for Klass objects.  They get filled in later.
+ 
++  void** vtbl_list = (void**)buffer;
++  buffer += vtbl_list_size * sizeof(void*);
++  Universe::init_self_patching_vtbl_list(vtbl_list, vtbl_list_size);
++
+   // Skip over (reserve space for) dummy C++ vtables Klass objects.
+   // They are used as is.
+ 
+-  void** vtbl_list = (void**)buffer;
+-  buffer += vtbl_list_size * sizeof(void*);
+   intptr_t vtable_size = *(intptr_t*)buffer;
+   buffer += sizeof(intptr_t);
+   buffer += vtable_size;
+ 
++  // Skip the recorded symbols.
++
++  intptr_t total_symbol_size = *(intptr_t*)buffer;
++  buffer += sizeof(intptr_t) * 2;
++  buffer += total_symbol_size;
++
+   // Create the symbol table using the bucket array at this spot in the
+   // misc data space.  Since the symbol table is often modified, this
+   // region (of mapped pages) will be copy-on-write.
+diff --git a/src/share/vm/memory/serialize.cpp b/src/share/vm/memory/serialize.cpp
+--- openjdk/hotspot/src/share/vm/memory/serialize.cpp
++++ openjdk/hotspot/src/share/vm/memory/serialize.cpp
+@@ -61,7 +61,7 @@
+   soc->do_tag(sizeof(constantPoolCacheOopDesc));
+   soc->do_tag(objArrayOopDesc::base_offset_in_bytes());
+   soc->do_tag(typeArrayOopDesc::base_offset_in_bytes(T_BYTE));
+-  soc->do_tag(sizeof(symbolOopDesc));
++  soc->do_tag(sizeof(Symbol));
+   soc->do_tag(sizeof(klassOopDesc));
+   soc->do_tag(sizeof(markOopDesc));
+   soc->do_tag(sizeof(compiledICHolderOopDesc));
+@@ -83,8 +83,12 @@
+   // Dump/restore miscellaneous oops.
+   Universe::oops_do(soc, true);
+   soc->do_tag(--tag);
++  CodeCache::oops_do(soc);
++  soc->do_tag(--tag);
+ 
+-  vmSymbols::oops_do(soc, true);               soc->do_tag(--tag);
+-  CodeCache::oops_do(soc);                     soc->do_tag(--tag);
++  // Dump/restore references to commonly used names and signatures.
++  vmSymbols::serialize(soc);
++  soc->do_tag(--tag);
++
+   soc->do_tag(666);
+ }
+diff --git a/src/share/vm/memory/sharedHeap.cpp b/src/share/vm/memory/sharedHeap.cpp
+--- openjdk/hotspot/src/share/vm/memory/sharedHeap.cpp
++++ openjdk/hotspot/src/share/vm/memory/sharedHeap.cpp
+@@ -46,7 +46,6 @@
+   SH_PS_Management_oops_do,
+   SH_PS_SystemDictionary_oops_do,
+   SH_PS_jvmti_oops_do,
+-  SH_PS_vmSymbols_oops_do,
+   SH_PS_SymbolTable_oops_do,
+   SH_PS_StringTable_oops_do,
+   SH_PS_CodeCache_oops_do,
+@@ -169,11 +168,6 @@
+   }
+ 
+   if (!_process_strong_tasks->is_task_claimed(SH_PS_SymbolTable_oops_do)) {
+-    if (so & SO_Symbols) {
+-      SymbolTable::oops_do(roots);
+-    }
+-    // Verify if the symbol table contents are in the perm gen
+-    NOT_PRODUCT(SymbolTable::oops_do(&assert_is_perm_closure));
+   }
+ 
+   if (!_process_strong_tasks->is_task_claimed(SH_PS_StringTable_oops_do)) {
+@@ -210,20 +204,6 @@
+     NOT_PRODUCT(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_perm));
+   }
+ 
+-  // Roots that should point only into permanent generation.
+-  {
+-    OopClosure* blk = NULL;
+-    if (collecting_perm_gen) {
+-      blk = roots;
+-    } else {
+-      debug_only(blk = &assert_is_perm_closure);
+-    }
+-    if (blk != NULL) {
+-      if (!_process_strong_tasks->is_task_claimed(SH_PS_vmSymbols_oops_do))
+-        vmSymbols::oops_do(blk);
+-    }
+-  }
+-
+   if (!collecting_perm_gen) {
+     // All threads perform this; coordination is handled internally.
+ 
+@@ -273,7 +253,6 @@
+   JNIHandles::weak_oops_do(&always_true, root_closure);
+ 
+   CodeCache::blobs_do(code_roots);
+-  SymbolTable::oops_do(root_closure);
+   if (UseSharedSpaces && !DumpSharedSpaces) {
+     SkipAdjustingSharedStrings skip_closure(root_closure);
+     StringTable::oops_do(&skip_closure);
+diff --git a/src/share/vm/memory/universe.cpp b/src/share/vm/memory/universe.cpp
+--- openjdk/hotspot/src/share/vm/memory/universe.cpp
++++ openjdk/hotspot/src/share/vm/memory/universe.cpp
+@@ -60,7 +60,6 @@
+ #include "oops/methodKlass.hpp"
+ #include "oops/objArrayKlassKlass.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolKlass.hpp"
+ #include "oops/typeArrayKlass.hpp"
+ #include "oops/typeArrayKlassKlass.hpp"
+ #include "prims/jvmtiRedefineClassesTrace.hpp"
+@@ -109,7 +108,6 @@
+ klassOop Universe::_doubleArrayKlassObj               = NULL;
+ klassOop Universe::_typeArrayKlassObjs[T_VOID+1]      = { NULL /*, NULL...*/ };
+ klassOop Universe::_objectArrayKlassObj               = NULL;
+-klassOop Universe::_symbolKlassObj                    = NULL;
+ klassOop Universe::_methodKlassObj                    = NULL;
+ klassOop Universe::_constMethodKlassObj               = NULL;
+ klassOop Universe::_methodDataKlassObj                = NULL;
+@@ -157,7 +155,6 @@
+ oop Universe::_arithmetic_exception_instance          = NULL;
+ oop Universe::_virtual_machine_error_instance         = NULL;
+ oop Universe::_vm_exception                           = NULL;
+-oop Universe::_emptySymbol                            = NULL;
+ 
+ // These variables are guarded by FullGCALot_lock.
+ debug_only(objArrayOop Universe::_fullgc_alot_dummy_array = NULL;)
+@@ -192,7 +189,6 @@
+ 
+ 
+ void Universe::system_classes_do(void f(klassOop)) {
+-  f(symbolKlassObj());
+   f(methodKlassObj());
+   f(constMethodKlassObj());
+   f(methodDataKlassObj());
+@@ -244,7 +240,6 @@
+       }
+     }
+   }
+-  f->do_oop((oop*)&_symbolKlassObj);
+   f->do_oop((oop*)&_methodKlassObj);
+   f->do_oop((oop*)&_constMethodKlassObj);
+   f->do_oop((oop*)&_methodDataKlassObj);
+@@ -282,7 +277,6 @@
+   f->do_oop((oop*)&_main_thread_group);
+   f->do_oop((oop*)&_system_thread_group);
+   f->do_oop((oop*)&_vm_exception);
+-  f->do_oop((oop*)&_emptySymbol);
+   debug_only(f->do_oop((oop*)&_fullgc_alot_dummy_array);)
+ }
+ 
+@@ -315,10 +309,6 @@
+         _instanceKlassKlassObj  = instanceKlassKlass::create_klass(CHECK);
+         _typeArrayKlassKlassObj = typeArrayKlassKlass::create_klass(CHECK);
+ 
+-        _symbolKlassObj         = symbolKlass::create_klass(CHECK);
+-
+-        _emptySymbol            = oopFactory::new_symbol("", CHECK);
+-
+         _boolArrayKlassObj      = typeArrayKlass::create_klass(T_BOOLEAN, sizeof(jboolean), CHECK);
+         _charArrayKlassObj      = typeArrayKlass::create_klass(T_CHAR,    sizeof(jchar),    CHECK);
+         _singleArrayKlassObj    = typeArrayKlass::create_klass(T_FLOAT,   sizeof(jfloat),   CHECK);
+@@ -352,13 +342,6 @@
+         _the_empty_system_obj_array = oopFactory::new_system_objArray(0, CHECK);
+ 
+         _the_array_interfaces_array = oopFactory::new_system_objArray(2, CHECK);
+-        _vm_exception               = oopFactory::new_symbol("vm exception holder", CHECK);
+-      } else {
+-        FileMapInfo *mapinfo = FileMapInfo::current_info();
+-        char* buffer = mapinfo->region_base(CompactingPermGenGen::md);
+-        void** vtbl_list = (void**)buffer;
+-        init_self_patching_vtbl_list(vtbl_list,
+-                                     CompactingPermGenGen::vtbl_list_size);
+       }
+     }
+ 
+@@ -452,15 +435,15 @@
+   if (JDK_Version::is_partially_initialized()) {
+     uint8_t jdk_version;
+     klassOop k = SystemDictionary::resolve_or_null(
+-        vmSymbolHandles::java_lang_management_MemoryUsage(), THREAD);
++        vmSymbols::java_lang_management_MemoryUsage(), THREAD);
+     CLEAR_PENDING_EXCEPTION; // ignore exceptions
+     if (k == NULL) {
+       k = SystemDictionary::resolve_or_null(
+-          vmSymbolHandles::java_lang_CharSequence(), THREAD);
++          vmSymbols::java_lang_CharSequence(), THREAD);
+       CLEAR_PENDING_EXCEPTION; // ignore exceptions
+       if (k == NULL) {
+         k = SystemDictionary::resolve_or_null(
+-            vmSymbolHandles::java_lang_Shutdown(), THREAD);
++            vmSymbols::java_lang_Shutdown(), THREAD);
+         CLEAR_PENDING_EXCEPTION; // ignore exceptions
+         if (k == NULL) {
+           jdk_version = 2;
+@@ -523,11 +506,16 @@
+ }
+ 
+ 
+-static inline void add_vtable(void** list, int* n, Klass* o, int count) {
+-  list[(*n)++] = *(void**)&o->vtbl_value();
+-  guarantee((*n) <= count, "vtable list too small.");
++static inline void* dereference(void* addr) {
++  return *(void**)addr;
+ }
+ 
++static inline void add_vtable(void** list, int* n, void* o, int count) {
++  guarantee((*n) < count, "vtable list too small");
++  void* vtable = dereference(o);
++  assert(dereference(vtable) != NULL, "invalid vtable");
++  list[(*n)++] = vtable;
++}
+ 
+ void Universe::init_self_patching_vtbl_list(void** list, int count) {
+   int n = 0;
+@@ -539,7 +527,6 @@
+   { instanceMirrorKlass o;    add_vtable(list, &n, &o, count); }
+   { instanceRefKlass o;       add_vtable(list, &n, &o, count); }
+   { typeArrayKlassKlass o;    add_vtable(list, &n, &o, count); }
+-  { symbolKlass o;            add_vtable(list, &n, &o, count); }
+   { typeArrayKlass o;         add_vtable(list, &n, &o, count); }
+   { methodKlass o;            add_vtable(list, &n, &o, count); }
+   { constMethodKlass o;       add_vtable(list, &n, &o, count); }
+@@ -548,6 +535,11 @@
+   { objArrayKlass o;          add_vtable(list, &n, &o, count); }
+   { methodDataKlass o;        add_vtable(list, &n, &o, count); }
+   { compiledICHolderKlass o;  add_vtable(list, &n, &o, count); }
++#ifndef PRODUCT
++  // In non-product builds CHeapObj is derived from AllocatedObj,
++  // so symbols in CDS archive should have their vtable pointer patched.
++  { Symbol o;                 add_vtable(list, &n, &o, count); }
++#endif
+ }
+ 
+ 
+@@ -641,8 +633,8 @@
+     JavaCalls::call_static(
+       &result,
+       finalizer_klass,
+-      vmSymbolHandles::run_finalizers_on_exit_name(),
+-      vmSymbolHandles::void_method_signature(),
++      vmSymbols::run_finalizers_on_exit_name(),
++      vmSymbols::void_method_signature(),
+       THREAD
+     );
+     // Ignore any pending exceptions
+@@ -1046,7 +1038,7 @@
+     // Setup preallocated empty java.lang.Class array
+     Universe::_the_empty_class_klass_array = oopFactory::new_objArray(SystemDictionary::Class_klass(), 0, CHECK_false);
+     // Setup preallocated OutOfMemoryError errors
+-    k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_OutOfMemoryError(), true, CHECK_false);
++    k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_OutOfMemoryError(), true, CHECK_false);
+     k_h = instanceKlassHandle(THREAD, k);
+     Universe::_out_of_memory_error_java_heap = k_h->allocate_permanent_instance(CHECK_false);
+     Universe::_out_of_memory_error_perm_gen = k_h->allocate_permanent_instance(CHECK_false);
+@@ -1056,15 +1048,15 @@
+ 
+     // Setup preallocated NullPointerException
+     // (this is currently used for a cheap & dirty solution in compiler exception handling)
+-    k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_NullPointerException(), true, CHECK_false);
++    k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_NullPointerException(), true, CHECK_false);
+     Universe::_null_ptr_exception_instance = instanceKlass::cast(k)->allocate_permanent_instance(CHECK_false);
+     // Setup preallocated ArithmeticException
+     // (this is currently used for a cheap & dirty solution in compiler exception handling)
+-    k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_ArithmeticException(), true, CHECK_false);
++    k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ArithmeticException(), true, CHECK_false);
+     Universe::_arithmetic_exception_instance = instanceKlass::cast(k)->allocate_permanent_instance(CHECK_false);
+     // Virtual Machine Error for when we get into a situation we can't resolve
+     k = SystemDictionary::resolve_or_fail(
+-      vmSymbolHandles::java_lang_VirtualMachineError(), true, CHECK_false);
++      vmSymbols::java_lang_VirtualMachineError(), true, CHECK_false);
+     bool linked = instanceKlass::cast(k)->link_class_or_fail(CHECK_false);
+     if (!linked) {
+       tty->print_cr("Unable to link/verify VirtualMachineError class");
+@@ -1072,6 +1064,9 @@
+     }
+     Universe::_virtual_machine_error_instance =
+       instanceKlass::cast(k)->allocate_permanent_instance(CHECK_false);
++
++    Universe::_vm_exception               = instanceKlass::cast(k)->allocate_permanent_instance(CHECK_false);
++
+   }
+   if (!DumpSharedSpaces) {
+     // These are the only Java fields that are currently set during shared space dumping.
+@@ -1126,7 +1121,7 @@
+   // Note: No race-condition here, since a resolve will always return the same result
+ 
+   // Setup method for security checks
+-  k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_reflect_Method(), true, CHECK_false);
++  k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_reflect_Method(), true, CHECK_false);
+   k_h = instanceKlassHandle(THREAD, k);
+   k_h->link_class(CHECK_false);
+   m = k_h->find_method(vmSymbols::invoke_name(), vmSymbols::object_object_array_object_signature());
+diff --git a/src/share/vm/memory/universe.hpp b/src/share/vm/memory/universe.hpp
+--- openjdk/hotspot/src/share/vm/memory/universe.hpp
++++ openjdk/hotspot/src/share/vm/memory/universe.hpp
+@@ -139,7 +139,6 @@
+ 
+   static klassOop _objectArrayKlassObj;
+ 
+-  static klassOop _symbolKlassObj;
+   static klassOop _methodKlassObj;
+   static klassOop _constMethodKlassObj;
+   static klassOop _methodDataKlassObj;
+@@ -199,8 +198,6 @@
+   // the vm thread.
+   static oop          _vm_exception;
+ 
+-  static oop          _emptySymbol;                   // Canonical empty string ("") symbol
+-
+   // The particular choice of collected heap.
+   static CollectedHeap* _collectedHeap;
+ 
+@@ -274,7 +271,6 @@
+     return _typeArrayKlassObjs[t];
+   }
+ 
+-  static klassOop symbolKlassObj()                    { return _symbolKlassObj;            }
+   static klassOop methodKlassObj()                    { return _methodKlassObj;            }
+   static klassOop constMethodKlassObj()               { return _constMethodKlassObj;         }
+   static klassOop methodDataKlassObj()                { return _methodDataKlassObj;        }
+@@ -288,9 +284,8 @@
+   static klassOop compiledICHolderKlassObj()          { return _compiledICHolderKlassObj;  }
+   static klassOop systemObjArrayKlassObj()            { return _systemObjArrayKlassObj;    }
+ 
+-  // Known objects in tbe VM
+-  static oop int_mirror()                   { return check_mirror(_int_mirror);
+-}
++  // Known objects in the VM
++  static oop int_mirror()                   { return check_mirror(_int_mirror); }
+   static oop float_mirror()                 { return check_mirror(_float_mirror); }
+   static oop double_mirror()                { return check_mirror(_double_mirror); }
+   static oop byte_mirror()                  { return check_mirror(_byte_mirror); }
+@@ -329,7 +324,6 @@
+   static oop          arithmetic_exception_instance() { return _arithmetic_exception_instance; }
+   static oop          virtual_machine_error_instance() { return _virtual_machine_error_instance; }
+   static oop          vm_exception()                  { return _vm_exception; }
+-  static oop          emptySymbol()                   { return _emptySymbol; }
+ 
+   // OutOfMemoryError support. Returns an error with the required message. The returned error
+   // may or may not have a backtrace. If error has a backtrace then the stack trace is already
+diff --git a/src/share/vm/oops/arrayKlass.cpp b/src/share/vm/oops/arrayKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/arrayKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/arrayKlass.cpp
+@@ -64,7 +64,7 @@
+   return NULL;
+ }
+ 
+-methodOop arrayKlass::uncached_lookup_method(symbolOop name, symbolOop signature) const {
++methodOop arrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
+   // There are no methods in an array klass but the super class (Object) has some
+   assert(super(), "super klass must be present");
+   return Klass::cast(super())->uncached_lookup_method(name, signature);
+diff --git a/src/share/vm/oops/arrayKlass.hpp b/src/share/vm/oops/arrayKlass.hpp
+--- openjdk/hotspot/src/share/vm/oops/arrayKlass.hpp
++++ openjdk/hotspot/src/share/vm/oops/arrayKlass.hpp
+@@ -84,7 +84,7 @@
+   objArrayOop allocate_arrayArray(int n, int length, TRAPS);
+ 
+   // Lookup operations
+-  methodOop uncached_lookup_method(symbolOop name, symbolOop signature) const;
++  methodOop uncached_lookup_method(Symbol* name, Symbol* signature) const;
+ 
+   // Casting from klassOop
+   static arrayKlass* cast(klassOop k) {
+diff --git a/src/share/vm/oops/arrayOop.cpp b/src/share/vm/oops/arrayOop.cpp
+--- openjdk/hotspot/src/share/vm/oops/arrayOop.cpp
++++ openjdk/hotspot/src/share/vm/oops/arrayOop.cpp
+@@ -26,6 +26,6 @@
+ #include "oops/arrayOop.hpp"
+ #include "oops/objArrayOop.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ 
+ // <<this page is intentionally left blank>>
+diff --git a/src/share/vm/oops/constantPoolKlass.cpp b/src/share/vm/oops/constantPoolKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/constantPoolKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/constantPoolKlass.cpp
+@@ -33,7 +33,7 @@
+ #include "oops/constantPoolOop.hpp"
+ #include "oops/oop.inline.hpp"
+ #include "oops/oop.inline2.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/handles.inline.hpp"
+ #ifdef TARGET_OS_FAMILY_linux
+ # include "thread_linux.inline.hpp"
+@@ -388,8 +388,12 @@
+       case JVM_CONSTANT_UnresolvedClass :               // fall-through
+       case JVM_CONSTANT_UnresolvedClassInError: {
+         // unresolved_klass_at requires lock or safe world.
+-        oop entry = *cp->obj_at_addr(index);
+-        entry->print_value_on(st);
++        CPSlot entry = cp->slot_at(index);
++        if (entry.is_oop()) {
++          entry.get_oop()->print_value_on(st);
++        } else {
++          entry.get_symbol()->print_value_on(st);
++        }
+         }
+         break;
+       case JVM_CONSTANT_MethodHandle :
+@@ -450,36 +454,43 @@
+   constantPoolOop cp = constantPoolOop(obj);
+   guarantee(cp->is_perm(), "should be in permspace");
+   if (!cp->partially_loaded()) {
+-    oop* base = (oop*)cp->base();
+     for (int i = 0; i< cp->length();  i++) {
++      CPSlot entry = cp->slot_at(i);
+       if (cp->tag_at(i).is_klass()) {
+-        guarantee((*base)->is_perm(),     "should be in permspace");
+-        guarantee((*base)->is_klass(),    "should be klass");
++        if (entry.is_oop()) {
++          guarantee(entry.get_oop()->is_perm(),     "should be in permspace");
++          guarantee(entry.get_oop()->is_klass(),    "should be klass");
++        }
+       }
+       if (cp->tag_at(i).is_unresolved_klass()) {
+-        guarantee((*base)->is_perm(),     "should be in permspace");
+-        guarantee((*base)->is_symbol() || (*base)->is_klass(),
+-                  "should be symbol or klass");
++        if (entry.is_oop()) {
++          guarantee(entry.get_oop()->is_perm(),     "should be in permspace");
++          guarantee(entry.get_oop()->is_klass(),    "should be klass");
++        }
+       }
+       if (cp->tag_at(i).is_symbol()) {
+-        guarantee((*base)->is_perm(),     "should be in permspace");
+-        guarantee((*base)->is_symbol(),   "should be symbol");
++        guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count");
+       }
+       if (cp->tag_at(i).is_unresolved_string()) {
+-        guarantee((*base)->is_perm(),     "should be in permspace");
+-        guarantee((*base)->is_symbol() || (*base)->is_instance(),
+-                  "should be symbol or instance");
++        if (entry.is_oop()) {
++          guarantee(entry.get_oop()->is_perm(),     "should be in permspace");
++          guarantee(entry.get_oop()->is_instance(), "should be instance");
++        }
++        else {
++          guarantee(entry.get_symbol()->refcount() != 0, "should have nonzero reference count");
++        }
+       }
+       if (cp->tag_at(i).is_string()) {
+         if (!cp->has_pseudo_string()) {
+-          guarantee((*base)->is_perm(),   "should be in permspace");
+-          guarantee((*base)->is_instance(), "should be instance");
++          if (entry.is_oop()) {
++            guarantee(entry.get_oop()->is_perm(),   "should be in permspace");
++            guarantee(entry.get_oop()->is_instance(), "should be instance");
++          }
+         } else {
+           // can be non-perm, can be non-instance (array)
+         }
+       }
+       // FIXME: verify JSR 292 tags JVM_CONSTANT_MethodHandle, etc.
+-      base++;
+     }
+     guarantee(cp->tags()->is_perm(),         "should be in permspace");
+     guarantee(cp->tags()->is_typeArray(),    "should be type array");
+diff --git a/src/share/vm/oops/constantPoolOop.cpp b/src/share/vm/oops/constantPoolOop.cpp
+--- openjdk/hotspot/src/share/vm/oops/constantPoolOop.cpp
++++ openjdk/hotspot/src/share/vm/oops/constantPoolOop.cpp
+@@ -52,13 +52,14 @@
+ }
+ 
+ klassOop constantPoolOopDesc::klass_at_impl(constantPoolHandle this_oop, int which, TRAPS) {
+-  // A resolved constantPool entry will contain a klassOop, otherwise a symbolOop.
++  // A resolved constantPool entry will contain a klassOop, otherwise a Symbol*.
+   // It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and
+   // tag is not updated atomicly.
+-  oop entry = *(this_oop->obj_at_addr(which));
+-  if (entry->is_klass()) {
++  CPSlot entry = this_oop->slot_at(which);
++  if (entry.is_oop()) {
++    assert(entry.get_oop()->is_klass(), "must be");
+     // Already resolved - return entry.
+-    return (klassOop)entry;
++    return (klassOop)entry.get_oop();
+   }
+ 
+   // Acquire lock on constant oop while doing update. After we get the lock, we check if another object
+@@ -67,7 +68,7 @@
+   bool do_resolve = false;
+   bool in_error = false;
+ 
+-  symbolHandle name;
++  Symbol* name = NULL;
+   Handle       loader;
+   { ObjectLocker ol(this_oop, THREAD);
+ 
+@@ -76,7 +77,7 @@
+         in_error = true;
+       } else {
+         do_resolve = true;
+-        name   = symbolHandle(THREAD, this_oop->unresolved_klass_at(which));
++        name   = this_oop->unresolved_klass_at(which);
+         loader = Handle(THREAD, instanceKlass::cast(this_oop->pool_holder())->class_loader());
+       }
+     }
+@@ -86,8 +87,8 @@
+   // The original attempt to resolve this constant pool entry failed so find the
+   // original error and throw it again (JVMS 5.4.3).
+   if (in_error) {
+-    symbolOop error = SystemDictionary::find_resolution_error(this_oop, which);
+-    guarantee(error != (symbolOop)NULL, "tag mismatch with resolution error table");
++    Symbol* error = SystemDictionary::find_resolution_error(this_oop, which);
++    guarantee(error != (Symbol*)NULL, "tag mismatch with resolution error table");
+     ResourceMark rm;
+     // exception text will be the class name
+     const char* className = this_oop->unresolved_klass_at(which)->as_C_string();
+@@ -110,7 +111,7 @@
+     // to resolve this constant pool entry fail with the same error (JVMS 5.4.3).
+     if (HAS_PENDING_EXCEPTION) {
+       ResourceMark rm;
+-      symbolHandle error(PENDING_EXCEPTION->klass()->klass_part()->name());
++      Symbol* error = PENDING_EXCEPTION->klass()->klass_part()->name();
+ 
+       bool throw_orig_error = false;
+       {
+@@ -120,7 +121,7 @@
+         if (this_oop->tag_at(which).is_klass()) {
+           CLEAR_PENDING_EXCEPTION;
+           entry = this_oop->resolved_klass_at(which);
+-          return (klassOop)entry;
++          return (klassOop)entry.get_oop();
+         }
+ 
+         if (!PENDING_EXCEPTION->
+@@ -135,8 +136,8 @@
+           this_oop->tag_at_put(which, JVM_CONSTANT_UnresolvedClassInError);
+         } else {
+           // some other thread has put the class in error state.
+-          error = symbolHandle(SystemDictionary::find_resolution_error(this_oop, which));
+-          assert(!error.is_null(), "checking");
++          error = SystemDictionary::find_resolution_error(this_oop, which);
++          assert(error != NULL, "checking");
+           throw_orig_error = true;
+         }
+       } // unlocked
+@@ -162,7 +163,7 @@
+         vframeStream vfst(JavaThread::current());
+         if (!vfst.at_end()) {
+           line_number = vfst.method()->line_number_from_bci(vfst.bci());
+-          symbolOop s = instanceKlass::cast(vfst.method()->method_holder())->source_file_name();
++          Symbol* s = instanceKlass::cast(vfst.method()->method_holder())->source_file_name();
+           if (s != NULL) {
+             source_file = s->as_C_string();
+           }
+@@ -192,8 +193,8 @@
+   }
+ 
+   entry = this_oop->resolved_klass_at(which);
+-  assert(entry->is_klass(), "must be resolved at this point");
+-  return (klassOop)entry;
++  assert(entry.is_oop() && entry.get_oop()->is_klass(), "must be resolved at this point");
++  return (klassOop)entry.get_oop();
+ }
+ 
+ 
+@@ -202,13 +203,14 @@
+ // instanceof operations. Returns NULL if the class has not been loaded or
+ // if the verification of constant pool failed
+ klassOop constantPoolOopDesc::klass_at_if_loaded(constantPoolHandle this_oop, int which) {
+-  oop entry = *this_oop->obj_at_addr(which);
+-  if (entry->is_klass()) {
+-    return (klassOop)entry;
++  CPSlot entry = this_oop->slot_at(which);
++  if (entry.is_oop()) {
++    assert(entry.get_oop()->is_klass(), "must be");
++    return (klassOop)entry.get_oop();
+   } else {
+-    assert(entry->is_symbol(), "must be either symbol or klass");
++    assert(entry.is_metadata(), "must be either symbol or klass");
+     Thread *thread = Thread::current();
+-    symbolHandle name (thread, (symbolOop)entry);
++    Symbol* name = entry.get_symbol();
+     oop loader = instanceKlass::cast(this_oop->pool_holder())->class_loader();
+     oop protection_domain = Klass::cast(this_oop->pool_holder())->protection_domain();
+     Handle h_prot (thread, protection_domain);
+@@ -244,12 +246,13 @@
+ // Note: We cannot update the ConstantPool from the vm_thread.
+ klassOop constantPoolOopDesc::klass_ref_at_if_loaded_check(constantPoolHandle this_oop, int index, TRAPS) {
+   int which = this_oop->klass_ref_index_at(index);
+-  oop entry = *this_oop->obj_at_addr(which);
+-  if (entry->is_klass()) {
+-    return (klassOop)entry;
++  CPSlot entry = this_oop->slot_at(which);
++  if (entry.is_oop()) {
++    assert(entry.get_oop()->is_klass(), "must be");
++    return (klassOop)entry.get_oop();
+   } else {
+-    assert(entry->is_symbol(), "must be either symbol or klass");
+-    symbolHandle name (THREAD, (symbolOop)entry);
++    assert(entry.is_metadata(), "must be either symbol or klass");
++    Symbol*  name  = entry.get_symbol();
+     oop loader = instanceKlass::cast(this_oop->pool_holder())->class_loader();
+     oop protection_domain = Klass::cast(this_oop->pool_holder())->protection_domain();
+     Handle h_loader(THREAD, loader);
+@@ -263,13 +266,13 @@
+ }
+ 
+ 
+-symbolOop constantPoolOopDesc::impl_name_ref_at(int which, bool uncached) {
++Symbol* constantPoolOopDesc::impl_name_ref_at(int which, bool uncached) {
+   int name_index = name_ref_index_at(impl_name_and_type_ref_index_at(which, uncached));
+   return symbol_at(name_index);
+ }
+ 
+ 
+-symbolOop constantPoolOopDesc::impl_signature_ref_at(int which, bool uncached) {
++Symbol* constantPoolOopDesc::impl_signature_ref_at(int which, bool uncached) {
+   int signature_index = signature_ref_index_at(impl_name_and_type_ref_index_at(which, uncached));
+   return symbol_at(signature_index);
+ }
+@@ -361,39 +364,40 @@
+ }
+ 
+ 
+-symbolOop constantPoolOopDesc::klass_name_at(int which) {
++Symbol* constantPoolOopDesc::klass_name_at(int which) {
+   assert(tag_at(which).is_unresolved_klass() || tag_at(which).is_klass(),
+          "Corrupted constant pool");
+-  // A resolved constantPool entry will contain a klassOop, otherwise a symbolOop.
++  // A resolved constantPool entry will contain a klassOop, otherwise a Symbol*.
+   // It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and
+   // tag is not updated atomicly.
+-  oop entry = *(obj_at_addr(which));
+-  if (entry->is_klass()) {
++  CPSlot entry = slot_at(which);
++  if (entry.is_oop()) {
+     // Already resolved - return entry's name.
+-    return klassOop(entry)->klass_part()->name();
++    assert(entry.get_oop()->is_klass(), "must be");
++    return klassOop(entry.get_oop())->klass_part()->name();
+   } else {
+-    assert(entry->is_symbol(), "must be either symbol or klass");
+-    return (symbolOop)entry;
++    assert(entry.is_metadata(), "must be either symbol or klass");
++    return entry.get_symbol();
+   }
+ }
+ 
+-symbolOop constantPoolOopDesc::klass_ref_at_noresolve(int which) {
++Symbol* constantPoolOopDesc::klass_ref_at_noresolve(int which) {
+   jint ref_index = klass_ref_index_at(which);
+   return klass_at_noresolve(ref_index);
+ }
+ 
+-symbolOop constantPoolOopDesc::uncached_klass_ref_at_noresolve(int which) {
++Symbol* constantPoolOopDesc::uncached_klass_ref_at_noresolve(int which) {
+   jint ref_index = uncached_klass_ref_index_at(which);
+   return klass_at_noresolve(ref_index);
+ }
+ 
+ char* constantPoolOopDesc::string_at_noresolve(int which) {
+   // Test entry type in case string is resolved while in here.
+-  oop entry = *(obj_at_addr(which));
+-  if (entry->is_symbol()) {
+-    return ((symbolOop)entry)->as_C_string();
+-  } else if (java_lang_String::is_instance(entry)) {
+-    return java_lang_String::as_utf8_string(entry);
++  CPSlot entry = slot_at(which);
++  if (entry.is_metadata()) {
++    return (entry.get_symbol())->as_C_string();
++  } else if (java_lang_String::is_instance(entry.get_oop())) {
++    return java_lang_String::as_utf8_string(entry.get_oop());
+   } else {
+     return (char*)"<pseudo-string>";
+   }
+@@ -498,8 +502,8 @@
+     {
+       int ref_kind                 = this_oop->method_handle_ref_kind_at(index);
+       int callee_index             = this_oop->method_handle_klass_index_at(index);
+-      symbolHandle name(THREAD,      this_oop->method_handle_name_ref_at(index));
+-      symbolHandle signature(THREAD, this_oop->method_handle_signature_ref_at(index));
++      Symbol*  name =      this_oop->method_handle_name_ref_at(index);
++      Symbol*  signature = this_oop->method_handle_signature_ref_at(index);
+       if (PrintMiscellaneous)
+         tty->print_cr("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s",
+                       ref_kind, index, this_oop->method_handle_index_at(index),
+@@ -524,7 +528,7 @@
+ 
+   case JVM_CONSTANT_MethodType:
+     {
+-      symbolHandle signature(THREAD, this_oop->method_type_signature_at(index));
++      Symbol*  signature = this_oop->method_type_signature_at(index);
+       if (PrintMiscellaneous)
+         tty->print_cr("resolve JVM_CONSTANT_MethodType [%d/%d] %s",
+                       index, this_oop->method_type_index_at(index),
+@@ -605,30 +609,33 @@
+ }
+ 
+ oop constantPoolOopDesc::string_at_impl(constantPoolHandle this_oop, int which, TRAPS) {
+-  oop entry = *(this_oop->obj_at_addr(which));
+-  if (entry->is_symbol()) {
++  oop str = NULL;
++  CPSlot entry = this_oop->slot_at(which);
++  if (entry.is_metadata()) {
+     ObjectLocker ol(this_oop, THREAD);
+     if (this_oop->tag_at(which).is_unresolved_string()) {
+       // Intern string
+-      symbolOop sym = this_oop->unresolved_string_at(which);
+-      entry = StringTable::intern(sym, CHECK_(constantPoolOop(NULL)));
+-      this_oop->string_at_put(which, entry);
++      Symbol* sym = this_oop->unresolved_string_at(which);
++      str = StringTable::intern(sym, CHECK_(constantPoolOop(NULL)));
++      this_oop->string_at_put(which, str);
+     } else {
+       // Another thread beat us and interned string, read string from constant pool
+-      entry = this_oop->resolved_string_at(which);
++      str = this_oop->resolved_string_at(which);
+     }
++  } else {
++    str = entry.get_oop();
+   }
+-  assert(java_lang_String::is_instance(entry), "must be string");
+-  return entry;
++  assert(java_lang_String::is_instance(str), "must be string");
++  return str;
+ }
+ 
+ 
+ bool constantPoolOopDesc::is_pseudo_string_at(int which) {
+-  oop entry = *(obj_at_addr(which));
+-  if (entry->is_symbol())
++  CPSlot entry = slot_at(which);
++  if (entry.is_metadata())
+     // Not yet resolved, but it will resolve to a string.
+     return false;
+-  else if (java_lang_String::is_instance(entry))
++  else if (java_lang_String::is_instance(entry.get_oop()))
+     return false; // actually, it might be a non-interned or non-perm string
+   else
+     // truly pseudo
+@@ -638,8 +645,8 @@
+ 
+ bool constantPoolOopDesc::klass_name_at_matches(instanceKlassHandle k,
+                                                 int which) {
+-  // Names are interned, so we can compare symbolOops directly
+-  symbolOop cp_name = klass_name_at(which);
++  // Names are interned, so we can compare Symbol*s directly
++  Symbol* cp_name = klass_name_at(which);
+   return (cp_name == k->name());
+ }
+ 
+@@ -650,7 +657,7 @@
+   for (int index = 1; index < tags()->length(); index++) { // Index 0 is unused
+     if (tag_at(index).is_unresolved_string()) {
+       // Intern string
+-      symbolOop sym = unresolved_string_at(index);
++      Symbol* sym = unresolved_string_at(index);
+       oop entry = StringTable::intern(sym, CHECK_(-1));
+       string_at_put(index, entry);
+     }
+@@ -658,23 +665,39 @@
+   return count;
+ }
+ 
++// Iterate over symbols and decrement ones which are Symbol*s.
++// This is done during GC so do not need to lock constantPool unless we
++// have per-thread safepoints.
++// Only decrement the UTF8 symbols. Unresolved classes and strings point to
++// these symbols but didn't increment the reference count.
++void constantPoolOopDesc::unreference_symbols() {
++  for (int index = 1; index < length(); index++) { // Index 0 is unused
++    constantTag tag = tag_at(index);
++    if (tag.is_symbol()) {
++      symbol_at(index)->decrement_refcount();
++    }
++  }
++}
+ 
+ // Iterate over symbols which are used as class, field, method names and
+ // signatures (in preparation for writing to the shared archive).
+ 
+-void constantPoolOopDesc::shared_symbols_iterate(OopClosure* closure) {
++void constantPoolOopDesc::shared_symbols_iterate(SymbolClosure* closure) {
+   for (int index = 1; index < length(); index++) { // Index 0 is unused
+     switch (tag_at(index).value()) {
+ 
+     case JVM_CONSTANT_UnresolvedClass:
+-      closure->do_oop(obj_at_addr(index));
++    case JVM_CONSTANT_UnresolvedString:
++    case JVM_CONSTANT_Utf8:
++      assert(slot_at(index).is_metadata(), "must be symbol");
++      closure->do_symbol(symbol_at_addr(index));
+       break;
+ 
+     case JVM_CONSTANT_NameAndType:
+       {
+         int i = *int_at_addr(index);
+-        closure->do_oop(obj_at_addr((unsigned)i >> 16));
+-        closure->do_oop(obj_at_addr((unsigned)i & 0xffff));
++        closure->do_symbol(symbol_at_addr((unsigned)i >> 16));
++        closure->do_symbol(symbol_at_addr((unsigned)i & 0xffff));
+       }
+       break;
+ 
+@@ -692,12 +715,6 @@
+       // Do nothing!  Not a symbol.
+       break;
+ 
+-    case JVM_CONSTANT_UnresolvedString:
+-    case JVM_CONSTANT_Utf8:
+-      // These constants are symbols, but unless these symbols are
+-      // actually to be used for something, we don't want to mark them.
+-      break;
+-
+     case JVM_CONSTANT_Long:
+     case JVM_CONSTANT_Double:
+       // Do nothing!  Not an oop. (But takes two pool entries.)
+@@ -744,7 +761,7 @@
+       break;
+ 
+     case JVM_CONSTANT_String:
+-      closure->do_oop(obj_at_addr(index));
++      closure->do_oop(obj_at_addr_raw(index));
+       break;
+ 
+     case JVM_CONSTANT_UnresolvedString:
+@@ -904,8 +921,8 @@
+ 
+   case JVM_CONSTANT_UnresolvedClass:
+   {
+-    symbolOop k1 = unresolved_klass_at(index1);
+-    symbolOop k2 = cp2->unresolved_klass_at(index2);
++    Symbol* k1 = unresolved_klass_at(index1);
++    Symbol* k2 = cp2->unresolved_klass_at(index2);
+     if (k1 == k2) {
+       return true;
+     }
+@@ -960,8 +977,8 @@
+ 
+   case JVM_CONSTANT_UnresolvedString:
+   {
+-    symbolOop s1 = unresolved_string_at(index1);
+-    symbolOop s2 = cp2->unresolved_string_at(index2);
++    Symbol* s1 = unresolved_string_at(index1);
++    Symbol* s2 = cp2->unresolved_string_at(index2);
+     if (s1 == s2) {
+       return true;
+     }
+@@ -969,8 +986,8 @@
+ 
+   case JVM_CONSTANT_Utf8:
+   {
+-    symbolOop s1 = symbol_at(index1);
+-    symbolOop s2 = cp2->symbol_at(index2);
++    Symbol* s1 = symbol_at(index1);
++    Symbol* s2 = cp2->symbol_at(index2);
+     if (s1 == s2) {
+       return true;
+     }
+@@ -1158,13 +1175,13 @@
+ 
+   case JVM_CONSTANT_UnresolvedClass:
+   {
+-    symbolOop k = from_cp->unresolved_klass_at(from_i);
++    Symbol* k = from_cp->unresolved_klass_at(from_i);
+     to_cp->unresolved_klass_at_put(to_i, k);
+   } break;
+ 
+   case JVM_CONSTANT_UnresolvedClassInError:
+   {
+-    symbolOop k = from_cp->unresolved_klass_at(from_i);
++    Symbol* k = from_cp->unresolved_klass_at(from_i);
+     to_cp->unresolved_klass_at_put(to_i, k);
+     to_cp->tag_at_put(to_i, JVM_CONSTANT_UnresolvedClassInError);
+   } break;
+@@ -1172,14 +1189,16 @@
+ 
+   case JVM_CONSTANT_UnresolvedString:
+   {
+-    symbolOop s = from_cp->unresolved_string_at(from_i);
++    Symbol* s = from_cp->unresolved_string_at(from_i);
+     to_cp->unresolved_string_at_put(to_i, s);
+   } break;
+ 
+   case JVM_CONSTANT_Utf8:
+   {
+-    symbolOop s = from_cp->symbol_at(from_i);
++    Symbol* s = from_cp->symbol_at(from_i);
+     to_cp->symbol_at_put(to_i, s);
++    // This constantPool has the same lifetime as the original, so don't
++    // increase reference counts for the copy.
+   } break;
+ 
+   case JVM_CONSTANT_MethodType:
+@@ -1453,7 +1472,7 @@
+ 
+     switch(tag) {
+       case JVM_CONSTANT_Utf8: {
+-        symbolOop sym = symbol_at(idx);
++        Symbol* sym = symbol_at(idx);
+         symmap->add_entry(sym, idx);
+         DBG(printf("adding symbol entry %s = %d\n", sym->as_utf8(), idx));
+         break;
+@@ -1461,7 +1480,7 @@
+       case JVM_CONSTANT_Class:
+       case JVM_CONSTANT_UnresolvedClass:
+       case JVM_CONSTANT_UnresolvedClassInError: {
+-        symbolOop sym = klass_name_at(idx);
++        Symbol* sym = klass_name_at(idx);
+         classmap->add_entry(sym, idx);
+         DBG(printf("adding class entry %s = %d\n", sym->as_utf8(), idx));
+         break;
+@@ -1509,7 +1528,7 @@
+         break;
+       }
+       case JVM_CONSTANT_Utf8: {
+-        symbolOop sym = symbol_at(idx);
++        Symbol* sym = symbol_at(idx);
+         char*     str = sym->as_utf8();
+         // Warning! It's crashing on x86 with len = sym->utf8_length()
+         int       len = (int) strlen(str);
+@@ -1546,7 +1565,7 @@
+       case JVM_CONSTANT_UnresolvedClass:
+       case JVM_CONSTANT_UnresolvedClassInError: {
+         *bytes = JVM_CONSTANT_Class;
+-        symbolOop sym = klass_name_at(idx);
++        Symbol* sym = klass_name_at(idx);
+         idx1 = tbl->symbol_to_value(sym);
+         assert(idx1 != 0, "Have not found a hashtable entry");
+         Bytes::put_Java_u2((address) (bytes+1), idx1);
+@@ -1556,19 +1575,19 @@
+       case JVM_CONSTANT_String: {
+         unsigned int hash;
+         char *str = string_at_noresolve(idx);
+-        symbolOop sym = SymbolTable::lookup_only(str, (int) strlen(str), hash);
++        TempNewSymbol sym = SymbolTable::lookup_only(str, (int) strlen(str), hash);
+         if (sym == NULL) {
+           // sym can be NULL if string refers to incorrectly encoded JVM_CONSTANT_Utf8
+           // this can happen with JVM TI; see CR 6839599 for more details
+-          oop string = *(obj_at_addr(idx));
++          oop string = *(obj_at_addr_raw(idx));
+           assert(java_lang_String::is_instance(string),"Not a String");
+           DBG(printf("Error #%03hd tag=%03hd\n", idx, tag));
+           idx1 = 0;
+           for (int j = 0; j < tbl->table_size() && idx1 == 0; j++) {
+             for (SymbolHashMapEntry* cur = tbl->bucket(j); cur != NULL; cur = cur->next()) {
+               int length;
+-              sym = cur->symbol();
+-              jchar* chars = sym->as_unicode(length);
++              Symbol* s = cur->symbol();
++              jchar* chars = s->as_unicode(length);
+               if (java_lang_String::equals(string, chars, length)) {
+                 idx1 = cur->value();
+                 DBG(printf("Index found: %d\n",idx1));
+@@ -1586,7 +1605,7 @@
+       }
+       case JVM_CONSTANT_UnresolvedString: {
+         *bytes = JVM_CONSTANT_String;
+-        symbolOop sym = unresolved_string_at(idx);
++        Symbol* sym = unresolved_string_at(idx);
+         idx1 = tbl->symbol_to_value(sym);
+         assert(idx1 != 0, "Have not found a hashtable entry");
+         Bytes::put_Java_u2((address) (bytes+1), idx1);
+@@ -1666,7 +1685,7 @@
+ } /* end copy_cpool_bytes */
+ 
+ 
+-void SymbolHashMap::add_entry(symbolOop sym, u2 value) {
++void SymbolHashMap::add_entry(Symbol* sym, u2 value) {
+   char *str = sym->as_utf8();
+   unsigned int hash = compute_hash(str, sym->utf8_length());
+   unsigned int index = hash % table_size();
+@@ -1687,7 +1706,7 @@
+   assert(entry->symbol() != NULL, "SymbolHashMapEntry symbol is NULL");
+ }
+ 
+-SymbolHashMapEntry* SymbolHashMap::find_entry(symbolOop sym) {
++SymbolHashMapEntry* SymbolHashMap::find_entry(Symbol* sym) {
+   assert(sym != NULL, "SymbolHashMap::find_entry - symbol is NULL");
+   char *str = sym->as_utf8();
+   int   len = sym->utf8_length();
+diff --git a/src/share/vm/oops/constantPoolOop.hpp b/src/share/vm/oops/constantPoolOop.hpp
+--- openjdk/hotspot/src/share/vm/oops/constantPoolOop.hpp
++++ openjdk/hotspot/src/share/vm/oops/constantPoolOop.hpp
+@@ -27,6 +27,7 @@
+ 
+ #include "oops/arrayOop.hpp"
+ #include "oops/cpCacheOop.hpp"
++#include "oops/symbol.hpp"
+ #include "oops/typeArrayOop.hpp"
+ #include "utilities/constantTag.hpp"
+ #ifdef TARGET_ARCH_x86
+@@ -47,10 +48,32 @@
+ // modified when the entry is resolved.  If a klass or string constant pool
+ // entry is read without a lock, only the resolved state guarantees that
+ // the entry in the constant pool is a klass or String object and
+-// not a symbolOop.
++// not a Symbol*.
+ 
+ class SymbolHashMap;
+ 
++class CPSlot VALUE_OBJ_CLASS_SPEC {
++  intptr_t _ptr;
++ public:
++  CPSlot(intptr_t ptr): _ptr(ptr) {}
++  CPSlot(void* ptr): _ptr((intptr_t)ptr) {}
++  CPSlot(oop ptr): _ptr((intptr_t)ptr) {}
++  CPSlot(Symbol* ptr): _ptr((intptr_t)ptr | 1) {}
++
++  intptr_t value()   { return _ptr; }
++  bool is_oop()      { return (_ptr & 1) == 0; }
++  bool is_metadata() { return (_ptr & 1) == 1; }
++
++  oop get_oop() {
++    assert(is_oop(), "bad call");
++    return oop(_ptr);
++  }
++  Symbol* get_symbol() {
++    assert(is_metadata(), "bad call");
++    return (Symbol*)(_ptr & ~1);
++  }
++};
++
+ class constantPoolOopDesc : public oopDesc {
+   friend class VMStructs;
+   friend class BytecodeInterpreter;  // Directly extracts an oop in the pool for fast instanceof/checkcast
+@@ -89,11 +112,41 @@
+   oop* cache_addr()      { return (oop*)&_cache; }
+   oop* operands_addr()   { return (oop*)&_operands; }
+ 
+-  oop* obj_at_addr(int which) const {
++  CPSlot slot_at(int which) {
++    assert(is_within_bounds(which), "index out of bounds");
++    // There's a transitional value of zero when converting from
++    // Symbol->0->Klass for G1 when resolving classes and strings.
++    // wait for the value to be non-zero (this is temporary)
++    volatile intptr_t adr = (intptr_t)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which));
++    if (adr == 0 && which != 0) {
++      constantTag t = tag_at(which);
++      if (t.is_unresolved_klass() || t.is_klass() ||
++          t.is_unresolved_string() || t.is_string()) {
++        while ((adr = (intptr_t)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))) == 0);
++      }
++    }
++    return CPSlot(adr);
++  }
++
++  void slot_at_put(int which, CPSlot s) const {
++    assert(is_within_bounds(which), "index out of bounds");
++    *(intptr_t*)&base()[which] = s.value();
++  }
++  oop* obj_at_addr_raw(int which) const {
+     assert(is_within_bounds(which), "index out of bounds");
+     return (oop*) &base()[which];
+   }
+ 
++  void obj_at_put_without_check(int which, oop o) {
++    assert(is_within_bounds(which), "index out of bounds");
++    oop_store_without_check((volatile oop *)obj_at_addr_raw(which), o);
++  }
++
++  void obj_at_put(int which, oop o) const {
++    assert(is_within_bounds(which), "index out of bounds");
++    oop_store((volatile oop*)obj_at_addr_raw(which), o);
++  }
++
+   jint* int_at_addr(int which) const {
+     assert(is_within_bounds(which), "index out of bounds");
+     return (jint*) &base()[which];
+@@ -141,15 +194,20 @@
+   // Storing constants
+ 
+   void klass_at_put(int which, klassOop k) {
+-    oop_store_without_check((volatile oop *)obj_at_addr(which), oop(k));
++    // Overwrite the old index with a GC friendly value so
++    // that if G1 looks during the transition during oop_store it won't
++    // assert the symbol is not an oop.
++    *obj_at_addr_raw(which) = NULL;
++    assert(k != NULL, "resolved class shouldn't be null");
++    obj_at_put_without_check(which, k);
+     // The interpreter assumes when the tag is stored, the klass is resolved
+-    // and the klassOop is a klass rather than a symbolOop, so we need
++    // and the klassOop is a klass rather than a Symbol*, so we need
+     // hardware store ordering here.
+     release_tag_at_put(which, JVM_CONSTANT_Class);
+     if (UseConcMarkSweepGC) {
+       // In case the earlier card-mark was consumed by a concurrent
+       // marking thread before the tag was updated, redirty the card.
+-      oop_store_without_check((volatile oop *)obj_at_addr(which), oop(k));
++      obj_at_put_without_check(which, k);
+     }
+   }
+ 
+@@ -160,13 +218,9 @@
+   }
+ 
+   // Temporary until actual use
+-  void unresolved_klass_at_put(int which, symbolOop s) {
+-    // Overwrite the old index with a GC friendly value so
+-    // that if GC looks during the transition it won't try
+-    // to treat a small integer as oop.
+-    *obj_at_addr(which) = NULL;
++  void unresolved_klass_at_put(int which, Symbol* s) {
+     release_tag_at_put(which, JVM_CONSTANT_UnresolvedClass);
+-    oop_store_without_check(obj_at_addr(which), oop(s));
++    slot_at_put(which, s);
+   }
+ 
+   void method_handle_index_at_put(int which, int ref_kind, int ref_index) {
+@@ -191,10 +245,9 @@
+   }
+ 
+   // Temporary until actual use
+-  void unresolved_string_at_put(int which, symbolOop s) {
+-    *obj_at_addr(which) = NULL;
++  void unresolved_string_at_put(int which, Symbol* s) {
+     release_tag_at_put(which, JVM_CONSTANT_UnresolvedString);
+-    oop_store_without_check(obj_at_addr(which), oop(s));
++    slot_at_put(which, s);
+   }
+ 
+   void int_at_put(int which, jint i) {
+@@ -220,28 +273,39 @@
+     Bytes::put_native_u8((address) double_at_addr(which), *((u8*) &d));
+   }
+ 
+-  void symbol_at_put(int which, symbolOop s) {
++  Symbol** symbol_at_addr(int which) const {
++    assert(is_within_bounds(which), "index out of bounds");
++    return (Symbol**) &base()[which];
++  }
++
++  void symbol_at_put(int which, Symbol* s) {
++    assert(s->refcount() != 0, "should have nonzero refcount");
+     tag_at_put(which, JVM_CONSTANT_Utf8);
+-    oop_store_without_check(obj_at_addr(which), oop(s));
++    slot_at_put(which, s);
+   }
+ 
+   void string_at_put(int which, oop str) {
+-    oop_store((volatile oop*)obj_at_addr(which), str);
++    // Overwrite the old index with a GC friendly value so
++    // that if G1 looks during the transition during oop_store it won't
++    // assert the symbol is not an oop.
++    *obj_at_addr_raw(which) = NULL;
++    assert(str != NULL, "resolved string shouldn't be null");
++    obj_at_put(which, str);
+     release_tag_at_put(which, JVM_CONSTANT_String);
+     if (UseConcMarkSweepGC) {
+       // In case the earlier card-mark was consumed by a concurrent
+       // marking thread before the tag was updated, redirty the card.
+-      oop_store_without_check((volatile oop *)obj_at_addr(which), str);
++      obj_at_put_without_check(which, str);
+     }
+   }
+ 
+   void object_at_put(int which, oop str) {
+-    oop_store((volatile oop*) obj_at_addr(which), str);
++    obj_at_put(which, str);
+     release_tag_at_put(which, JVM_CONSTANT_Object);
+     if (UseConcMarkSweepGC) {
+       // In case the earlier card-mark was consumed by a concurrent
+       // marking thread before the tag was updated, redirty the card.
+-      oop_store_without_check((volatile oop*) obj_at_addr(which), str);
++      obj_at_put_without_check(which, str);
+     }
+   }
+ 
+@@ -279,13 +343,19 @@
+   bool is_pointer_entry(int which) {
+     constantTag tag = tag_at(which);
+     return tag.is_klass() ||
+-      tag.is_unresolved_klass() ||
+-      tag.is_symbol() ||
+-      tag.is_unresolved_string() ||
+       tag.is_string() ||
+       tag.is_object();
+   }
+ 
++  // Whether the entry points to an object for ldc (resolved or not)
++  bool is_object_entry(int which) {
++    constantTag tag = tag_at(which);
++    return is_pointer_entry(which) ||
++      tag.is_unresolved_klass() ||
++      tag.is_unresolved_string() ||
++      tag.is_symbol();
++  }
++
+   // Fetching constants
+ 
+   klassOop klass_at(int which, TRAPS) {
+@@ -293,25 +363,25 @@
+     return klass_at_impl(h_this, which, CHECK_NULL);
+   }
+ 
+-  symbolOop klass_name_at(int which);  // Returns the name, w/o resolving.
++  Symbol* klass_name_at(int which);  // Returns the name, w/o resolving.
+ 
+   klassOop resolved_klass_at(int which) {  // Used by Compiler
+     guarantee(tag_at(which).is_klass(), "Corrupted constant pool");
+     // Must do an acquire here in case another thread resolved the klass
+     // behind our back, lest we later load stale values thru the oop.
+-    return klassOop((oop)OrderAccess::load_ptr_acquire(obj_at_addr(which)));
++    return klassOop(CPSlot(OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_oop());
+   }
+ 
+   // This method should only be used with a cpool lock or during parsing or gc
+-  symbolOop unresolved_klass_at(int which) {     // Temporary until actual use
+-    symbolOop s = symbolOop((oop)OrderAccess::load_ptr_acquire(obj_at_addr(which)));
++  Symbol* unresolved_klass_at(int which) {     // Temporary until actual use
++    Symbol* s = CPSlot(OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_symbol();
+     // check that the klass is still unresolved.
+     assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool");
+     return s;
+   }
+ 
+   // RedefineClasses() API support:
+-  symbolOop klass_at_noresolve(int which) { return klass_name_at(which); }
++  Symbol* klass_at_noresolve(int which) { return klass_name_at(which); }
+ 
+   jint int_at(int which) {
+     assert(tag_at(which).is_int(), "Corrupted constant pool");
+@@ -336,9 +406,9 @@
+     return *((jdouble*)&tmp);
+   }
+ 
+-  symbolOop symbol_at(int which) {
++  Symbol* symbol_at(int which) {
+     assert(tag_at(which).is_utf8(), "Corrupted constant pool");
+-    return symbolOop(*obj_at_addr(which));
++    return slot_at(which).get_symbol();
+   }
+ 
+   oop string_at(int which, TRAPS) {
+@@ -348,7 +418,7 @@
+ 
+   oop object_at(int which) {
+     assert(tag_at(which).is_object(), "Corrupted constant pool");
+-    return *obj_at_addr(which);
++    return slot_at(which).get_oop();
+   }
+ 
+   // A "pseudo-string" is an non-string oop that has found is way into
+@@ -362,7 +432,7 @@
+ 
+   oop pseudo_string_at(int which) {
+     assert(tag_at(which).is_string(), "Corrupted constant pool");
+-    return *obj_at_addr(which);
++    return slot_at(which).get_oop();
+   }
+ 
+   void pseudo_string_at_put(int which, oop x) {
+@@ -378,12 +448,12 @@
+     assert(tag_at(which).is_string(), "Corrupted constant pool");
+     // Must do an acquire here in case another thread resolved the klass
+     // behind our back, lest we later load stale values thru the oop.
+-    return (oop)OrderAccess::load_ptr_acquire(obj_at_addr(which));
++    return CPSlot(OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_oop();
+   }
+ 
+   // This method should only be used with a cpool lock or during parsing or gc
+-  symbolOop unresolved_string_at(int which) {    // Temporary until actual use
+-    symbolOop s = symbolOop((oop)OrderAccess::load_ptr_acquire(obj_at_addr(which)));
++  Symbol* unresolved_string_at(int which) {    // Temporary until actual use
++    Symbol* s = CPSlot(OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_symbol();
+     // check that the string is still unresolved.
+     assert(tag_at(which).is_unresolved_string(), "Corrupted constant pool");
+     return s;
+@@ -391,7 +461,7 @@
+ 
+   // Returns an UTF8 for a CONSTANT_String entry at a given index.
+   // UTF8 char* representation was chosen to avoid conversion of
+-  // java_lang_Strings at resolved entries into symbolOops
++  // java_lang_Strings at resolved entries into Symbol*s
+   // or vice versa.
+   // Caller is responsible for checking for pseudo-strings.
+   char* string_at_noresolve(int which);
+@@ -414,11 +484,11 @@
+     return *int_at_addr(which);
+   }
+   // Derived queries:
+-  symbolOop method_handle_name_ref_at(int which) {
++  Symbol* method_handle_name_ref_at(int which) {
+     int member = method_handle_index_at(which);
+     return impl_name_ref_at(member, true);
+   }
+-  symbolOop method_handle_signature_ref_at(int which) {
++  Symbol* method_handle_signature_ref_at(int which) {
+     int member = method_handle_index_at(which);
+     return impl_signature_ref_at(member, true);
+   }
+@@ -426,7 +496,7 @@
+     int member = method_handle_index_at(which);
+     return impl_klass_ref_index_at(member, true);
+   }
+-  symbolOop method_type_signature_at(int which) {
++  Symbol* method_type_signature_at(int which) {
+     int sym = method_type_index_at(which);
+     return symbol_at(sym);
+   }
+@@ -534,9 +604,9 @@
+ 
+   // Lookup for entries consisting of (klass_index, name_and_type index)
+   klassOop klass_ref_at(int which, TRAPS);
+-  symbolOop klass_ref_at_noresolve(int which);
+-  symbolOop name_ref_at(int which)                { return impl_name_ref_at(which, false); }
+-  symbolOop signature_ref_at(int which)           { return impl_signature_ref_at(which, false); }
++  Symbol* klass_ref_at_noresolve(int which);
++  Symbol* name_ref_at(int which)                { return impl_name_ref_at(which, false); }
++  Symbol* signature_ref_at(int which)           { return impl_signature_ref_at(which, false); }
+ 
+   int klass_ref_index_at(int which)               { return impl_klass_ref_index_at(which, false); }
+   int name_and_type_ref_index_at(int which)       { return impl_name_and_type_ref_index_at(which, false); }
+@@ -605,15 +675,15 @@
+   // Routines currently used for annotations (only called by jvm.cpp) but which might be used in the
+   // future by other Java code. These take constant pool indices rather than
+   // constant pool cache indices as do the peer methods above.
+-  symbolOop uncached_klass_ref_at_noresolve(int which);
+-  symbolOop uncached_name_ref_at(int which)                 { return impl_name_ref_at(which, true); }
+-  symbolOop uncached_signature_ref_at(int which)            { return impl_signature_ref_at(which, true); }
++  Symbol* uncached_klass_ref_at_noresolve(int which);
++  Symbol* uncached_name_ref_at(int which)                 { return impl_name_ref_at(which, true); }
++  Symbol* uncached_signature_ref_at(int which)            { return impl_signature_ref_at(which, true); }
+   int       uncached_klass_ref_index_at(int which)          { return impl_klass_ref_index_at(which, true); }
+   int       uncached_name_and_type_ref_index_at(int which)  { return impl_name_and_type_ref_index_at(which, true); }
+ 
+   // Sharing
+   int pre_resolve_shared_klasses(TRAPS);
+-  void shared_symbols_iterate(OopClosure* closure0);
++  void shared_symbols_iterate(SymbolClosure* closure0);
+   void shared_tags_iterate(OopClosure* closure0);
+   void shared_strings_iterate(OopClosure* closure0);
+ 
+@@ -628,8 +698,8 @@
+ 
+  private:
+ 
+-  symbolOop impl_name_ref_at(int which, bool uncached);
+-  symbolOop impl_signature_ref_at(int which, bool uncached);
++  Symbol* impl_name_ref_at(int which, bool uncached);
++  Symbol* impl_signature_ref_at(int which, bool uncached);
+   int       impl_klass_ref_index_at(int which, bool uncached);
+   int       impl_name_and_type_ref_index_at(int which, bool uncached);
+ 
+@@ -672,6 +742,9 @@
+   int  orig_length() const                { return _orig_length; }
+   void set_orig_length(int orig_length)   { _orig_length = orig_length; }
+ 
++  // Decrease ref counts of symbols that are in the constant pool
++  // when the holder class is unloaded
++  void unreference_symbols();
+ 
+   // JVMTI accesss - GetConstantPool, RetransformClasses, ...
+   friend class JvmtiConstantPoolReconstituter;
+@@ -694,7 +767,7 @@
+  private:
+   unsigned int        _hash;   // 32-bit hash for item
+   SymbolHashMapEntry* _next;   // Next element in the linked list for this bucket
+-  symbolOop           _symbol; // 1-st part of the mapping: symbol => value
++  Symbol*             _symbol; // 1-st part of the mapping: symbol => value
+   u2                  _value;  // 2-nd part of the mapping: symbol => value
+ 
+  public:
+@@ -704,13 +777,13 @@
+   SymbolHashMapEntry* next() const        { return _next;   }
+   void set_next(SymbolHashMapEntry* next) { _next = next;   }
+ 
+-  symbolOop  symbol() const               { return _symbol; }
+-  void       set_symbol(symbolOop sym)    { _symbol = sym;  }
++  Symbol*    symbol() const               { return _symbol; }
++  void       set_symbol(Symbol* sym)      { _symbol = sym;  }
+ 
+   u2         value() const                {  return _value; }
+   void       set_value(u2 value)          { _value = value; }
+ 
+-  SymbolHashMapEntry(unsigned int hash, symbolOop symbol, u2 value)
++  SymbolHashMapEntry(unsigned int hash, Symbol* symbol, u2 value)
+     : _hash(hash), _symbol(symbol), _value(value), _next(NULL) {}
+ 
+ }; // End SymbolHashMapEntry class
+@@ -769,10 +842,10 @@
+     return _buckets[i].entry();
+   }
+ 
+-  void add_entry(symbolOop sym, u2 value);
+-  SymbolHashMapEntry* find_entry(symbolOop sym);
++  void add_entry(Symbol* sym, u2 value);
++  SymbolHashMapEntry* find_entry(Symbol* sym);
+ 
+-  u2 symbol_to_value(symbolOop sym) {
++  u2 symbol_to_value(Symbol* sym) {
+     SymbolHashMapEntry *entry = find_entry(sym);
+     return (entry == NULL) ? 0 : entry->value();
+   }
+diff --git a/src/share/vm/oops/generateOopMap.cpp b/src/share/vm/oops/generateOopMap.cpp
+--- openjdk/hotspot/src/share/vm/oops/generateOopMap.cpp
++++ openjdk/hotspot/src/share/vm/oops/generateOopMap.cpp
+@@ -26,7 +26,7 @@
+ #include "interpreter/bytecodeStream.hpp"
+ #include "oops/generateOopMap.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/handles.inline.hpp"
+ #include "runtime/java.hpp"
+ #include "runtime/relocator.hpp"
+@@ -123,7 +123,7 @@
+                                            set(CellTypeState::value); }
+ 
+ public:
+-  ComputeCallStack(symbolOop signature) : SignatureIterator(signature) {};
++  ComputeCallStack(Symbol* signature) : SignatureIterator(signature) {};
+ 
+   // Compute methods
+   int compute_for_parameters(bool is_static, CellTypeState *effect) {
+@@ -177,7 +177,7 @@
+                                           set(CellTypeState::value); }
+ 
+ public:
+-  ComputeEntryStack(symbolOop signature) : SignatureIterator(signature) {};
++  ComputeEntryStack(Symbol* signature) : SignatureIterator(signature) {};
+ 
+   // Compute methods
+   int compute_for_parameters(bool is_static, CellTypeState *effect) {
+@@ -669,7 +669,7 @@
+   _monitor_top = 0;
+ }
+ 
+-int GenerateOopMap::methodsig_to_effect(symbolOop signature, bool is_static, CellTypeState* effect) {
++int GenerateOopMap::methodsig_to_effect(Symbol* signature, bool is_static, CellTypeState* effect) {
+   ComputeEntryStack ces(signature);
+   return ces.compute_for_parameters(is_static, effect);
+ }
+@@ -1285,7 +1285,7 @@
+         constantPoolOop cp    = method()->constants();
+         int nameAndTypeIdx    = cp->name_and_type_ref_index_at(idx);
+         int signatureIdx      = cp->signature_ref_index_at(nameAndTypeIdx);
+-        symbolOop signature   = cp->symbol_at(signatureIdx);
++        Symbol* signature     = cp->symbol_at(signatureIdx);
+         os->print("%s", signature->as_C_string());
+     }
+     os->cr();
+@@ -1317,7 +1317,7 @@
+         constantPoolOop cp    = method()->constants();
+         int nameAndTypeIdx    = cp->name_and_type_ref_index_at(idx);
+         int signatureIdx      = cp->signature_ref_index_at(nameAndTypeIdx);
+-        symbolOop signature   = cp->symbol_at(signatureIdx);
++        Symbol* signature     = cp->symbol_at(signatureIdx);
+         os->print("%s", signature->as_C_string());
+     }
+     os->cr();
+@@ -1864,7 +1864,7 @@
+   // Make sure bt==T_OBJECT is the same as old code (is_pointer_entry).
+   // Note that CONSTANT_MethodHandle entries are u2 index pairs, not pointer-entries,
+   // and they are processed by _fast_aldc and the CP cache.
+-  assert((ldc.has_cache_index() || cp->is_pointer_entry(ldc.pool_index()))
++  assert((ldc.has_cache_index() || cp->is_object_entry(ldc.pool_index()))
+          ? (bt == T_OBJECT) : true, "expected object type");
+   ppush1(cts);
+ }
+@@ -1904,7 +1904,7 @@
+   constantPoolOop cp     = method()->constants();
+   int nameAndTypeIdx     = cp->name_and_type_ref_index_at(idx);
+   int signatureIdx       = cp->signature_ref_index_at(nameAndTypeIdx);
+-  symbolOop signature    = cp->symbol_at(signatureIdx);
++  Symbol* signature      = cp->symbol_at(signatureIdx);
+ 
+   // Parse signature (espcially simple for fields)
+   assert(signature->utf8_length() > 0, "field signatures cannot have zero length");
+@@ -1932,7 +1932,7 @@
+ void GenerateOopMap::do_method(int is_static, int is_interface, int idx, int bci) {
+  // Dig up signature for field in constant pool
+   constantPoolOop cp  = _method->constants();
+-  symbolOop signature = cp->signature_ref_at(idx);
++  Symbol* signature   = cp->signature_ref_at(idx);
+ 
+   // Parse method signature
+   CellTypeState out[4];
+diff --git a/src/share/vm/oops/generateOopMap.hpp b/src/share/vm/oops/generateOopMap.hpp
+--- openjdk/hotspot/src/share/vm/oops/generateOopMap.hpp
++++ openjdk/hotspot/src/share/vm/oops/generateOopMap.hpp
+@@ -323,7 +323,7 @@
+   // Cell type methods
+   void            init_state();
+   void            make_context_uninitialized ();
+-  int             methodsig_to_effect        (symbolOop signature, bool isStatic, CellTypeState* effect);
++  int             methodsig_to_effect        (Symbol* signature, bool isStatic, CellTypeState* effect);
+   bool            merge_local_state_vectors  (CellTypeState* cts, CellTypeState* bbts);
+   bool            merge_monitor_state_vectors(CellTypeState* cts, CellTypeState* bbts);
+   void            copy_state                 (CellTypeState *dst, CellTypeState *src);
+diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlass.cpp
+@@ -42,7 +42,7 @@
+ #include "oops/methodOop.hpp"
+ #include "oops/objArrayKlassKlass.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "prims/jvmtiExport.hpp"
+ #include "prims/jvmtiRedefineClassesTrace.hpp"
+ #include "runtime/fieldDescriptor.hpp"
+@@ -97,7 +97,7 @@
+   {                                                              \
+     char* data = NULL;                                           \
+     int len = 0;                                                 \
+-    symbolOop name = (clss)->name();                             \
++    Symbol* name = (clss)->name();                               \
+     if (name != NULL) {                                          \
+       data = (char*)name->bytes();                               \
+       len = name->utf8_length();                                 \
+@@ -110,7 +110,7 @@
+   {                                                              \
+     char* data = NULL;                                           \
+     int len = 0;                                                 \
+-    symbolOop name = (clss)->name();                             \
++    Symbol* name = (clss)->name();                               \
+     if (name != NULL) {                                          \
+       data = (char*)name->bytes();                               \
+       len = name->utf8_length();                                 \
+@@ -267,7 +267,7 @@
+       ResourceMark rm(THREAD);
+       Exceptions::fthrow(
+         THREAD_AND_LOCATION,
+-        vmSymbolHandles::java_lang_IncompatibleClassChangeError(),
++        vmSymbols::java_lang_IncompatibleClassChangeError(),
+         "class %s has interface %s as super class",
+         this_oop->external_name(),
+         super->external_name()
+@@ -501,8 +501,8 @@
+       THROW_OOP(e());
+     } else {
+       JavaCallArguments args(e);
+-      THROW_ARG(vmSymbolHandles::java_lang_ExceptionInInitializerError(),
+-                vmSymbolHandles::throwable_void_signature(),
++      THROW_ARG(vmSymbols::java_lang_ExceptionInInitializerError(),
++                vmSymbols::throwable_void_signature(),
+                 &args);
+     }
+   }
+@@ -773,13 +773,13 @@
+ }
+ 
+ 
+-bool instanceKlass::find_local_field(symbolOop name, symbolOop sig, fieldDescriptor* fd) const {
++bool instanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
+   const int n = fields()->length();
+   for (int i = 0; i < n; i += next_offset ) {
+     int name_index = fields()->ushort_at(i + name_index_offset);
+     int sig_index  = fields()->ushort_at(i + signature_index_offset);
+-    symbolOop f_name = constants()->symbol_at(name_index);
+-    symbolOop f_sig  = constants()->symbol_at(sig_index);
++    Symbol* f_name = constants()->symbol_at(name_index);
++    Symbol* f_sig  = constants()->symbol_at(sig_index);
+     if (f_name == name && f_sig == sig) {
+       fd->initialize(as_klassOop(), i);
+       return true;
+@@ -789,21 +789,23 @@
+ }
+ 
+ 
+-void instanceKlass::field_names_and_sigs_iterate(OopClosure* closure) {
++void instanceKlass::shared_symbols_iterate(SymbolClosure* closure) {
++  Klass::shared_symbols_iterate(closure);
++  closure->do_symbol(&_generic_signature);
++  closure->do_symbol(&_source_file_name);
++  closure->do_symbol(&_source_debug_extension);
++
+   const int n = fields()->length();
+   for (int i = 0; i < n; i += next_offset ) {
+     int name_index = fields()->ushort_at(i + name_index_offset);
+-    symbolOop name = constants()->symbol_at(name_index);
+-    closure->do_oop((oop*)&name);
+-
++    closure->do_symbol(constants()->symbol_at_addr(name_index));
+     int sig_index  = fields()->ushort_at(i + signature_index_offset);
+-    symbolOop sig = constants()->symbol_at(sig_index);
+-    closure->do_oop((oop*)&sig);
++    closure->do_symbol(constants()->symbol_at_addr(sig_index));
+   }
+ }
+ 
+ 
+-klassOop instanceKlass::find_interface_field(symbolOop name, symbolOop sig, fieldDescriptor* fd) const {
++klassOop instanceKlass::find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
+   const int n = local_interfaces()->length();
+   for (int i = 0; i < n; i++) {
+     klassOop intf1 = klassOop(local_interfaces()->obj_at(i));
+@@ -822,7 +824,7 @@
+ }
+ 
+ 
+-klassOop instanceKlass::find_field(symbolOop name, symbolOop sig, fieldDescriptor* fd) const {
++klassOop instanceKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
+   // search order according to newest JVM spec (5.4.3.2, p.167).
+   // 1) search for field in current klass
+   if (find_local_field(name, sig, fd)) {
+@@ -841,7 +843,7 @@
+ }
+ 
+ 
+-klassOop instanceKlass::find_field(symbolOop name, symbolOop sig, bool is_static, fieldDescriptor* fd) const {
++klassOop instanceKlass::find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const {
+   // search order according to newest JVM spec (5.4.3.2, p.167).
+   // 1) search for field in current klass
+   if (find_local_field(name, sig, fd)) {
+@@ -969,7 +971,7 @@
+ }
+ 
+ #ifdef ASSERT
+-static int linear_search(objArrayOop methods, symbolOop name, symbolOop signature) {
++static int linear_search(objArrayOop methods, Symbol* name, Symbol* signature) {
+   int len = methods->length();
+   for (int index = 0; index < len; index++) {
+     methodOop m = (methodOop)(methods->obj_at(index));
+@@ -982,11 +984,11 @@
+ }
+ #endif
+ 
+-methodOop instanceKlass::find_method(symbolOop name, symbolOop signature) const {
++methodOop instanceKlass::find_method(Symbol* name, Symbol* signature) const {
+   return instanceKlass::find_method(methods(), name, signature);
+ }
+ 
+-methodOop instanceKlass::find_method(objArrayOop methods, symbolOop name, symbolOop signature) {
++methodOop instanceKlass::find_method(objArrayOop methods, Symbol* name, Symbol* signature) {
+   int len = methods->length();
+   // methods are sorted, so do binary search
+   int l = 0;
+@@ -1034,7 +1036,7 @@
+   return NULL;
+ }
+ 
+-methodOop instanceKlass::uncached_lookup_method(symbolOop name, symbolOop signature) const {
++methodOop instanceKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
+   klassOop klass = as_klassOop();
+   while (klass != NULL) {
+     methodOop method = instanceKlass::cast(klass)->find_method(name, signature);
+@@ -1045,8 +1047,8 @@
+ }
+ 
+ // lookup a method in all the interfaces that this class implements
+-methodOop instanceKlass::lookup_method_in_all_interfaces(symbolOop name,
+-                                                         symbolOop signature) const {
++methodOop instanceKlass::lookup_method_in_all_interfaces(Symbol* name,
++                                                         Symbol* signature) const {
+   objArrayOop all_ifs = instanceKlass::cast(as_klassOop())->transitive_interfaces();
+   int num_ifs = all_ifs->length();
+   instanceKlass *ik = NULL;
+@@ -1893,6 +1895,26 @@
+     _cached_class_file_bytes = NULL;
+     _cached_class_file_len = 0;
+   }
++
++  // Decrement symbol reference counts associated with the unloaded class.
++  if (_name != NULL) _name->decrement_refcount();
++  // unreference array name derived from this class name (arrays of an unloaded
++  // class can't be referenced anymore).
++  if (_array_name != NULL)  _array_name->decrement_refcount();
++  if (_source_file_name != NULL) _source_file_name->decrement_refcount();
++  if (_source_debug_extension != NULL) _source_debug_extension->decrement_refcount();
++  // walk constant pool and decrement symbol reference counts
++  _constants->unreference_symbols();
++}
++
++void instanceKlass::set_source_file_name(Symbol* n) {
++  _source_file_name = n;
++  if (_source_file_name != NULL) _source_file_name->increment_refcount();
++}
++
++void instanceKlass::set_source_debug_extension(Symbol* n) {
++  _source_debug_extension = n;
++  if (_source_debug_extension != NULL) _source_debug_extension->increment_refcount();
+ }
+ 
+ address instanceKlass::static_field_addr(int offset) {
+@@ -1919,7 +1941,7 @@
+ bool instanceKlass::is_same_class_package(klassOop class2) {
+   klassOop class1 = as_klassOop();
+   oop classloader1 = instanceKlass::cast(class1)->class_loader();
+-  symbolOop classname1 = Klass::cast(class1)->name();
++  Symbol* classname1 = Klass::cast(class1)->name();
+ 
+   if (Klass::cast(class2)->oop_is_objArray()) {
+     class2 = objArrayKlass::cast(class2)->bottom_klass();
+@@ -1931,16 +1953,16 @@
+     assert(Klass::cast(class2)->oop_is_typeArray(), "should be type array");
+     classloader2 = NULL;
+   }
+-  symbolOop classname2 = Klass::cast(class2)->name();
++  Symbol* classname2 = Klass::cast(class2)->name();
+ 
+   return instanceKlass::is_same_class_package(classloader1, classname1,
+                                               classloader2, classname2);
+ }
+ 
+-bool instanceKlass::is_same_class_package(oop classloader2, symbolOop classname2) {
++bool instanceKlass::is_same_class_package(oop classloader2, Symbol* classname2) {
+   klassOop class1 = as_klassOop();
+   oop classloader1 = instanceKlass::cast(class1)->class_loader();
+-  symbolOop classname1 = Klass::cast(class1)->name();
++  Symbol* classname1 = Klass::cast(class1)->name();
+ 
+   return instanceKlass::is_same_class_package(classloader1, classname1,
+                                               classloader2, classname2);
+@@ -1948,8 +1970,8 @@
+ 
+ // return true if two classes are in the same package, classloader
+ // and classname information is enough to determine a class's package
+-bool instanceKlass::is_same_class_package(oop class_loader1, symbolOop class_name1,
+-                                          oop class_loader2, symbolOop class_name2) {
++bool instanceKlass::is_same_class_package(oop class_loader1, Symbol* class_name1,
++                                          oop class_loader2, Symbol* class_name2) {
+   if (class_loader1 != class_loader2) {
+     return false;
+   } else if (class_name1 == class_name2) {
+@@ -1957,14 +1979,14 @@
+   } else {
+     ResourceMark rm;
+ 
+-    // The symbolOop's are in UTF8 encoding. Since we only need to check explicitly
++    // The Symbol*'s are in UTF8 encoding. Since we only need to check explicitly
+     // for ASCII characters ('/', 'L', '['), we can keep them in UTF8 encoding.
+     // Otherwise, we just compare jbyte values between the strings.
+-    jbyte *name1 = class_name1->base();
+-    jbyte *name2 = class_name2->base();
+-
+-    jbyte *last_slash1 = UTF8::strrchr(name1, class_name1->utf8_length(), '/');
+-    jbyte *last_slash2 = UTF8::strrchr(name2, class_name2->utf8_length(), '/');
++    const jbyte *name1 = class_name1->base();
++    const jbyte *name2 = class_name2->base();
++
++    const jbyte *last_slash1 = UTF8::strrchr(name1, class_name1->utf8_length(), '/');
++    const jbyte *last_slash2 = UTF8::strrchr(name2, class_name2->utf8_length(), '/');
+ 
+     if ((last_slash1 == NULL) || (last_slash2 == NULL)) {
+       // One of the two doesn't have a package.  Only return true
+@@ -2005,7 +2027,7 @@
+ // Assumes name-signature match
+ // "this" is instanceKlass of super_method which must exist
+ // note that the instanceKlass of the method in the targetclassname has not always been created yet
+-bool instanceKlass::is_override(methodHandle super_method, Handle targetclassloader, symbolHandle targetclassname, TRAPS) {
++bool instanceKlass::is_override(methodHandle super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS) {
+    // Private methods can not be overridden
+    if (super_method->is_private()) {
+      return false;
+@@ -2017,12 +2039,12 @@
+    }
+    // Package-private methods are not inherited outside of package
+    assert(super_method->is_package_private(), "must be package private");
+-   return(is_same_class_package(targetclassloader(), targetclassname()));
++   return(is_same_class_package(targetclassloader(), targetclassname));
+ }
+ 
+ /* defined for now in jvm.cpp, for historical reasons *--
+ klassOop instanceKlass::compute_enclosing_class_impl(instanceKlassHandle self,
+-                                                     symbolOop& simple_name_result, TRAPS) {
++                                                     Symbol*& simple_name_result, TRAPS) {
+   ...
+ }
+ */
+@@ -2093,7 +2115,7 @@
+ 
+       // only look at classes that are already loaded
+       // since we are looking for the flags for our self.
+-      symbolOop inner_name = ik->constants()->klass_name_at(ioff);
++      Symbol* inner_name = ik->constants()->klass_name_at(ioff);
+       if ((ik->name() == inner_name)) {
+         // This is really a member class.
+         access = inner_class_list_h->ushort_at(i + instanceKlass::inner_class_access_flags_offset);
+@@ -2132,7 +2154,7 @@
+     // If the interface isn't implemented by the receiver class,
+     // the VM should throw IncompatibleClassChangeError.
+     if (cnt >= nof_interfaces) {
+-      THROW_OOP_0(vmSymbols::java_lang_IncompatibleClassChangeError());
++      THROW_0(vmSymbols::java_lang_IncompatibleClassChangeError());
+     }
+ 
+     klassOop ik = ioe->interface_klass();
+@@ -2142,7 +2164,7 @@
+   itableMethodEntry* ime = ioe->first_method_entry(as_klassOop());
+   methodOop m = ime[index].method();
+   if (m == NULL) {
+-    THROW_OOP_0(vmSymbols::java_lang_AbstractMethodError());
++    THROW_0(vmSymbols::java_lang_AbstractMethodError());
+   }
+   return m;
+ }
+@@ -2635,8 +2657,8 @@
+       if (!emcp_methods->at(i)) {
+         // only obsolete methods are interesting
+         methodOop old_method = (methodOop) old_methods->obj_at(i);
+-        symbolOop m_name = old_method->name();
+-        symbolOop m_signature = old_method->signature();
++        Symbol* m_name = old_method->name();
++        Symbol* m_signature = old_method->signature();
+ 
+         // skip the last entry since we just added it
+         for (int j = _previous_versions->length() - 2; j >= 0; j--) {
+diff --git a/src/share/vm/oops/instanceKlass.hpp b/src/share/vm/oops/instanceKlass.hpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlass.hpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlass.hpp
+@@ -187,16 +187,10 @@
+   klassOop        _host_klass;
+   // Class signers.
+   objArrayOop     _signers;
+-  // Name of source file containing this klass, NULL if not specified.
+-  symbolOop       _source_file_name;
+-  // the source debug extension for this klass, NULL if not specified.
+-  symbolOop       _source_debug_extension;
+   // inner_classes attribute.
+   typeArrayOop    _inner_classes;
+   // Implementors of this interface (not valid if it overflows)
+   klassOop        _implementors[implementors_limit];
+-  // Generic signature, or null if none.
+-  symbolOop       _generic_signature;
+   // invokedynamic bootstrap method (a java.dyn.MethodHandle)
+   oop             _bootstrap_method;
+   // Annotations for this class, or null if none.
+@@ -220,6 +214,16 @@
+   // End of the oop block.
+   //
+ 
++  // Name of source file containing this klass, NULL if not specified.
++  Symbol*         _source_file_name;
++  // the source debug extension for this klass, NULL if not specified.
++  Symbol*         _source_debug_extension;
++  // Generic signature, or null if none.
++  Symbol*         _generic_signature;
++  // Array name derived from this class which needs unreferencing
++  // if this class is unloaded.
++  Symbol*         _array_name;
++
+   // Number of heapOopSize words used by non-static fields in this klass
+   // (including inherited fields but after header_size()).
+   int             _nonstatic_field_size;
+@@ -341,12 +345,12 @@
+   };
+ 
+   // method override check
+-  bool is_override(methodHandle super_method, Handle targetclassloader, symbolHandle targetclassname, TRAPS);
++  bool is_override(methodHandle super_method, Handle targetclassloader, Symbol* targetclassname, TRAPS);
+ 
+   // package
+   bool is_same_class_package(klassOop class2);
+-  bool is_same_class_package(oop classloader2, symbolOop classname2);
+-  static bool is_same_class_package(oop class_loader1, symbolOop class_name1, oop class_loader2, symbolOop class_name2);
++  bool is_same_class_package(oop classloader2, Symbol* classname2);
++  static bool is_same_class_package(oop class_loader1, Symbol* class_name1, oop class_loader2, Symbol* class_name2);
+ 
+   // find an enclosing class (defined where original code was, in jvm.cpp!)
+   klassOop compute_enclosing_class(bool* inner_is_member, TRAPS) {
+@@ -400,13 +404,13 @@
+   void set_reference_type(ReferenceType t) { _reference_type = t; }
+ 
+   // find local field, returns true if found
+-  bool find_local_field(symbolOop name, symbolOop sig, fieldDescriptor* fd) const;
++  bool find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
+   // find field in direct superinterfaces, returns the interface in which the field is defined
+-  klassOop find_interface_field(symbolOop name, symbolOop sig, fieldDescriptor* fd) const;
++  klassOop find_interface_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
+   // find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined
+-  klassOop find_field(symbolOop name, symbolOop sig, fieldDescriptor* fd) const;
++  klassOop find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;
+   // find instance or static fields according to JVM spec 5.4.3.2, returns the klass in which the field is defined
+-  klassOop find_field(symbolOop name, symbolOop sig, bool is_static, fieldDescriptor* fd) const;
++  klassOop find_field(Symbol* name, Symbol* sig, bool is_static, fieldDescriptor* fd) const;
+ 
+   // find a non-static or static field given its offset within the class.
+   bool contains_field_offset(int offset) {
+@@ -417,15 +421,15 @@
+   bool find_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const;
+ 
+   // find a local method (returns NULL if not found)
+-  methodOop find_method(symbolOop name, symbolOop signature) const;
+-  static methodOop find_method(objArrayOop methods, symbolOop name, symbolOop signature);
++  methodOop find_method(Symbol* name, Symbol* signature) const;
++  static methodOop find_method(objArrayOop methods, Symbol* name, Symbol* signature);
+ 
+   // lookup operation (returns NULL if not found)
+-  methodOop uncached_lookup_method(symbolOop name, symbolOop signature) const;
++  methodOop uncached_lookup_method(Symbol* name, Symbol* signature) const;
+ 
+   // lookup a method in all the interfaces that this class implements
+   // (returns NULL if not found)
+-  methodOop lookup_method_in_all_interfaces(symbolOop name, symbolOop signature) const;
++  methodOop lookup_method_in_all_interfaces(Symbol* name, Symbol* signature) const;
+ 
+   // constant pool
+   constantPoolOop constants() const        { return _constants; }
+@@ -449,8 +453,8 @@
+   void set_signers(objArrayOop s)          { oop_store((oop*) &_signers, oop(s)); }
+ 
+   // source file name
+-  symbolOop source_file_name() const       { return _source_file_name; }
+-  void set_source_file_name(symbolOop n)   { oop_store_without_check((oop*) &_source_file_name, (oop) n); }
++  Symbol* source_file_name() const         { return _source_file_name; }
++  void set_source_file_name(Symbol* n);
+ 
+   // minor and major version numbers of class file
+   u2 minor_version() const                 { return _minor_version; }
+@@ -459,8 +463,12 @@
+   void set_major_version(u2 major_version) { _major_version = major_version; }
+ 
+   // source debug extension
+-  symbolOop source_debug_extension() const    { return _source_debug_extension; }
+-  void set_source_debug_extension(symbolOop n){ oop_store_without_check((oop*) &_source_debug_extension, (oop) n); }
++  Symbol* source_debug_extension() const   { return _source_debug_extension; }
++  void set_source_debug_extension(Symbol* n);
++
++  // symbol unloading support (refcount already added)
++  Symbol* array_name()                     { return _array_name; }
++  void set_array_name(Symbol* name)        { assert(_array_name == NULL, "name already created"); _array_name = name; }
+ 
+   // nonstatic oop-map blocks
+   static int nonstatic_oop_map_size(unsigned int oop_map_count) {
+@@ -509,8 +517,9 @@
+   void set_initial_method_idnum(u2 value)             { _idnum_allocated_count = value; }
+ 
+   // generics support
+-  symbolOop generic_signature() const                 { return _generic_signature; }
+-  void set_generic_signature(symbolOop sig)           { oop_store_without_check((oop*)&_generic_signature, (oop)sig); }
++  Symbol* generic_signature() const                   { return _generic_signature; }
++  void set_generic_signature(Symbol* sig)             { _generic_signature = sig; }
++
+   u2 enclosing_method_class_index() const             { return _enclosing_method_class_index; }
+   u2 enclosing_method_method_index() const            { return _enclosing_method_method_index; }
+   void set_enclosing_method_indices(u2 class_index,
+@@ -782,11 +791,8 @@
+   oop* adr_protection_domain() const { return (oop*)&this->_protection_domain;}
+   oop* adr_host_klass() const        { return (oop*)&this->_host_klass;}
+   oop* adr_signers() const           { return (oop*)&this->_signers;}
+-  oop* adr_source_file_name() const  { return (oop*)&this->_source_file_name;}
+-  oop* adr_source_debug_extension() const { return (oop*)&this->_source_debug_extension;}
+   oop* adr_inner_classes() const     { return (oop*)&this->_inner_classes;}
+   oop* adr_implementors() const      { return (oop*)&this->_implementors[0];}
+-  oop* adr_generic_signature() const { return (oop*)&this->_generic_signature;}
+   oop* adr_bootstrap_method() const  { return (oop*)&this->_bootstrap_method;}
+   oop* adr_methods_jmethod_ids() const             { return (oop*)&this->_methods_jmethod_ids;}
+   oop* adr_methods_cached_itable_indices() const   { return (oop*)&this->_methods_cached_itable_indices;}
+@@ -818,7 +824,7 @@
+ public:
+   // sharing support
+   virtual void remove_unshareable_info();
+-  void field_names_and_sigs_iterate(OopClosure* closure);
++  virtual void shared_symbols_iterate(SymbolClosure* closure);
+ 
+   // jvm support
+   jint compute_modifier_flags(TRAPS) const;
+diff --git a/src/share/vm/oops/instanceKlassKlass.cpp b/src/share/vm/oops/instanceKlassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
+@@ -38,7 +38,7 @@
+ #include "oops/objArrayOop.hpp"
+ #include "oops/oop.inline.hpp"
+ #include "oops/oop.inline2.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "oops/typeArrayOop.hpp"
+ #include "prims/jvmtiExport.hpp"
+ #include "runtime/fieldDescriptor.hpp"
+@@ -101,13 +101,10 @@
+   MarkSweep::mark_and_push(ik->adr_fields());
+   MarkSweep::mark_and_push(ik->adr_constants());
+   MarkSweep::mark_and_push(ik->adr_class_loader());
+-  MarkSweep::mark_and_push(ik->adr_source_file_name());
+-  MarkSweep::mark_and_push(ik->adr_source_debug_extension());
+   MarkSweep::mark_and_push(ik->adr_inner_classes());
+   MarkSweep::mark_and_push(ik->adr_protection_domain());
+   MarkSweep::mark_and_push(ik->adr_host_klass());
+   MarkSweep::mark_and_push(ik->adr_signers());
+-  MarkSweep::mark_and_push(ik->adr_generic_signature());
+   MarkSweep::mark_and_push(ik->adr_bootstrap_method());
+   MarkSweep::mark_and_push(ik->adr_class_annotations());
+   MarkSweep::mark_and_push(ik->adr_fields_annotations());
+@@ -141,13 +138,10 @@
+   PSParallelCompact::mark_and_push(cm, ik->adr_fields());
+   PSParallelCompact::mark_and_push(cm, ik->adr_constants());
+   PSParallelCompact::mark_and_push(cm, ik->adr_class_loader());
+-  PSParallelCompact::mark_and_push(cm, ik->adr_source_file_name());
+-  PSParallelCompact::mark_and_push(cm, ik->adr_source_debug_extension());
+   PSParallelCompact::mark_and_push(cm, ik->adr_inner_classes());
+   PSParallelCompact::mark_and_push(cm, ik->adr_protection_domain());
+   PSParallelCompact::mark_and_push(cm, ik->adr_host_klass());
+   PSParallelCompact::mark_and_push(cm, ik->adr_signers());
+-  PSParallelCompact::mark_and_push(cm, ik->adr_generic_signature());
+   PSParallelCompact::mark_and_push(cm, ik->adr_bootstrap_method());
+   PSParallelCompact::mark_and_push(cm, ik->adr_class_annotations());
+   PSParallelCompact::mark_and_push(cm, ik->adr_fields_annotations());
+@@ -187,13 +181,10 @@
+   blk->do_oop(ik->adr_protection_domain());
+   blk->do_oop(ik->adr_host_klass());
+   blk->do_oop(ik->adr_signers());
+-  blk->do_oop(ik->adr_source_file_name());
+-  blk->do_oop(ik->adr_source_debug_extension());
+   blk->do_oop(ik->adr_inner_classes());
+   for (int i = 0; i < instanceKlass::implementors_limit; i++) {
+     blk->do_oop(&ik->adr_implementors()[i]);
+   }
+-  blk->do_oop(ik->adr_generic_signature());
+   blk->do_oop(ik->adr_bootstrap_method());
+   blk->do_oop(ik->adr_class_annotations());
+   blk->do_oop(ik->adr_fields_annotations());
+@@ -242,18 +233,12 @@
+   if (mr.contains(adr)) blk->do_oop(adr);
+   adr = ik->adr_signers();
+   if (mr.contains(adr)) blk->do_oop(adr);
+-  adr = ik->adr_source_file_name();
+-  if (mr.contains(adr)) blk->do_oop(adr);
+-  adr = ik->adr_source_debug_extension();
+-  if (mr.contains(adr)) blk->do_oop(adr);
+   adr = ik->adr_inner_classes();
+   if (mr.contains(adr)) blk->do_oop(adr);
+   adr = ik->adr_implementors();
+   for (int i = 0; i < instanceKlass::implementors_limit; i++) {
+     if (mr.contains(&adr[i])) blk->do_oop(&adr[i]);
+   }
+-  adr = ik->adr_generic_signature();
+-  if (mr.contains(adr)) blk->do_oop(adr);
+   adr = ik->adr_bootstrap_method();
+   if (mr.contains(adr)) blk->do_oop(adr);
+   adr = ik->adr_class_annotations();
+@@ -292,13 +277,10 @@
+   MarkSweep::adjust_pointer(ik->adr_protection_domain());
+   MarkSweep::adjust_pointer(ik->adr_host_klass());
+   MarkSweep::adjust_pointer(ik->adr_signers());
+-  MarkSweep::adjust_pointer(ik->adr_source_file_name());
+-  MarkSweep::adjust_pointer(ik->adr_source_debug_extension());
+   MarkSweep::adjust_pointer(ik->adr_inner_classes());
+   for (int i = 0; i < instanceKlass::implementors_limit; i++) {
+     MarkSweep::adjust_pointer(&ik->adr_implementors()[i]);
+   }
+-  MarkSweep::adjust_pointer(ik->adr_generic_signature());
+   MarkSweep::adjust_pointer(ik->adr_bootstrap_method());
+   MarkSweep::adjust_pointer(ik->adr_class_annotations());
+   MarkSweep::adjust_pointer(ik->adr_fields_annotations());
+@@ -452,6 +434,8 @@
+     ik->set_signers(NULL);
+     ik->set_source_file_name(NULL);
+     ik->set_source_debug_extension(NULL);
++    ik->set_source_debug_extension(NULL);
++    ik->set_array_name(NULL);
+     ik->set_inner_classes(NULL);
+     ik->set_static_oop_field_count(0);
+     ik->set_nonstatic_field_size(0);
+@@ -657,7 +641,7 @@
+ #endif
+     // Verify that klass is present in SystemDictionary
+     if (ik->is_loaded() && !ik->is_anonymous()) {
+-      symbolHandle h_name (thread, ik->name());
++      Symbol* h_name = ik->name();
+       Handle h_loader (thread, ik->class_loader());
+       Handle h_obj(thread, obj);
+       SystemDictionary::verify_obj_klass_present(h_obj, h_name, h_loader);
+@@ -782,14 +766,6 @@
+     guarantee(ik->constants()->is_constantPool(),    "should be constant pool");
+     guarantee(ik->inner_classes()->is_perm(),        "should be in permspace");
+     guarantee(ik->inner_classes()->is_typeArray(),   "should be type array");
+-    if (ik->source_file_name() != NULL) {
+-      guarantee(ik->source_file_name()->is_perm(),   "should be in permspace");
+-      guarantee(ik->source_file_name()->is_symbol(), "should be symbol");
+-    }
+-    if (ik->source_debug_extension() != NULL) {
+-      guarantee(ik->source_debug_extension()->is_perm(),   "should be in permspace");
+-      guarantee(ik->source_debug_extension()->is_symbol(), "should be symbol");
+-    }
+     if (ik->protection_domain() != NULL) {
+       guarantee(ik->protection_domain()->is_oop(),  "should be oop");
+     }
+@@ -799,10 +775,6 @@
+     if (ik->signers() != NULL) {
+       guarantee(ik->signers()->is_objArray(),       "should be obj array");
+     }
+-    if (ik->generic_signature() != NULL) {
+-      guarantee(ik->generic_signature()->is_perm(),   "should be in permspace");
+-      guarantee(ik->generic_signature()->is_symbol(), "should be symbol");
+-    }
+     if (ik->class_annotations() != NULL) {
+       guarantee(ik->class_annotations()->is_typeArray(), "should be type array");
+     }
+diff --git a/src/share/vm/oops/klass.cpp b/src/share/vm/oops/klass.cpp
+--- openjdk/hotspot/src/share/vm/oops/klass.cpp
++++ openjdk/hotspot/src/share/vm/oops/klass.cpp
+@@ -35,6 +35,10 @@
+ #include "oops/oop.inline2.hpp"
+ #include "runtime/atomic.hpp"
+ 
++void Klass::set_name(Symbol* n) {
++  _name = n;
++  if (_name != NULL) _name->increment_refcount();
++}
+ 
+ bool Klass::is_subclass_of(klassOop k) const {
+   // Run up the super chain and check
+@@ -115,7 +119,7 @@
+ }
+ 
+ 
+-methodOop Klass::uncached_lookup_method(symbolOop name, symbolOop signature) const {
++methodOop Klass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
+ #ifdef ASSERT
+   tty->print_cr("Error: uncached_lookup_method called on a klass oop."
+                 " Likely error: reflection method does not correctly"
+@@ -454,6 +458,11 @@
+ }
+ 
+ 
++void Klass::shared_symbols_iterate(SymbolClosure* closure) {
++  closure->do_symbol(&_name);
++}
++
++
+ klassOop Klass::array_klass_or_null(int rank) {
+   EXCEPTION_MARK;
+   // No exception can be thrown by array_klass_impl when called with or_null == true.
+diff --git a/src/share/vm/oops/klass.hpp b/src/share/vm/oops/klass.hpp
+--- openjdk/hotspot/src/share/vm/oops/klass.hpp
++++ openjdk/hotspot/src/share/vm/oops/klass.hpp
+@@ -212,6 +212,10 @@
+   // secondary supers, else is &_primary_supers[depth()].
+   juint       _super_check_offset;
+ 
++  // Class name.  Instance classes: java/lang/String, etc.  Array classes: [I,
++  // [Ljava/lang/String;, etc.  Set to zero for all other kinds of classes.
++  Symbol*     _name;
++
+  public:
+   oop* oop_block_beg() const { return adr_secondary_super_cache(); }
+   oop* oop_block_end() const { return adr_next_sibling() + 1; }
+@@ -235,9 +239,6 @@
+   oop       _java_mirror;
+   // Superclass
+   klassOop  _super;
+-  // Class name.  Instance classes: java/lang/String, etc.  Array classes: [I,
+-  // [Ljava/lang/String;, etc.  Set to zero for all other kinds of classes.
+-  symbolOop _name;
+   // First subclass (NULL if none); _subklass->next_sibling() is next one
+   klassOop _subklass;
+   // Sibling link (or NULL); links all subklasses of a klass
+@@ -361,7 +362,6 @@
+   oop* adr_secondary_super_cache() const { return (oop*)&_secondary_super_cache; }
+   oop* adr_secondary_supers()const { return (oop*)&_secondary_supers;  }
+   oop* adr_java_mirror()     const { return (oop*)&_java_mirror;       }
+-  oop* adr_name()            const { return (oop*)&_name;              }
+   oop* adr_subklass()        const { return (oop*)&_subklass;          }
+   oop* adr_next_sibling()    const { return (oop*)&_next_sibling;      }
+ 
+@@ -511,9 +511,9 @@
+   virtual void initialize(TRAPS);
+   // lookup operation for MethodLookupCache
+   friend class MethodLookupCache;
+-  virtual methodOop uncached_lookup_method(symbolOop name, symbolOop signature) const;
++  virtual methodOop uncached_lookup_method(Symbol* name, Symbol* signature) const;
+  public:
+-  methodOop lookup_method(symbolOop name, symbolOop signature) const {
++  methodOop lookup_method(Symbol* name, Symbol* signature) const {
+     return uncached_lookup_method(name, signature);
+   }
+ 
+@@ -537,6 +537,7 @@
+ 
+  public:
+   virtual void remove_unshareable_info();
++  virtual void shared_symbols_iterate(SymbolClosure* closure);
+ 
+  protected:
+   // computes the subtype relationship
+@@ -580,7 +581,6 @@
+   virtual bool oop_is_instanceRef()         const { return false; }
+   virtual bool oop_is_array()               const { return false; }
+   virtual bool oop_is_objArray_slow()       const { return false; }
+-  virtual bool oop_is_symbol()              const { return false; }
+   virtual bool oop_is_klass()               const { return false; }
+   virtual bool oop_is_thread()              const { return false; }
+   virtual bool oop_is_method()              const { return false; }
+@@ -782,8 +782,8 @@
+   Klass *up_cast_abstract();
+ 
+   // klass name
+-  symbolOop name() const                   { return _name; }
+-  void set_name(symbolOop n)               { oop_store_without_check((oop*) &_name, (oop) n); }
++  Symbol* name() const                   { return _name; }
++  void set_name(Symbol* n);
+ 
+   friend class klassKlass;
+ 
+diff --git a/src/share/vm/oops/klassKlass.cpp b/src/share/vm/oops/klassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/klassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/klassKlass.cpp
+@@ -37,8 +37,7 @@
+ #include "oops/objArrayKlass.hpp"
+ #include "oops/oop.inline.hpp"
+ #include "oops/oop.inline2.hpp"
+-#include "oops/symbolKlass.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "oops/typeArrayKlass.hpp"
+ #include "runtime/handles.inline.hpp"
+ #ifndef SERIALGC
+@@ -74,7 +73,6 @@
+   MarkSweep::mark_and_push(k->adr_secondary_super_cache());
+   MarkSweep::mark_and_push(k->adr_secondary_supers());
+   MarkSweep::mark_and_push(k->adr_java_mirror());
+-  MarkSweep::mark_and_push(k->adr_name());
+   // We follow the subklass and sibling links at the end of the
+   // marking phase, since otherwise following them will prevent
+   // class unloading (all classes are transitively linked from
+@@ -94,7 +92,6 @@
+   PSParallelCompact::mark_and_push(cm, k->adr_secondary_super_cache());
+   PSParallelCompact::mark_and_push(cm, k->adr_secondary_supers());
+   PSParallelCompact::mark_and_push(cm, k->adr_java_mirror());
+-  PSParallelCompact::mark_and_push(cm, k->adr_name());
+   // We follow the subklass and sibling links at the end of the
+   // marking phase, since otherwise following them will prevent
+   // class unloading (all classes are transitively linked from
+@@ -114,7 +111,6 @@
+   blk->do_oop(k->adr_secondary_super_cache());
+   blk->do_oop(k->adr_secondary_supers());
+   blk->do_oop(k->adr_java_mirror());
+-  blk->do_oop(k->adr_name());
+   // The following are in the perm gen and are treated
+   // specially in a later phase of a perm gen collection; ...
+   assert(oop(k)->is_perm(), "should be in perm");
+@@ -148,8 +144,6 @@
+   if (mr.contains(adr)) blk->do_oop(adr);
+   adr = k->adr_java_mirror();
+   if (mr.contains(adr)) blk->do_oop(adr);
+-  adr = k->adr_name();
+-  if (mr.contains(adr)) blk->do_oop(adr);
+   // The following are "weak links" in the perm gen and are
+   // treated specially in a later phase of a perm gen collection.
+   assert(oop(k)->is_perm(), "should be in perm");
+@@ -178,7 +172,6 @@
+   MarkSweep::adjust_pointer(k->adr_secondary_super_cache());
+   MarkSweep::adjust_pointer(k->adr_secondary_supers());
+   MarkSweep::adjust_pointer(k->adr_java_mirror());
+-  MarkSweep::adjust_pointer(k->adr_name());
+   MarkSweep::adjust_pointer(k->adr_subklass());
+   MarkSweep::adjust_pointer(k->adr_next_sibling());
+   return size;
+@@ -266,9 +259,4 @@
+     guarantee(k->java_mirror()->is_perm() || !JavaObjectsInPerm,       "should be in permspace");
+     guarantee(k->java_mirror()->is_instance(),   "should be instance");
+   }
+-  if (k->name() != NULL) {
+-    guarantee(Universe::heap()->is_in_permanent(k->name()),
+-              "should be in permspace");
+-    guarantee(k->name()->is_symbol(), "should be symbol");
+-  }
+ }
+diff --git a/src/share/vm/oops/klassVtable.cpp b/src/share/vm/oops/klassVtable.cpp
+--- openjdk/hotspot/src/share/vm/oops/klassVtable.cpp
++++ openjdk/hotspot/src/share/vm/oops/klassVtable.cpp
+@@ -61,7 +61,7 @@
+                                                        objArrayOop methods,
+                                                        AccessFlags class_flags,
+                                                        Handle classloader,
+-                                                       symbolHandle classname,
++                                                       Symbol* classname,
+                                                        objArrayOop local_interfaces,
+                                                        TRAPS
+                                                        ) {
+@@ -210,7 +210,7 @@
+ // the superclass's method, but might indirectly override a super-super class's vtable entry
+ // If none found, return a null superk, else return the superk of the method this does override
+ instanceKlass* klassVtable::find_transitive_override(instanceKlass* initialsuper, methodHandle target_method,
+-                            int vtable_index, Handle target_loader, symbolHandle target_classname, Thread * THREAD) {
++                            int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) {
+   instanceKlass* superk = initialsuper;
+   while (superk != NULL && superk->super() != NULL) {
+     instanceKlass* supersuperklass = instanceKlass::cast(superk->super());
+@@ -218,9 +218,9 @@
+     if (vtable_index < ssVtable->length()) {
+       methodOop super_method = ssVtable->method_at(vtable_index);
+ #ifndef PRODUCT
+-      symbolHandle name(THREAD,target_method()->name());
+-      symbolHandle signature(THREAD,target_method()->signature());
+-      assert(super_method->name() == name() && super_method->signature() == signature(), "vtable entry name/sig mismatch");
++      Symbol* name= target_method()->name();
++      Symbol* signature = target_method()->signature();
++      assert(super_method->name() == name && super_method->signature() == signature, "vtable entry name/sig mismatch");
+ #endif
+       if (supersuperklass->is_override(super_method, target_loader, target_classname, THREAD)) {
+ #ifndef PRODUCT
+@@ -294,14 +294,14 @@
+   // which can block for gc, once we are in this loop, use handles
+   // For classfiles built with >= jdk7, we now look for transitive overrides
+ 
+-  symbolHandle name(THREAD,target_method()->name());
+-  symbolHandle signature(THREAD,target_method()->signature());
++  Symbol* name = target_method()->name();
++  Symbol* signature = target_method()->signature();
+   Handle target_loader(THREAD, _klass->class_loader());
+-  symbolHandle target_classname(THREAD, _klass->name());
++  Symbol*  target_classname = _klass->name();
+   for(int i = 0; i < super_vtable_len; i++) {
+     methodOop super_method = method_at(i);
+     // Check if method name matches
+-    if (super_method->name() == name() && super_method->signature() == signature()) {
++    if (super_method->name() == name && super_method->signature() == signature) {
+ 
+       // get super_klass for method_holder for the found method
+       instanceKlass* super_klass =  instanceKlass::cast(super_method->method_holder());
+@@ -406,7 +406,7 @@
+ bool klassVtable::needs_new_vtable_entry(methodHandle target_method,
+                                          klassOop super,
+                                          Handle classloader,
+-                                         symbolHandle classname,
++                                         Symbol* classname,
+                                          AccessFlags class_flags,
+                                          TRAPS) {
+   if ((class_flags.is_final() || target_method()->is_final()) ||
+@@ -436,8 +436,8 @@
+   // search through the super class hierarchy to see if we need
+   // a new entry
+   ResourceMark rm;
+-  symbolOop name = target_method()->name();
+-  symbolOop signature = target_method()->signature();
++  Symbol* name = target_method()->name();
++  Symbol* signature = target_method()->signature();
+   klassOop k = super;
+   methodOop super_method = NULL;
+   instanceKlass *holder = NULL;
+@@ -485,7 +485,7 @@
+ // Support for miranda methods
+ 
+ // get the vtable index of a miranda method with matching "name" and "signature"
+-int klassVtable::index_of_miranda(symbolOop name, symbolOop signature) {
++int klassVtable::index_of_miranda(Symbol* name, Symbol* signature) {
+   // search from the bottom, might be faster
+   for (int i = (length() - 1); i >= 0; i--) {
+     methodOop m = table()[i].method();
+@@ -516,9 +516,8 @@
+ // check if a method is a miranda method, given a class's methods table and it's super
+ // the caller must make sure that the method belongs to an interface implemented by the class
+ bool klassVtable::is_miranda(methodOop m, objArrayOop class_methods, klassOop super) {
+-  symbolOop name = m->name();
+-  symbolOop signature = m->signature();
+-
++  Symbol* name = m->name();
++  Symbol* signature = m->signature();
+   if (instanceKlass::find_method(class_methods, name, signature) == NULL) {
+     // did not find it in the method table of the current class
+     if (super == NULL) {
+@@ -929,8 +928,8 @@
+   // methods needs a handle in case of gc from check_signature_loaders
+   for(; i < nof_methods; i++) {
+     methodOop m = (methodOop)methods()->obj_at(i);
+-    symbolOop method_name = m->name();
+-    symbolOop method_signature = m->signature();
++    Symbol* method_name = m->name();
++    Symbol* method_signature = m->signature();
+ 
+     // This is same code as in Linkresolver::lookup_instance_method_in_klasses
+     methodOop target = klass->uncached_lookup_method(method_name, method_signature);
+diff --git a/src/share/vm/oops/klassVtable.hpp b/src/share/vm/oops/klassVtable.hpp
+--- openjdk/hotspot/src/share/vm/oops/klassVtable.hpp
++++ openjdk/hotspot/src/share/vm/oops/klassVtable.hpp
+@@ -71,7 +71,7 @@
+ 
+   // searching; all methods return -1 if not found
+   int index_of(methodOop m) const                         { return index_of(m, _length); }
+-  int index_of_miranda(symbolOop name, symbolOop signature);
++  int index_of_miranda(Symbol* name, Symbol* signature);
+ 
+   void initialize_vtable(bool checkconstraints, TRAPS);   // initialize vtable of a new klass
+ 
+@@ -79,7 +79,7 @@
+   static void compute_vtable_size_and_num_mirandas(int &vtable_length, int &num_miranda_methods,
+                                                    klassOop super, objArrayOop methods,
+                                                    AccessFlags class_flags, Handle classloader,
+-                                                   symbolHandle classname, objArrayOop local_interfaces,
++                                                   Symbol* classname, objArrayOop local_interfaces,
+                                                    TRAPS);
+ 
+   // RedefineClasses() API support:
+@@ -125,11 +125,11 @@
+   int  initialize_from_super(KlassHandle super);
+   int  index_of(methodOop m, int len) const; // same as index_of, but search only up to len
+   void put_method_at(methodOop m, int index);
+-  static bool needs_new_vtable_entry(methodHandle m, klassOop super, Handle classloader, symbolHandle classname, AccessFlags access_flags, TRAPS);
++  static bool needs_new_vtable_entry(methodHandle m, klassOop super, Handle classloader, Symbol* classname, AccessFlags access_flags, TRAPS);
+ 
+   bool update_inherited_vtable(instanceKlass* klass, methodHandle target_method, int super_vtable_len, bool checkconstraints, TRAPS);
+  instanceKlass* find_transitive_override(instanceKlass* initialsuper, methodHandle target_method, int vtable_index,
+-                                         Handle target_loader, symbolHandle target_classname, Thread* THREAD);
++                                         Handle target_loader, Symbol* target_classname, Thread* THREAD);
+ 
+   // support for miranda methods
+   bool is_miranda_entry_at(int i);
+diff --git a/src/share/vm/oops/markOop.hpp b/src/share/vm/oops/markOop.hpp
+--- openjdk/hotspot/src/share/vm/oops/markOop.hpp
++++ openjdk/hotspot/src/share/vm/oops/markOop.hpp
+@@ -118,14 +118,7 @@
+   };
+ 
+   // The biased locking code currently requires that the age bits be
+-  // contiguous to the lock bits. Class data sharing would prefer the
+-  // hash bits to be lower down to provide more random hash codes for
+-  // shared read-only symbolOop objects, because these objects' mark
+-  // words are set to their own address with marked_value in the lock
+-  // bit, and using lower bits would make their identity hash values
+-  // more random. However, the performance decision was made in favor
+-  // of the biased locking code.
+-
++  // contiguous to the lock bits.
+   enum { lock_shift               = 0,
+          biased_lock_shift        = lock_bits,
+          age_shift                = lock_bits + biased_lock_bits,
+diff --git a/src/share/vm/oops/methodKlass.cpp b/src/share/vm/oops/methodKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/methodKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/methodKlass.cpp
+@@ -36,7 +36,7 @@
+ #include "oops/methodKlass.hpp"
+ #include "oops/oop.inline.hpp"
+ #include "oops/oop.inline2.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/handles.inline.hpp"
+ 
+ klassOop methodKlass::create_klass(TRAPS) {
+@@ -353,10 +353,6 @@
+   if (!obj->partially_loaded()) {
+     methodOop m = methodOop(obj);
+     guarantee(m->is_perm(),  "should be in permspace");
+-    guarantee(m->name()->is_perm(), "should be in permspace");
+-    guarantee(m->name()->is_symbol(), "should be symbol");
+-    guarantee(m->signature()->is_perm(), "should be in permspace");
+-    guarantee(m->signature()->is_symbol(), "should be symbol");
+     guarantee(m->constants()->is_perm(), "should be in permspace");
+     guarantee(m->constants()->is_constantPool(), "should be constant pool");
+     guarantee(m->constMethod()->is_constMethod(), "should be constMethodOop");
+diff --git a/src/share/vm/oops/methodOop.cpp b/src/share/vm/oops/methodOop.cpp
+--- openjdk/hotspot/src/share/vm/oops/methodOop.cpp
++++ openjdk/hotspot/src/share/vm/oops/methodOop.cpp
+@@ -38,7 +38,7 @@
+ #include "oops/methodDataOop.hpp"
+ #include "oops/methodOop.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "prims/jvmtiExport.hpp"
+ #include "prims/methodHandleWalk.hpp"
+ #include "prims/nativeLookup.hpp"
+@@ -77,7 +77,7 @@
+   return name_and_sig_as_C_string(Klass::cast(constants()->pool_holder()), name(), signature(), buf, size);
+ }
+ 
+-char* methodOopDesc::name_and_sig_as_C_string(Klass* klass, symbolOop method_name, symbolOop signature) {
++char* methodOopDesc::name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature) {
+   const char* klass_name = klass->external_name();
+   int klass_name_len  = (int)strlen(klass_name);
+   int method_name_len = method_name->utf8_length();
+@@ -91,8 +91,8 @@
+   return dest;
+ }
+ 
+-char* methodOopDesc::name_and_sig_as_C_string(Klass* klass, symbolOop method_name, symbolOop signature, char* buf, int size) {
+-  symbolOop klass_name = klass->name();
++char* methodOopDesc::name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature, char* buf, int size) {
++  Symbol* klass_name = klass->name();
+   klass_name->as_klass_external_name(buf, size);
+   int len = (int)strlen(buf);
+ 
+@@ -221,7 +221,7 @@
+ }
+ 
+ 
+-symbolOop methodOopDesc::klass_name() const {
++Symbol* methodOopDesc::klass_name() const {
+   klassOop k = method_holder();
+   assert(k->is_klass(), "must be klass");
+   instanceKlass* ik = (instanceKlass*) k->klass_part();
+@@ -333,8 +333,7 @@
+ 
+ 
+ void methodOopDesc::compute_size_of_parameters(Thread *thread) {
+-  symbolHandle h_signature(thread, signature());
+-  ArgumentSizeComputer asc(h_signature);
++  ArgumentSizeComputer asc(signature());
+   set_size_of_parameters(asc.size() + (is_static() ? 0 : 1));
+ }
+ 
+@@ -520,7 +519,7 @@
+ bool methodOopDesc::is_klass_loaded_by_klass_index(int klass_index) const {
+   if( _constants->tag_at(klass_index).is_unresolved_klass() ) {
+     Thread *thread = Thread::current();
+-    symbolHandle klass_name(thread, _constants->klass_name_at(klass_index));
++    Symbol* klass_name = _constants->klass_name_at(klass_index);
+     Handle loader(thread, instanceKlass::cast(method_holder())->class_loader());
+     Handle prot  (thread, Klass::cast(method_holder())->protection_domain());
+     return SystemDictionary::find(klass_name, loader, prot, thread) != NULL;
+@@ -852,7 +851,7 @@
+ // Constant pool structure for invoke methods:
+ enum {
+   _imcp_invoke_name = 1,        // utf8: 'invokeExact' or 'invokeGeneric'
+-  _imcp_invoke_signature,       // utf8: (variable symbolOop)
++  _imcp_invoke_signature,       // utf8: (variable Symbol*)
+   _imcp_method_type_value,      // string: (variable java/dyn/MethodType, sic)
+   _imcp_limit
+ };
+@@ -895,8 +894,8 @@
+ }
+ 
+ methodHandle methodOopDesc::make_invoke_method(KlassHandle holder,
+-                                               symbolHandle name,
+-                                               symbolHandle signature,
++                                               Symbol* name,
++                                               Symbol* signature,
+                                                Handle method_type, TRAPS) {
+   methodHandle empty;
+ 
+@@ -914,9 +913,9 @@
+     constantPoolOop cp_oop = oopFactory::new_constantPool(_imcp_limit, IsSafeConc, CHECK_(empty));
+     cp = constantPoolHandle(THREAD, cp_oop);
+   }
+-  cp->symbol_at_put(_imcp_invoke_name,       name());
+-  cp->symbol_at_put(_imcp_invoke_signature,  signature());
+-  cp->string_at_put(_imcp_method_type_value, vmSymbols::void_signature());
++  cp->symbol_at_put(_imcp_invoke_name,       name);
++  cp->symbol_at_put(_imcp_invoke_signature,  signature);
++  cp->string_at_put(_imcp_method_type_value, Universe::the_null_string());
+   cp->set_pool_holder(holder());
+ 
+   // set up the fancy stuff:
+@@ -932,7 +931,7 @@
+   m->set_name_index(_imcp_invoke_name);
+   m->set_signature_index(_imcp_invoke_signature);
+   assert(is_method_handle_invoke_name(m->name()), "");
+-  assert(m->signature() == signature(), "");
++  assert(m->signature() == signature, "");
+   assert(m->is_method_handle_invoke(), "");
+ #ifdef CC_INTERP
+   ResultTypeFinder rtf(signature());
+@@ -1047,7 +1046,7 @@
+     return vmSymbols::NO_SID;   // regardless of name, no intrinsics here
+ 
+   // see if the klass name is well-known:
+-  symbolOop klass_name = instanceKlass::cast(holder)->name();
++  Symbol* klass_name = instanceKlass::cast(holder)->name();
+   return vmSymbols::find_sid(klass_name);
+ }
+ 
+@@ -1123,11 +1122,12 @@
+   bool sig_is_loaded = true;
+   Handle class_loader(THREAD, instanceKlass::cast(m->method_holder())->class_loader());
+   Handle protection_domain(THREAD, Klass::cast(m->method_holder())->protection_domain());
+-  symbolHandle signature(THREAD, m->signature());
++  ResourceMark rm(THREAD);
++  Symbol*  signature = m->signature();
+   for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
+     if (ss.is_object()) {
+-      symbolOop sym = ss.as_symbol(CHECK_(false));
+-      symbolHandle name (THREAD, sym);
++      Symbol* sym = ss.as_symbol(CHECK_(false));
++      Symbol*  name  = sym;
+       klassOop klass = SystemDictionary::resolve_or_null(name, class_loader,
+                                              protection_domain, THREAD);
+       // We are loading classes eagerly. If a ClassNotFoundException or
+@@ -1149,11 +1149,12 @@
+ bool methodOopDesc::has_unloaded_classes_in_signature(methodHandle m, TRAPS) {
+   Handle class_loader(THREAD, instanceKlass::cast(m->method_holder())->class_loader());
+   Handle protection_domain(THREAD, Klass::cast(m->method_holder())->protection_domain());
+-  symbolHandle signature(THREAD, m->signature());
++  ResourceMark rm(THREAD);
++  Symbol*  signature = m->signature();
+   for(SignatureStream ss(signature); !ss.is_done(); ss.next()) {
+     if (ss.type() == T_OBJECT) {
+-      symbolHandle name(THREAD, ss.as_symbol_or_null());
+-      if (name() == NULL) return true;
++      Symbol* name = ss.as_symbol_or_null();
++      if (name == NULL) return true;
+       klassOop klass = SystemDictionary::find(name, class_loader, protection_domain, THREAD);
+       if (klass == NULL) return true;
+     }
+@@ -1317,7 +1318,7 @@
+   }
+ 
+  public:
+-  SignatureTypePrinter(symbolHandle signature, outputStream* st) : SignatureTypeNames(signature) {
++  SignatureTypePrinter(Symbol* signature, outputStream* st) : SignatureTypeNames(signature) {
+     _st = st;
+     _use_separator = false;
+   }
+diff --git a/src/share/vm/oops/methodOop.hpp b/src/share/vm/oops/methodOop.hpp
+--- openjdk/hotspot/src/share/vm/oops/methodOop.hpp
++++ openjdk/hotspot/src/share/vm/oops/methodOop.hpp
+@@ -161,17 +161,17 @@
+   void set_access_flags(AccessFlags flags)       { _access_flags = flags; }
+ 
+   // name
+-  symbolOop name() const                         { return _constants->symbol_at(name_index()); }
++  Symbol* name() const                           { return _constants->symbol_at(name_index()); }
+   int name_index() const                         { return constMethod()->name_index();         }
+   void set_name_index(int index)                 { constMethod()->set_name_index(index);       }
+ 
+   // signature
+-  symbolOop signature() const                    { return _constants->symbol_at(signature_index()); }
++  Symbol* signature() const                      { return _constants->symbol_at(signature_index()); }
+   int signature_index() const                    { return constMethod()->signature_index();         }
+   void set_signature_index(int index)            { constMethod()->set_signature_index(index);       }
+ 
+   // generics support
+-  symbolOop generic_signature() const            { int idx = generic_signature_index(); return ((idx != 0) ? _constants->symbol_at(idx) : (symbolOop)NULL); }
++  Symbol* generic_signature() const              { int idx = generic_signature_index(); return ((idx != 0) ? _constants->symbol_at(idx) : (Symbol*)NULL); }
+   int generic_signature_index() const            { return constMethod()->generic_signature_index(); }
+   void set_generic_signature_index(int index)    { constMethod()->set_generic_signature_index(index); }
+ 
+@@ -193,8 +193,8 @@
+   char* name_and_sig_as_C_string(char* buf, int size);
+ 
+   // Static routine in the situations we don't have a methodOop
+-  static char* name_and_sig_as_C_string(Klass* klass, symbolOop method_name, symbolOop signature);
+-  static char* name_and_sig_as_C_string(Klass* klass, symbolOop method_name, symbolOop signature, char* buf, int size);
++  static char* name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature);
++  static char* name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature, char* buf, int size);
+ 
+   Bytecodes::Code java_code_at(int bci) const {
+     return Bytecodes::java_code_at(this, bcp_from(bci));
+@@ -433,7 +433,7 @@
+   klassOop method_holder() const                 { return _constants->pool_holder(); }
+ 
+   void compute_size_of_parameters(Thread *thread); // word size of parameters (receiver if any + arguments)
+-  symbolOop klass_name() const;                  // returns the name of the method holder
++  Symbol* klass_name() const;                    // returns the name of the method holder
+   BasicType result_type() const;                 // type of the method result
+   int result_type_index() const;                 // type index of the method result
+   bool is_returning_oop() const                  { BasicType r = result_type(); return (r == T_OBJECT || r == T_ARRAY); }
+@@ -564,15 +564,15 @@
+   // JSR 292 support
+   bool is_method_handle_invoke() const              { return access_flags().is_method_handle_invoke(); }
+   static bool is_method_handle_invoke_name(vmSymbols::SID name_sid);
+-  static bool is_method_handle_invoke_name(symbolOop name) {
++  static bool is_method_handle_invoke_name(Symbol* name) {
+     return is_method_handle_invoke_name(vmSymbols::find_sid(name));
+   }
+   // Tests if this method is an internal adapter frame from the
+   // MethodHandleCompiler.
+   bool is_method_handle_adapter() const;
+   static methodHandle make_invoke_method(KlassHandle holder,
+-                                         symbolHandle name, //invokeExact or invokeGeneric
+-                                         symbolHandle signature, //anything at all
++                                         Symbol* name, //invokeExact or invokeGeneric
++                                         Symbol* signature, //anything at all
+                                          Handle method_type,
+                                          TRAPS);
+   // these operate only on invoke methods:
+diff --git a/src/share/vm/oops/objArrayKlass.cpp b/src/share/vm/oops/objArrayKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/objArrayKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/objArrayKlass.cpp
+@@ -37,7 +37,7 @@
+ #include "oops/objArrayOop.hpp"
+ #include "oops/oop.inline.hpp"
+ #include "oops/oop.inline2.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/handles.inline.hpp"
+ #include "runtime/mutexLocker.hpp"
+ #include "utilities/copy.hpp"
+diff --git a/src/share/vm/oops/objArrayKlassKlass.cpp b/src/share/vm/oops/objArrayKlassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp
+@@ -117,14 +117,11 @@
+     }
+   }
+ 
+-  // Create type name for klass (except for symbol arrays, since symbolKlass
+-  // does not have a name).  This will potentially allocate an object, cause
+-  // GC, and all other kinds of things.  Hence, this must be done before we
+-  // get a handle to the new objArrayKlass we want to construct.  We cannot
+-  // block while holding a handling to a partly initialized object.
+-  symbolHandle name = symbolHandle();
++  // Create type name for klass.
++  Symbol* name = NULL;
++  if (!element_klass->oop_is_instance() ||
++      (name = instanceKlass::cast(element_klass())->array_name()) == NULL) {
+ 
+-  if (!element_klass->oop_is_symbol()) {
+     ResourceMark rm(THREAD);
+     char *name_str = element_klass->name()->as_C_string();
+     int len = element_klass->name()->utf8_length();
+@@ -140,7 +137,11 @@
+       new_str[idx++] = ';';
+     }
+     new_str[idx++] = '\0';
+-    name = oopFactory::new_symbol_handle(new_str, CHECK_0);
++    name = SymbolTable::new_symbol(new_str, CHECK_0);
++    if (element_klass->oop_is_instance()) {
++      instanceKlass* ik = instanceKlass::cast(element_klass());
++      ik->set_array_name(name);
++    }
+   }
+ 
+   objArrayKlass o;
+@@ -149,12 +150,15 @@
+                                                           this_oop,
+                                                            CHECK_0);
+ 
+-
+   // Initialize instance variables
+   objArrayKlass* oak = objArrayKlass::cast(k());
+   oak->set_dimension(n);
+   oak->set_element_klass(element_klass());
+-  oak->set_name(name());
++  oak->set_name(name);
++  // decrement refcount because object arrays are not explicitly freed.  The
++  // instanceKlass array_name() keeps the name counted while the klass is
++  // loaded.
++  name->decrement_refcount();
+ 
+   klassOop bk;
+   if (element_klass->oop_is_objArray()) {
+diff --git a/src/share/vm/oops/oop.hpp b/src/share/vm/oops/oop.hpp
+--- openjdk/hotspot/src/share/vm/oops/oop.hpp
++++ openjdk/hotspot/src/share/vm/oops/oop.hpp
+@@ -128,7 +128,6 @@
+   bool is_instanceRef()        const;
+   bool is_array()              const;
+   bool is_objArray()           const;
+-  bool is_symbol()             const;
+   bool is_klass()              const;
+   bool is_thread()             const;
+   bool is_method()             const;
+diff --git a/src/share/vm/oops/oop.inline.hpp b/src/share/vm/oops/oop.inline.hpp
+--- openjdk/hotspot/src/share/vm/oops/oop.inline.hpp
++++ openjdk/hotspot/src/share/vm/oops/oop.inline.hpp
+@@ -141,7 +141,6 @@
+ inline bool oopDesc::is_objArray()           const { return blueprint()->oop_is_objArray(); }
+ inline bool oopDesc::is_typeArray()          const { return blueprint()->oop_is_typeArray(); }
+ inline bool oopDesc::is_javaArray()          const { return blueprint()->oop_is_javaArray(); }
+-inline bool oopDesc::is_symbol()             const { return blueprint()->oop_is_symbol(); }
+ inline bool oopDesc::is_klass()              const { return blueprint()->oop_is_klass(); }
+ inline bool oopDesc::is_thread()             const { return blueprint()->oop_is_thread(); }
+ inline bool oopDesc::is_method()             const { return blueprint()->oop_is_method(); }
+diff --git a/src/share/vm/oops/oopsHierarchy.hpp b/src/share/vm/oops/oopsHierarchy.hpp
+--- openjdk/hotspot/src/share/vm/oops/oopsHierarchy.hpp
++++ openjdk/hotspot/src/share/vm/oops/oopsHierarchy.hpp
+@@ -49,7 +49,6 @@
+ typedef class     typeArrayOopDesc*            typeArrayOop;
+ typedef class   constantPoolOopDesc*            constantPoolOop;
+ typedef class   constantPoolCacheOopDesc*   constantPoolCacheOop;
+-typedef class   symbolOopDesc*                    symbolOop;
+ typedef class   klassOopDesc*                    klassOop;
+ typedef class   markOopDesc*                    markOop;
+ typedef class   compiledICHolderOopDesc*    compiledICHolderOop;
+@@ -166,7 +165,6 @@
+ DEF_OOP(constantPoolCache);
+ DEF_OOP(objArray);
+ DEF_OOP(typeArray);
+-DEF_OOP(symbol);
+ DEF_OOP(klass);
+ DEF_OOP(compiledICHolder);
+ 
+@@ -191,7 +189,6 @@
+ class     typeArrayKlass;
+ class   constantPoolKlass;
+ class   constantPoolCacheKlass;
+-class   symbolKlass;
+ class   compiledICHolderKlass;
+ 
+ #endif // SHARE_VM_OOPS_OOPSHIERARCHY_HPP
+diff --git a/src/share/vm/oops/symbolOop.cpp b/src/share/vm/oops/symbol.cpp
+rename from src/share/vm/oops/symbolOop.cpp
+rename to src/share/vm/oops/symbol.cpp
+--- openjdk/hotspot/src/share/vm/oops/symbolOop.cpp
++++ openjdk/hotspot/src/share/vm/oops/symbol.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -22,16 +22,29 @@
+  *
+  */
+ 
++
+ #include "precompiled.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
++#include "runtime/os.hpp"
++#include "memory/allocation.inline.hpp"
+ 
++Symbol::Symbol(const u1* name, int length) : _refcount(0), _length(length) {
++  _identity_hash = os::random();
++  for (int i = 0; i < _length; i++) {
++    byte_at_put(i, name[i]);
++  }
++}
++
++void* Symbol::operator new(size_t size, int len) {
++  return (void *) AllocateHeap(object_size(len) * HeapWordSize, "symbol");
++}
+ 
+ // ------------------------------------------------------------------
+-// symbolOopDesc::equals
++// Symbol::equals
+ //
+ // Compares the symbol with a string of the given length.
+-bool symbolOopDesc::equals(const char* str, int len) const {
++bool Symbol::equals(const char* str, int len) const {
+   int l = utf8_length();
+   if (l != len) return false;
+   while (l-- > 0) {
+@@ -44,11 +57,11 @@
+ 
+ 
+ // ------------------------------------------------------------------
+-// symbolOopDesc::starts_with
++// Symbol::starts_with
+ //
+ // Tests if the symbol starts with the specified prefix of the given
+ // length.
+-bool symbolOopDesc::starts_with(const char* prefix, int len) const {
++bool Symbol::starts_with(const char* prefix, int len) const {
+   if (len > utf8_length()) return false;
+   while (len-- > 0) {
+     if (prefix[len] != (char) byte_at(len))
+@@ -60,15 +73,15 @@
+ 
+ 
+ // ------------------------------------------------------------------
+-// symbolOopDesc::index_of
++// Symbol::index_of
+ //
+ // Finds if the given string is a substring of this symbol's utf8 bytes.
+ // Return -1 on failure.  Otherwise return the first index where str occurs.
+-int symbolOopDesc::index_of_at(int i, const char* str, int len) const {
++int Symbol::index_of_at(int i, const char* str, int len) const {
+   assert(i >= 0 && i <= utf8_length(), "oob");
+   if (len <= 0)  return 0;
+   char first_char = str[0];
+-  address bytes = (address) ((symbolOopDesc*)this)->base();
++  address bytes = (address) ((Symbol*)this)->base();
+   address limit = bytes + utf8_length() - len;  // inclusive limit
+   address scan = bytes + i;
+   if (scan > limit)
+@@ -84,7 +97,7 @@
+ }
+ 
+ 
+-char* symbolOopDesc::as_C_string(char* buf, int size) const {
++char* Symbol::as_C_string(char* buf, int size) const {
+   if (size > 0) {
+     int len = MIN2(size - 1, utf8_length());
+     for (int i = 0; i < len; i++) {
+@@ -95,13 +108,13 @@
+   return buf;
+ }
+ 
+-char* symbolOopDesc::as_C_string() const {
++char* Symbol::as_C_string() const {
+   int len = utf8_length();
+   char* str = NEW_RESOURCE_ARRAY(char, len + 1);
+   return as_C_string(str, len + 1);
+ }
+ 
+-char* symbolOopDesc::as_C_string_flexible_buffer(Thread* t,
++char* Symbol::as_C_string_flexible_buffer(Thread* t,
+                                                  char* buf, int size) const {
+   char* str;
+   int len = utf8_length();
+@@ -114,7 +127,7 @@
+   return as_C_string(str, buf_len);
+ }
+ 
+-void symbolOopDesc::print_symbol_on(outputStream* st) {
++void Symbol::print_symbol_on(outputStream* st) const {
+   st = st ? st : tty;
+   int length = UTF8::unicode_length((const char*)bytes(), utf8_length());
+   const char *ptr = (const char *)bytes();
+@@ -129,8 +142,8 @@
+   }
+ }
+ 
+-jchar* symbolOopDesc::as_unicode(int& length) const {
+-  symbolOopDesc* this_ptr = (symbolOopDesc*)this;
++jchar* Symbol::as_unicode(int& length) const {
++  Symbol* this_ptr = (Symbol*)this;
+   length = UTF8::unicode_length((char*)this_ptr->bytes(), utf8_length());
+   jchar* result = NEW_RESOURCE_ARRAY(jchar, length);
+   if (length > 0) {
+@@ -139,7 +152,7 @@
+   return result;
+ }
+ 
+-const char* symbolOopDesc::as_klass_external_name(char* buf, int size) const {
++const char* Symbol::as_klass_external_name(char* buf, int size) const {
+   if (size > 0) {
+     char* str    = as_C_string(buf, size);
+     int   length = (int)strlen(str);
+@@ -155,7 +168,7 @@
+   }
+ }
+ 
+-const char* symbolOopDesc::as_klass_external_name() const {
++const char* Symbol::as_klass_external_name() const {
+   char* str    = as_C_string();
+   int   length = (int)strlen(str);
+   // Turn all '/'s into '.'s (also for array klasses)
+@@ -166,3 +179,53 @@
+   }
+   return str;
+ }
++
++
++void Symbol::print_on(outputStream* st) const {
++  if (this == NULL) {
++    st->print_cr("NULL");
++  } else {
++    st->print("Symbol: '");
++    print_symbol_on(st);
++    st->print("'");
++    st->print(" count %d", refcount());
++  }
++}
++
++// The print_value functions are present in all builds, to support the
++// disassembler and error reporting.
++void Symbol::print_value_on(outputStream* st) const {
++  if (this == NULL) {
++    st->print("NULL");
++  } else {
++    st->print("'");
++    for (int i = 0; i < utf8_length(); i++) {
++      st->print("%c", byte_at(i));
++    }
++    st->print("'");
++  }
++}
++
++void Symbol::increment_refcount() {
++  // Only increment the refcount if positive.  If negative either
++  // overflow has occurred or it is a permanent symbol in a read only
++  // shared archive.
++  if (_refcount >= 0) {
++    Atomic::inc(&_refcount);
++    NOT_PRODUCT(Atomic::inc(&_total_count);)
++  }
++}
++
++void Symbol::decrement_refcount() {
++  if (_refcount >= 0) {
++    Atomic::dec(&_refcount);
++#ifdef ASSERT
++    if (_refcount < 0) {
++      print();
++      assert(false, "reference count underflow for symbol");
++    }
++#endif
++  }
++}
++
++NOT_PRODUCT(int Symbol::_total_count = 0;)
+diff --git a/src/share/vm/oops/symbolOop.hpp b/src/share/vm/oops/symbol.hpp
+rename from src/share/vm/oops/symbolOop.hpp
+rename to src/share/vm/oops/symbol.hpp
+--- openjdk/hotspot/src/share/vm/oops/symbolOop.hpp
++++ openjdk/hotspot/src/share/vm/oops/symbol.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -22,19 +22,86 @@
+  *
+  */
+ 
+-#ifndef SHARE_VM_OOPS_SYMBOLOOP_HPP
+-#define SHARE_VM_OOPS_SYMBOLOOP_HPP
++#ifndef SHARE_VM_OOPS_SYMBOL_HPP
++#define SHARE_VM_OOPS_SYMBOL_HPP
+ 
+-#include "oops/typeArrayOop.hpp"
+ #include "utilities/utf8.hpp"
++#include "memory/allocation.hpp"
+ 
+-// A symbolOop is a canonicalized string.
+-// All symbolOops reside in global symbolTable.
+-// See oopFactory::new_symbol for how to allocate a symbolOop
++// A Symbol is a canonicalized string.
++// All Symbols reside in global SymbolTable and are reference counted.
+ 
+-class symbolOopDesc : public oopDesc {
++// Reference counting
++//
++// All Symbols are allocated and added to the SymbolTable.
++// When a class is unloaded, the reference counts of the Symbol pointers in
++// the ConstantPool and in instanceKlass (see release_C_heap_structures) are
++// decremented.  When the reference count for a Symbol goes to 0, the garbage
++// collector can free the Symbol and remove it from the SymbolTable.
++//
++// 0) Symbols need to be reference counted when a pointer to the Symbol is
++// saved in persistent storage.  This does not include the pointer
++// in the SymbolTable bucket (the _literal field in HashtableEntry)
++// that points to the Symbol.  All other stores of a Symbol*
++// to a field of a persistent variable (e.g., the _name filed in
++// FieldAccessInfo or _ptr in a CPSlot) is reference counted.
++//
++// 1) The lookup of a "name" in the SymbolTable either creates a Symbol F for
++// "name" and returns a pointer to F or finds a pre-existing Symbol F for
++// "name" and returns a pointer to it. In both cases the reference count for F
++// is incremented under the assumption that a pointer to F will be created from
++// the return value. Thus the increment of the reference count is on the lookup
++// and not on the assignment to the new Symbol*.  That is
++//    Symbol* G = lookup()
++//                ^ increment on lookup()
++// and not
++//    Symbol* G = lookup()
++//              ^ increment on assignmnet
++// The reference count must be decremented manually when the copy of the
++// pointer G is destroyed.
++//
++// 2) For a local Symbol* A that is a copy of an existing Symbol* B, the
++// reference counting is elided when the scope of B is greater than the scope
++// of A.  For example, in the code fragment
++// below "klass" is passed as a parameter to the method.  Symbol* "kn"
++// is a copy of the name in "klass".
++//
++//   Symbol*  kn = klass->name();
++//   unsigned int d_hash = dictionary()->compute_hash(kn, class_loader);
++//
++// The scope of "klass" is greater than the scope of "kn" so the reference
++// counting for "kn" is elided.
++//
++// Symbol* copied from ConstantPool entries are good candidates for reference
++// counting elision.  The ConstantPool entries for a class C exist until C is
++// unloaded.  If a Symbol* is copied out of the ConstantPool into Symbol* X,
++// the Symbol* in the ConstantPool will in general out live X so the reference
++// counting on X can be elided.
++//
++// For cases where the scope of A is not greater than the scope of B,
++// the reference counting is explicitly done.  See ciSymbol,
++// ResolutionErrorEntry and ClassVerifier for examples.
++//
++// 3) When a Symbol K is created for temporary use, generally for substrings of
++// an existing symbol or to create a new symbol, assign it to a
++// TempNewSymbol. The SymbolTable methods new_symbol(), lookup()
++// and probe() all potentially return a pointer to a new Symbol.
++// The allocation (or lookup) of K increments the reference count for K
++// and the destructor decrements the reference count.
++//
++// Another example of TempNewSymbol usage is parsed_name used in
++// ClassFileParser::parseClassFile() where parsed_name is used in the cleanup
++// after a failed attempt to load a class.  Here parsed_name is a
++// TempNewSymbol (passed in as a parameter) so the reference count on its symbol
++// will be decremented when it goes out of scope.
++
++class Symbol : public CHeapObj {
+   friend class VMStructs;
++  friend class SymbolTable;
++  friend class MoveSymbols;
+  private:
++  volatile int   _refcount;
++  int            _identity_hash;
+   unsigned short _length; // number of UTF8 characters in the symbol
+   jbyte _body[1];
+ 
+@@ -42,40 +109,49 @@
+     // max_symbol_length is constrained by type of _length
+     max_symbol_length = (1 << 16) -1
+   };
++
++  static int object_size(int length) {
++    size_t size = heap_word_size(sizeof(Symbol) + length);
++    return align_object_size(size);
++  }
++
++  void byte_at_put(int index, int value) {
++    assert(index >=0 && index < _length, "symbol index overflow");
++    _body[index] = value;
++  }
++
++  Symbol(const u1* name, int length);
++  void* operator new(size_t size, int len);
++
+  public:
++  // Low-level access (used with care, since not GC-safe)
++  const jbyte* base() const { return &_body[0]; }
+ 
+-  // Low-level access (used with care, since not GC-safe)
+-  jbyte* base() { return &_body[0]; }
+-
++  int object_size() { return object_size(utf8_length()); }
+ 
+   // Returns the largest size symbol we can safely hold.
+   static int max_length() {
+     return max_symbol_length;
+   }
+ 
+-  static int object_size(int length) {
+-    int size = header_size() + (sizeof(unsigned short) + length + HeapWordSize - 1) / HeapWordSize;
+-    return align_object_size(size);
++  int identity_hash() {
++    return _identity_hash;
+   }
+ 
+-  int object_size() { return object_size(utf8_length()); }
++  // Reference counting.  See comments above this class for when to use.
++  int refcount() const { return _refcount; }
++  void increment_refcount();
++  void decrement_refcount();
+ 
+   int byte_at(int index) const {
+     assert(index >=0 && index < _length, "symbol index overflow");
+-    return ((symbolOopDesc*)this)->base()[index];
++    return base()[index];
+   }
+ 
+-  void byte_at_put(int index, int value) {
+-    assert(index >=0 && index < _length, "symbol index overflow");
+-    ((symbolOopDesc*)this)->base()[index] = value;
+-  }
+-
+-  jbyte* bytes() { return base(); }
++  const jbyte* bytes() const { return base(); }
+ 
+   int utf8_length() const { return _length; }
+ 
+-  void set_utf8_length(int len) { _length = len; }
+-
+   // Compares the symbol with a string.
+   bool equals(const char* str, int len) const;
+   bool equals(const char* str) const { return equals(str, (int) strlen(str)); }
+@@ -94,7 +170,7 @@
+ 
+   // Three-way compare for sorting; returns -1/0/1 if receiver is </==/> than arg
+   // note that the ordering is not alfabetical
+-  inline int fast_compare(symbolOop other) const;
++  inline int fast_compare(Symbol* other) const;
+ 
+   // Returns receiver converted to null-terminated UTF-8 string; string is
+   // allocated in resource area, or in the char buffer provided by caller.
+@@ -118,22 +194,30 @@
+   const char* as_klass_external_name() const;
+   const char* as_klass_external_name(char* buf, int size) const;
+ 
+-  bool object_is_parsable() const {
+-    return (utf8_length() > 0 || (oop)this == Universe::emptySymbol());
+-  }
++  // Printing
++  void print_symbol_on(outputStream* st = NULL) const;
++  void print_on(outputStream* st) const;         // First level print
++  void print_value_on(outputStream* st) const;   // Second level print.
+ 
+-  // Printing
+-  void print_symbol_on(outputStream* st = NULL);
++  // printing on default output stream
++  void print()         { print_on(tty);       }
++  void print_value()   { print_value_on(tty); }
++
++#ifndef PRODUCT
++  // Empty constructor to create a dummy symbol object on stack
++  // only for getting its vtable pointer.
++  Symbol() { }
++
++  static int _total_count;
++#endif
+ };
+ 
+-
+ // Note: this comparison is used for vtable sorting only; it doesn't matter
+ // what order it defines, as long as it is a total, time-invariant order
+-// Since symbolOops are in permSpace, their relative order in memory never changes,
++// Since Symbol*s are in C_HEAP, their relative order in memory never changes,
+ // so use address comparison for speed
+-int symbolOopDesc::fast_compare(symbolOop other) const {
++int Symbol::fast_compare(Symbol* other) const {
+  return (((uintptr_t)this < (uintptr_t)other) ? -1
+    : ((uintptr_t)this == (uintptr_t) other) ? 0 : 1);
+ }
+-
+-#endif // SHARE_VM_OOPS_SYMBOLOOP_HPP
++#endif // SHARE_VM_OOPS_SYMBOL_HPP
+diff --git a/src/share/vm/oops/symbolKlass.cpp b/src/share/vm/oops/symbolKlass.cpp
+deleted file mode 100644
+--- openjdk/hotspot/src/share/vm/oops/symbolKlass.cpp
++++ /dev/null
+@@ -1,230 +0,0 @@
+-/*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+- *
+- */
+-
+-#include "precompiled.hpp"
+-#include "classfile/symbolTable.hpp"
+-#include "memory/gcLocker.hpp"
+-#include "oops/oop.inline.hpp"
+-#include "oops/symbolKlass.hpp"
+-#include "oops/symbolOop.hpp"
+-#include "runtime/handles.inline.hpp"
+-
+-symbolOop symbolKlass::allocate_symbol(u1* name, int len, TRAPS) {
+-  // Don't allow symbol oops to be created which cannot fit in a symbolOop.
+-  if (len > symbolOopDesc::max_length()) {
+-    THROW_MSG_0(vmSymbols::java_lang_InternalError(),
+-                "name is too long to represent");
+-  }
+-  int size = symbolOopDesc::object_size(len);
+-  symbolKlassHandle h_k(THREAD, as_klassOop());
+-  symbolOop sym = (symbolOop)
+-    CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
+-  assert(!sym->is_parsable(), "not expecting parsability yet.");
+-  No_Safepoint_Verifier no_safepoint;
+-  sym->set_utf8_length(len);
+-  for (int i = 0; i < len; i++) {
+-    sym->byte_at_put(i, name[i]);
+-  }
+-  // Let the first emptySymbol be created and
+-  // ensure only one is ever created.
+-  assert(sym->is_parsable() || Universe::emptySymbol() == NULL,
+-         "should be parsable here.");
+-  return sym;
+-}
+-
+-bool symbolKlass::allocate_symbols(int names_count, const char** names,
+-                                   int* lengths, symbolOop* sym_oops, TRAPS) {
+-  if (UseConcMarkSweepGC || UseParallelGC) {
+-    // Concurrent GC needs to mark all the allocated symbol oops after
+-    // the remark phase which isn't done below (except the first symbol oop).
+-    // So return false which will let the symbols be allocated one by one.
+-    // The parallel collector uses an object start array to find the
+-    // start of objects on a dirty card.  The object start array is not
+-    // updated for the start of each symbol so is not precise.  During
+-    // object array verification this causes a verification failure.
+-    // In a product build this causes extra searching for the start of
+-    // a symbol.  As with the concurrent collector a return of false will
+-    // cause each symbol to be allocated separately and in the case
+-    // of the parallel collector will cause the object
+-    // start array to be updated.
+-    return false;
+-  }
+-
+-  assert(names_count > 0, "can't allocate 0 symbols");
+-
+-  int total_size = 0;
+-  int i, sizes[SymbolTable::symbol_alloc_batch_size];
+-  for (i=0; i<names_count; i++) {
+-    int len = lengths[i];
+-    if (len > symbolOopDesc::max_length()) {
+-      return false;
+-    }
+-    int sz = symbolOopDesc::object_size(len);
+-    sizes[i] = sz * HeapWordSize;
+-    total_size += sz;
+-  }
+-  symbolKlassHandle h_k(THREAD, as_klassOop());
+-  HeapWord* base = Universe::heap()->permanent_mem_allocate(total_size);
+-  if (base == NULL) {
+-    return false;
+-  }
+-
+-  // CAN'T take any safepoint during the initialization of the symbol oops !
+-  No_Safepoint_Verifier nosafepoint;
+-
+-  klassOop sk = h_k();
+-  int pos = 0;
+-  for (i=0; i<names_count; i++) {
+-    symbolOop s = (symbolOop) (((char*)base) + pos);
+-    s->set_mark(markOopDesc::prototype());
+-    s->set_klass(sk);
+-    s->set_utf8_length(lengths[i]);
+-    const char* name = names[i];
+-    for (int j=0; j<lengths[i]; j++) {
+-      s->byte_at_put(j, name[j]);
+-    }
+-
+-    assert(s->is_parsable(), "should be parsable here.");
+-
+-    sym_oops[i] = s;
+-    pos += sizes[i];
+-  }
+-  return true;
+-}
+-
+-klassOop symbolKlass::create_klass(TRAPS) {
+-  symbolKlass o;
+-  KlassHandle h_this_klass(THREAD, Universe::klassKlassObj());
+-  KlassHandle k = base_create_klass(h_this_klass, header_size(), o.vtbl_value(), CHECK_NULL);
+-  // Make sure size calculation is right
+-  assert(k()->size() == align_object_size(header_size()), "wrong size for object");
+-//  java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
+-  return k();
+-}
+-
+-int symbolKlass::oop_size(oop obj) const {
+-  assert(obj->is_symbol(),"must be a symbol");
+-  symbolOop s = symbolOop(obj);
+-  int size = s->object_size();
+-  return size;
+-}
+-
+-bool symbolKlass::oop_is_parsable(oop obj) const {
+-  assert(obj->is_symbol(),"must be a symbol");
+-  symbolOop s = symbolOop(obj);
+-  return s->object_is_parsable();
+-}
+-
+-void symbolKlass::oop_follow_contents(oop obj) {
+-  assert (obj->is_symbol(), "object must be symbol");
+-  // Performance tweak: We skip iterating over the klass pointer since we
+-  // know that Universe::symbolKlassObj never moves.
+-  // Note: do not follow next link here (see SymbolTable::follow_contents)
+-}
+-
+-#ifndef SERIALGC
+-void symbolKlass::oop_follow_contents(ParCompactionManager* cm, oop obj) {
+-  assert (obj->is_symbol(), "object must be symbol");
+-  // Performance tweak: We skip iterating over the klass pointer since we
+-  // know that Universe::symbolKlassObj never moves.
+-  // Note: do not follow next link here (see SymbolTable::follow_contents)
+-}
+-#endif // SERIALGC
+-
+-int symbolKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
+-  assert(obj->is_symbol(), "object must be symbol");
+-  symbolOop s = symbolOop(obj);
+-  // Get size before changing pointers.
+-  // Don't call size() or oop_size() since that is a virtual call.
+-  int size = s->object_size();
+-  // Performance tweak: We skip iterating over the klass pointer since we
+-  // know that Universe::symbolKlassObj never moves.
+-  return size;
+-}
+-
+-
+-int symbolKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
+-  assert(obj->is_symbol(), "object must be symbol");
+-  symbolOop s = symbolOop(obj);
+-  // Get size before changing pointers.
+-  // Don't call size() or oop_size() since that is a virtual call.
+-  int size = s->object_size();
+-  // Performance tweak: We skip iterating over the klass pointer since we
+-  // know that Universe::symbolKlassObj never moves.
+-  return size;
+-}
+-
+-
+-int symbolKlass::oop_adjust_pointers(oop obj) {
+-  assert(obj->is_symbol(), "should be symbol");
+-  symbolOop s = symbolOop(obj);
+-  // Get size before changing pointers.
+-  // Don't call size() or oop_size() since that is a virtual call.
+-  int size = s->object_size();
+-  // Performance tweak: We skip iterating over the klass pointer since we
+-  // know that Universe::symbolKlassObj never moves.
+-  return size;
+-}
+-
+-
+-#ifndef SERIALGC
+-void symbolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
+-  assert(obj->is_symbol(), "should be symbol");
+-}
+-
+-int symbolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
+-  assert(obj->is_symbol(), "should be symbol");
+-  return symbolOop(obj)->object_size();
+-}
+-
+-int symbolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                     HeapWord* beg_addr, HeapWord* end_addr) {
+-  assert(obj->is_symbol(), "should be symbol");
+-  return symbolOop(obj)->object_size();
+-}
+-#endif // SERIALGC
+-
+-#ifndef PRODUCT
+-// Printing
+-
+-void symbolKlass::oop_print_on(oop obj, outputStream* st) {
+-  st->print("Symbol: '");
+-  symbolOop(obj)->print_symbol_on(st);
+-  st->print("'");
+-}
+-
+-#endif //PRODUCT
+-
+-void symbolKlass::oop_print_value_on(oop obj, outputStream* st) {
+-  symbolOop sym = symbolOop(obj);
+-  st->print("'");
+-  for (int i = 0; i < sym->utf8_length(); i++) {
+-    st->print("%c", sym->byte_at(i));
+-  }
+-  st->print("'");
+-}
+-
+-const char* symbolKlass::internal_name() const {
+-  return "{symbol}";
+-}
+diff --git a/src/share/vm/oops/symbolKlass.hpp b/src/share/vm/oops/symbolKlass.hpp
+deleted file mode 100644
+--- openjdk/hotspot/src/share/vm/oops/symbolKlass.hpp
++++ /dev/null
+@@ -1,81 +0,0 @@
+-/*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+- *
+- */
+-
+-#ifndef SHARE_VM_OOPS_SYMBOLKLASS_HPP
+-#define SHARE_VM_OOPS_SYMBOLKLASS_HPP
+-
+-#include "oops/typeArrayKlass.hpp"
+-
+-// a symbolKlass is the klass for a symbolOop
+-
+-class symbolKlass : public Klass {
+-  friend class VMStructs;
+- private:
+-  juint    _alloc_size;        // allocation profiling support
+- public:
+-  // Allocation
+-  DEFINE_ALLOCATE_PERMANENT(symbolKlass);
+-  static klassOop create_klass(TRAPS);
+-  symbolOop allocate_symbol(u1* name, int len, TRAPS);   // Assumes no characters larger than 0x7F
+-  bool allocate_symbols(int names_count, const char** names, int* lengths, symbolOop* sym_oops, TRAPS);
+-
+-  // Test operation
+-  bool oop_is_symbol() const { return true; }
+-
+-  // Casting from klassOop
+-  static symbolKlass* cast(klassOop k) {
+-    assert(k->klass_part()->oop_is_symbol(), "cast to symbolKlass");
+-    return (symbolKlass*) k->klass_part();
+-  }
+-
+-  static int header_size()       { return oopDesc::header_size() + sizeof(symbolKlass)/HeapWordSize; }
+-  int oop_size(oop obj) const;
+-  int klass_oop_size() const     { return object_size(); }
+-  int object_size() const        { return align_object_size(header_size()); }
+-
+-    // Garbage collection
+-  void oop_follow_contents(oop obj);
+-  int  oop_adjust_pointers(oop obj);
+-  bool oop_is_parsable(oop obj) const;
+-
+-  // Parallel Scavenge and Parallel Old
+-  PARALLEL_GC_DECLS
+-
+-  // Allocation profiling support
+-  juint alloc_size() const              { return _alloc_size; }
+-  void set_alloc_size(juint n)          { _alloc_size = n; }
+-
+-  // Iterators
+-  int  oop_oop_iterate(oop obj, OopClosure* blk);
+-  int  oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr);
+-
+-  // Printing
+-  void oop_print_value_on(oop obj, outputStream* st);
+-#ifndef PRODUCT
+-  void oop_print_on(oop obj, outputStream* st);
+-#endif //PRODUCT
+-  const char* internal_name() const;
+-};
+-
+-#endif // SHARE_VM_OOPS_SYMBOLKLASS_HPP
+diff --git a/src/share/vm/oops/typeArrayKlass.cpp b/src/share/vm/oops/typeArrayKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/typeArrayKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/typeArrayKlass.cpp
+@@ -53,16 +53,15 @@
+                                       const char* name_str, TRAPS) {
+   typeArrayKlass o;
+ 
+-  symbolHandle sym(symbolOop(NULL));
+-  // bootstrapping: don't create sym if symbolKlass not created yet
+-  if (Universe::symbolKlassObj() != NULL && name_str != NULL) {
+-    sym = oopFactory::new_symbol_handle(name_str, CHECK_NULL);
++  Symbol* sym = NULL;
++  if (name_str != NULL) {
++    sym = SymbolTable::new_symbol(name_str, CHECK_NULL);
+   }
+   KlassHandle klassklass (THREAD, Universe::typeArrayKlassKlassObj());
+ 
+   arrayKlassHandle k = base_create_array_klass(o.vtbl_value(), header_size(), klassklass, CHECK_NULL);
+   typeArrayKlass* ak = typeArrayKlass::cast(k());
+-  ak->set_name(sym());
++  ak->set_name(sym);
+   ak->set_layout_helper(array_layout_helper(type));
+   assert(scale == (1 << ak->log2_element_size()), "scale must check out");
+   assert(ak->oop_is_javaArray(), "sanity");
+diff --git a/src/share/vm/opto/runtime.cpp b/src/share/vm/opto/runtime.cpp
+--- openjdk/hotspot/src/share/vm/opto/runtime.cpp
++++ openjdk/hotspot/src/share/vm/opto/runtime.cpp
+@@ -477,7 +477,7 @@
+ const TypeFunc *OptoRuntime::uncommon_trap_Type() {
+   // create input type (domain)
+   const Type **fields = TypeTuple::fields(1);
+-  // symbolOop name of class to be loaded
++  // Symbol* name of class to be loaded
+   fields[TypeFunc::Parms+0] = TypeInt::INT;
+   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
+ 
+@@ -586,7 +586,7 @@
+ const TypeFunc *OptoRuntime::Math_D_D_Type() {
+   // create input type (domain)
+   const Type **fields = TypeTuple::fields(2);
+-  // symbolOop name of class to be loaded
++  // Symbol* name of class to be loaded
+   fields[TypeFunc::Parms+0] = Type::DOUBLE;
+   fields[TypeFunc::Parms+1] = Type::HALF;
+   const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
+diff --git a/src/share/vm/precompiled.hpp b/src/share/vm/precompiled.hpp
+--- openjdk/hotspot/src/share/vm/precompiled.hpp
++++ openjdk/hotspot/src/share/vm/precompiled.hpp
+@@ -169,7 +169,7 @@
+ # include "oops/oop.inline.hpp"
+ # include "oops/oop.inline2.hpp"
+ # include "oops/oopsHierarchy.hpp"
+-# include "oops/symbolOop.hpp"
++# include "oops/symbol.hpp"
+ # include "oops/typeArrayKlass.hpp"
+ # include "oops/typeArrayOop.hpp"
+ # include "prims/jni.h"
+diff --git a/src/share/vm/prims/jni.cpp b/src/share/vm/prims/jni.cpp
+--- openjdk/hotspot/src/share/vm/prims/jni.cpp
++++ openjdk/hotspot/src/share/vm/prims/jni.cpp
+@@ -40,7 +40,7 @@
+ #include "oops/objArrayKlass.hpp"
+ #include "oops/objArrayOop.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "oops/typeArrayKlass.hpp"
+ #include "oops/typeArrayOop.hpp"
+ #include "prims/jni.h"
+@@ -338,16 +338,15 @@
+ 
+   // Since exceptions can be thrown, class initialization can take place
+   // if name is NULL no check for class name in .class stream has to be made.
+-  symbolHandle class_name;
+   if (name != NULL) {
+     const int str_len = (int)strlen(name);
+-    if (str_len > symbolOopDesc::max_length()) {
++    if (str_len > Symbol::max_length()) {
+       // It's impossible to create this class;  the name cannot fit
+       // into the constant pool.
+       THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
+     }
+-    class_name = oopFactory::new_symbol_handle(name, str_len, CHECK_NULL);
+   }
++  TempNewSymbol class_name = SymbolTable::new_symbol(name, THREAD);
+ 
+   ResourceMark rm(THREAD);
+   ClassFileStream st((u1*) buf, bufLen, NULL);
+@@ -394,7 +393,7 @@
+ 
+   // Sanity check the name:  it cannot be null or larger than the maximum size
+   // name we can fit in the constant pool.
+-  if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) {
++  if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
+     THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
+   }
+ 
+@@ -411,8 +410,8 @@
+         k->name() == vmSymbols::java_lang_ClassLoader_NativeLibrary()) {
+       JavaValue result(T_OBJECT);
+       JavaCalls::call_static(&result, k,
+-                                      vmSymbolHandles::getFromClass_name(),
+-                                      vmSymbolHandles::void_class_signature(),
++                                      vmSymbols::getFromClass_name(),
++                                      vmSymbols::void_class_signature(),
+                                       thread);
+       if (HAS_PENDING_EXCEPTION) {
+         Handle ex(thread, thread->pending_exception());
+@@ -430,7 +429,7 @@
+     loader = Handle(THREAD, SystemDictionary::java_system_loader());
+   }
+ 
+-  symbolHandle sym = oopFactory::new_symbol_handle(name, CHECK_NULL);
++  TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL);
+   result = find_class_from_class_loader(env, sym, true, loader,
+                                         protection_domain, true, thread);
+ 
+@@ -609,7 +608,7 @@
+   DT_RETURN_MARK(ThrowNew, jint, (const jint&)ret);
+ 
+   instanceKlass* k = instanceKlass::cast(java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz)));
+-  symbolHandle name = symbolHandle(THREAD, k->name());
++  Symbol*  name = k->name();
+   Handle class_loader (THREAD,  k->class_loader());
+   Handle protection_domain (THREAD, k->protection_domain());
+   THROW_MSG_LOADER_(name, (char *)message, class_loader, protection_domain, JNI_OK);
+@@ -663,8 +662,8 @@
+                                 ex,
+                                 KlassHandle(THREAD,
+                                   SystemDictionary::Throwable_klass()),
+-                                vmSymbolHandles::printStackTrace_name(),
+-                                vmSymbolHandles::void_method_signature(),
++                                vmSymbols::printStackTrace_name(),
++                                vmSymbols::void_method_signature(),
+                                 THREAD);
+         // If an exception is thrown in the call it gets thrown away. Not much
+         // we can do with it. The native code that calls this, does not check
+@@ -838,8 +837,7 @@
+   virtual void get_double () = 0;
+   virtual void get_object () = 0;
+ 
+-  JNI_ArgumentPusher(Thread *thread, symbolOop signature)
+-       : SignatureIterator(thread, signature) {
++  JNI_ArgumentPusher(Symbol* signature) : SignatureIterator(signature) {
+     this->_return_type = T_ILLEGAL;
+     _arguments = NULL;
+   }
+@@ -895,12 +893,12 @@
+   }
+ 
+  public:
+-  JNI_ArgumentPusherVaArg(Thread *thread, symbolOop signature, va_list rap)
+-       : JNI_ArgumentPusher(thread, signature) {
++  JNI_ArgumentPusherVaArg(Symbol* signature, va_list rap)
++       : JNI_ArgumentPusher(signature) {
+     set_ap(rap);
+   }
+-  JNI_ArgumentPusherVaArg(Thread *thread, jmethodID method_id, va_list rap)
+-      : JNI_ArgumentPusher(thread, JNIHandles::resolve_jmethod_id(method_id)->signature()) {
++  JNI_ArgumentPusherVaArg(jmethodID method_id, va_list rap)
++      : JNI_ArgumentPusher(JNIHandles::resolve_jmethod_id(method_id)->signature()) {
+     set_ap(rap);
+   }
+ 
+@@ -966,12 +964,12 @@
+   inline void set_ap(const jvalue *rap) { _ap = rap; }
+ 
+  public:
+-  JNI_ArgumentPusherArray(Thread *thread, symbolOop signature, const jvalue *rap)
+-       : JNI_ArgumentPusher(thread, signature) {
++  JNI_ArgumentPusherArray(Symbol* signature, const jvalue *rap)
++       : JNI_ArgumentPusher(signature) {
+     set_ap(rap);
+   }
+-  JNI_ArgumentPusherArray(Thread *thread, jmethodID method_id, const jvalue *rap)
+-      : JNI_ArgumentPusher(thread, JNIHandles::resolve_jmethod_id(method_id)->signature()) {
++  JNI_ArgumentPusherArray(jmethodID method_id, const jvalue *rap)
++      : JNI_ArgumentPusher(JNIHandles::resolve_jmethod_id(method_id)->signature()) {
+     set_ap(rap);
+   }
+ 
+@@ -1038,8 +1036,8 @@
+   KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc)
+   if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass());
+   KlassHandle spec_klass (THREAD, method->method_holder());
+-  symbolHandle name (THREAD, method->name());
+-  symbolHandle signature (THREAD, method->signature());
++  Symbol*  name  = method->name();
++  Symbol*  signature  = method->signature();
+   CallInfo info;
+   LinkResolver::resolve_interface_call(info, recv, recv_klass,  spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle()));
+   return info.selected_method();
+@@ -1051,8 +1049,8 @@
+   KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc)
+   if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass());
+   KlassHandle spec_klass (THREAD, method->method_holder());
+-  symbolHandle name (THREAD, method->name());
+-  symbolHandle signature (THREAD, method->signature());
++  Symbol*  name  = method->name();
++  Symbol*  signature  = method->signature();
+   CallInfo info;
+   LinkResolver::resolve_virtual_call(info, recv, recv_klass,  spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle()));
+   return info.selected_method();
+@@ -1073,7 +1071,7 @@
+   assert(method->is_static(), "method should be static");
+ 
+   // Fill out JavaCallArguments object
+-  args->iterate( Fingerprinter(THREAD, method).fingerprint() );
++  args->iterate( Fingerprinter(method).fingerprint() );
+   // Initialize result type
+   result->set_type(args->get_ret_type());
+ 
+@@ -1149,7 +1147,7 @@
+   args->push_receiver(h_recv); // Push jobject handle
+ 
+   // Fill out JavaCallArguments object
+-  args->iterate( Fingerprinter(THREAD, method).fingerprint() );
++  args->iterate( Fingerprinter(method).fingerprint() );
+   // Initialize result type
+   result->set_type(args->get_ret_type());
+ 
+@@ -1196,7 +1194,7 @@
+   instanceOop i = alloc_object(clazz, CHECK_NULL);
+   obj = JNIHandles::make_local(env, i);
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherArray ap(THREAD, methodID, args);
++  JNI_ArgumentPusherArray ap(methodID, args);
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL);
+   return obj;
+ JNI_END
+@@ -1212,7 +1210,7 @@
+   instanceOop i = alloc_object(clazz, CHECK_NULL);
+   obj = JNIHandles::make_local(env, i);
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args);
++  JNI_ArgumentPusherVaArg ap(methodID, args);
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL);
+   return obj;
+ JNI_END
+@@ -1230,7 +1228,7 @@
+   va_list args;
+   va_start(args, methodID);
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args);
++  JNI_ArgumentPusherVaArg ap(methodID, args);
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_NULL);
+   va_end(args);
+   return obj;
+@@ -1271,16 +1269,13 @@
+   // The class should have been loaded (we have an instance of the class
+   // passed in) so the method and signature should already be in the symbol
+   // table.  If they're not there, the method doesn't exist.
+-  symbolHandle signature =
+-           symbolHandle(THREAD, SymbolTable::probe(sig, (int)strlen(sig)));
+-  symbolHandle name;
+-  if (name_str == NULL) {
+-    name = vmSymbolHandles::object_initializer_name();
+-  } else {
+-    name = symbolHandle(THREAD,
+-                        SymbolTable::probe(name_str, (int)strlen(name_str)));
+-  }
+-  if (name.is_null() || signature.is_null()) {
++  const char *name_to_probe = (name_str == NULL)
++                        ? vmSymbols::object_initializer_name()->as_C_string()
++                        : name_str;
++  TempNewSymbol name = SymbolTable::probe(name_to_probe, (int)strlen(name_to_probe));
++  TempNewSymbol signature = SymbolTable::probe(sig, (int)strlen(sig));
++
++  if (name == NULL || signature == NULL) {
+     THROW_MSG_0(vmSymbols::java_lang_NoSuchMethodError(), name_str);
+   }
+ 
+@@ -1298,20 +1293,20 @@
+   Klass::cast(klass())->initialize(CHECK_NULL);
+ 
+   methodOop m;
+-  if (name() == vmSymbols::object_initializer_name() ||
+-      name() == vmSymbols::class_initializer_name()) {
++  if (name == vmSymbols::object_initializer_name() ||
++      name == vmSymbols::class_initializer_name()) {
+     // Never search superclasses for constructors
+     if (klass->oop_is_instance()) {
+-      m = instanceKlass::cast(klass())->find_method(name(), signature());
++      m = instanceKlass::cast(klass())->find_method(name, signature);
+     } else {
+       m = NULL;
+     }
+   } else {
+-    m = klass->lookup_method(name(), signature());
++    m = klass->lookup_method(name, signature);
+     // Look up interfaces
+     if (m == NULL && klass->oop_is_instance()) {
+-      m = instanceKlass::cast(klass())->lookup_method_in_all_interfaces(name(),
+-                                                                   signature());
++      m = instanceKlass::cast(klass())->lookup_method_in_all_interfaces(name,
++                                                                   signature);
+     }
+   }
+   if (m == NULL || (m->is_static() != is_static)) {
+@@ -1365,7 +1360,7 @@
+   va_list args; \
+   va_start(args, methodID); \
+   JavaValue jvalue(Tag); \
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \
++  JNI_ArgumentPusherVaArg ap(methodID, args); \
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \
+   va_end(args); \
+   ret = jvalue.get_##ResultType(); \
+@@ -1383,7 +1378,7 @@
+                      (const ResultType&)ret);\
+ \
+   JavaValue jvalue(Tag); \
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \
++  JNI_ArgumentPusherVaArg ap(methodID, args); \
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \
+   ret = jvalue.get_##ResultType(); \
+   return ret;\
+@@ -1399,7 +1394,7 @@
+                      (const ResultType&)ret);\
+ \
+   JavaValue jvalue(Tag); \
+-  JNI_ArgumentPusherArray ap(THREAD, methodID, args); \
++  JNI_ArgumentPusherArray ap(methodID, args); \
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \
+   ret = jvalue.get_##ResultType(); \
+   return ret;\
+@@ -1429,7 +1424,7 @@
+   va_list args;
+   va_start(args, methodID);
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args);
++  JNI_ArgumentPusherVaArg ap(methodID, args);
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK);
+   va_end(args);
+ JNI_END
+@@ -1441,7 +1436,7 @@
+   DT_VOID_RETURN_MARK(CallVoidMethodV);
+ 
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args);
++  JNI_ArgumentPusherVaArg ap(methodID, args);
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK);
+ JNI_END
+ 
+@@ -1452,7 +1447,7 @@
+   DT_VOID_RETURN_MARK(CallVoidMethodA);
+ 
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherArray ap(THREAD, methodID, args);
++  JNI_ArgumentPusherArray ap(methodID, args);
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK);
+ JNI_END
+ 
+@@ -1475,7 +1470,7 @@
+   va_list args; \
+   va_start(args, methodID); \
+   JavaValue jvalue(Tag); \
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \
++  JNI_ArgumentPusherVaArg ap(methodID, args); \
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \
+   va_end(args); \
+   ret = jvalue.get_##ResultType(); \
+@@ -1491,7 +1486,7 @@
+                      (const ResultType&)ret);\
+ \
+   JavaValue jvalue(Tag); \
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \
++  JNI_ArgumentPusherVaArg ap(methodID, args); \
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \
+   ret = jvalue.get_##ResultType(); \
+   return ret;\
+@@ -1506,7 +1501,7 @@
+                      (const ResultType&)ret);\
+ \
+   JavaValue jvalue(Tag); \
+-  JNI_ArgumentPusherArray ap(THREAD, methodID, args); \
++  JNI_ArgumentPusherArray ap(methodID, args); \
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \
+   ret = jvalue.get_##ResultType(); \
+   return ret;\
+@@ -1539,7 +1534,7 @@
+   va_list args;
+   va_start(args, methodID);
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args);
++  JNI_ArgumentPusherVaArg ap(methodID, args);
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK);
+   va_end(args);
+ JNI_END
+@@ -1553,7 +1548,7 @@
+   DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodV);
+ 
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args);
++  JNI_ArgumentPusherVaArg ap(methodID, args);
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK);
+ JNI_END
+ 
+@@ -1564,7 +1559,7 @@
+                 env, obj, cls, methodID);
+   DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodA);
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherArray ap(THREAD, methodID, args);
++  JNI_ArgumentPusherArray ap(methodID, args);
+   jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK);
+ JNI_END
+ 
+@@ -1587,7 +1582,7 @@
+   va_list args; \
+   va_start(args, methodID); \
+   JavaValue jvalue(Tag); \
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \
++  JNI_ArgumentPusherVaArg ap(methodID, args); \
+   jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \
+   va_end(args); \
+   ret = jvalue.get_##ResultType(); \
+@@ -1603,7 +1598,7 @@
+                      (const ResultType&)ret);\
+ \
+   JavaValue jvalue(Tag); \
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args); \
++  JNI_ArgumentPusherVaArg ap(methodID, args); \
+   jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \
+   ret = jvalue.get_##ResultType(); \
+   return ret;\
+@@ -1618,7 +1613,7 @@
+                      (const ResultType&)ret);\
+ \
+   JavaValue jvalue(Tag); \
+-  JNI_ArgumentPusherArray ap(THREAD, methodID, args); \
++  JNI_ArgumentPusherArray ap(methodID, args); \
+   jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \
+   ret = jvalue.get_##ResultType(); \
+   return ret;\
+@@ -1649,7 +1644,7 @@
+   va_list args;
+   va_start(args, methodID);
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args);
++  JNI_ArgumentPusherVaArg ap(methodID, args);
+   jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK);
+   va_end(args);
+ JNI_END
+@@ -1661,7 +1656,7 @@
+   DT_VOID_RETURN_MARK(CallStaticVoidMethodV);
+ 
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherVaArg ap(THREAD, methodID, args);
++  JNI_ArgumentPusherVaArg ap(methodID, args);
+   jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK);
+ JNI_END
+ 
+@@ -1672,7 +1667,7 @@
+   DT_VOID_RETURN_MARK(CallStaticVoidMethodA);
+ 
+   JavaValue jvalue(T_VOID);
+-  JNI_ArgumentPusherArray ap(THREAD, methodID, args);
++  JNI_ArgumentPusherArray ap(methodID, args);
+   jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK);
+ JNI_END
+ 
+@@ -1694,11 +1689,9 @@
+   // The class should have been loaded (we have an instance of the class
+   // passed in) so the field and signature should already be in the symbol
+   // table.  If they're not there, the field doesn't exist.
+-  symbolHandle fieldname =
+-            symbolHandle(THREAD, SymbolTable::probe(name, (int)strlen(name)));
+-  symbolHandle signame   =
+-            symbolHandle(THREAD, SymbolTable::probe(sig, (int)strlen(sig)));
+-  if (fieldname.is_null() || signame.is_null()) {
++  TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name));
++  TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig));
++  if (fieldname == NULL || signame == NULL) {
+     THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
+   }
+   KlassHandle k(THREAD,
+@@ -1708,7 +1701,7 @@
+ 
+   fieldDescriptor fd;
+   if (!Klass::cast(k())->oop_is_instance() ||
+-      !instanceKlass::cast(k())->find_field(fieldname(), signame(), false, &fd)) {
++      !instanceKlass::cast(k())->find_field(fieldname, signame, false, &fd)) {
+     THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
+   }
+ 
+@@ -1893,11 +1886,9 @@
+   // The class should have been loaded (we have an instance of the class
+   // passed in) so the field and signature should already be in the symbol
+   // table.  If they're not there, the field doesn't exist.
+-  symbolHandle fieldname =
+-           symbolHandle(THREAD, SymbolTable::probe(name, (int)strlen(name)));
+-  symbolHandle signame   =
+-           symbolHandle(THREAD, SymbolTable::probe(sig, (int)strlen(sig)));
+-  if (fieldname.is_null() || signame.is_null()) {
++  TempNewSymbol fieldname = SymbolTable::probe(name, (int)strlen(name));
++  TempNewSymbol signame = SymbolTable::probe(sig, (int)strlen(sig));
++  if (fieldname == NULL || signame == NULL) {
+     THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
+   }
+   KlassHandle k(THREAD,
+@@ -1907,7 +1898,7 @@
+ 
+   fieldDescriptor fd;
+   if (!Klass::cast(k())->oop_is_instance() ||
+-      !instanceKlass::cast(k())->find_field(fieldname(), signame(), true, &fd)) {
++      !instanceKlass::cast(k())->find_field(fieldname, signame, true, &fd)) {
+     THROW_MSG_0(vmSymbols::java_lang_NoSuchFieldError(), (char*) name);
+   }
+ 
+@@ -2387,7 +2378,7 @@
+ // to see if the native method is now wrapped with the prefixes.  See the
+ // SetNativeMethodPrefix(es) functions in the JVM TI Spec for details.
+ static methodOop find_prefixed_native(KlassHandle k,
+-                                      symbolHandle name, symbolHandle signature, TRAPS) {
++                                      Symbol* name, Symbol* signature, TRAPS) {
+   ResourceMark rm(THREAD);
+   methodOop method;
+   int name_len = name->utf8_length();
+@@ -2403,11 +2394,11 @@
+     char* trial_name_str = NEW_RESOURCE_ARRAY(char, trial_len + 1);
+     strcpy(trial_name_str, prefix);
+     strcat(trial_name_str, name_str);
+-    symbolHandle trial_name(THREAD, SymbolTable::probe(trial_name_str, trial_len));
+-    if (trial_name.is_null()) {
++    TempNewSymbol trial_name = SymbolTable::probe(trial_name_str, trial_len);
++    if (trial_name == NULL) {
+       continue; // no such symbol, so this prefix wasn't used, try the next prefix
+     }
+-    method = Klass::cast(k())->lookup_method(trial_name(), signature());
++    method = Klass::cast(k())->lookup_method(trial_name, signature);
+     if (method == NULL) {
+       continue; // signature doesn't match, try the next prefix
+     }
+@@ -2422,13 +2413,13 @@
+   return NULL; // not found
+ }
+ 
+-static bool register_native(KlassHandle k, symbolHandle name, symbolHandle signature, address entry, TRAPS) {
+-  methodOop method = Klass::cast(k())->lookup_method(name(), signature());
++static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, address entry, TRAPS) {
++  methodOop method = Klass::cast(k())->lookup_method(name, signature);
+   if (method == NULL) {
+     ResourceMark rm;
+     stringStream st;
+     st.print("Method %s name or signature does not match",
+-             methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name(), signature()));
++             methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name, signature));
+     THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
+   }
+   if (!method->is_native()) {
+@@ -2438,7 +2429,7 @@
+       ResourceMark rm;
+       stringStream st;
+       st.print("Method %s is not declared as native",
+-               methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name(), signature()));
++               methodOopDesc::name_and_sig_as_C_string(Klass::cast(k()), name, signature));
+       THROW_MSG_(vmSymbols::java_lang_NoSuchMethodError(), st.as_string(), false);
+     }
+   }
+@@ -2478,10 +2469,10 @@
+     // The class should have been loaded (we have an instance of the class
+     // passed in) so the method and signature should already be in the symbol
+     // table.  If they're not there, the method doesn't exist.
+-    symbolHandle name(THREAD, SymbolTable::probe(meth_name, meth_name_len));
+-    symbolHandle signature(THREAD, SymbolTable::probe(meth_sig, (int)strlen(meth_sig)));
+-
+-    if (name.is_null() || signature.is_null()) {
++    TempNewSymbol  name = SymbolTable::probe(meth_name, meth_name_len);
++    TempNewSymbol  signature = SymbolTable::probe(meth_sig, (int)strlen(meth_sig));
++
++    if (name == NULL || signature == NULL) {
+       ResourceMark rm;
+       stringStream st;
+       st.print("Method %s.%s%s not found", Klass::cast(h_k())->external_name(), meth_name, meth_sig);
+@@ -2715,7 +2706,7 @@
+   Handle loader;            // null (bootstrap) loader
+   Handle protection_domain; // null protection domain
+ 
+-  symbolHandle sym = oopFactory::new_symbol_handle(name, CHECK_NULL);
++  TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL);
+   jclass result =  find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL);
+ 
+   if (TraceClassResolution && result != NULL) {
+diff --git a/src/share/vm/prims/jniCheck.cpp b/src/share/vm/prims/jniCheck.cpp
+--- openjdk/hotspot/src/share/vm/prims/jniCheck.cpp
++++ openjdk/hotspot/src/share/vm/prims/jniCheck.cpp
+@@ -27,7 +27,7 @@
+ #include "classfile/vmSymbols.hpp"
+ #include "oops/instanceKlass.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "prims/jni.h"
+ #include "prims/jniCheck.hpp"
+ #include "prims/jvm_misc.hpp"
+diff --git a/src/share/vm/prims/jvm.cpp b/src/share/vm/prims/jvm.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvm.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvm.cpp
+@@ -124,9 +124,9 @@
+     vframeStream vfst(jthread);
+ 
+     // scan up the stack skipping ClassLoader, AccessController and PrivilegedAction frames
+-    symbolHandle access_controller = oopFactory::new_symbol_handle("java/security/AccessController", CHECK);
++    TempNewSymbol access_controller = SymbolTable::new_symbol("java/security/AccessController", CHECK);
+     klassOop access_controller_klass = SystemDictionary::resolve_or_fail(access_controller, false, CHECK);
+-    symbolHandle privileged_action = oopFactory::new_symbol_handle("java/security/PrivilegedAction", CHECK);
++    TempNewSymbol privileged_action = SymbolTable::new_symbol("java/security/PrivilegedAction", CHECK);
+     klassOop privileged_action_klass = SystemDictionary::resolve_or_fail(privileged_action, false, CHECK);
+ 
+     methodOop last_caller = NULL;
+@@ -175,7 +175,7 @@
+         // show method name if it's a native method
+         trace = vfst.method()->name_and_sig_as_C_string();
+       }
+-      symbolOop s = instanceKlass::cast(caller)->source_file_name();
++      Symbol* s = instanceKlass::cast(caller)->source_file_name();
+       if (s != NULL) {
+         source_file = s->as_C_string();
+       }
+@@ -311,8 +311,8 @@
+   JavaCalls::call_virtual(&r,
+                           props,
+                           KlassHandle(THREAD, SystemDictionary::Properties_klass()),
+-                          vmSymbolHandles::put_name(),
+-                          vmSymbolHandles::object_object_object_signature(),
++                          vmSymbols::put_name(),
++                          vmSymbols::object_object_object_signature(),
+                           key_str,
+                           value_str,
+                           THREAD);
+@@ -716,13 +716,13 @@
+   JVMWrapper2("JVM_FindClassFromBootLoader %s", name);
+ 
+   // Java libraries should ensure that name is never null...
+-  if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) {
++  if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
+     // It's impossible to create this class;  the name cannot fit
+     // into the constant pool.
+     return NULL;
+   }
+ 
+-  symbolHandle h_name = oopFactory::new_symbol_handle(name, CHECK_NULL);
++  TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
+   klassOop k = SystemDictionary::resolve_or_null(h_name, CHECK_NULL);
+   if (k == NULL) {
+     return NULL;
+@@ -740,7 +740,7 @@
+   JVMWrapper3("JVM_FindClassFromClassLoader %s throw %s", name,
+                throwError ? "error" : "exception");
+   // Java libraries should ensure that name is never null...
+-  if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) {
++  if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
+     // It's impossible to create this class;  the name cannot fit
+     // into the constant pool.
+     if (throwError) {
+@@ -749,7 +749,7 @@
+       THROW_MSG_0(vmSymbols::java_lang_ClassNotFoundException(), name);
+     }
+   }
+-  symbolHandle h_name = oopFactory::new_symbol_handle(name, CHECK_NULL);
++  TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
+   Handle h_loader(THREAD, JNIHandles::resolve(loader));
+   jclass result = find_class_from_class_loader(env, h_name, init, h_loader,
+                                                Handle(), throwError, THREAD);
+@@ -764,12 +764,12 @@
+ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name,
+                                          jboolean init, jclass from))
+   JVMWrapper2("JVM_FindClassFromClass %s", name);
+-  if (name == NULL || (int)strlen(name) > symbolOopDesc::max_length()) {
++  if (name == NULL || (int)strlen(name) > Symbol::max_length()) {
+     // It's impossible to create this class;  the name cannot fit
+     // into the constant pool.
+     THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
+   }
+-  symbolHandle h_name = oopFactory::new_symbol_handle(name, CHECK_NULL);
++  TempNewSymbol h_name = SymbolTable::new_symbol(name, CHECK_NULL);
+   oop from_class_oop = JNIHandles::resolve(from);
+   klassOop from_class = (from_class_oop == NULL)
+                            ? (klassOop)NULL
+@@ -838,15 +838,15 @@
+ 
+   // Since exceptions can be thrown, class initialization can take place
+   // if name is NULL no check for class name in .class stream has to be made.
+-  symbolHandle class_name;
++  TempNewSymbol class_name = NULL;
+   if (name != NULL) {
+     const int str_len = (int)strlen(name);
+-    if (str_len > symbolOopDesc::max_length()) {
++    if (str_len > Symbol::max_length()) {
+       // It's impossible to create this class;  the name cannot fit
+       // into the constant pool.
+       THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), name);
+     }
+-    class_name = oopFactory::new_symbol_handle(name, str_len, CHECK_NULL);
++    class_name = SymbolTable::new_symbol(name, str_len, CHECK_NULL);
+   }
+ 
+   ResourceMark rm(THREAD);
+@@ -905,12 +905,12 @@
+   if (str == NULL) return NULL;
+ 
+   const int str_len = (int)strlen(str);
+-  if (str_len > symbolOopDesc::max_length()) {
++  if (str_len > Symbol::max_length()) {
+     // It's impossible to create this class;  the name cannot fit
+     // into the constant pool.
+     return NULL;
+   }
+-  symbolHandle klass_name = oopFactory::new_symbol_handle(str, str_len,CHECK_NULL);
++  TempNewSymbol klass_name = SymbolTable::new_symbol(str, str_len, CHECK_NULL);
+ 
+   // Security Note:
+   //   The Java level wrapper will perform the necessary security check allowing
+@@ -1224,8 +1224,8 @@
+         !pending_exception->is_a(SystemDictionary::RuntimeException_klass())) {
+       // Throw a java.security.PrivilegedActionException(Exception e) exception
+       JavaCallArguments args(pending_exception);
+-      THROW_ARG_0(vmSymbolHandles::java_security_PrivilegedActionException(),
+-                  vmSymbolHandles::exception_void_signature(),
++      THROW_ARG_0(vmSymbols::java_security_PrivilegedActionException(),
++                  vmSymbols::exception_void_signature(),
+                   &args);
+     }
+   }
+@@ -1521,8 +1521,8 @@
+   if (!java_lang_Class::is_primitive(JNIHandles::resolve(cls))) {
+     klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve(cls));
+     if (Klass::cast(k)->oop_is_instance()) {
+-      symbolHandle sym = symbolHandle(THREAD, instanceKlass::cast(k)->generic_signature());
+-      if (sym.is_null()) return NULL;
++      Symbol* sym = instanceKlass::cast(k)->generic_signature();
++      if (sym == NULL) return NULL;
+       Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
+       return (jstring) JNIHandles::make_local(env, str());
+     }
+@@ -1911,8 +1911,8 @@
+     if (k_o == NULL) return NULL;
+   }
+   instanceKlassHandle k(THREAD, k_o);
+-  symbolOop name = cp->uncached_name_ref_at(index);
+-  symbolOop sig  = cp->uncached_signature_ref_at(index);
++  Symbol* name = cp->uncached_name_ref_at(index);
++  Symbol* sig  = cp->uncached_signature_ref_at(index);
+   methodHandle m (THREAD, k->find_method(name, sig));
+   if (m.is_null()) {
+     THROW_MSG_0(vmSymbols::java_lang_RuntimeException(), "Unable to look up method in target class");
+@@ -1962,8 +1962,8 @@
+     if (k_o == NULL) return NULL;
+   }
+   instanceKlassHandle k(THREAD, k_o);
+-  symbolOop name = cp->uncached_name_ref_at(index);
+-  symbolOop sig  = cp->uncached_signature_ref_at(index);
++  Symbol* name = cp->uncached_name_ref_at(index);
++  Symbol* sig  = cp->uncached_signature_ref_at(index);
+   fieldDescriptor fd;
+   klassOop target_klass = k->find_field(name, sig, &fd);
+   if (target_klass == NULL) {
+@@ -2006,9 +2006,9 @@
+     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index");
+   }
+   int klass_ref = cp->uncached_klass_ref_index_at(index);
+-  symbolHandle klass_name (THREAD, cp->klass_name_at(klass_ref));
+-  symbolHandle member_name(THREAD, cp->uncached_name_ref_at(index));
+-  symbolHandle member_sig (THREAD, cp->uncached_signature_ref_at(index));
++  Symbol*  klass_name  = cp->klass_name_at(klass_ref);
++  Symbol*  member_name = cp->uncached_name_ref_at(index);
++  Symbol*  member_sig  = cp->uncached_signature_ref_at(index);
+   objArrayOop  dest_o = oopFactory::new_objArray(SystemDictionary::String_klass(), 3, CHECK_NULL);
+   objArrayHandle dest(THREAD, dest_o);
+   Handle str = java_lang_String::create_from_symbol(klass_name, CHECK_NULL);
+@@ -2097,8 +2097,7 @@
+   if (!tag.is_symbol()) {
+     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index");
+   }
+-  symbolOop sym_o = cp->symbol_at(index);
+-  symbolHandle sym(THREAD, sym_o);
++  Symbol* sym = cp->symbol_at(index);
+   Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
+   return (jstring) JNIHandles::make_local(str());
+ }
+@@ -2425,7 +2424,7 @@
+   klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls));
+   k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread);
+   constantPoolOop cp = instanceKlass::cast(k)->constants();
+-  symbolOop classname = cp->klass_name_at(cp_index);
++  Symbol* classname = cp->klass_name_at(cp_index);
+   return classname->as_utf8();
+ JVM_END
+ 
+@@ -2438,7 +2437,7 @@
+   switch (cp->tag_at(cp_index).value()) {
+     case JVM_CONSTANT_Fieldref: {
+       int class_index = cp->uncached_klass_ref_index_at(cp_index);
+-      symbolOop classname = cp->klass_name_at(class_index);
++      Symbol* classname = cp->klass_name_at(class_index);
+       return classname->as_utf8();
+     }
+     default:
+@@ -2458,7 +2457,7 @@
+     case JVM_CONSTANT_Methodref:
+     case JVM_CONSTANT_InterfaceMethodref: {
+       int class_index = cp->uncached_klass_ref_index_at(cp_index);
+-      symbolOop classname = cp->klass_name_at(class_index);
++      Symbol* classname = cp->klass_name_at(class_index);
+       return classname->as_utf8();
+     }
+     default:
+@@ -2479,8 +2478,8 @@
+   constantPoolOop cp_called = instanceKlass::cast(k_called)->constants();
+   switch (cp->tag_at(cp_index).value()) {
+     case JVM_CONSTANT_Fieldref: {
+-      symbolOop name      = cp->uncached_name_ref_at(cp_index);
+-      symbolOop signature = cp->uncached_signature_ref_at(cp_index);
++      Symbol* name      = cp->uncached_name_ref_at(cp_index);
++      Symbol* signature = cp->uncached_signature_ref_at(cp_index);
+       typeArrayOop fields = instanceKlass::cast(k_called)->fields();
+       int fields_count = fields->length();
+       for (int i = 0; i < fields_count; i += instanceKlass::next_offset) {
+@@ -2509,8 +2508,8 @@
+   switch (cp->tag_at(cp_index).value()) {
+     case JVM_CONSTANT_Methodref:
+     case JVM_CONSTANT_InterfaceMethodref: {
+-      symbolOop name      = cp->uncached_name_ref_at(cp_index);
+-      symbolOop signature = cp->uncached_signature_ref_at(cp_index);
++      Symbol* name      = cp->uncached_name_ref_at(cp_index);
++      Symbol* signature = cp->uncached_signature_ref_at(cp_index);
+       objArrayOop methods = instanceKlass::cast(k_called)->methods();
+       int methods_count = methods->length();
+       for (int i = 0; i < methods_count; i++) {
+@@ -2698,8 +2697,8 @@
+   JavaCalls::call_virtual(&result,
+                           obj,
+                           KlassHandle(THREAD, SystemDictionary::Thread_klass()),
+-                          vmSymbolHandles::run_method_name(),
+-                          vmSymbolHandles::void_method_signature(),
++                          vmSymbols::run_method_name(),
++                          vmSymbols::void_method_signature(),
+                           THREAD);
+ }
+ 
+@@ -3175,9 +3174,8 @@
+   Handle class_name_str = java_lang_String::internalize_classname(h_name, CHECK_0);
+ 
+   const char* str = java_lang_String::as_utf8_string(class_name_str());
+-  symbolHandle class_name_sym =
+-                symbolHandle(THREAD, SymbolTable::probe(str, (int)strlen(str)));
+-  if (class_name_sym.is_null()) {
++  TempNewSymbol class_name_sym = SymbolTable::probe(str, (int)strlen(str));
++  if (class_name_sym == NULL) {
+     return -1;
+   }
+ 
+@@ -3187,7 +3185,7 @@
+     if (!vfst.method()->is_native()) {
+       klassOop holder = vfst.method()->method_holder();
+       assert(holder->is_klass(), "just checking");
+-      if (instanceKlass::cast(holder)->name() == class_name_sym()) {
++      if (instanceKlass::cast(holder)->name() == class_name_sym) {
+         return depth;
+       }
+       depth++;
+@@ -3386,13 +3384,13 @@
+ 
+   const char* str = java_lang_String::as_utf8_string(string());
+ 
+-  if (str == NULL || (int)strlen(str) > symbolOopDesc::max_length()) {
++  if (str == NULL || (int)strlen(str) > Symbol::max_length()) {
+     // It's impossible to create this class;  the name cannot fit
+     // into the constant pool.
+     THROW_MSG_0(vmSymbols::java_lang_NoClassDefFoundError(), str);
+   }
+ 
+-  symbolHandle name = oopFactory::new_symbol_handle(str, CHECK_NULL);
++  TempNewSymbol name = SymbolTable::new_symbol(str, CHECK_NULL);
+   Handle curr_klass (THREAD, JNIHandles::resolve(currClass));
+   // Find the most recent class on the stack with a non-null classloader
+   oop loader = NULL;
+@@ -4035,7 +4033,7 @@
+ 
+ // Shared JNI/JVM entry points //////////////////////////////////////////////////////////////
+ 
+-jclass find_class_from_class_loader(JNIEnv* env, symbolHandle name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) {
++jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS) {
+   // Security Note:
+   //   The Java level wrapper will perform the necessary security check allowing
+   //   us to pass the NULL as the initiating class loader.
+@@ -4131,14 +4129,13 @@
+   Handle str (THREAD, JNIHandles::resolve_non_null(name));
+ 
+   const char* cstr = java_lang_String::as_utf8_string(str());
+-  symbolHandle field_name =
+-           symbolHandle(THREAD, SymbolTable::probe(cstr, (int)strlen(cstr)));
+-  if (field_name.is_null()) {
++  TempNewSymbol field_name = SymbolTable::probe(cstr, (int)strlen(cstr));
++  if (field_name == NULL) {
+     THROW_0(vmSymbols::java_lang_NoSuchFieldException());
+   }
+ 
+   oop mirror = JNIHandles::resolve_non_null(cls);
+-  oop result = Reflection::reflect_field(mirror, field_name(), which, CHECK_NULL);
++  oop result = Reflection::reflect_field(mirror, field_name, which, CHECK_NULL);
+   if (result == NULL) {
+     THROW_0(vmSymbols::java_lang_NoSuchFieldException());
+   }
+@@ -4155,9 +4152,8 @@
+   Handle str (THREAD, JNIHandles::resolve_non_null(name));
+ 
+   const char* cstr = java_lang_String::as_utf8_string(str());
+-  symbolHandle method_name =
+-          symbolHandle(THREAD, SymbolTable::probe(cstr, (int)strlen(cstr)));
+-  if (method_name.is_null()) {
++  TempNewSymbol method_name = SymbolTable::probe(cstr, (int)strlen(cstr));
++  if (method_name == NULL) {
+     THROW_0(vmSymbols::java_lang_NoSuchMethodException());
+   }
+ 
+@@ -4530,16 +4526,14 @@
+   dest->obj_at_put(0, Klass::cast(enc_k)->java_mirror());
+   int encl_method_method_idx = ik_h->enclosing_method_method_index();
+   if (encl_method_method_idx != 0) {
+-    symbolOop sym_o = ik_h->constants()->symbol_at(
++    Symbol* sym = ik_h->constants()->symbol_at(
+                         extract_low_short_from_int(
+                           ik_h->constants()->name_and_type_at(encl_method_method_idx)));
+-    symbolHandle sym(THREAD, sym_o);
+     Handle str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
+     dest->obj_at_put(1, str());
+-    sym_o = ik_h->constants()->symbol_at(
++    sym = ik_h->constants()->symbol_at(
+               extract_high_short_from_int(
+                 ik_h->constants()->name_and_type_at(encl_method_method_idx)));
+-    sym = symbolHandle(THREAD, sym_o);
+     str = java_lang_String::create_from_symbol(sym, CHECK_NULL);
+     dest->obj_at_put(2, str());
+   }
+diff --git a/src/share/vm/prims/jvm_misc.hpp b/src/share/vm/prims/jvm_misc.hpp
+--- openjdk/hotspot/src/share/vm/prims/jvm_misc.hpp
++++ openjdk/hotspot/src/share/vm/prims/jvm_misc.hpp
+@@ -31,7 +31,7 @@
+ // Useful entry points shared by JNI and JVM interface.
+ // We do not allow real JNI or JVM entry point to call each other.
+ 
+-jclass find_class_from_class_loader(JNIEnv* env, symbolHandle name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS);
++jclass find_class_from_class_loader(JNIEnv* env, Symbol* name, jboolean init, Handle loader, Handle protection_domain, jboolean throwError, TRAPS);
+ 
+ void trace_class_resolution(klassOop to_class);
+ 
+diff --git a/src/share/vm/prims/jvmtiClassFileReconstituter.cpp b/src/share/vm/prims/jvmtiClassFileReconstituter.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp
+@@ -461,11 +461,11 @@
+ // JVMSpec|     attribute_info attributes[attributes_count];
+ void JvmtiClassFileReconstituter::write_class_attributes() {
+   u2 inner_classes_length = inner_classes_attribute_length();
+-  symbolHandle generic_signature(thread(), ikh()->generic_signature());
++  Symbol* generic_signature = ikh()->generic_signature();
+   typeArrayHandle anno(thread(), ikh()->class_annotations());
+ 
+   int attr_count = 0;
+-  if (generic_signature() != NULL) {
++  if (generic_signature != NULL) {
+     ++attr_count;
+   }
+   if (ikh()->source_file_name() != NULL) {
+@@ -483,8 +483,8 @@
+ 
+   write_u2(attr_count);
+ 
+-  if (generic_signature() != NULL) {
+-    write_signature_attribute(symbol_to_cpool_index(generic_signature()));
++  if (generic_signature != NULL) {
++    write_signature_attribute(symbol_to_cpool_index(generic_signature));
+   }
+   if (ikh()->source_file_name() != NULL) {
+     write_source_file_attribute();
+@@ -609,8 +609,7 @@
+ }
+ 
+ void JvmtiClassFileReconstituter::write_attribute_name_index(const char* name) {
+-  unsigned int hash_ignored;
+-  symbolOop sym = SymbolTable::lookup_only(name, (int)strlen(name), hash_ignored);
++  TempNewSymbol sym = SymbolTable::probe(name, (int)strlen(name));
+   assert(sym != NULL, "attribute name symbol not found");
+   u2 attr_name_index = symbol_to_cpool_index(sym);
+   assert(attr_name_index != 0, "attribute name symbol not in constant pool");
+diff --git a/src/share/vm/prims/jvmtiClassFileReconstituter.hpp b/src/share/vm/prims/jvmtiClassFileReconstituter.hpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.hpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.hpp
+@@ -41,11 +41,11 @@
+   instanceKlassHandle  ikh()     { return _ikh; };
+   constantPoolHandle   cpool()   { return _cpool; };
+ 
+-  u2 symbol_to_cpool_index(symbolOop sym) {
++  u2 symbol_to_cpool_index(Symbol* sym) {
+     return _symmap->symbol_to_value(sym);
+   }
+ 
+-  u2 class_symbol_to_cpool_index(symbolOop sym) {
++  u2 class_symbol_to_cpool_index(Symbol* sym) {
+     return _classmap->symbol_to_value(sym);
+   }
+ 
+diff --git a/src/share/vm/prims/jvmtiEnv.cpp b/src/share/vm/prims/jvmtiEnv.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiEnv.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiEnv.cpp
+@@ -541,12 +541,12 @@
+       JavaCalls::call_special(&res,
+                               loader,
+                               loader_ik,
+-                              vmSymbolHandles::appendToClassPathForInstrumentation_name(),
+-                              vmSymbolHandles::appendToClassPathForInstrumentation_signature(),
++                              vmSymbols::appendToClassPathForInstrumentation_name(),
++                              vmSymbols::appendToClassPathForInstrumentation_signature(),
+                               path,
+                               THREAD);
+       if (HAS_PENDING_EXCEPTION) {
+-        symbolOop ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
++        Symbol* ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
+         CLEAR_PENDING_EXCEPTION;
+ 
+         if (ex_name == vmSymbols::java_lang_NoSuchMethodError()) {
+@@ -2124,7 +2124,7 @@
+   if (generic_ptr != NULL) {
+     *generic_ptr = NULL;
+     if (!isPrimitive && Klass::cast(k)->oop_is_instance()) {
+-      symbolOop soo = instanceKlass::cast(k)->generic_signature();
++      Symbol* soo = instanceKlass::cast(k)->generic_signature();
+       if (soo != NULL) {
+         const char *gen_sig = soo->as_C_string();
+         if (gen_sig != NULL) {
+@@ -2176,7 +2176,7 @@
+     return JVMTI_ERROR_ABSENT_INFORMATION;
+   }
+ 
+-  symbolOop sfnOop = instanceKlass::cast(k_klass)->source_file_name();
++  Symbol* sfnOop = instanceKlass::cast(k_klass)->source_file_name();
+   NULL_CHECK(sfnOop, JVMTI_ERROR_ABSENT_INFORMATION);
+   {
+     JavaThread* current_thread  = JavaThread::current();
+@@ -2539,7 +2539,7 @@
+     if (!Klass::cast(k)->oop_is_instance()) {
+       return JVMTI_ERROR_ABSENT_INFORMATION;
+     }
+-    symbolOop sdeOop = instanceKlass::cast(k)->source_debug_extension();
++    Symbol* sdeOop = instanceKlass::cast(k)->source_debug_extension();
+     NULL_CHECK(sdeOop, JVMTI_ERROR_ABSENT_INFORMATION);
+ 
+     {
+@@ -2619,7 +2619,7 @@
+   }
+   if (generic_ptr != NULL) {
+     *generic_ptr = NULL;
+-    symbolOop soop = fdesc_ptr->generic_signature();
++    Symbol* soop = fdesc_ptr->generic_signature();
+     if (soop != NULL) {
+       const char* gen_sig = soop->as_C_string();
+       if (gen_sig != NULL) {
+@@ -2695,7 +2695,7 @@
+ 
+   if (generic_ptr != NULL) {
+     *generic_ptr = NULL;
+-    symbolOop soop = method_oop->generic_signature();
++    Symbol* soop = method_oop->generic_signature();
+     if (soop != NULL) {
+       const char* gen_sig = soop->as_C_string();
+       if (gen_sig != NULL) {
+diff --git a/src/share/vm/prims/jvmtiEnvBase.cpp b/src/share/vm/prims/jvmtiEnvBase.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
+@@ -1353,7 +1353,7 @@
+   }
+ 
+   // Get information about method return type
+-  symbolHandle signature(current_thread, jvf->method()->signature());
++  Symbol* signature = jvf->method()->signature();
+ 
+   ResultTypeFinder rtf(signature);
+   TosState fr_tos = as_TosState(rtf.type());
+diff --git a/src/share/vm/prims/jvmtiExport.cpp b/src/share/vm/prims/jvmtiExport.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiExport.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiExport.cpp
+@@ -268,9 +268,9 @@
+   jclass  _class_being_redefined;
+ 
+ public:
+-  JvmtiClassFileLoadEventMark(JavaThread *thread, symbolHandle name,
++  JvmtiClassFileLoadEventMark(JavaThread *thread, Symbol* name,
+      Handle class_loader, Handle prot_domain, KlassHandle *class_being_redefined) : JvmtiThreadEventMark(thread) {
+-      _class_name = name() != NULL? name->as_utf8() : NULL;
++      _class_name = name != NULL? name->as_utf8() : NULL;
+       _jloader = (jobject)to_jobject(class_loader());
+       _protection_domain = (jobject)to_jobject(prot_domain());
+       if (class_being_redefined == NULL) {
+@@ -506,7 +506,7 @@
+ 
+ class JvmtiClassFileLoadHookPoster : public StackObj {
+  private:
+-  symbolHandle         _h_name;
++  Symbol*            _h_name;
+   Handle               _class_loader;
+   Handle               _h_protection_domain;
+   unsigned char **     _data_ptr;
+@@ -522,7 +522,7 @@
+   JvmtiClassLoadKind   _load_kind;
+ 
+  public:
+-  inline JvmtiClassFileLoadHookPoster(symbolHandle h_name, Handle class_loader,
++  inline JvmtiClassFileLoadHookPoster(Symbol* h_name, Handle class_loader,
+                                       Handle h_protection_domain,
+                                       unsigned char **data_ptr, unsigned char **end_ptr,
+                                       unsigned char **cached_data_ptr,
+@@ -597,7 +597,7 @@
+ //    EVT_TRACE(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK,
+ //     ("JVMTI [%s] class file load hook event sent %s  data_ptr = %d, data_len = %d",
+ //               JvmtiTrace::safe_get_thread_name(_thread),
+-//               _h_name.is_null() ? "NULL" : _h_name->as_utf8(),
++//               _h_name == NULL ? "NULL" : _h_name->as_utf8(),
+ //               _curr_data, _curr_len ));
+     JvmtiClassFileLoadEventMark jem(_thread, _h_name, _class_loader,
+                                     _h_protection_domain,
+@@ -655,7 +655,7 @@
+ bool JvmtiExport::_should_post_class_file_load_hook = false;
+ 
+ // this entry is for class file load hook on class load, redefine and retransform
+-void JvmtiExport::post_class_file_load_hook(symbolHandle h_name,
++void JvmtiExport::post_class_file_load_hook(Symbol* h_name,
+                                             Handle class_loader,
+                                             Handle h_protection_domain,
+                                             unsigned char **data_ptr,
+diff --git a/src/share/vm/prims/jvmtiExport.hpp b/src/share/vm/prims/jvmtiExport.hpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiExport.hpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiExport.hpp
+@@ -306,7 +306,7 @@
+   static bool _should_post_class_file_load_hook;
+   inline static void set_should_post_class_file_load_hook(bool on)     { _should_post_class_file_load_hook = on;  }
+   inline static bool should_post_class_file_load_hook()           { return _should_post_class_file_load_hook; }
+-  static void post_class_file_load_hook(symbolHandle h_name, Handle class_loader,
++  static void post_class_file_load_hook(Symbol* h_name, Handle class_loader,
+                                         Handle h_protection_domain,
+                                         unsigned char **data_ptr, unsigned char **end_ptr,
+                                         unsigned char **cached_data_ptr,
+diff --git a/src/share/vm/prims/jvmtiImpl.cpp b/src/share/vm/prims/jvmtiImpl.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiImpl.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiImpl.cpp
+@@ -285,8 +285,8 @@
+   // not saved in the PreviousVersionInfo.
+   Thread *thread = Thread::current();
+   instanceKlassHandle ikh = instanceKlassHandle(thread, _method->method_holder());
+-  symbolOop m_name = _method->name();
+-  symbolOop m_signature = _method->signature();
++  Symbol* m_name = _method->name();
++  Symbol* m_signature = _method->signature();
+ 
+   {
+     ResourceMark rm(thread);
+@@ -628,22 +628,22 @@
+     ty_sign++;
+     len -= 2;
+   }
+-  symbolHandle ty_sym = oopFactory::new_symbol_handle(ty_sign, len, thread);
+-  if (klass->name() == ty_sym()) {
++  TempNewSymbol ty_sym = SymbolTable::new_symbol(ty_sign, len, thread);
++  if (klass->name() == ty_sym) {
+     return true;
+   }
+   // Compare primary supers
+   int super_depth = klass->super_depth();
+   int idx;
+   for (idx = 0; idx < super_depth; idx++) {
+-    if (Klass::cast(klass->primary_super_of_depth(idx))->name() == ty_sym()) {
++    if (Klass::cast(klass->primary_super_of_depth(idx))->name() == ty_sym) {
+       return true;
+     }
+   }
+   // Compare secondary supers
+   objArrayOop sec_supers = klass->secondary_supers();
+   for (idx = 0; idx < sec_supers->length(); idx++) {
+-    if (Klass::cast((klassOop) sec_supers->obj_at(idx))->name() == ty_sym()) {
++    if (Klass::cast((klassOop) sec_supers->obj_at(idx))->name() == ty_sym) {
+       return true;
+     }
+   }
+@@ -690,7 +690,7 @@
+     _result = JVMTI_ERROR_INVALID_SLOT;
+     return false;       // Incorrect slot index
+   }
+-  symbolOop   sign_sym  = method_oop->constants()->symbol_at(signature_idx);
++  Symbol*   sign_sym  = method_oop->constants()->symbol_at(signature_idx);
+   const char* signature = (const char *) sign_sym->as_utf8();
+   BasicType slot_type = char2type(signature[0]);
+ 
+diff --git a/src/share/vm/prims/jvmtiRedefineClasses.cpp b/src/share/vm/prims/jvmtiRedefineClasses.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
+@@ -235,7 +235,7 @@
+     case JVM_CONSTANT_String:      // fall through
+ 
+     // These were indirect CP entries, but they have been changed into
+-    // symbolOops so these entries can be directly appended.
++    // Symbol*s so these entries can be directly appended.
+     case JVM_CONSTANT_UnresolvedClass:  // fall through
+     case JVM_CONSTANT_UnresolvedString:
+     {
+@@ -575,12 +575,12 @@
+     // name and signature
+     jshort name_index = k_old_fields->short_at(i + instanceKlass::name_index_offset);
+     jshort sig_index = k_old_fields->short_at(i +instanceKlass::signature_index_offset);
+-    symbolOop name_sym1 = the_class->constants()->symbol_at(name_index);
+-    symbolOop sig_sym1 = the_class->constants()->symbol_at(sig_index);
++    Symbol* name_sym1 = the_class->constants()->symbol_at(name_index);
++    Symbol* sig_sym1 = the_class->constants()->symbol_at(sig_index);
+     name_index = k_new_fields->short_at(i + instanceKlass::name_index_offset);
+     sig_index = k_new_fields->short_at(i + instanceKlass::signature_index_offset);
+-    symbolOop name_sym2 = scratch_class->constants()->symbol_at(name_index);
+-    symbolOop sig_sym2 = scratch_class->constants()->symbol_at(sig_index);
++    Symbol* name_sym2 = scratch_class->constants()->symbol_at(name_index);
++    Symbol* sig_sym2 = scratch_class->constants()->symbol_at(sig_index);
+     if (name_sym1 != name_sym2 || sig_sym1 != sig_sym2) {
+       return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
+     }
+@@ -855,7 +855,7 @@
+     }
+     klassOop the_class_oop = java_lang_Class::as_klassOop(mirror);
+     instanceKlassHandle the_class = instanceKlassHandle(THREAD, the_class_oop);
+-    symbolHandle the_class_sym = symbolHandle(THREAD, the_class->name());
++    Symbol*  the_class_sym = the_class->name();
+ 
+     // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
+     RC_TRACE_WITH_THREAD(0x00000001, THREAD,
+@@ -886,7 +886,7 @@
+     instanceKlassHandle scratch_class (THREAD, k);
+ 
+     if (HAS_PENDING_EXCEPTION) {
+-      symbolOop ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
++      Symbol* ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
+       // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
+       RC_TRACE_WITH_THREAD(0x00000002, THREAD, ("parse_stream exception: '%s'",
+         ex_name->as_C_string()));
+@@ -912,7 +912,7 @@
+     if (!the_class->is_linked()) {
+       the_class->link_class(THREAD);
+       if (HAS_PENDING_EXCEPTION) {
+-        symbolOop ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
++        Symbol* ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
+         // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
+         RC_TRACE_WITH_THREAD(0x00000002, THREAD, ("link_class exception: '%s'",
+           ex_name->as_C_string()));
+@@ -950,7 +950,7 @@
+     }
+ 
+     if (HAS_PENDING_EXCEPTION) {
+-      symbolOop ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
++      Symbol* ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
+       // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
+       RC_TRACE_WITH_THREAD(0x00000002, THREAD,
+         ("verify_byte_codes exception: '%s'", ex_name->as_C_string()));
+@@ -976,7 +976,7 @@
+       }
+ 
+       if (HAS_PENDING_EXCEPTION) {
+-        symbolOop ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
++        Symbol* ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
+         // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark
+         RC_TRACE_WITH_THREAD(0x00000002, THREAD,
+           ("verify_byte_codes post merge-CP exception: '%s'",
+@@ -993,7 +993,7 @@
+ 
+     Rewriter::rewrite(scratch_class, THREAD);
+     if (HAS_PENDING_EXCEPTION) {
+-      symbolOop ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
++      Symbol* ex_name = PENDING_EXCEPTION->klass()->klass_part()->name();
+       CLEAR_PENDING_EXCEPTION;
+       if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) {
+         return JVMTI_ERROR_OUT_OF_MEMORY;
+@@ -2857,8 +2857,8 @@
+   //    (2) with the prefix.
+   // where 'prefix' is the prefix at that 'depth' (first prefix, second prefix,...)
+   methodOop search_prefix_name_space(int depth, char* name_str, size_t name_len,
+-                                     symbolOop signature) {
+-    symbolOop name_symbol = SymbolTable::probe(name_str, (int)name_len);
++                                     Symbol* signature) {
++    TempNewSymbol name_symbol = SymbolTable::probe(name_str, (int)name_len);
+     if (name_symbol != NULL) {
+       methodOop method = Klass::cast(the_class())->lookup_method(name_symbol, signature);
+       if (method != NULL) {
+@@ -2897,7 +2897,7 @@
+ 
+   // Return the method name with old prefixes stripped away.
+   char* method_name_without_prefixes(methodOop method) {
+-    symbolOop name = method->name();
++    Symbol* name = method->name();
+     char* name_str = name->as_utf8();
+ 
+     // Old prefixing may be defunct, strip prefixes, if any.
+diff --git a/src/share/vm/prims/jvmtiRedefineClasses.hpp b/src/share/vm/prims/jvmtiRedefineClasses.hpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp
+@@ -223,8 +223,8 @@
+ // JVM_CONSTANT_UnresolvedClass and JVM_CONSTANT_UnresolvedString
+ // entries. During this conversion process, the UTF8 values that are
+ // indirectly referenced by the JVM_CONSTANT_ClassIndex and
+-// JVM_CONSTANT_StringIndex entries are changed into symbolOops and the
+-// entries are modified to refer to the symbolOops. This optimization
++// JVM_CONSTANT_StringIndex entries are changed into Symbol*s and the
++// entries are modified to refer to the Symbol*s. This optimization
+ // eliminates one level of indirection for those two CP entry types and
+ // gets the entries ready for verification. During class file parsing
+ // it is also possible for JVM_CONSTANT_UnresolvedString entries to be
+diff --git a/src/share/vm/prims/jvmtiTagMap.cpp b/src/share/vm/prims/jvmtiTagMap.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
+@@ -2611,7 +2611,7 @@
+     }
+ 
+     // some objects are ignored - in the case of simple
+-    // roots it's mostly symbolOops that we are skipping
++    // roots it's mostly Symbol*s that we are skipping
+     // here.
+     if (!ServiceUtil::visible_oop(o)) {
+       return;
+diff --git a/src/share/vm/prims/methodComparator.cpp b/src/share/vm/prims/methodComparator.cpp
+--- openjdk/hotspot/src/share/vm/prims/methodComparator.cpp
++++ openjdk/hotspot/src/share/vm/prims/methodComparator.cpp
+@@ -24,7 +24,7 @@
+ 
+ #include "precompiled.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "prims/jvmtiRedefineClassesTrace.hpp"
+ #include "prims/methodComparator.hpp"
+ #include "runtime/handles.inline.hpp"
+diff --git a/src/share/vm/prims/methodHandleWalk.cpp b/src/share/vm/prims/methodHandleWalk.cpp
+--- openjdk/hotspot/src/share/vm/prims/methodHandleWalk.cpp
++++ openjdk/hotspot/src/share/vm/prims/methodHandleWalk.cpp
+@@ -120,6 +120,7 @@
+       if (cur_slot == arg_slot)
+         return T_OBJECT;
+     }
++    ResourceMark rm(THREAD);
+     for (SignatureStream ss(m->signature()); !ss.is_done(); ss.next()) {
+       BasicType bt = ss.type();
+       cur_slot -= type2size[bt];
+@@ -961,9 +962,9 @@
+     m = vmIntrinsics::method_for(iid);
+   }
+ 
+-  klassOop  klass     = m->method_holder();
+-  symbolOop name      = m->name();
+-  symbolOop signature = m->signature();
++  klassOop  klass   = m->method_holder();
++  Symbol* name      = m->name();
++  Symbol* signature = m->signature();
+ 
+   if (tailcall) {
+     // Actually, in order to make these methods more recognizable,
+@@ -1141,7 +1142,7 @@
+   for (int i = 1; i < _constants.length(); i++) {
+     ConstantValue* cv = _constants.at(i);
+     switch (cv->tag()) {
+-    case JVM_CONSTANT_Utf8:        cpool->symbol_at_put(       i, cv->symbol_oop()                     ); break;
++    case JVM_CONSTANT_Utf8:        cpool->symbol_at_put(       i, cv->symbol()                         ); break;
+     case JVM_CONSTANT_Integer:     cpool->int_at_put(          i, cv->get_jint()                       ); break;
+     case JVM_CONSTANT_Float:       cpool->float_at_put(        i, cv->get_jfloat()                     ); break;
+     case JVM_CONSTANT_Long:        cpool->long_at_put(         i, cv->get_jlong()                      ); break;
+@@ -1331,7 +1332,7 @@
+   virtual ArgToken make_invoke(methodOop m, vmIntrinsics::ID iid,
+                                Bytecodes::Code op, bool tailcall,
+                                int argc, ArgToken* argv, TRAPS) {
+-    symbolOop name, sig;
++    Symbol* name, sig;
+     if (m != NULL) {
+       name = m->name();
+       sig  = m->signature();
+diff --git a/src/share/vm/prims/methodHandleWalk.hpp b/src/share/vm/prims/methodHandleWalk.hpp
+--- openjdk/hotspot/src/share/vm/prims/methodHandleWalk.hpp
++++ openjdk/hotspot/src/share/vm/prims/methodHandleWalk.hpp
+@@ -258,16 +258,20 @@
+     int       _tag;   // Constant pool tag type.
+     JavaValue _value;
+     Handle    _handle;
++    Symbol*   _sym;
+ 
+   public:
+     // Constructor for oop types.
+     ConstantValue(int tag, Handle con) : _tag(tag), _handle(con) {
+-      assert(tag == JVM_CONSTANT_Utf8   ||
+-             tag == JVM_CONSTANT_Class  ||
++      assert(tag == JVM_CONSTANT_Class  ||
+              tag == JVM_CONSTANT_String ||
+              tag == JVM_CONSTANT_Object, "must be oop type");
+     }
+ 
++    ConstantValue(int tag, Symbol* con) : _tag(tag), _sym(con) {
++      assert(tag == JVM_CONSTANT_Utf8, "must be symbol type");
++    }
++
+     // Constructor for oop reference types.
+     ConstantValue(int tag, int index) : _tag(tag) {
+       assert(JVM_CONSTANT_Fieldref <= tag && tag <= JVM_CONSTANT_NameAndType, "must be ref type");
+@@ -291,7 +295,7 @@
+     }
+ 
+     int       tag()          const { return _tag; }
+-    symbolOop symbol_oop()   const { return (symbolOop) _handle(); }
++    Symbol*   symbol()       const { return _sym; }
+     klassOop  klass_oop()    const { return (klassOop)  _handle(); }
+     oop       object_oop()   const { return _handle(); }
+     int       index()        const { return _value.get_jint(); }
+@@ -336,6 +340,12 @@
+     return _constants.append(cv);
+   }
+ 
++  int cpool_symbol_put(int tag, Symbol* con) {
++    if (con == NULL)  return 0;
++    ConstantValue* cv = new ConstantValue(tag, con);
++    return _constants.append(cv);
++  }
++
+   int cpool_oop_reference_put(int tag, int first_index, int second_index) {
+     if (first_index == 0 && second_index == 0)  return 0;
+     assert(first_index != 0 && second_index != 0, "no zero indexes");
+@@ -365,8 +375,8 @@
+   int cpool_object_put(Handle obj) {
+     return cpool_oop_put(JVM_CONSTANT_Object, obj);
+   }
+-  int cpool_symbol_put(symbolOop sym) {
+-    return cpool_oop_put(JVM_CONSTANT_Utf8, sym);
++  int cpool_symbol_put(Symbol* sym) {
++    return cpool_symbol_put(JVM_CONSTANT_Utf8, sym);
+   }
+   int cpool_klass_put(klassOop klass) {
+     return cpool_oop_put(JVM_CONSTANT_Class, klass);
+diff --git a/src/share/vm/prims/methodHandles.cpp b/src/share/vm/prims/methodHandles.cpp
+--- openjdk/hotspot/src/share/vm/prims/methodHandles.cpp
++++ openjdk/hotspot/src/share/vm/prims/methodHandles.cpp
+@@ -278,7 +278,7 @@
+   assert(m->is_method(), "");
+   if (m->is_static()) {
+     // check that signature begins '(L' or '([' (not '(I', '()', etc.)
+-    symbolOop sig = m->signature();
++    Symbol* sig = m->signature();
+     BasicType recv_bt = char2type(sig->byte_at(1));
+     // Note: recv_bt might be T_ILLEGAL if byte_at(2) is ')'
+     assert(sig->byte_at(0) == '(', "must be method sig");
+@@ -438,6 +438,25 @@
+   return m;
+ }
+ 
++// convert the external string or reflective type to an internal signature
++Symbol* MethodHandles::convert_to_signature(oop type_str,
++                                            bool polymorphic,
++                                            TRAPS) {
++  if (java_dyn_MethodType::is_instance(type_str)) {
++    return java_dyn_MethodType::as_signature(type_str, polymorphic, CHECK_NULL);
++  } else if (java_lang_Class::is_instance(type_str)) {
++    return java_lang_Class::as_signature(type_str, false, CHECK_NULL);
++  } else if (java_lang_String::is_instance(type_str)) {
++    if (polymorphic) {
++      return java_lang_String::as_symbol(type_str, CHECK_NULL);
++    } else {
++      return java_lang_String::as_symbol_or_null(type_str);
++    }
++  } else {
++    THROW_MSG_(vmSymbols::java_lang_InternalError(), "unrecognized type", NULL);
++  }
++}
++
+ // An unresolved member name is a mere symbolic reference.
+ // Resolving it plants a vmtarget/vmindex in it,
+ // which refers dirctly to JVM internals.
+@@ -478,39 +497,24 @@
+   defc->link_class(CHECK);
+ 
+   // convert the external string name to an internal symbol
+-  symbolHandle name(THREAD, java_lang_String::as_symbol_or_null(name_str));
+-  if (name.is_null())  return;  // no such name
++  TempNewSymbol name = java_lang_String::as_symbol_or_null(name_str);
++  if (name == NULL)  return;  // no such name
+   name_str = NULL;  // safety
+ 
+   Handle polymorphic_method_type;
+   bool polymorphic_signature = false;
+   if ((flags & ALL_KINDS) == IS_METHOD &&
+       (defc() == SystemDictionary::MethodHandle_klass() &&
+-       methodOopDesc::is_method_handle_invoke_name(name())))
++       methodOopDesc::is_method_handle_invoke_name(name)))
+     polymorphic_signature = true;
+ 
+   // convert the external string or reflective type to an internal signature
+-  symbolHandle type; {
+-    symbolOop type_sym = NULL;
+-    if (java_dyn_MethodType::is_instance(type_str)) {
+-      type_sym = java_dyn_MethodType::as_signature(type_str, polymorphic_signature, CHECK);
+-      if (polymorphic_signature)
+-        polymorphic_method_type = Handle(THREAD, type_str);  //preserve exactly
+-    } else if (java_lang_Class::is_instance(type_str)) {
+-      type_sym = java_lang_Class::as_signature(type_str, false, CHECK);
+-    } else if (java_lang_String::is_instance(type_str)) {
+-      if (polymorphic_signature) {
+-        type     = java_lang_String::as_symbol(type_str, CHECK);
+-      } else {
+-        type_sym = java_lang_String::as_symbol_or_null(type_str);
+-      }
+-    } else {
+-      THROW_MSG(vmSymbols::java_lang_InternalError(), "unrecognized type");
+-    }
+-    if (type_sym != NULL)
+-      type = symbolHandle(THREAD, type_sym);
++  TempNewSymbol type = convert_to_signature(type_str, polymorphic_signature, CHECK);
++  if (java_dyn_MethodType::is_instance(type_str) && polymorphic_signature) {
++    polymorphic_method_type = Handle(THREAD, type_str);  //preserve exactly
+   }
+-  if (type.is_null())  return;  // no such signature exists in the VM
++
++  if (type == NULL)  return;  // no such signature exists in the VM
+   type_str = NULL; // safety
+ 
+   // Time to do the lookup.
+@@ -566,7 +570,7 @@
+       CallInfo result;
+       {
+         EXCEPTION_MARK;
+-        if (name() == vmSymbols::object_initializer_name()) {
++        if (name == vmSymbols::object_initializer_name()) {
+           LinkResolver::resolve_special_call(result,
+                         defc, name, type, KlassHandle(), false, THREAD);
+         } else {
+@@ -594,7 +598,7 @@
+     {
+       // This is taken from LinkResolver::resolve_field, sans access checks.
+       fieldDescriptor fd; // find_field initializes fd if found
+-      KlassHandle sel_klass(THREAD, instanceKlass::cast(defc())->find_field(name(), type(), &fd));
++      KlassHandle sel_klass(THREAD, instanceKlass::cast(defc())->find_field(name, type, &fd));
+       // check if field exists; i.e., if a klass containing the field def has been selected
+       if (sel_klass.is_null())  return;
+       oop vmtarget = sel_klass->as_klassOop();
+@@ -725,7 +729,7 @@
+ }
+ 
+ int MethodHandles::find_MemberNames(klassOop k,
+-                                    symbolOop name, symbolOop sig,
++                                    Symbol* name, Symbol* sig,
+                                     int mflags, klassOop caller,
+                                     int skip, objArrayOop results) {
+   DEBUG_ONLY(No_Safepoint_Verifier nsv);
+@@ -782,8 +786,8 @@
+ 
+   if ((match_flags & (IS_METHOD | IS_CONSTRUCTOR)) != 0) {
+     // watch out for these guys:
+-    symbolOop init_name   = vmSymbols::object_initializer_name();
+-    symbolOop clinit_name = vmSymbols::class_initializer_name();
++    Symbol* init_name   = vmSymbols::object_initializer_name();
++    Symbol* clinit_name = vmSymbols::class_initializer_name();
+     if (name == clinit_name)  clinit_name = NULL; // hack for exposing <clinit>
+     bool negate_name_test = false;
+     // fix name so that it captures the intention of IS_CONSTRUCTOR
+@@ -807,7 +811,7 @@
+     }
+     for (MethodStream st(k, local_only, !search_intfc); !st.eos(); st.next()) {
+       methodOop m = st.method();
+-      symbolOop m_name = m->name();
++      Symbol* m_name = m->name();
+       if (m_name == clinit_name)
+         continue;
+       if (name != NULL && ((m_name != name) ^ negate_name_test))
+@@ -928,7 +932,7 @@
+   // Must be on the boot class path:
+   if (ik->class_loader() != NULL)  return false;
+   // Check the name.
+-  symbolOop name = ik->name();
++  Symbol* name = ik->name();
+   for (int i = 0; ; i++) {
+     const char* test_name = always_null_names[i];
+     if (test_name == NULL)  break;
+@@ -1026,6 +1030,7 @@
+   int pmax = ptypes->length();
+   int mnum = 0;                 // method argument
+   const char* err = NULL;
++  ResourceMark rm(THREAD);
+   for (SignatureStream ss(m->signature()); !ss.is_done(); ss.next()) {
+     oop ptype_oop = NULL;
+     if (ss.at_return_type()) {
+@@ -1061,15 +1066,14 @@
+       }
+       KlassHandle pklass_handle(THREAD, pklass); pklass = NULL;
+       // If we fail to resolve types at this point, we will throw an error.
+-      symbolOop    name_oop = ss.as_symbol(CHECK);
+-      symbolHandle name(THREAD, name_oop);
++      Symbol* name = ss.as_symbol(CHECK);
+       instanceKlass* mk = instanceKlass::cast(m->method_holder());
+       Handle loader(THREAD, mk->class_loader());
+       Handle domain(THREAD, mk->protection_domain());
+       mklass = SystemDictionary::resolve_or_null(name, loader, domain, CHECK);
+       pklass = pklass_handle();
+       if (mklass == NULL && pklass != NULL &&
+-          Klass::cast(pklass)->name() == name() &&
++          Klass::cast(pklass)->name() == name &&
+           m->is_method_handle_invoke()) {
+         // Assume a match.  We can't really decode the signature of MH.invoke*.
+         continue;
+@@ -2288,7 +2292,8 @@
+     tty->print("creating MethodType form ");
+     if (WizardMode || Verbose) {   // Warning: this calls Java code on the MH!
+       // call Object.toString()
+-      symbolOop name = vmSymbols::toString_name(), sig = vmSymbols::void_string_signature();
++      Symbol* name = vmSymbols::toString_name();
++      Symbol* sig = vmSymbols::void_string_signature();
+       JavaCallArguments args(Handle(THREAD, JNIHandles::resolve_non_null(erased_jh)));
+       JavaValue result(T_OBJECT);
+       JavaCalls::call_virtual(&result, SystemDictionary::Object_klass(), name, sig,
+@@ -2452,7 +2457,8 @@
+   objArrayOop results = (objArrayOop) JNIHandles::resolve(results_jh);
+   if (results == NULL || !results->is_objArray())       return -1;
+ 
+-  symbolOop name = NULL, sig = NULL;
++  TempNewSymbol name = NULL;
++  TempNewSymbol sig = NULL;
+   if (name_jh != NULL) {
+     name = java_lang_String::as_symbol_or_null(JNIHandles::resolve_non_null(name_jh));
+     if (name == NULL)  return 0; // a match is not possible
+@@ -2611,10 +2617,10 @@
+   if (enable_MH) {
+     KlassHandle MHI_klass = SystemDictionaryHandles::MethodHandleImpl_klass();
+     if (MHI_klass.not_null()) {
+-      symbolHandle raiseException_name = oopFactory::new_symbol_handle("raiseException", CHECK);
+-      symbolHandle raiseException_sig  = oopFactory::new_symbol_handle("(ILjava/lang/Object;Ljava/lang/Object;)V", CHECK);
++      TempNewSymbol raiseException_name = SymbolTable::new_symbol("raiseException", CHECK);
++      TempNewSymbol raiseException_sig = SymbolTable::new_symbol("(ILjava/lang/Object;Ljava/lang/Object;)V", CHECK);
+       methodOop raiseException_method  = instanceKlass::cast(MHI_klass->as_klassOop())
+-                    ->find_method(raiseException_name(), raiseException_sig());
++                    ->find_method(raiseException_name, raiseException_sig);
+       if (raiseException_method != NULL && raiseException_method->is_static()) {
+         MethodHandles::set_raise_exception_method(raiseException_method);
+       } else {
+diff --git a/src/share/vm/prims/methodHandles.hpp b/src/share/vm/prims/methodHandles.hpp
+--- openjdk/hotspot/src/share/vm/prims/methodHandles.hpp
++++ openjdk/hotspot/src/share/vm/prims/methodHandles.hpp
+@@ -287,7 +287,7 @@
+   static void init_MemberName(oop mname_oop, oop target); // compute vmtarget/vmindex from target
+   static void init_MemberName(oop mname_oop, methodOop m, bool do_dispatch = true);
+   static void init_MemberName(oop mname_oop, klassOop field_holder, AccessFlags mods, int offset);
+-  static int find_MemberNames(klassOop k, symbolOop name, symbolOop sig,
++  static int find_MemberNames(klassOop k, Symbol* name, Symbol* sig,
+                               int mflags, klassOop caller,
+                               int skip, objArrayOop results);
+   // bit values for suppress argument to expand_MemberName:
+@@ -466,6 +466,8 @@
+                                Register temp_reg, Register temp2_reg, Register temp3_reg = noreg);
+ 
+   static void trace_method_handle(MacroAssembler* _masm, const char* adaptername) PRODUCT_RETURN;
++
++  static Symbol* convert_to_signature(oop type_str, bool polymorphic, TRAPS);
+ };
+ 
+ 
+diff --git a/src/share/vm/prims/nativeLookup.cpp b/src/share/vm/prims/nativeLookup.cpp
+--- openjdk/hotspot/src/share/vm/prims/nativeLookup.cpp
++++ openjdk/hotspot/src/share/vm/prims/nativeLookup.cpp
+@@ -32,7 +32,7 @@
+ #include "oops/instanceKlass.hpp"
+ #include "oops/methodOop.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "prims/jvm_misc.hpp"
+ #include "prims/nativeLookup.hpp"
+ #include "runtime/arguments.hpp"
+@@ -51,7 +51,7 @@
+ #endif
+ 
+ 
+-static void mangle_name_on(outputStream* st, symbolOop name, int begin, int end) {
++static void mangle_name_on(outputStream* st, Symbol* name, int begin, int end) {
+   char* bytes = (char*)name->bytes() + begin;
+   char* end_bytes = (char*)name->bytes() + end;
+   while (bytes < end_bytes) {
+@@ -70,7 +70,7 @@
+ }
+ 
+ 
+-static void mangle_name_on(outputStream* st, symbolOop name) {
++static void mangle_name_on(outputStream* st, Symbol* name) {
+   mangle_name_on(st, name, 0, name->utf8_length());
+ }
+ 
+@@ -91,7 +91,7 @@
+ char* NativeLookup::long_jni_name(methodHandle method) {
+   // Signature ignore the wrapping parenteses and the trailing return type
+   stringStream st;
+-  symbolOop signature = method->signature();
++  Symbol* signature = method->signature();
+   st.print("__");
+   // find ')'
+   int end;
+@@ -168,8 +168,8 @@
+   JavaValue result(T_LONG);
+   JavaCalls::call_static(&result,
+                          klass,
+-                         vmSymbolHandles::findNative_name(),
+-                         vmSymbolHandles::classloader_string_long_signature(),
++                         vmSymbols::findNative_name(),
++                         vmSymbols::classloader_string_long_signature(),
+                          // Arguments
+                          loader,
+                          name_arg,
+@@ -249,10 +249,10 @@
+   if (wrapper_name != in_name) {
+     // we have a name for a wrapping method
+     int wrapper_name_len = (int)strlen(wrapper_name);
+-    symbolHandle wrapper_symbol(THREAD, SymbolTable::probe(wrapper_name, wrapper_name_len));
+-    if (!wrapper_symbol.is_null()) {
++    TempNewSymbol wrapper_symbol = SymbolTable::probe(wrapper_name, wrapper_name_len);
++    if (wrapper_symbol != NULL) {
+       KlassHandle kh(method->method_holder());
+-      methodOop wrapper_method = Klass::cast(kh())->lookup_method(wrapper_symbol(),
++      methodOop wrapper_method = Klass::cast(kh())->lookup_method(wrapper_symbol,
+                                                                   method->signature());
+       if (wrapper_method != NULL && !wrapper_method->is_native()) {
+         // we found a wrapper method, use its native entry
+@@ -301,9 +301,9 @@
+ address NativeLookup::base_library_lookup(const char* class_name, const char* method_name, const char* signature) {
+   EXCEPTION_MARK;
+   bool in_base_library = true;  // SharedRuntime inits some math methods.
+-  symbolHandle c_name = oopFactory::new_symbol_handle(class_name,  CATCH);
+-  symbolHandle m_name = oopFactory::new_symbol_handle(method_name, CATCH);
+-  symbolHandle s_name = oopFactory::new_symbol_handle(signature,   CATCH);
++  TempNewSymbol c_name = SymbolTable::new_symbol(class_name,  CATCH);
++  TempNewSymbol m_name = SymbolTable::new_symbol(method_name, CATCH);
++  TempNewSymbol s_name = SymbolTable::new_symbol(signature,   CATCH);
+ 
+   // Find the class
+   klassOop k = SystemDictionary::resolve_or_fail(c_name, true, CATCH);
+@@ -311,7 +311,7 @@
+ 
+   // Find method and invoke standard lookup
+   methodHandle method (THREAD,
+-                       klass->uncached_lookup_method(m_name(), s_name()));
++                       klass->uncached_lookup_method(m_name, s_name));
+   address result = lookup(method, in_base_library, CATCH);
+   assert(in_base_library, "must be in basic library");
+   guarantee(result != NULL, "must be non NULL");
+diff --git a/src/share/vm/prims/unsafe.cpp b/src/share/vm/prims/unsafe.cpp
+--- openjdk/hotspot/src/share/vm/prims/unsafe.cpp
++++ openjdk/hotspot/src/share/vm/prims/unsafe.cpp
+@@ -991,7 +991,7 @@
+ 
+   instanceKlassHandle anon_klass;
+   {
+-    symbolHandle no_class_name;
++    Symbol* no_class_name = NULL;
+     klassOop anonk = SystemDictionary::parse_stream(no_class_name,
+                                                     host_loader, host_domain,
+                                                     &st, host_klass, cp_patches,
+diff --git a/src/share/vm/runtime/deoptimization.cpp b/src/share/vm/runtime/deoptimization.cpp
+--- openjdk/hotspot/src/share/vm/runtime/deoptimization.cpp
++++ openjdk/hotspot/src/share/vm/runtime/deoptimization.cpp
+@@ -396,7 +396,7 @@
+     HandleMark hm;
+     methodHandle method(thread, array->element(0)->method());
+     Bytecode_invoke invoke = Bytecode_invoke_check(method, array->element(0)->bci());
+-    return_type = invoke.is_valid() ? invoke.result_type(thread) : T_ILLEGAL;
++    return_type = invoke.is_valid() ? invoke.result_type() : T_ILLEGAL;
+   }
+ 
+   // Compute information for handling adapters and adjusting the frame size of the caller.
+@@ -601,7 +601,7 @@
+           cur_code == Bytecodes::_invokestatic  ||
+           cur_code == Bytecodes::_invokeinterface) {
+         Bytecode_invoke invoke(mh, iframe->interpreter_frame_bci());
+-        symbolHandle signature(thread, invoke.signature());
++        Symbol* signature = invoke.signature();
+         ArgumentSizeComputer asc(signature);
+         cur_invoke_parameter_size = asc.size();
+         if (cur_code != Bytecodes::_invokestatic) {
+@@ -1156,7 +1156,7 @@
+   if (!constant_pool->tag_at(index).is_symbol()) return;
+ 
+   Handle class_loader (THREAD, instanceKlass::cast(constant_pool->pool_holder())->class_loader());
+-  symbolHandle symbol (THREAD, constant_pool->symbol_at(index));
++  Symbol*  symbol  = constant_pool->symbol_at(index);
+ 
+   // class name?
+   if (symbol->byte_at(0) != '(') {
+@@ -1166,10 +1166,10 @@
+   }
+ 
+   // then it must be a signature!
++  ResourceMark rm(THREAD);
+   for (SignatureStream ss(symbol); !ss.is_done(); ss.next()) {
+     if (ss.is_object()) {
+-      symbolOop s = ss.as_symbol(CHECK);
+-      symbolHandle class_name (THREAD, s);
++      Symbol* class_name = ss.as_symbol(CHECK);
+       Handle protection_domain (THREAD, Klass::cast(constant_pool->pool_holder())->protection_domain());
+       SystemDictionary::resolve_or_null(class_name, class_loader, protection_domain, CHECK);
+     }
+@@ -1246,19 +1246,17 @@
+                          format_trap_request(buf, sizeof(buf), trap_request));
+         nm->log_identity(xtty);
+       }
+-      symbolHandle class_name;
++      Symbol* class_name = NULL;
+       bool unresolved = false;
+       if (unloaded_class_index >= 0) {
+         constantPoolHandle constants (THREAD, trap_method->constants());
+         if (constants->tag_at(unloaded_class_index).is_unresolved_klass()) {
+-          class_name = symbolHandle(THREAD,
+-            constants->klass_name_at(unloaded_class_index));
++          class_name = constants->klass_name_at(unloaded_class_index);
+           unresolved = true;
+           if (xtty != NULL)
+             xtty->print(" unresolved='1'");
+         } else if (constants->tag_at(unloaded_class_index).is_symbol()) {
+-          class_name = symbolHandle(THREAD,
+-            constants->symbol_at(unloaded_class_index));
++          class_name = constants->symbol_at(unloaded_class_index);
+         }
+         if (xtty != NULL)
+           xtty->name(class_name);
+@@ -1294,7 +1292,7 @@
+                    trap_reason_name(reason),
+                    trap_action_name(action),
+                    unloaded_class_index);
+-        if (class_name.not_null()) {
++        if (class_name != NULL) {
+           tty->print(unresolved ? " unresolved class: " : " symbol: ");
+           class_name->print_symbol_on(tty);
+         }
+diff --git a/src/share/vm/runtime/fieldDescriptor.hpp b/src/share/vm/runtime/fieldDescriptor.hpp
+--- openjdk/hotspot/src/share/vm/runtime/fieldDescriptor.hpp
++++ openjdk/hotspot/src/share/vm/runtime/fieldDescriptor.hpp
+@@ -28,7 +28,7 @@
+ #include "oops/constantPoolOop.hpp"
+ #include "oops/klassOop.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/fieldType.hpp"
+ #include "utilities/accessFlags.hpp"
+ #include "utilities/constantTag.hpp"
+@@ -49,15 +49,15 @@
+   constantPoolHandle  _cp;
+ 
+  public:
+-  symbolOop name() const               { return _cp->symbol_at(_name_index); }
+-  symbolOop signature() const          { return _cp->symbol_at(_signature_index); }
++  Symbol* name() const                 { return _cp->symbol_at(_name_index); }
++  Symbol* signature() const            { return _cp->symbol_at(_signature_index); }
+   klassOop field_holder() const        { return _cp->pool_holder(); }
+   constantPoolOop constants() const    { return _cp(); }
+   AccessFlags access_flags() const     { return _access_flags; }
+   oop loader() const;
+   // Offset (in words) of field from start of instanceOop / klassOop
+   int offset() const                   { return _offset; }
+-  symbolOop generic_signature() const  { return (_generic_signature_index > 0 ? _cp->symbol_at(_generic_signature_index) : (symbolOop)NULL); }
++  Symbol* generic_signature() const    { return (_generic_signature_index > 0 ? _cp->symbol_at(_generic_signature_index) : (Symbol*)NULL); }
+   int index() const                    { return _index; }
+   typeArrayOop annotations() const;
+ 
+diff --git a/src/share/vm/runtime/fieldType.cpp b/src/share/vm/runtime/fieldType.cpp
+--- openjdk/hotspot/src/share/vm/runtime/fieldType.cpp
++++ openjdk/hotspot/src/share/vm/runtime/fieldType.cpp
+@@ -30,7 +30,7 @@
+ #include "runtime/fieldType.hpp"
+ #include "runtime/signature.hpp"
+ 
+-void FieldType::skip_optional_size(symbolOop signature, int* index) {
++void FieldType::skip_optional_size(Symbol* signature, int* index) {
+   jchar c = signature->byte_at(*index);
+   while (c >= '0' && c <= '9') {
+     *index = *index + 1;
+@@ -38,12 +38,12 @@
+   }
+ }
+ 
+-BasicType FieldType::basic_type(symbolOop signature) {
++BasicType FieldType::basic_type(Symbol* signature) {
+   return char2type(signature->byte_at(0));
+ }
+ 
+ // Check if it is a valid array signature
+-bool FieldType::is_valid_array_signature(symbolOop sig) {
++bool FieldType::is_valid_array_signature(Symbol* sig) {
+   assert(sig->utf8_length() > 1, "this should already have been checked");
+   assert(sig->byte_at(0) == '[', "this should already have been checked");
+   // The first character is already checked
+@@ -73,7 +73,7 @@
+ }
+ 
+ 
+-BasicType FieldType::get_array_info(symbolOop signature, jint* dimension, symbolOop* object_key, TRAPS) {
++BasicType FieldType::get_array_info(Symbol* signature, FieldArrayInfo& fd, TRAPS) {
+   assert(basic_type(signature) == T_ARRAY, "must be array");
+   int index = 1;
+   int dim   = 1;
+@@ -84,14 +84,15 @@
+     skip_optional_size(signature, &index);
+   }
+   ResourceMark rm;
+-  symbolOop element = oopFactory::new_symbol(signature->as_C_string() + index, CHECK_(T_BYTE));
+-  BasicType element_type = FieldType::basic_type(element);
++  char *element = signature->as_C_string() + index;
++  BasicType element_type = char2type(element[0]);
+   if (element_type == T_OBJECT) {
+-    char* object_type = element->as_C_string();
+-    object_type[element->utf8_length() - 1] = '\0';
+-    *object_key = oopFactory::new_symbol(object_type + 1, CHECK_(T_BYTE));
++    int len = (int)strlen(element);
++    assert(element[len-1] == ';', "last char should be a semicolon");
++    element[len-1] = '\0';        // chop off semicolon
++    fd._object_key = SymbolTable::new_symbol(element + 1, CHECK_(T_BYTE));
+   }
+   // Pass dimension back to caller
+-  *dimension = dim;
++  fd._dimension = dim;
+   return element_type;
+ }
+diff --git a/src/share/vm/runtime/fieldType.hpp b/src/share/vm/runtime/fieldType.hpp
+--- openjdk/hotspot/src/share/vm/runtime/fieldType.hpp
++++ openjdk/hotspot/src/share/vm/runtime/fieldType.hpp
+@@ -26,26 +26,42 @@
+ #define SHARE_VM_RUNTIME_FIELDTYPE_HPP
+ 
+ #include "memory/allocation.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ 
+ // Note: FieldType should be based on the SignatureIterator (or vice versa).
+ //       In any case, this structure should be re-thought at some point.
+ 
+ // A FieldType is used to determine the type of a field from a signature string.
+ 
++// Information returned by get_array_info, which is scoped to decrement
++// reference count if a Symbol is created in the case of T_OBJECT
++class FieldArrayInfo : public StackObj {
++  friend class FieldType;  // field type can set these fields.
++  int       _dimension;
++  Symbol*   _object_key;
++ public:
++  int       dimension()    { return _dimension; }
++  Symbol*   object_key()   { return _object_key; }
++  // basic constructor
++  FieldArrayInfo() : _dimension(0), _object_key(NULL) {}
++  // destructor decrements object key's refcount if created
++  ~FieldArrayInfo() { if (_object_key != NULL) _object_key->decrement_refcount(); }
++};
++
++
+ class FieldType: public AllStatic {
+  private:
+-  static void skip_optional_size(symbolOop signature, int* index);
+-  static bool is_valid_array_signature(symbolOop signature);
++  static void skip_optional_size(Symbol* signature, int* index);
++  static bool is_valid_array_signature(Symbol* signature);
+  public:
+ 
+   // Return basic type
+-  static BasicType basic_type(symbolOop signature);
++  static BasicType basic_type(Symbol* signature);
+ 
+   // Testing
+-  static bool is_array(symbolOop signature) { return signature->utf8_length() > 1 && signature->byte_at(0) == '[' && is_valid_array_signature(signature); }
++  static bool is_array(Symbol* signature) { return signature->utf8_length() > 1 && signature->byte_at(0) == '[' && is_valid_array_signature(signature); }
+ 
+-  static bool is_obj(symbolOop signature) {
++  static bool is_obj(Symbol* signature) {
+      int sig_length = signature->utf8_length();
+      // Must start with 'L' and end with ';'
+      return (sig_length >= 2 &&
+@@ -54,7 +70,7 @@
+   }
+ 
+   // Parse field and extract array information. Works for T_ARRAY only.
+-  static BasicType get_array_info(symbolOop signature, jint* dimension, symbolOop *object_key, TRAPS);
++  static BasicType get_array_info(Symbol* signature, FieldArrayInfo& ai, TRAPS);
+ };
+ 
+ #endif // SHARE_VM_RUNTIME_FIELDTYPE_HPP
+diff --git a/src/share/vm/runtime/fprofiler.cpp b/src/share/vm/runtime/fprofiler.cpp
+--- openjdk/hotspot/src/share/vm/runtime/fprofiler.cpp
++++ openjdk/hotspot/src/share/vm/runtime/fprofiler.cpp
+@@ -31,7 +31,7 @@
+ #include "memory/universe.inline.hpp"
+ #include "oops/oop.inline.hpp"
+ #include "oops/oop.inline2.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/deoptimization.hpp"
+ #include "runtime/fprofiler.hpp"
+ #include "runtime/mutexLocker.hpp"
+@@ -318,7 +318,7 @@
+     int limit;
+     int i;
+     methodOop m = method();
+-    symbolOop k = m->klass_name();
++    Symbol* k = m->klass_name();
+     // Print the class name with dots instead of slashes
+     limit = k->utf8_length();
+     for (i = 0 ; i < limit ; i += 1) {
+@@ -331,7 +331,7 @@
+     if (limit > 0) {
+       st->print(".");
+     }
+-    symbolOop n = m->name();
++    Symbol* n = m->name();
+     limit = n->utf8_length();
+     for (i = 0 ; i < limit ; i += 1) {
+       char c = (char) n->byte_at(i);
+@@ -339,7 +339,7 @@
+     }
+     if( Verbose ) {
+       // Disambiguate overloaded methods
+-      symbolOop sig = m->signature();
++      Symbol* sig = m->signature();
+       sig->print_symbol_on(st);
+     }
+   }
+diff --git a/src/share/vm/runtime/frame.cpp b/src/share/vm/runtime/frame.cpp
+--- openjdk/hotspot/src/share/vm/runtime/frame.cpp
++++ openjdk/hotspot/src/share/vm/runtime/frame.cpp
+@@ -792,7 +792,7 @@
+   }
+ 
+  public:
+-  InterpretedArgumentOopFinder(symbolHandle signature, bool has_receiver, frame* fr, OopClosure* f) : SignatureInfo(signature), _has_receiver(has_receiver) {
++  InterpretedArgumentOopFinder(Symbol* signature, bool has_receiver, frame* fr, OopClosure* f) : SignatureInfo(signature), _has_receiver(has_receiver) {
+     // compute size of arguments
+     int args_size = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0);
+     assert(!fr->is_interpreted_frame() ||
+@@ -846,7 +846,7 @@
+   }
+ 
+  public:
+-   EntryFrameOopFinder(frame* frame, symbolHandle signature, bool is_static) : SignatureInfo(signature) {
++   EntryFrameOopFinder(frame* frame, Symbol* signature, bool is_static) : SignatureInfo(signature) {
+      _f = NULL; // will be set later
+      _fr = frame;
+      _is_static = is_static;
+@@ -861,7 +861,7 @@
+ 
+ };
+ 
+-oop* frame::interpreter_callee_receiver_addr(symbolHandle signature) {
++oop* frame::interpreter_callee_receiver_addr(Symbol* signature) {
+   ArgumentSizeComputer asc(signature);
+   int size = asc.size();
+   return (oop *)interpreter_frame_tos_at(size);
+@@ -922,7 +922,7 @@
+ 
+   int max_locals = m->is_native() ? m->size_of_parameters() : m->max_locals();
+ 
+-  symbolHandle signature;
++  Symbol* signature = NULL;
+   bool has_receiver = false;
+ 
+   // Process a callee's arguments if we are at a call site
+@@ -932,7 +932,7 @@
+   if (!m->is_native()) {
+     Bytecode_invoke call = Bytecode_invoke_check(m, bci);
+     if (call.is_valid()) {
+-      signature = symbolHandle(thread, call.signature());
++      signature = call.signature();
+       has_receiver = call.has_receiver();
+       if (map->include_argument_oops() &&
+           interpreter_frame_expression_stack_size() > 0) {
+@@ -965,7 +965,7 @@
+ }
+ 
+ 
+-void frame::oops_interpreted_arguments_do(symbolHandle signature, bool has_receiver, OopClosure* f) {
++void frame::oops_interpreted_arguments_do(Symbol* signature, bool has_receiver, OopClosure* f) {
+   InterpretedArgumentOopFinder finder(signature, has_receiver, this, f);
+   finder.oops_do();
+ }
+@@ -1014,7 +1014,7 @@
+   }
+ 
+  public:
+-  CompiledArgumentOopFinder(symbolHandle signature, bool has_receiver, OopClosure* f, frame fr,  const RegisterMap* reg_map)
++  CompiledArgumentOopFinder(Symbol* signature, bool has_receiver, OopClosure* f, frame fr,  const RegisterMap* reg_map)
+     : SignatureInfo(signature) {
+ 
+     // initialize CompiledArgumentOopFinder
+@@ -1026,7 +1026,7 @@
+     _arg_size  = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0);
+ 
+     int arg_size;
+-    _regs = SharedRuntime::find_callee_arguments(signature(), has_receiver, &arg_size);
++    _regs = SharedRuntime::find_callee_arguments(signature, has_receiver, &arg_size);
+     assert(arg_size == _arg_size, "wrong arg size");
+   }
+ 
+@@ -1039,7 +1039,7 @@
+   }
+ };
+ 
+-void frame::oops_compiled_arguments_do(symbolHandle signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f) {
++void frame::oops_compiled_arguments_do(Symbol* signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f) {
+   ResourceMark rm;
+   CompiledArgumentOopFinder finder(signature, has_receiver, f, *this, reg_map);
+   finder.oops_do();
+@@ -1099,8 +1099,7 @@
+     // must collect argument oops, as nobody else is doing it
+     Thread *thread = Thread::current();
+     methodHandle m (thread, entry_frame_call_wrapper()->callee_method());
+-    symbolHandle signature (thread, m->signature());
+-    EntryFrameOopFinder finder(this, signature, m->is_static());
++    EntryFrameOopFinder finder(this, m->signature(), m->is_static());
+     finder.arguments_do(f);
+   }
+   // Traverse the Handle Block saved in the entry frame
+diff --git a/src/share/vm/runtime/frame.hpp b/src/share/vm/runtime/frame.hpp
+--- openjdk/hotspot/src/share/vm/runtime/frame.hpp
++++ openjdk/hotspot/src/share/vm/runtime/frame.hpp
+@@ -261,10 +261,10 @@
+ 
+   // Find receiver for an invoke when arguments are just pushed on stack (i.e., callee stack-frame is
+   // not setup)
+-  oop interpreter_callee_receiver(symbolHandle signature)     { return *interpreter_callee_receiver_addr(signature); }
++  oop interpreter_callee_receiver(Symbol* signature)     { return *interpreter_callee_receiver_addr(signature); }
+ 
+ 
+-  oop* interpreter_callee_receiver_addr(symbolHandle signature);
++  oop* interpreter_callee_receiver_addr(Symbol* signature);
+ 
+ 
+   // expression stack (may go up or down, direction == 1 or -1)
+@@ -386,11 +386,11 @@
+   oop* oopmapreg_to_location(VMReg reg, const RegisterMap* regmap) const;
+ 
+   // Oops-do's
+-  void oops_compiled_arguments_do(symbolHandle signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f);
++  void oops_compiled_arguments_do(Symbol* signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f);
+   void oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool query_oop_map_cache = true);
+ 
+  private:
+-  void oops_interpreted_arguments_do(symbolHandle signature, bool has_receiver, OopClosure* f);
++  void oops_interpreted_arguments_do(Symbol* signature, bool has_receiver, OopClosure* f);
+ 
+   // Iteration of oops
+   void oops_do_internal(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache);
+diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp
+--- openjdk/hotspot/src/share/vm/runtime/globals.hpp
++++ openjdk/hotspot/src/share/vm/runtime/globals.hpp
+@@ -607,6 +607,9 @@
+   notproduct(bool, ZombieALot, false,                                       \
+           "creates zombies (non-entrant) at exit from the runt. system")    \
+                                                                             \
++  product(bool, UnlinkSymbolsALot, false,                                   \
++          "unlink unreferenced symbols from the symbol table at safepoints")\
++                                                                            \
+   notproduct(bool, WalkStackALot, false,                                    \
+           "trace stack (no print) at every exit from the runtime system")   \
+                                                                             \
+diff --git a/src/share/vm/runtime/handles.hpp b/src/share/vm/runtime/handles.hpp
+--- openjdk/hotspot/src/share/vm/runtime/handles.hpp
++++ openjdk/hotspot/src/share/vm/runtime/handles.hpp
+@@ -196,7 +196,6 @@
+ DEF_HANDLE(constantPoolCache, is_constantPoolCache)
+ DEF_HANDLE(objArray         , is_objArray         )
+ DEF_HANDLE(typeArray        , is_typeArray        )
+-DEF_HANDLE(symbol           , is_symbol           )
+ 
+ //------------------------------------------------------------------------------------------------------------------------
+ // Specific KlassHandles for different Klass types
+@@ -233,7 +232,6 @@
+ DEF_KLASS_HANDLE(arrayKlass            , oop_is_array         )
+ DEF_KLASS_HANDLE(typeArrayKlass        , oop_is_typeArray_slow)
+ DEF_KLASS_HANDLE(objArrayKlass         , oop_is_objArray_slow )
+-DEF_KLASS_HANDLE(symbolKlass           , oop_is_symbol        )
+ DEF_KLASS_HANDLE(constantPoolKlass     , oop_is_constantPool  )
+ DEF_KLASS_HANDLE(constantPoolCacheKlass, oop_is_constantPool  )
+ 
+diff --git a/src/share/vm/runtime/interfaceSupport.cpp b/src/share/vm/runtime/interfaceSupport.cpp
+--- openjdk/hotspot/src/share/vm/runtime/interfaceSupport.cpp
++++ openjdk/hotspot/src/share/vm/runtime/interfaceSupport.cpp
+@@ -198,6 +198,11 @@
+   }
+ }
+ 
++void InterfaceSupport::unlinkSymbols() {
++  VM_UnlinkSymbols op;
++  VMThread::execute(&op);
++}
++
+ void InterfaceSupport::deoptimizeAll() {
+   if (is_init_completed() ) {
+     if (DeoptimizeALot && deoptimizeAllCounter > DeoptimizeALotInterval) {
+diff --git a/src/share/vm/runtime/interfaceSupport.hpp b/src/share/vm/runtime/interfaceSupport.hpp
+--- openjdk/hotspot/src/share/vm/runtime/interfaceSupport.hpp
++++ openjdk/hotspot/src/share/vm/runtime/interfaceSupport.hpp
+@@ -97,6 +97,7 @@
+ # endif
+ 
+   static void zombieAll();
++  static void unlinkSymbols();
+   static void deoptimizeAll();
+   static void stress_derived_pointers();
+   static void verify_stack();
+@@ -375,6 +376,9 @@
+     if (ZombieALot) {
+       InterfaceSupport::zombieAll();
+     }
++    if (UnlinkSymbolsALot) {
++      InterfaceSupport::unlinkSymbols();
++    }
+     // do verification AFTER potential deoptimization
+     if (VerifyStack) {
+       InterfaceSupport::verify_stack();
+diff --git a/src/share/vm/runtime/java.cpp b/src/share/vm/runtime/java.cpp
+--- openjdk/hotspot/src/share/vm/runtime/java.cpp
++++ openjdk/hotspot/src/share/vm/runtime/java.cpp
+@@ -41,7 +41,7 @@
+ #include "oops/methodOop.hpp"
+ #include "oops/objArrayOop.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "prims/jvmtiExport.hpp"
+ #include "runtime/aprofiler.hpp"
+ #include "runtime/arguments.hpp"
+@@ -615,7 +615,7 @@
+   vm_abort(false);
+ }
+ 
+-void vm_exit_during_initialization(symbolHandle ex, const char* message) {
++void vm_exit_during_initialization(Symbol* ex, const char* message) {
+   ResourceMark rm;
+   vm_notify_during_shutdown(ex->as_C_string(), message);
+ 
+diff --git a/src/share/vm/runtime/java.hpp b/src/share/vm/runtime/java.hpp
+--- openjdk/hotspot/src/share/vm/runtime/java.hpp
++++ openjdk/hotspot/src/share/vm/runtime/java.hpp
+@@ -49,7 +49,7 @@
+ 
+ // VM exit if error occurs during initialization of VM
+ extern void vm_exit_during_initialization(Handle exception);
+-extern void vm_exit_during_initialization(symbolHandle exception_name, const char* message);
++extern void vm_exit_during_initialization(Symbol* exception_name, const char* message);
+ extern void vm_exit_during_initialization(const char* error, const char* message = NULL);
+ extern void vm_shutdown_during_initialization(const char* error, const char* message = NULL);
+ 
+diff --git a/src/share/vm/runtime/javaCalls.cpp b/src/share/vm/runtime/javaCalls.cpp
+--- openjdk/hotspot/src/share/vm/runtime/javaCalls.cpp
++++ openjdk/hotspot/src/share/vm/runtime/javaCalls.cpp
+@@ -200,7 +200,7 @@
+ 
+ // ============ Virtual calls ============
+ 
+-void JavaCalls::call_virtual(JavaValue* result, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, JavaCallArguments* args, TRAPS) {
++void JavaCalls::call_virtual(JavaValue* result, KlassHandle spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS) {
+   CallInfo callinfo;
+   Handle receiver = args->receiver();
+   KlassHandle recvrKlass(THREAD, receiver.is_null() ? (klassOop)NULL : receiver->klass());
+@@ -215,13 +215,13 @@
+ }
+ 
+ 
+-void JavaCalls::call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, TRAPS) {
++void JavaCalls::call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, TRAPS) {
+   JavaCallArguments args(receiver); // One oop argument
+   call_virtual(result, spec_klass, name, signature, &args, CHECK);
+ }
+ 
+ 
+-void JavaCalls::call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, Handle arg1, TRAPS) {
++void JavaCalls::call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS) {
+   JavaCallArguments args(receiver); // One oop argument
+   args.push_oop(arg1);
+   call_virtual(result, spec_klass, name, signature, &args, CHECK);
+@@ -229,7 +229,7 @@
+ 
+ 
+ 
+-void JavaCalls::call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, Handle arg1, Handle arg2, TRAPS) {
++void JavaCalls::call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS) {
+   JavaCallArguments args(receiver); // One oop argument
+   args.push_oop(arg1);
+   args.push_oop(arg2);
+@@ -239,7 +239,7 @@
+ 
+ // ============ Special calls ============
+ 
+-void JavaCalls::call_special(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, JavaCallArguments* args, TRAPS) {
++void JavaCalls::call_special(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS) {
+   CallInfo callinfo;
+   LinkResolver::resolve_special_call(callinfo, klass, name, signature, KlassHandle(), false, CHECK);
+   methodHandle method = callinfo.selected_method();
+@@ -250,20 +250,20 @@
+ }
+ 
+ 
+-void JavaCalls::call_special(JavaValue* result, Handle receiver, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
++void JavaCalls::call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
+   JavaCallArguments args(receiver); // One oop argument
+   call_special(result, klass, name, signature, &args, CHECK);
+ }
+ 
+ 
+-void JavaCalls::call_special(JavaValue* result, Handle receiver, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, TRAPS) {
++void JavaCalls::call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS) {
+   JavaCallArguments args(receiver); // One oop argument
+   args.push_oop(arg1);
+   call_special(result, klass, name, signature, &args, CHECK);
+ }
+ 
+ 
+-void JavaCalls::call_special(JavaValue* result, Handle receiver, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, Handle arg2, TRAPS) {
++void JavaCalls::call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS) {
+   JavaCallArguments args(receiver); // One oop argument
+   args.push_oop(arg1);
+   args.push_oop(arg2);
+@@ -273,7 +273,7 @@
+ 
+ // ============ Static calls ============
+ 
+-void JavaCalls::call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, JavaCallArguments* args, TRAPS) {
++void JavaCalls::call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS) {
+   CallInfo callinfo;
+   LinkResolver::resolve_static_call(callinfo, klass, name, signature, KlassHandle(), false, true, CHECK);
+   methodHandle method = callinfo.selected_method();
+@@ -284,19 +284,19 @@
+ }
+ 
+ 
+-void JavaCalls::call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS) {
++void JavaCalls::call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS) {
+   JavaCallArguments args; // No argument
+   call_static(result, klass, name, signature, &args, CHECK);
+ }
+ 
+ 
+-void JavaCalls::call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, TRAPS) {
++void JavaCalls::call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS) {
+   JavaCallArguments args(arg1); // One oop argument
+   call_static(result, klass, name, signature, &args, CHECK);
+ }
+ 
+ 
+-void JavaCalls::call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, Handle arg2, TRAPS) {
++void JavaCalls::call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS) {
+   JavaCallArguments args; // One oop argument
+   args.push_oop(arg1);
+   args.push_oop(arg2);
+@@ -459,7 +459,7 @@
+  public:
+   bool _is_return;
+ 
+-  SignatureChekker(symbolHandle signature, BasicType return_type, bool is_static, bool* is_oop, intptr_t* value, Thread* thread) : SignatureIterator(signature) {
++  SignatureChekker(Symbol* signature, BasicType return_type, bool is_static, bool* is_oop, intptr_t* value, Thread* thread) : SignatureIterator(signature) {
+     _is_oop = is_oop;
+     _is_return = false;
+     _return_type = return_type;
+@@ -550,7 +550,7 @@
+   if (return_type == T_ARRAY) return_type = T_OBJECT;
+ 
+   // Check that oop information is correct
+-  symbolHandle signature (thread,  method->signature());
++  Symbol* signature = method->signature();
+ 
+   SignatureChekker sc(signature, return_type, method->is_static(),_is_oop, _value, thread);
+   sc.iterate_parameters();
+diff --git a/src/share/vm/runtime/javaCalls.hpp b/src/share/vm/runtime/javaCalls.hpp
+--- openjdk/hotspot/src/share/vm/runtime/javaCalls.hpp
++++ openjdk/hotspot/src/share/vm/runtime/javaCalls.hpp
+@@ -189,29 +189,29 @@
+   // call_special
+   // ------------
+   // The receiver must be first oop in argument list
+-  static void call_special(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, JavaCallArguments* args, TRAPS);
++  static void call_special(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
+ 
+-  static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS); // No args
+-  static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, TRAPS);
+-  static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, Handle arg2, TRAPS);
++  static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS); // No args
++  static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS);
++  static void call_special(JavaValue* result, Handle receiver, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS);
+ 
+   // virtual call
+   // ------------
+ 
+   // The receiver must be first oop in argument list
+-  static void call_virtual(JavaValue* result, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, JavaCallArguments* args, TRAPS);
++  static void call_virtual(JavaValue* result, KlassHandle spec_klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
+ 
+-  static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, TRAPS); // No args
+-  static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, Handle arg1, TRAPS);
+-  static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, symbolHandle name, symbolHandle signature, Handle arg1, Handle arg2, TRAPS);
++  static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, TRAPS); // No args
++  static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS);
++  static void call_virtual(JavaValue* result, Handle receiver, KlassHandle spec_klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS);
+ 
+   // Static call
+   // -----------
+-  static void call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, JavaCallArguments* args, TRAPS);
++  static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, JavaCallArguments* args, TRAPS);
+ 
+-  static void call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, TRAPS);
+-  static void call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, TRAPS);
+-  static void call_static(JavaValue* result, KlassHandle klass, symbolHandle name, symbolHandle signature, Handle arg1, Handle arg2, TRAPS);
++  static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, TRAPS);
++  static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS);
++  static void call_static(JavaValue* result, KlassHandle klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS);
+ 
+   // Low-level interface
+   static void call(JavaValue* result, methodHandle method, JavaCallArguments* args, TRAPS);
+diff --git a/src/share/vm/runtime/objectMonitor.cpp b/src/share/vm/runtime/objectMonitor.cpp
+--- openjdk/hotspot/src/share/vm/runtime/objectMonitor.cpp
++++ openjdk/hotspot/src/share/vm/runtime/objectMonitor.cpp
+@@ -79,7 +79,7 @@
+   char* bytes = NULL;                                                      \
+   int len = 0;                                                             \
+   jlong jtid = SharedRuntime::get_java_tid(thread);                        \
+-  symbolOop klassname = ((oop)(klassOop))->klass()->klass_part()->name();  \
++  Symbol* klassname = ((oop)(klassOop))->klass()->klass_part()->name();    \
+   if (klassname != NULL) {                                                 \
+     bytes = (char*)klassname->bytes();                                     \
+     len = klassname->utf8_length();                                        \
+diff --git a/src/share/vm/runtime/os.cpp b/src/share/vm/runtime/os.cpp
+--- openjdk/hotspot/src/share/vm/runtime/os.cpp
++++ openjdk/hotspot/src/share/vm/runtime/os.cpp
+@@ -255,7 +255,7 @@
+       default: {
+         // Dispatch the signal to java
+         HandleMark hm(THREAD);
+-        klassOop k = SystemDictionary::resolve_or_null(vmSymbolHandles::sun_misc_Signal(), THREAD);
++        klassOop k = SystemDictionary::resolve_or_null(vmSymbols::sun_misc_Signal(), THREAD);
+         KlassHandle klass (THREAD, k);
+         if (klass.not_null()) {
+           JavaValue result(T_VOID);
+@@ -264,8 +264,8 @@
+           JavaCalls::call_static(
+             &result,
+             klass,
+-            vmSymbolHandles::dispatch_name(),
+-            vmSymbolHandles::int_void_signature(),
++            vmSymbols::dispatch_name(),
++            vmSymbols::int_void_signature(),
+             &args,
+             THREAD
+           );
+@@ -298,7 +298,7 @@
+   if (!ReduceSignalUsage) {
+     // Setup JavaThread for processing signals
+     EXCEPTION_MARK;
+-    klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_Thread(), true, CHECK);
++    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
+     instanceKlassHandle klass (THREAD, k);
+     instanceHandle thread_oop = klass->allocate_instance_handle(CHECK);
+ 
+@@ -310,8 +310,8 @@
+     JavaValue result(T_VOID);
+     JavaCalls::call_special(&result, thread_oop,
+                            klass,
+-                           vmSymbolHandles::object_initializer_name(),
+-                           vmSymbolHandles::threadgroup_string_void_signature(),
++                           vmSymbols::object_initializer_name(),
++                           vmSymbols::threadgroup_string_void_signature(),
+                            thread_group,
+                            string,
+                            CHECK);
+@@ -320,8 +320,8 @@
+     JavaCalls::call_special(&result,
+                             thread_group,
+                             group,
+-                            vmSymbolHandles::add_method_name(),
+-                            vmSymbolHandles::thread_void_signature(),
++                            vmSymbols::add_method_name(),
++                            vmSymbols::thread_void_signature(),
+                             thread_oop,         // ARG 1
+                             CHECK);
+ 
+diff --git a/src/share/vm/runtime/reflection.cpp b/src/share/vm/runtime/reflection.cpp
+--- openjdk/hotspot/src/share/vm/runtime/reflection.cpp
++++ openjdk/hotspot/src/share/vm/runtime/reflection.cpp
+@@ -64,7 +64,7 @@
+       // this frame is a likely suspect
+       caller = vfst.method()->method_holder();
+       line_number = vfst.method()->line_number_from_bci(vfst.bci());
+-      symbolOop s = instanceKlass::cast(vfst.method()->method_holder())->source_file_name();
++      Symbol* s = instanceKlass::cast(vfst.method()->method_holder())->source_file_name();
+       if (s != NULL) {
+         source_file = s->as_C_string();
+       }
+@@ -622,7 +622,7 @@
+   ResourceMark rm(THREAD);
+   Exceptions::fthrow(
+     THREAD_AND_LOCATION,
+-    vmSymbolHandles::java_lang_IncompatibleClassChangeError(),
++    vmSymbols::java_lang_IncompatibleClassChangeError(),
+     "%s and %s disagree on InnerClasses attribute",
+     outer->external_name(),
+     inner->external_name()
+@@ -638,11 +638,11 @@
+       return java_lang_Class::primitive_mirror(ss->type());
+     case T_OBJECT:
+     case T_ARRAY:
+-      symbolOop name        = ss->as_symbol(CHECK_NULL);
++      Symbol* name        = ss->as_symbol(CHECK_NULL);
+       oop loader            = instanceKlass::cast(method->method_holder())->class_loader();
+       oop protection_domain = instanceKlass::cast(method->method_holder())->protection_domain();
+       klassOop k = SystemDictionary::resolve_or_fail(
+-                                       symbolHandle(THREAD, name),
++                                       name,
+                                        Handle(THREAD, loader),
+                                        Handle(THREAD, protection_domain),
+                                        true, CHECK_NULL);
+@@ -660,7 +660,8 @@
+   objArrayHandle mirrors (THREAD, m);
+   int index = 0;
+   // Collect parameter types
+-  symbolHandle signature (THREAD, method->signature());
++  ResourceMark rm(THREAD);
++  Symbol*  signature  = method->signature();
+   SignatureStream ss(signature);
+   while (!ss.at_return_type()) {
+     oop mirror = get_mirror_from_signature(method, &ss, CHECK_(objArrayHandle()));
+@@ -681,9 +682,9 @@
+ }
+ 
+ 
+-Handle Reflection::new_type(symbolHandle signature, KlassHandle k, TRAPS) {
++Handle Reflection::new_type(Symbol* signature, KlassHandle k, TRAPS) {
+   // Basic types
+-  BasicType type = vmSymbols::signature_type(signature());
++  BasicType type = vmSymbols::signature_type(signature);
+   if (type != T_OBJECT) {
+     return Handle(THREAD, Universe::java_mirror(type));
+   }
+@@ -714,7 +715,7 @@
+   instanceKlassHandle holder (THREAD, method->method_holder());
+   int slot = method->method_idnum();
+ 
+-  symbolHandle signature (THREAD, method->signature());
++  Symbol*  signature  = method->signature();
+   int parameter_count = ArgumentCount(signature).size();
+   oop return_type_oop = NULL;
+   objArrayHandle parameter_types = get_parameter_types(method, parameter_count, &return_type_oop, CHECK_NULL);
+@@ -726,16 +727,16 @@
+ 
+   if (exception_types.is_null()) return NULL;
+ 
+-  symbolHandle method_name(THREAD, method->name());
++  Symbol*  method_name = method->name();
+   Handle name;
+   if (intern_name) {
+     // intern_name is only true with UseNewReflection
+-    oop name_oop = StringTable::intern(method_name(), CHECK_NULL);
++    oop name_oop = StringTable::intern(method_name, CHECK_NULL);
+     name = Handle(THREAD, name_oop);
+   } else {
+     name = java_lang_String::create_from_symbol(method_name, CHECK_NULL);
+   }
+-  if (name.is_null()) return NULL;
++  if (name == NULL) return NULL;
+ 
+   int modifiers = method->access_flags().as_int() & JVM_RECOGNIZED_METHOD_MODIFIERS;
+ 
+@@ -751,7 +752,7 @@
+   java_lang_reflect_Method::set_override(mh(), false);
+   if (java_lang_reflect_Method::has_signature_field() &&
+       method->generic_signature() != NULL) {
+-    symbolHandle gs(THREAD, method->generic_signature());
++    Symbol*  gs = method->generic_signature();
+     Handle sig = java_lang_String::create_from_symbol(gs, CHECK_NULL);
+     java_lang_reflect_Method::set_signature(mh(), sig());
+   }
+@@ -774,7 +775,7 @@
+   instanceKlassHandle  holder (THREAD, method->method_holder());
+   int slot = method->method_idnum();
+ 
+-  symbolHandle signature (THREAD, method->signature());
++  Symbol*  signature  = method->signature();
+   int parameter_count = ArgumentCount(signature).size();
+   objArrayHandle parameter_types = get_parameter_types(method, parameter_count, NULL, CHECK_NULL);
+   if (parameter_types.is_null()) return NULL;
+@@ -794,7 +795,7 @@
+   java_lang_reflect_Constructor::set_override(ch(), false);
+   if (java_lang_reflect_Constructor::has_signature_field() &&
+       method->generic_signature() != NULL) {
+-    symbolHandle gs(THREAD, method->generic_signature());
++    Symbol*  gs = method->generic_signature();
+     Handle sig = java_lang_String::create_from_symbol(gs, CHECK_NULL);
+     java_lang_reflect_Constructor::set_signature(ch(), sig());
+   }
+@@ -809,16 +810,16 @@
+ 
+ 
+ oop Reflection::new_field(fieldDescriptor* fd, bool intern_name, TRAPS) {
+-  symbolHandle field_name(THREAD, fd->name());
++  Symbol*  field_name = fd->name();
+   Handle name;
+   if (intern_name) {
+     // intern_name is only true with UseNewReflection
+-    oop name_oop = StringTable::intern(field_name(), CHECK_NULL);
++    oop name_oop = StringTable::intern(field_name, CHECK_NULL);
+     name = Handle(THREAD, name_oop);
+   } else {
+     name = java_lang_String::create_from_symbol(field_name, CHECK_NULL);
+   }
+-  symbolHandle signature (THREAD, fd->signature());
++  Symbol*  signature  = fd->signature();
+   KlassHandle  holder    (THREAD, fd->field_holder());
+   Handle type = new_type(signature, holder, CHECK_NULL);
+   Handle rh  = java_lang_reflect_Field::create(CHECK_NULL);
+@@ -832,7 +833,7 @@
+   java_lang_reflect_Field::set_override(rh(), false);
+   if (java_lang_reflect_Field::has_signature_field() &&
+       fd->generic_signature() != NULL) {
+-    symbolHandle gs(THREAD, fd->generic_signature());
++    Symbol*  gs = fd->generic_signature();
+     Handle sig = java_lang_String::create_from_symbol(gs, CHECK_NULL);
+     java_lang_reflect_Field::set_signature(rh(), sig());
+   }
+@@ -858,8 +859,8 @@
+   assert(!method.is_null() , "method should not be null");
+ 
+   CallInfo info;
+-  symbolHandle signature (THREAD, method->signature());
+-  symbolHandle name      (THREAD, method->name());
++  Symbol*  signature  = method->signature();
++  Symbol*  name       = method->name();
+   LinkResolver::resolve_interface_call(info, receiver, recv_klass, klass,
+                                        name, signature,
+                                        KlassHandle(), false, true,
+@@ -912,8 +913,8 @@
+             oop resolution_exception = PENDING_EXCEPTION;
+             CLEAR_PENDING_EXCEPTION;
+             JavaCallArguments args(Handle(THREAD, resolution_exception));
+-            THROW_ARG_0(vmSymbolHandles::java_lang_reflect_InvocationTargetException(),
+-                vmSymbolHandles::throwable_void_signature(),
++            THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
++                vmSymbols::throwable_void_signature(),
+                 &args);
+           }
+         } else {
+@@ -941,8 +942,8 @@
+                      method->name(),
+                      method->signature()));
+               JavaCallArguments args(h_origexception);
+-              THROW_ARG_0(vmSymbolHandles::java_lang_reflect_InvocationTargetException(),
+-                vmSymbolHandles::throwable_void_signature(),
++              THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
++                vmSymbols::throwable_void_signature(),
+                 &args);
+             } else {
+               ResourceMark rm(THREAD);
+@@ -1043,8 +1044,8 @@
+     oop target_exception = PENDING_EXCEPTION;
+     CLEAR_PENDING_EXCEPTION;
+     JavaCallArguments args(Handle(THREAD, target_exception));
+-    THROW_ARG_0(vmSymbolHandles::java_lang_reflect_InvocationTargetException(),
+-                vmSymbolHandles::throwable_void_signature(),
++    THROW_ARG_0(vmSymbols::java_lang_reflect_InvocationTargetException(),
++                vmSymbols::throwable_void_signature(),
+                 &args);
+   } else {
+     if (rtype == T_BOOLEAN || rtype == T_BYTE || rtype == T_CHAR || rtype == T_SHORT)
+@@ -1097,9 +1098,9 @@
+ 
+ 
+ oop Reflection::new_field(FieldStream* st, TRAPS) {
+-  symbolHandle field_name(THREAD, st->name());
++  Symbol*  field_name = st->name();
+   Handle name = java_lang_String::create_from_symbol(field_name, CHECK_NULL);
+-  symbolHandle signature(THREAD, st->signature());
++  Symbol*  signature = st->signature();
+   Handle type = new_type(signature, st->klass(), CHECK_NULL);
+   Handle rh  = java_lang_reflect_Field::create(CHECK_NULL);
+   oop result = rh();
+@@ -1242,7 +1243,7 @@
+     case T_ARRAY: {
+       Handle obj(THREAD, (oop) value->l);
+       if (obj.not_null()) {
+-        symbolHandle signature(THREAD, fd->signature());
++        Symbol*  signature = fd->signature();
+         Handle       loader   (THREAD, fd->loader());
+         Handle       protect  (THREAD, Klass::cast(fd->field_holder())->protection_domain());
+         klassOop k = SystemDictionary::resolve_or_fail(signature, loader, protect, true, CHECK); // may block
+@@ -1259,7 +1260,7 @@
+ }
+ 
+ 
+-oop Reflection::reflect_field(oop mirror, symbolOop field_name, jint which, TRAPS) {
++oop Reflection::reflect_field(oop mirror, Symbol* field_name, jint which, TRAPS) {
+   // Exclude primitive types and array types
+   if (java_lang_Class::is_primitive(mirror))                             return NULL;
+   if (Klass::cast(java_lang_Class::as_klassOop(mirror))->oop_is_array()) return NULL;
+@@ -1287,7 +1288,7 @@
+   // Exclude primitive types and array types
+   if (java_lang_Class::is_primitive(mirror)
+       || Klass::cast(java_lang_Class::as_klassOop(mirror))->oop_is_array()) {
+-    symbolHandle name = vmSymbolHandles::java_lang_reflect_Field();
++    Symbol* name = vmSymbols::java_lang_reflect_Field();
+     klassOop klass = SystemDictionary::resolve_or_fail(name, true, CHECK_NULL);
+     return oopFactory::new_objArray(klass, 0, CHECK_NULL);  // Return empty array
+   }
+@@ -1308,7 +1309,7 @@
+   }
+ 
+   // Allocate result
+-  symbolHandle name = vmSymbolHandles::java_lang_reflect_Field();
++  Symbol* name = vmSymbols::java_lang_reflect_Field();
+   klassOop klass = SystemDictionary::resolve_or_fail(name, true, CHECK_NULL);
+   objArrayOop r = oopFactory::new_objArray(klass, count, CHECK_NULL);
+   objArrayHandle result (THREAD, r);
+@@ -1327,7 +1328,7 @@
+ }
+ 
+ 
+-oop Reflection::reflect_method(oop mirror, symbolHandle method_name, objArrayHandle types, jint which, TRAPS) {
++oop Reflection::reflect_method(oop mirror, Symbol* method_name, objArrayHandle types, jint which, TRAPS) {
+   if (java_lang_Class::is_primitive(mirror))  return NULL;
+   klassOop klass = java_lang_Class::as_klassOop(mirror);
+   if (Klass::cast(klass)->oop_is_array() && which == MEMBER_DECLARED)  return NULL;
+@@ -1351,8 +1352,8 @@
+         for (MethodStream st(h_k, false, false); !st.eos(); st.next()) {
+           methodHandle m(THREAD, st.method());
+           // For interfaces include static initializers since classic does that!
+-          if (method_name() == m->name() && (include_clinit || (m->is_public() && !m->is_static() && !m->is_initializer()))) {
+-            symbolHandle signature(THREAD, m->signature());
++          if (method_name == m->name() && (include_clinit || (m->is_public() && !m->is_static() && !m->is_initializer()))) {
++            Symbol*  signature = m->signature();
+             bool parameter_match = match_parameter_types(m, types, ArgumentCount(signature).size(), CHECK_NULL);
+             if (parameter_match) {
+               return new_method(m, false, false, THREAD);
+@@ -1364,8 +1365,8 @@
+       {
+         for (MethodStream st(h_k, false, false); !st.eos(); st.next()) {
+           methodHandle m(THREAD, st.method());
+-          if (method_name() == m->name() && m->is_public() && m->is_static() && !m->is_initializer()) {
+-            symbolHandle signature(THREAD, m->signature());
++          if (method_name == m->name() && m->is_public() && m->is_static() && !m->is_initializer()) {
++            Symbol*  signature = m->signature();
+             bool parameter_match = match_parameter_types(m, types, ArgumentCount(signature).size(), CHECK_NULL);
+             if (parameter_match) {
+               return new_method(m, false, false, THREAD);
+@@ -1379,8 +1380,8 @@
+       {
+         for (MethodStream st(h_k, true, true); !st.eos(); st.next()) {
+           methodHandle m(THREAD, st.method());
+-          if (method_name() == m->name() && !m->is_initializer()) {
+-            symbolHandle signature(THREAD, m->signature());
++          if (method_name == m->name() && !m->is_initializer()) {
++            Symbol*  signature = m->signature();
+             bool parameter_match = match_parameter_types(m, types, ArgumentCount(signature).size(), CHECK_NULL);
+             if (parameter_match) {
+               return new_method(m, false, false, THREAD);
+@@ -1531,7 +1532,7 @@
+   for (MethodStream st(h_k, true, true); !st.eos(); st.next()) {
+     methodHandle m(THREAD, st.method());
+     if (m->name() == vmSymbols::object_initializer_name() && (local_only || m->is_public())) {
+-      symbolHandle signature(THREAD, m->signature());
++      Symbol*  signature = m->signature();
+       bool parameter_match = match_parameter_types(m, types, ArgumentCount(signature).size(), CHECK_NULL);
+       if (parameter_match) {
+         return new_constructor(m, THREAD);
+@@ -1569,7 +1570,7 @@
+   }
+ 
+   // Allocate result
+-  symbolHandle name = vmSymbolHandles::java_lang_reflect_Constructor();
++  Symbol* name = vmSymbols::java_lang_reflect_Constructor();
+   klassOop klass = SystemDictionary::resolve_or_fail(name, true, CHECK_NULL);
+   objArrayOop r = oopFactory::new_objArray(klass, count, CHECK_NULL);
+   objArrayHandle h_result (THREAD, r);
+diff --git a/src/share/vm/runtime/reflection.hpp b/src/share/vm/runtime/reflection.hpp
+--- openjdk/hotspot/src/share/vm/runtime/reflection.hpp
++++ openjdk/hotspot/src/share/vm/runtime/reflection.hpp
+@@ -55,7 +55,7 @@
+   static objArrayHandle get_parameter_types(methodHandle method, int parameter_count, oop* return_type, TRAPS);
+   static objArrayHandle get_exception_types(methodHandle method, TRAPS);
+   // Creating new java.lang.reflect.xxx wrappers
+-  static Handle new_type(symbolHandle signature, KlassHandle k, TRAPS);
++  static Handle new_type(Symbol* signature, KlassHandle k, TRAPS);
+ 
+  public:
+   // Constants defined by java reflection api classes
+@@ -157,11 +157,11 @@
+   static void      field_set(jvalue* value, fieldDescriptor* fd, Handle receiver, BasicType value_type, TRAPS);
+ 
+   // Reflective lookup of fields. Returns java.lang.reflect.Field instances.
+-  static oop         reflect_field(oop mirror, symbolOop field_name, jint which, TRAPS);
++  static oop         reflect_field(oop mirror, Symbol* field_name, jint which, TRAPS);
+   static objArrayOop reflect_fields(oop mirror, jint which, TRAPS);
+ 
+   // Reflective lookup of methods. Returns java.lang.reflect.Method instances.
+-  static oop         reflect_method(oop mirror, symbolHandle method_name, objArrayHandle types, jint which, TRAPS);
++  static oop         reflect_method(oop mirror, Symbol* method_name, objArrayHandle types, jint which, TRAPS);
+   static objArrayOop reflect_methods(oop mirror, jint which, TRAPS);
+ 
+   // Reflective lookup of constructors. Returns java.lang.reflect.Constructor instances.
+diff --git a/src/share/vm/runtime/reflectionUtils.hpp b/src/share/vm/runtime/reflectionUtils.hpp
+--- openjdk/hotspot/src/share/vm/runtime/reflectionUtils.hpp
++++ openjdk/hotspot/src/share/vm/runtime/reflectionUtils.hpp
+@@ -100,7 +100,7 @@
+ // Usage:
+ //
+ //    for (FieldStream st(k, false, false); !st.eos(); st.next()) {
+-//      symbolOop field_name = st.name();
++//      Symbol* field_name = st.name();
+ //      ...
+ //    }
+ 
+@@ -126,11 +126,11 @@
+     flags.set_flags(fields()->ushort_at(index() + instanceKlass::access_flags_offset));
+     return flags;
+   }
+-  symbolOop name() const {
++  Symbol* name() const {
+     int name_index = fields()->ushort_at(index() + instanceKlass::name_index_offset);
+     return constants()->symbol_at(name_index);
+   }
+-  symbolOop signature() const {
++  Symbol* signature() const {
+     int signature_index = fields()->ushort_at(index() +
+                                        instanceKlass::signature_index_offset);
+     return constants()->symbol_at(signature_index);
+@@ -197,7 +197,7 @@
+ // Usage:
+ //
+ //    for (FilteredFieldStream st(k, false, false); !st.eos(); st.next()) {
+-//      symbolOop field_name = st.name();
++//      Symbol* field_name = st.name();
+ //      ...
+ //    }
+ 
+diff --git a/src/share/vm/runtime/rframe.cpp b/src/share/vm/runtime/rframe.cpp
+--- openjdk/hotspot/src/share/vm/runtime/rframe.cpp
++++ openjdk/hotspot/src/share/vm/runtime/rframe.cpp
+@@ -25,7 +25,7 @@
+ #include "precompiled.hpp"
+ #include "interpreter/interpreter.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/frame.inline.hpp"
+ #include "runtime/rframe.hpp"
+ #include "runtime/vframe.hpp"
+diff --git a/src/share/vm/runtime/safepoint.cpp b/src/share/vm/runtime/safepoint.cpp
+--- openjdk/hotspot/src/share/vm/runtime/safepoint.cpp
++++ openjdk/hotspot/src/share/vm/runtime/safepoint.cpp
+@@ -35,7 +35,7 @@
+ #include "memory/resourceArea.hpp"
+ #include "memory/universe.inline.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/compilationPolicy.hpp"
+ #include "runtime/deoptimization.hpp"
+ #include "runtime/frame.inline.hpp"
+diff --git a/src/share/vm/runtime/sharedRuntime.cpp b/src/share/vm/runtime/sharedRuntime.cpp
+--- openjdk/hotspot/src/share/vm/runtime/sharedRuntime.cpp
++++ openjdk/hotspot/src/share/vm/runtime/sharedRuntime.cpp
+@@ -527,7 +527,7 @@
+ }
+ 
+ 
+-oop SharedRuntime::retrieve_receiver( symbolHandle sig, frame caller ) {
++oop SharedRuntime::retrieve_receiver( Symbol* sig, frame caller ) {
+   assert(caller.is_interpreted_frame(), "");
+   int args_size = ArgumentSizeComputer(sig).size() + 1;
+   assert(args_size <= caller.interpreter_frame_expression_stack_size(), "receiver must be on interpreter stack");
+@@ -547,7 +547,7 @@
+   Exceptions::_throw(thread, __FILE__, __LINE__, h_exception);
+ }
+ 
+-void SharedRuntime::throw_and_post_jvmti_exception(JavaThread *thread, symbolOop name, const char *message) {
++void SharedRuntime::throw_and_post_jvmti_exception(JavaThread *thread, Symbol* name, const char *message) {
+   Handle h_exception = Exceptions::new_exception(thread, name, message);
+   throw_and_post_jvmti_exception(thread, h_exception);
+ }
+@@ -880,7 +880,7 @@
+   assert(DTraceAllocProbes, "wrong call");
+   Klass* klass = o->blueprint();
+   int size = o->size();
+-  symbolOop name = klass->name();
++  Symbol* name = klass->name();
+   HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread),
+                    name->bytes(), name->utf8_length(), size * HeapWordSize);
+   return 0;
+@@ -889,9 +889,9 @@
+ JRT_LEAF(int, SharedRuntime::dtrace_method_entry(
+     JavaThread* thread, methodOopDesc* method))
+   assert(DTraceMethodProbes, "wrong call");
+-  symbolOop kname = method->klass_name();
+-  symbolOop name = method->name();
+-  symbolOop sig = method->signature();
++  Symbol* kname = method->klass_name();
++  Symbol* name = method->name();
++  Symbol* sig = method->signature();
+   HS_DTRACE_PROBE7(hotspot, method__entry, get_java_tid(thread),
+       kname->bytes(), kname->utf8_length(),
+       name->bytes(), name->utf8_length(),
+@@ -902,9 +902,9 @@
+ JRT_LEAF(int, SharedRuntime::dtrace_method_exit(
+     JavaThread* thread, methodOopDesc* method))
+   assert(DTraceMethodProbes, "wrong call");
+-  symbolOop kname = method->klass_name();
+-  symbolOop name = method->name();
+-  symbolOop sig = method->signature();
++  Symbol* kname = method->klass_name();
++  Symbol* name = method->name();
++  Symbol* sig = method->signature();
+   HS_DTRACE_PROBE7(hotspot, method__return, get_java_tid(thread),
+       kname->bytes(), kname->utf8_length(),
+       name->bytes(), name->utf8_length(),
+@@ -2637,7 +2637,7 @@
+   return regs.first();
+ }
+ 
+-VMRegPair *SharedRuntime::find_callee_arguments(symbolOop sig, bool has_receiver, int* arg_size) {
++VMRegPair *SharedRuntime::find_callee_arguments(Symbol* sig, bool has_receiver, int* arg_size) {
+   // This method is returning a data structure allocating as a
+   // ResourceObject, so do not put any ResourceMarks in here.
+   char *s = sig->as_C_string();
+diff --git a/src/share/vm/runtime/sharedRuntime.hpp b/src/share/vm/runtime/sharedRuntime.hpp
+--- openjdk/hotspot/src/share/vm/runtime/sharedRuntime.hpp
++++ openjdk/hotspot/src/share/vm/runtime/sharedRuntime.hpp
+@@ -223,7 +223,7 @@
+ 
+   // Helper routine for full-speed JVMTI exception throwing support
+   static void throw_and_post_jvmti_exception(JavaThread *thread, Handle h_exception);
+-  static void throw_and_post_jvmti_exception(JavaThread *thread, symbolOop name, const char *message = NULL);
++  static void throw_and_post_jvmti_exception(JavaThread *thread, Symbol* name, const char *message = NULL);
+ 
+   // RedefineClasses() tracing support for obsolete method entry
+   static int rc_trace_method_entry(JavaThread* thread, methodOopDesc* m);
+@@ -237,7 +237,7 @@
+   // Used to back off a spin lock that is under heavy contention
+   static void yield_all(JavaThread* thread, int attempts = 0);
+ 
+-  static oop retrieve_receiver( symbolHandle sig, frame caller );
++  static oop retrieve_receiver( Symbol* sig, frame caller );
+ 
+   static void register_finalizer(JavaThread* thread, oopDesc* obj);
+ 
+@@ -417,7 +417,7 @@
+ 
+   // Convert a sig into a calling convention register layout
+   // and find interesting things about it.
+-  static VMRegPair* find_callee_arguments(symbolOop sig, bool has_receiver, int *arg_size);
++  static VMRegPair* find_callee_arguments(Symbol* sig, bool has_receiver, int *arg_size);
+   static VMReg     name_for_receiver();
+ 
+   // "Top of Stack" slots that may be unused by the calling convention but must
+diff --git a/src/share/vm/runtime/signature.cpp b/src/share/vm/runtime/signature.cpp
+--- openjdk/hotspot/src/share/vm/runtime/signature.cpp
++++ openjdk/hotspot/src/share/vm/runtime/signature.cpp
+@@ -28,7 +28,7 @@
+ #include "memory/oopFactory.hpp"
+ #include "oops/instanceKlass.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "oops/typeArrayKlass.hpp"
+ #include "runtime/signature.hpp"
+ 
+@@ -44,25 +44,11 @@
+ // ClassName  = string.
+ 
+ 
+-SignatureIterator::SignatureIterator(symbolHandle signature) {
+-  assert(signature->is_symbol(), "not a symbol");
++SignatureIterator::SignatureIterator(Symbol* signature) {
+   _signature       = signature;
+   _parameter_index = 0;
+ }
+ 
+-// Overloaded version called without handle
+-SignatureIterator::SignatureIterator(symbolOop signature) {
+-  symbolHandle sh(Thread::current(), signature);
+-  _signature       = sh;
+-  _parameter_index = 0;
+-}
+-
+-SignatureIterator::SignatureIterator(Thread *thread, symbolOop signature) {
+-  symbolHandle sh(thread, signature);
+-  _signature       = sh;
+-  _parameter_index = 0;
+-}
+-
+ void SignatureIterator::expect(char c) {
+   if (_signature->byte_at(_index) != c) fatal(err_msg("expecting %c", c));
+   _index++;
+@@ -70,7 +56,7 @@
+ 
+ 
+ void SignatureIterator::skip_optional_size() {
+-  symbolOop sig = _signature();
++  Symbol* sig = _signature;
+   char c = sig->byte_at(_index);
+   while ('0' <= c && c <= '9') c = sig->byte_at(++_index);
+ }
+@@ -104,7 +90,7 @@
+               _index++; size = T_VOID_size;  ; break;
+     case 'L':
+       { int begin = ++_index;
+-        symbolOop sig = _signature();
++        Symbol* sig = _signature;
+         while (sig->byte_at(_index++) != ';') ;
+         do_object(begin, _index);
+       }
+@@ -114,7 +100,7 @@
+     case '[':
+       { int begin = ++_index;
+         skip_optional_size();
+-        symbolOop sig = _signature();
++        Symbol* sig = _signature;
+         while (sig->byte_at(_index) == '[') {
+           _index++;
+           skip_optional_size();
+@@ -237,7 +223,7 @@
+   // Ignore parameters
+   _index = 0;
+   expect('(');
+-  symbolOop sig = _signature();
++  Symbol* sig = _signature;
+   while (sig->byte_at(_index) != ')') _index++;
+   expect(')');
+   // Parse return type
+@@ -264,9 +250,22 @@
+ 
+ 
+ // Implementation of SignatureStream
++SignatureStream::SignatureStream(Symbol* signature, bool is_method) :
++                   _signature(signature), _at_return_type(false) {
++  _begin = _end = (is_method ? 1 : 0);  // skip first '(' in method signatures
++  _names = new GrowableArray<Symbol*>(10);
++  next();
++}
++
++SignatureStream::~SignatureStream() {
++  // decrement refcount for names created during signature parsing
++  for (int i = 0; i < _names->length(); i++) {
++    _names->at(i)->decrement_refcount();
++  }
++}
+ 
+ bool SignatureStream::is_done() const {
+-  return _end > _signature()->utf8_length();
++  return _end > _signature->utf8_length();
+ }
+ 
+ 
+@@ -274,13 +273,13 @@
+   switch (t) {
+     case 'L': {
+       _type = T_OBJECT;
+-      symbolOop sig = _signature();
++      Symbol* sig = _signature;
+       while (sig->byte_at(_end++) != ';');
+       break;
+     }
+     case '[': {
+       _type = T_ARRAY;
+-      symbolOop sig = _signature();
++      Symbol* sig = _signature;
+       char c = sig->byte_at(_end);
+       while ('0' <= c && c <= '9') c = sig->byte_at(_end++);
+       while (sig->byte_at(_end) == '[') {
+@@ -319,25 +318,28 @@
+   return _type == T_ARRAY;
+ }
+ 
+-symbolOop SignatureStream::as_symbol(TRAPS) {
++Symbol* SignatureStream::as_symbol(TRAPS) {
+   // Create a symbol from for string _begin _end
+   int begin = _begin;
+   int end   = _end;
+ 
+-  if (   _signature()->byte_at(_begin) == 'L'
+-      && _signature()->byte_at(_end-1) == ';') {
++  if (   _signature->byte_at(_begin) == 'L'
++      && _signature->byte_at(_end-1) == ';') {
+     begin++;
+     end--;
+   }
+ 
+-  symbolOop result = oopFactory::new_symbol(_signature, begin, end, CHECK_NULL);
+-  return result;
++  // Save names for cleaning up reference count at the end of
++  // SignatureStream scope.
++  Symbol* name = SymbolTable::new_symbol(_signature, begin, end, CHECK_NULL);
++  _names->push(name);  // save new symbol for decrementing later
++  return name;
+ }
+ 
+ klassOop SignatureStream::as_klass(Handle class_loader, Handle protection_domain,
+                                    FailureMode failure_mode, TRAPS) {
+   if (!is_object())  return NULL;
+-  symbolOop name = as_symbol(CHECK_NULL);
++  Symbol* name = as_symbol(CHECK_NULL);
+   if (failure_mode == ReturnNull) {
+     return SystemDictionary::resolve_or_null(name, class_loader, protection_domain, THREAD);
+   } else {
+@@ -355,28 +357,28 @@
+   return Klass::cast(klass)->java_mirror();
+ }
+ 
+-symbolOop SignatureStream::as_symbol_or_null() {
++Symbol* SignatureStream::as_symbol_or_null() {
+   // Create a symbol from for string _begin _end
+   ResourceMark rm;
+ 
+   int begin = _begin;
+   int end   = _end;
+ 
+-  if (   _signature()->byte_at(_begin) == 'L'
+-      && _signature()->byte_at(_end-1) == ';') {
++  if (   _signature->byte_at(_begin) == 'L'
++      && _signature->byte_at(_end-1) == ';') {
+     begin++;
+     end--;
+   }
+ 
+   char* buffer = NEW_RESOURCE_ARRAY(char, end - begin);
+   for (int index = begin; index < end; index++) {
+-    buffer[index - begin] = _signature()->byte_at(index);
++    buffer[index - begin] = _signature->byte_at(index);
+   }
+-  symbolOop result = SymbolTable::probe(buffer, end - begin);
++  Symbol* result = SymbolTable::probe(buffer, end - begin);
+   return result;
+ }
+ 
+-bool SignatureVerifier::is_valid_signature(symbolHandle sig) {
++bool SignatureVerifier::is_valid_signature(Symbol* sig) {
+   const char* signature = (const char*)sig->bytes();
+   ssize_t len = sig->utf8_length();
+   if (signature == NULL || signature[0] == '\0' || len < 1) {
+@@ -388,7 +390,7 @@
+   }
+ }
+ 
+-bool SignatureVerifier::is_valid_method_signature(symbolHandle sig) {
++bool SignatureVerifier::is_valid_method_signature(Symbol* sig) {
+   const char* method_sig = (const char*)sig->bytes();
+   ssize_t len = sig->utf8_length();
+   ssize_t index = 0;
+@@ -411,7 +413,7 @@
+   return false;
+ }
+ 
+-bool SignatureVerifier::is_valid_type_signature(symbolHandle sig) {
++bool SignatureVerifier::is_valid_type_signature(Symbol* sig) {
+   const char* type_sig = (const char*)sig->bytes();
+   ssize_t len = sig->utf8_length();
+   return (type_sig != NULL && len >= 1 &&
+diff --git a/src/share/vm/runtime/signature.hpp b/src/share/vm/runtime/signature.hpp
+--- openjdk/hotspot/src/share/vm/runtime/signature.hpp
++++ openjdk/hotspot/src/share/vm/runtime/signature.hpp
+@@ -47,7 +47,7 @@
+ 
+ class SignatureIterator: public ResourceObj {
+  protected:
+-  symbolHandle _signature;             // the signature to iterate over
++  Symbol*      _signature;             // the signature to iterate over
+   int          _index;                 // the current character index (only valid during iteration)
+   int          _parameter_index;       // the current parameter index (0 outside iteration phase)
+   BasicType    _return_type;
+@@ -87,9 +87,7 @@
+   };
+ 
+   // Constructors
+-  SignatureIterator(symbolOop signature);
+-  SignatureIterator(Thread *thread, symbolOop signature);
+-  SignatureIterator(symbolHandle signature);
++  SignatureIterator(Symbol* signature);
+ 
+   // Iteration
+   void dispatch_field();               // dispatches once for field signatures
+@@ -138,7 +136,7 @@
+   void do_array (int begin, int end)   { type_name("jobject" ); }
+ 
+  public:
+-  SignatureTypeNames(symbolHandle signature) : SignatureIterator(signature) {}
++  SignatureTypeNames(Symbol* signature) : SignatureIterator(signature) {}
+ };
+ 
+ 
+@@ -166,7 +164,7 @@
+   void do_array (int begin, int end)   { set(T_ARRAY_size  , T_ARRAY  ); }
+ 
+  public:
+-  SignatureInfo(symbolHandle signature) : SignatureIterator(signature) {
++  SignatureInfo(Symbol* signature) : SignatureIterator(signature) {
+     _has_iterated = _has_iterated_return = false;
+     _size         = 0;
+     _return_type  = T_ILLEGAL;
+@@ -181,7 +179,7 @@
+  private:
+   void set(int size, BasicType type)   { _size += size; }
+  public:
+-  ArgumentSizeComputer(symbolHandle signature) : SignatureInfo(signature) {}
++  ArgumentSizeComputer(Symbol* signature) : SignatureInfo(signature) {}
+ 
+   int       size()                     { lazy_iterate_parameters(); return _size; }
+ };
+@@ -191,7 +189,7 @@
+  private:
+   void set(int size, BasicType type)   { _size ++; }
+  public:
+-  ArgumentCount(symbolHandle signature) : SignatureInfo(signature) {}
++  ArgumentCount(Symbol* signature) : SignatureInfo(signature) {}
+ 
+   int       size()                     { lazy_iterate_parameters(); return _size; }
+ };
+@@ -205,7 +203,7 @@
+  public:
+   BasicType type()                     { lazy_iterate_return(); return _return_type; }
+ 
+-  ResultTypeFinder(symbolHandle signature) : SignatureInfo(signature) {}
++  ResultTypeFinder(Symbol* signature) : SignatureInfo(signature) {}
+ };
+ 
+ 
+@@ -238,11 +236,6 @@
+     _fingerprint = 0;
+   }
+ 
+-  Fingerprinter(Thread *thread, methodHandle method) : SignatureIterator(thread, method->signature()) {
+-    mh = method;
+-    _fingerprint = 0;
+-  }
+-
+   uint64_t fingerprint() {
+     // See if we fingerprinted this method already
+     if (mh->constMethod()->fingerprint() != CONST64(0)) {
+@@ -356,18 +349,19 @@
+ 
+ class SignatureStream : public StackObj {
+  private:
+-  symbolHandle _signature;
++  Symbol*      _signature;
+   int          _begin;
+   int          _end;
+   BasicType    _type;
+   bool         _at_return_type;
++  GrowableArray<Symbol*>* _names;  // symbols created while parsing signature
+ 
+  public:
+   bool at_return_type() const                    { return _at_return_type; }
+   bool is_done() const;
+   void next_non_primitive(int t);
+   void next() {
+-    symbolOop sig = _signature();
++    Symbol* sig = _signature;
+     int len = sig->utf8_length();
+     if (_end >= len) {
+       _end = len + 1;
+@@ -392,32 +386,28 @@
+     _end++;
+   }
+ 
+-  SignatureStream(symbolHandle signature,
+-                  bool is_method = true) :
+-                   _signature(signature), _at_return_type(false) {
+-    _begin = _end = (is_method ? 1 : 0);  // skip first '(' in method signatures
+-    next();
+-  }
++  SignatureStream(Symbol* signature, bool is_method = true);
++  ~SignatureStream();
+ 
+   bool is_object() const;                        // True if this argument is an object
+   bool is_array() const;                         // True if this argument is an array
+   BasicType type() const                         { return _type; }
+-  symbolOop as_symbol(TRAPS);
++  Symbol* as_symbol(TRAPS);
+   enum FailureMode { ReturnNull, CNFException, NCDFError };
+   klassOop as_klass(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
+   oop as_java_mirror(Handle class_loader, Handle protection_domain, FailureMode failure_mode, TRAPS);
+ 
+   // return same as_symbol except allocation of new symbols is avoided.
+-  symbolOop as_symbol_or_null();
++  Symbol* as_symbol_or_null();
+ };
+ 
+ class SignatureVerifier : public StackObj {
+   public:
+     // Returns true if the symbol is valid method or type signature
+-    static bool is_valid_signature(symbolHandle sig);
++    static bool is_valid_signature(Symbol* sig);
+ 
+-    static bool is_valid_method_signature(symbolHandle sig);
+-    static bool is_valid_type_signature(symbolHandle sig);
++    static bool is_valid_method_signature(Symbol* sig);
++    static bool is_valid_type_signature(Symbol* sig);
+   private:
+ 
+     static ssize_t is_valid_type(const char*, ssize_t);
+diff --git a/src/share/vm/runtime/statSampler.cpp b/src/share/vm/runtime/statSampler.cpp
+--- openjdk/hotspot/src/share/vm/runtime/statSampler.cpp
++++ openjdk/hotspot/src/share/vm/runtime/statSampler.cpp
+@@ -196,8 +196,8 @@
+   // public static String getProperty(String key, String def);
+   JavaCalls::call_static(&result,
+                          KlassHandle(THREAD, SystemDictionary::System_klass()),
+-                         vmSymbolHandles::getProperty_name(),
+-                         vmSymbolHandles::string_string_signature(),
++                         vmSymbols::getProperty_name(),
++                         vmSymbols::string_string_signature(),
+                          key_str,
+                          CHECK_NULL);
+ 
+diff --git a/src/share/vm/runtime/synchronizer.cpp b/src/share/vm/runtime/synchronizer.cpp
+--- openjdk/hotspot/src/share/vm/runtime/synchronizer.cpp
++++ openjdk/hotspot/src/share/vm/runtime/synchronizer.cpp
+@@ -82,7 +82,7 @@
+   char* bytes = NULL;                                                      \
+   int len = 0;                                                             \
+   jlong jtid = SharedRuntime::get_java_tid(thread);                        \
+-  symbolOop klassname = ((oop)(klassOop))->klass()->klass_part()->name();  \
++  Symbol* klassname = ((oop)(klassOop))->klass()->klass_part()->name();  \
+   if (klassname != NULL) {                                                 \
+     bytes = (char*)klassname->bytes();                                     \
+     len = klassname->utf8_length();                                        \
+diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp
+--- openjdk/hotspot/src/share/vm/runtime/thread.cpp
++++ openjdk/hotspot/src/share/vm/runtime/thread.cpp
+@@ -37,7 +37,7 @@
+ #include "oops/instanceKlass.hpp"
+ #include "oops/objArrayOop.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "prims/jvm_misc.hpp"
+ #include "prims/jvmtiExport.hpp"
+ #include "prims/jvmtiThreadState.hpp"
+@@ -891,7 +891,7 @@
+   return os::create_main_thread((JavaThread*)this);
+ }
+ 
+-static void initialize_class(symbolHandle class_name, TRAPS) {
++static void initialize_class(Symbol* class_name, TRAPS) {
+   klassOop klass = SystemDictionary::resolve_or_fail(class_name, true, CHECK);
+   instanceKlass::cast(klass)->initialize(CHECK);
+ }
+@@ -899,7 +899,7 @@
+ 
+ // Creates the initial ThreadGroup
+ static Handle create_initial_thread_group(TRAPS) {
+-  klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_ThreadGroup(), true, CHECK_NH);
++  klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_ThreadGroup(), true, CHECK_NH);
+   instanceKlassHandle klass (THREAD, k);
+ 
+   Handle system_instance = klass->allocate_instance_handle(CHECK_NH);
+@@ -908,8 +908,8 @@
+     JavaCalls::call_special(&result,
+                             system_instance,
+                             klass,
+-                            vmSymbolHandles::object_initializer_name(),
+-                            vmSymbolHandles::void_method_signature(),
++                            vmSymbols::object_initializer_name(),
++                            vmSymbols::void_method_signature(),
+                             CHECK_NH);
+   }
+   Universe::set_system_thread_group(system_instance());
+@@ -921,8 +921,8 @@
+     JavaCalls::call_special(&result,
+                             main_instance,
+                             klass,
+-                            vmSymbolHandles::object_initializer_name(),
+-                            vmSymbolHandles::threadgroup_string_void_signature(),
++                            vmSymbols::object_initializer_name(),
++                            vmSymbols::threadgroup_string_void_signature(),
+                             system_instance,
+                             string,
+                             CHECK_NH);
+@@ -932,7 +932,7 @@
+ 
+ // Creates the initial Thread
+ static oop create_initial_thread(Handle thread_group, JavaThread* thread, TRAPS) {
+-  klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_Thread(), true, CHECK_NULL);
++  klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK_NULL);
+   instanceKlassHandle klass (THREAD, k);
+   instanceHandle thread_oop = klass->allocate_instance_handle(CHECK_NULL);
+ 
+@@ -945,8 +945,8 @@
+   JavaValue result(T_VOID);
+   JavaCalls::call_special(&result, thread_oop,
+                                    klass,
+-                                   vmSymbolHandles::object_initializer_name(),
+-                                   vmSymbolHandles::threadgroup_string_void_signature(),
++                                   vmSymbols::object_initializer_name(),
++                                   vmSymbols::threadgroup_string_void_signature(),
+                                    thread_group,
+                                    string,
+                                    CHECK_NULL);
+@@ -954,12 +954,12 @@
+ }
+ 
+ static void call_initializeSystemClass(TRAPS) {
+-  klassOop k =  SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_System(), true, CHECK);
++  klassOop k =  SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
+   instanceKlassHandle klass (THREAD, k);
+ 
+   JavaValue result(T_VOID);
+-  JavaCalls::call_static(&result, klass, vmSymbolHandles::initializeSystemClass_name(),
+-                                         vmSymbolHandles::void_method_signature(), CHECK);
++  JavaCalls::call_static(&result, klass, vmSymbols::initializeSystemClass_name(),
++                                         vmSymbols::void_method_signature(), CHECK);
+ }
+ 
+ #ifdef KERNEL
+@@ -973,8 +973,8 @@
+   }
+ 
+   JavaValue result(T_VOID);
+-  JavaCalls::call_static(&result, klass, vmSymbolHandles::setBootClassLoaderHook_name(),
+-                                         vmSymbolHandles::void_method_signature(), CHECK);
++  JavaCalls::call_static(&result, klass, vmSymbols::setBootClassLoaderHook_name(),
++                                         vmSymbols::void_method_signature(), CHECK);
+ }
+ #endif // KERNEL
+ 
+@@ -985,8 +985,8 @@
+   instanceKlassHandle klass (THREAD, k);
+   if (klass.not_null()) {
+     JavaValue result(T_VOID);
+-    JavaCalls::call_static(&result, klass, vmSymbolHandles::run_method_name(),
+-                                           vmSymbolHandles::void_method_signature(),
++    JavaCalls::call_static(&result, klass, vmSymbols::run_method_name(),
++                                           vmSymbols::void_method_signature(),
+                                            CHECK);
+   }
+ }
+@@ -997,7 +997,7 @@
+   const char *vm_info = VM_Version::vm_info_string();
+ 
+   // java.lang.System class
+-  klassOop k =  SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_System(), true, CHECK);
++  klassOop k =  SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
+   instanceKlassHandle klass (THREAD, k);
+ 
+   // setProperty arguments
+@@ -1010,8 +1010,8 @@
+   // public static String setProperty(String key, String value);
+   JavaCalls::call_static(&r,
+                          klass,
+-                         vmSymbolHandles::setProperty_name(),
+-                         vmSymbolHandles::string_string_string_signature(),
++                         vmSymbols::setProperty_name(),
++                         vmSymbols::string_string_string_signature(),
+                          key_str,
+                          value_str,
+                          CHECK);
+@@ -1022,7 +1022,7 @@
+   assert(thread_group.not_null(), "thread group should be specified");
+   assert(threadObj() == NULL, "should only create Java thread object once");
+ 
+-  klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_Thread(), true, CHECK);
++  klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
+   instanceKlassHandle klass (THREAD, k);
+   instanceHandle thread_oop = klass->allocate_instance_handle(CHECK);
+ 
+@@ -1037,8 +1037,8 @@
+     JavaCalls::call_special(&result,
+                             thread_oop,
+                             klass,
+-                            vmSymbolHandles::object_initializer_name(),
+-                            vmSymbolHandles::threadgroup_string_void_signature(),
++                            vmSymbols::object_initializer_name(),
++                            vmSymbols::threadgroup_string_void_signature(),
+                             thread_group, // Argument 1
+                             name,         // Argument 2
+                             THREAD);
+@@ -1048,8 +1048,8 @@
+     JavaCalls::call_special(&result,
+                             thread_oop,
+                             klass,
+-                            vmSymbolHandles::object_initializer_name(),
+-                            vmSymbolHandles::threadgroup_runnable_void_signature(),
++                            vmSymbols::object_initializer_name(),
++                            vmSymbols::threadgroup_runnable_void_signature(),
+                             thread_group, // Argument 1
+                             Handle(),     // Argument 2
+                             THREAD);
+@@ -1070,8 +1070,8 @@
+   JavaCalls::call_special(&result,
+                          thread_group,
+                          group,
+-                         vmSymbolHandles::add_method_name(),
+-                         vmSymbolHandles::thread_void_signature(),
++                         vmSymbols::add_method_name(),
++                         vmSymbols::thread_void_signature(),
+                          threadObj,          // Arg 1
+                          THREAD);
+ 
+@@ -1590,8 +1590,8 @@
+         CallInfo callinfo;
+         KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
+         LinkResolver::resolve_virtual_call(callinfo, threadObj, recvrKlass, thread_klass,
+-                                           vmSymbolHandles::dispatchUncaughtException_name(),
+-                                           vmSymbolHandles::throwable_void_signature(),
++                                           vmSymbols::dispatchUncaughtException_name(),
++                                           vmSymbols::throwable_void_signature(),
+                                            KlassHandle(), false, false, THREAD);
+         CLEAR_PENDING_EXCEPTION;
+         methodHandle method = callinfo.selected_method();
+@@ -1599,8 +1599,8 @@
+           JavaValue result(T_VOID);
+           JavaCalls::call_virtual(&result,
+                                   threadObj, thread_klass,
+-                                  vmSymbolHandles::dispatchUncaughtException_name(),
+-                                  vmSymbolHandles::throwable_void_signature(),
++                                  vmSymbols::dispatchUncaughtException_name(),
++                                  vmSymbols::throwable_void_signature(),
+                                   uncaught_exception,
+                                   THREAD);
+         } else {
+@@ -1608,8 +1608,8 @@
+           JavaValue result(T_VOID);
+           JavaCalls::call_virtual(&result,
+                                   group, thread_group,
+-                                  vmSymbolHandles::uncaughtException_name(),
+-                                  vmSymbolHandles::thread_throwable_void_signature(),
++                                  vmSymbols::uncaughtException_name(),
++                                  vmSymbols::thread_throwable_void_signature(),
+                                   threadObj,           // Arg 1
+                                   uncaught_exception,  // Arg 2
+                                   THREAD);
+@@ -1628,8 +1628,8 @@
+         KlassHandle thread_klass(THREAD, SystemDictionary::Thread_klass());
+         JavaCalls::call_virtual(&result,
+                               threadObj, thread_klass,
+-                              vmSymbolHandles::exit_method_name(),
+-                              vmSymbolHandles::void_method_signature(),
++                              vmSymbols::exit_method_name(),
++                              vmSymbols::void_method_signature(),
+                               THREAD);
+         CLEAR_PENDING_EXCEPTION;
+       }
+@@ -3161,7 +3161,7 @@
+     }
+ 
+     if (InitializeJavaLangString) {
+-      initialize_class(vmSymbolHandles::java_lang_String(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_String(), CHECK_0);
+     } else {
+       warning("java.lang.String not initialized");
+     }
+@@ -3171,10 +3171,10 @@
+         // Forcibly initialize java/util/HashMap and mutate the private
+         // static final "frontCacheEnabled" field before we start creating instances
+ #ifdef ASSERT
+-        klassOop tmp_k = SystemDictionary::find(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0);
++        klassOop tmp_k = SystemDictionary::find(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0);
+         assert(tmp_k == NULL, "java/util/HashMap should not be loaded yet");
+ #endif
+-        klassOop k_o = SystemDictionary::resolve_or_null(vmSymbolHandles::java_util_HashMap(), Handle(), Handle(), CHECK_0);
++        klassOop k_o = SystemDictionary::resolve_or_null(vmSymbols::java_util_HashMap(), Handle(), Handle(), CHECK_0);
+         KlassHandle k = KlassHandle(THREAD, k_o);
+         guarantee(k.not_null(), "Must find java/util/HashMap");
+         instanceKlassHandle ik = instanceKlassHandle(THREAD, k());
+@@ -3189,7 +3189,7 @@
+       if (UseStringCache) {
+         // Forcibly initialize java/lang/StringValue and mutate the private
+         // static final "stringCacheEnabled" field before we start creating instances
+-        klassOop k_o = SystemDictionary::resolve_or_null(vmSymbolHandles::java_lang_StringValue(), Handle(), Handle(), CHECK_0);
++        klassOop k_o = SystemDictionary::resolve_or_null(vmSymbols::java_lang_StringValue(), Handle(), Handle(), CHECK_0);
+         // Possible that StringValue isn't present: if so, silently don't break
+         if (k_o != NULL) {
+           KlassHandle k = KlassHandle(THREAD, k_o);
+@@ -3206,11 +3206,11 @@
+ 
+     // Initialize java_lang.System (needed before creating the thread)
+     if (InitializeJavaLangSystem) {
+-      initialize_class(vmSymbolHandles::java_lang_System(), CHECK_0);
+-      initialize_class(vmSymbolHandles::java_lang_ThreadGroup(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_System(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_ThreadGroup(), CHECK_0);
+       Handle thread_group = create_initial_thread_group(CHECK_0);
+       Universe::set_main_thread_group(thread_group());
+-      initialize_class(vmSymbolHandles::java_lang_Thread(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_Thread(), CHECK_0);
+       oop thread_object = create_initial_thread(thread_group, main_thread, CHECK_0);
+       main_thread->set_threadObj(thread_object);
+       // Set thread status to running since main thread has
+@@ -3219,10 +3219,10 @@
+                                           java_lang_Thread::RUNNABLE);
+ 
+       // The VM preresolve methods to these classes. Make sure that get initialized
+-      initialize_class(vmSymbolHandles::java_lang_reflect_Method(), CHECK_0);
+-      initialize_class(vmSymbolHandles::java_lang_ref_Finalizer(),  CHECK_0);
++      initialize_class(vmSymbols::java_lang_reflect_Method(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_ref_Finalizer(),  CHECK_0);
+       // The VM creates & returns objects of this class. Make sure it's initialized.
+-      initialize_class(vmSymbolHandles::java_lang_Class(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_Class(), CHECK_0);
+       call_initializeSystemClass(CHECK_0);
+     } else {
+       warning("java.lang.System not initialized");
+@@ -3230,13 +3230,13 @@
+ 
+     // an instance of OutOfMemory exception has been allocated earlier
+     if (InitializeJavaLangExceptionsErrors) {
+-      initialize_class(vmSymbolHandles::java_lang_OutOfMemoryError(), CHECK_0);
+-      initialize_class(vmSymbolHandles::java_lang_NullPointerException(), CHECK_0);
+-      initialize_class(vmSymbolHandles::java_lang_ClassCastException(), CHECK_0);
+-      initialize_class(vmSymbolHandles::java_lang_ArrayStoreException(), CHECK_0);
+-      initialize_class(vmSymbolHandles::java_lang_ArithmeticException(), CHECK_0);
+-      initialize_class(vmSymbolHandles::java_lang_StackOverflowError(), CHECK_0);
+-      initialize_class(vmSymbolHandles::java_lang_IllegalMonitorStateException(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_OutOfMemoryError(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_NullPointerException(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_ClassCastException(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_ArrayStoreException(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_ArithmeticException(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_StackOverflowError(), CHECK_0);
++      initialize_class(vmSymbols::java_lang_IllegalMonitorStateException(), CHECK_0);
+     } else {
+       warning("java.lang.OutOfMemoryError has not been initialized");
+       warning("java.lang.NullPointerException has not been initialized");
+@@ -3262,7 +3262,7 @@
+   // Future Fix : the best fix is to grant everyone permissions to read "java.compiler" and
+   //              read and write"java.vm.info" in the default policy file. See bugid 4211383
+   //              Once that is done, we should remove this hack.
+-  initialize_class(vmSymbolHandles::java_lang_Compiler(), CHECK_0);
++  initialize_class(vmSymbols::java_lang_Compiler(), CHECK_0);
+ 
+   // More hackery - the static initializer of java.lang.Compiler adds the string "nojit" to
+   // the java.vm.info property if no jit gets loaded through java.lang.Compiler (the hotspot
+@@ -3588,7 +3588,7 @@
+ 
+   EXCEPTION_MARK;
+   klassOop k =
+-    SystemDictionary::resolve_or_null(vmSymbolHandles::java_lang_Shutdown(),
++    SystemDictionary::resolve_or_null(vmSymbols::java_lang_Shutdown(),
+                                       THREAD);
+   if (k != NULL) {
+     // SystemDictionary::resolve_or_null will return null if there was
+@@ -3602,8 +3602,8 @@
+     JavaValue result(T_VOID);
+     JavaCalls::call_static(&result,
+                            shutdown_klass,
+-                           vmSymbolHandles::shutdown_method_name(),
+-                           vmSymbolHandles::void_method_signature(),
++                           vmSymbols::shutdown_method_name(),
++                           vmSymbols::void_method_signature(),
+                            THREAD);
+   }
+   CLEAR_PENDING_EXCEPTION;
+diff --git a/src/share/vm/runtime/vframe.cpp b/src/share/vm/runtime/vframe.cpp
+--- openjdk/hotspot/src/share/vm/runtime/vframe.cpp
++++ openjdk/hotspot/src/share/vm/runtime/vframe.cpp
+@@ -552,7 +552,7 @@
+   tty->print("%s.%s", Klass::cast(k)->internal_name(), m->name()->as_C_string());
+ 
+   if (!m->is_native()) {
+-    symbolOop  source_name = instanceKlass::cast(k)->source_file_name();
++    Symbol*  source_name = instanceKlass::cast(k)->source_file_name();
+     int        line_number = m->line_number_from_bci(bci());
+     if (source_name != NULL && (line_number != -1)) {
+       tty->print("(%s:%d)", source_name->as_C_string(), line_number);
+diff --git a/src/share/vm/runtime/vmStructs.cpp b/src/share/vm/runtime/vmStructs.cpp
+--- openjdk/hotspot/src/share/vm/runtime/vmStructs.cpp
++++ openjdk/hotspot/src/share/vm/runtime/vmStructs.cpp
+@@ -83,8 +83,7 @@
+ #include "oops/objArrayKlassKlass.hpp"
+ #include "oops/objArrayOop.hpp"
+ #include "oops/oop.inline.hpp"
+-#include "oops/symbolKlass.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "oops/typeArrayKlass.hpp"
+ #include "oops/typeArrayKlassKlass.hpp"
+ #include "oops/typeArrayOop.hpp"
+@@ -246,8 +245,8 @@
+   nonstatic_field(instanceKlass,               _class_loader,                                 oop)                                   \
+   nonstatic_field(instanceKlass,               _protection_domain,                            oop)                                   \
+   nonstatic_field(instanceKlass,               _signers,                                      objArrayOop)                           \
+-  nonstatic_field(instanceKlass,               _source_file_name,                             symbolOop)                             \
+-  nonstatic_field(instanceKlass,               _source_debug_extension,                       symbolOop)                             \
++  nonstatic_field(instanceKlass,               _source_file_name,                             Symbol*)                               \
++  nonstatic_field(instanceKlass,               _source_debug_extension,                       Symbol*)                               \
+   nonstatic_field(instanceKlass,               _inner_classes,                                typeArrayOop)                          \
+   nonstatic_field(instanceKlass,               _nonstatic_field_size,                         int)                                   \
+   nonstatic_field(instanceKlass,               _static_field_size,                            int)                                   \
+@@ -265,7 +264,7 @@
+   nonstatic_field(instanceKlass,               _jni_ids,                                      JNIid*)                                \
+   nonstatic_field(instanceKlass,               _osr_nmethods_head,                            nmethod*)                              \
+   nonstatic_field(instanceKlass,               _breakpoints,                                  BreakpointInfo*)                       \
+-  nonstatic_field(instanceKlass,               _generic_signature,                            symbolOop)                             \
++  nonstatic_field(instanceKlass,               _generic_signature,                            Symbol*)                               \
+   nonstatic_field(instanceKlass,               _methods_jmethod_ids,                          jmethodID*)                            \
+   nonstatic_field(instanceKlass,               _methods_cached_itable_indices,                int*)                                  \
+   volatile_nonstatic_field(instanceKlass,      _idnum_allocated_count,                        u2)                                    \
+@@ -282,7 +281,7 @@
+   nonstatic_field(Klass,                       _modifier_flags,                               jint)                                  \
+   nonstatic_field(Klass,                       _super,                                        klassOop)                              \
+   nonstatic_field(Klass,                       _layout_helper,                                jint)                                  \
+-  nonstatic_field(Klass,                       _name,                                         symbolOop)                             \
++  nonstatic_field(Klass,                       _name,                                         Symbol*)                               \
+   nonstatic_field(Klass,                       _access_flags,                                 AccessFlags)                           \
+   nonstatic_field(Klass,                       _subklass,                                     klassOop)                              \
+   nonstatic_field(Klass,                       _next_sibling,                                 klassOop)                              \
+@@ -326,9 +325,10 @@
+   nonstatic_field(constMethodOopDesc,          _generic_signature_index,                      u2)                                    \
+   nonstatic_field(objArrayKlass,               _element_klass,                                klassOop)                              \
+   nonstatic_field(objArrayKlass,               _bottom_klass,                                 klassOop)                              \
+-  nonstatic_field(symbolKlass,                 _alloc_size,                                   juint)                                 \
+-  nonstatic_field(symbolOopDesc,               _length,                                       unsigned short)                        \
+-  unchecked_nonstatic_field(symbolOopDesc,     _body,                                         sizeof(jbyte)) /* NOTE: no type */     \
++  volatile_nonstatic_field(Symbol,             _refcount,                                     int)                                   \
++  nonstatic_field(Symbol,                      _identity_hash,                                int)                                   \
++  nonstatic_field(Symbol,                      _length,                                       unsigned short)                        \
++  unchecked_nonstatic_field(Symbol,            _body,                                         sizeof(jbyte)) /* NOTE: no type */     \
+   nonstatic_field(typeArrayKlass,              _max_length,                                   int)                                   \
+                                                                                                                                      \
+   /***********************/                                                                                                          \
+@@ -375,7 +375,6 @@
+      static_field(Universe,                    _longArrayKlassObj,                            klassOop)                              \
+      static_field(Universe,                    _singleArrayKlassObj,                          klassOop)                              \
+      static_field(Universe,                    _doubleArrayKlassObj,                          klassOop)                              \
+-     static_field(Universe,                    _symbolKlassObj,                               klassOop)                              \
+      static_field(Universe,                    _methodKlassObj,                               klassOop)                              \
+      static_field(Universe,                    _constMethodKlassObj,                          klassOop)                              \
+      static_field(Universe,                    _methodDataKlassObj,                           klassOop)                              \
+@@ -648,7 +647,7 @@
+                                                                                                                                      \
+   nonstatic_field(BasicHashtableEntry,         _next,                                         BasicHashtableEntry*)                  \
+   nonstatic_field(BasicHashtableEntry,         _hash,                                         unsigned int)                          \
+-  nonstatic_field(HashtableEntry,              _literal,                                      oop)                                   \
++  nonstatic_field(HashtableEntry<intptr_t>,    _literal,                                      intptr_t) \
+                                                                                                                                      \
+   /*************/                                                                                                                    \
+   /* Hashtable */                                                                                                                    \
+@@ -683,7 +682,7 @@
+   /* LoaderConstraintEntry */                                                                                                        \
+   /*************************/                                                                                                        \
+                                                                                                                                      \
+-  nonstatic_field(LoaderConstraintEntry,       _name,                                         symbolOop)                             \
++  nonstatic_field(LoaderConstraintEntry,       _name,                                         Symbol*)                               \
+   nonstatic_field(LoaderConstraintEntry,       _num_loaders,                                  int)                                   \
+   nonstatic_field(LoaderConstraintEntry,       _max_loaders,                                  int)                                   \
+   nonstatic_field(LoaderConstraintEntry,       _loaders,                                      oop*)                                  \
+@@ -1097,11 +1096,11 @@
+            declare_type(objArrayKlassKlass, arrayKlassKlass)              \
+            declare_type(objArrayOopDesc, arrayOopDesc)                    \
+            declare_type(constMethodOopDesc, oopDesc)                      \
+-           declare_type(symbolKlass, Klass)                               \
+-           declare_type(symbolOopDesc, oopDesc)                           \
+            declare_type(typeArrayKlass, arrayKlass)                       \
+            declare_type(typeArrayKlassKlass, arrayKlassKlass)             \
+            declare_type(typeArrayOopDesc, arrayOopDesc)                   \
++           declare_toplevel_type(Symbol)                                  \
++           declare_toplevel_type(Symbol*)                                 \
+                                                                           \
+   /********/                                                              \
+   /* Oops */                                                              \
+@@ -1118,7 +1117,6 @@
+   declare_oop_type(narrowOop)                                             \
+   declare_oop_type(wideKlassOop)                                          \
+   declare_oop_type(constMethodOop)                                        \
+-  declare_oop_type(symbolOop)                                             \
+   declare_oop_type(typeArrayOop)                                          \
+                                                                           \
+   /*************************************/                                 \
+@@ -1216,33 +1214,21 @@
+   /*********************************/                                     \
+                                                                           \
+   declare_toplevel_type(BasicHashtable)                                   \
+-    declare_type(Hashtable, BasicHashtable)                               \
+-    declare_type(SymbolTable, Hashtable)                                  \
+-    declare_type(StringTable, Hashtable)                                  \
+-    declare_type(LoaderConstraintTable, Hashtable)                        \
+-    declare_type(TwoOopHashtable, Hashtable)                              \
+-    declare_type(Dictionary, TwoOopHashtable)                             \
+-    declare_type(PlaceholderTable, TwoOopHashtable)                       \
+-  declare_toplevel_type(Hashtable*)                                       \
+-  declare_toplevel_type(SymbolTable*)                                     \
+-  declare_toplevel_type(StringTable*)                                     \
+-  declare_toplevel_type(LoaderConstraintTable*)                           \
+-  declare_toplevel_type(TwoOopHashtable*)                                 \
+-  declare_toplevel_type(Dictionary*)                                      \
+-  declare_toplevel_type(PlaceholderTable*)                                \
++    declare_type(Hashtable<intptr_t>, BasicHashtable)                     \
++  declare_type(SymbolTable, Hashtable<Symbol*>)                           \
++  declare_type(StringTable, Hashtable<oop>)                               \
++    declare_type(LoaderConstraintTable, Hashtable<klassOop>)              \
++    declare_type(TwoOopHashtable<klassOop>, Hashtable<klassOop>)          \
++    declare_type(Dictionary, TwoOopHashtable<klassOop>)                   \
++    declare_type(PlaceholderTable, TwoOopHashtable<Symbol*>)              \
+   declare_toplevel_type(BasicHashtableEntry)                              \
+-  declare_toplevel_type(BasicHashtableEntry*)                             \
+-    declare_type(HashtableEntry, BasicHashtableEntry)                     \
+-    declare_type(DictionaryEntry, HashtableEntry)                         \
+-    declare_type(PlaceholderEntry, HashtableEntry)                        \
+-    declare_type(LoaderConstraintEntry, HashtableEntry)                   \
+-  declare_toplevel_type(HashtableEntry*)                                  \
+-  declare_toplevel_type(DictionaryEntry*)                                 \
++  declare_type(HashtableEntry<intptr_t>, BasicHashtableEntry)             \
++    declare_type(DictionaryEntry, HashtableEntry<klassOop>)               \
++    declare_type(PlaceholderEntry, HashtableEntry<Symbol*>)               \
++    declare_type(LoaderConstraintEntry, HashtableEntry<klassOop>)         \
+   declare_toplevel_type(HashtableBucket)                                  \
+-  declare_toplevel_type(HashtableBucket*)                                 \
+   declare_toplevel_type(SystemDictionary)                                 \
+   declare_toplevel_type(ProtectionDomainEntry)                            \
+-  declare_toplevel_type(ProtectionDomainEntry*)                           \
+                                                                           \
+   /***********************************************************/           \
+   /* Thread hierarchy (needed for run-time type information) */           \
+@@ -1677,10 +1663,10 @@
+   declare_constant(instanceKlass::initialization_error)                   \
+                                                                           \
+   /*********************************/                                     \
+-  /* symbolOop - symbol max length */                                     \
++  /* Symbol* - symbol max length */                                     \
+   /*********************************/                                     \
+                                                                           \
+-  declare_constant(symbolOopDesc::max_symbol_length)                      \
++  declare_constant(Symbol::max_symbol_length)                             \
+                                                                           \
+   /*************************************************/                     \
+   /* constantPoolOop layout enum for InvokeDynamic */                     \
+@@ -2432,17 +2418,69 @@
+ }
+ 
+ #ifdef ASSERT
++static int recursiveFindType(VMTypeEntry* origtypes, const char* typeName, bool isRecurse) {
++  {
++    VMTypeEntry* types = origtypes;
++    while (types->typeName != NULL) {
++      if (!strcmp(typeName, types->typeName)) {
++        return 1;
++      }
++      ++types;
++    }
++  }
++  size_t len = strlen(typeName);
++  if (typeName[len-1] == '*') {
++    char * s = new char[len];
++    strncpy(s, typeName, len - 1);
++    s[len-1] = '\0';
++    // tty->print_cr("checking \"%s\" for \"%s\"", s, typeName);
++    if (recursiveFindType(origtypes, s, true) == 1) {
++      delete s;
++      return 1;
++    }
++    delete s;
++  }
++  if (strstr(typeName, "GrowableArray<") == typeName) {
++    const char * start = typeName + strlen("GrowableArray<");
++    const char * end = strrchr(typeName, '>');
++    int len = end - start + 1;
++    char * s = new char[len];
++    strncpy(s, start, len - 1);
++    s[len-1] = '\0';
++    // tty->print_cr("checking \"%s\" for \"%s\"", s, typeName);
++    if (recursiveFindType(origtypes, s, true) == 1) {
++      delete s;
++      return 1;
++    }
++    delete s;
++  }
++  if (strstr(typeName, "const ") == typeName) {
++    const char * s = typeName + strlen("const ");
++    // tty->print_cr("checking \"%s\" for \"%s\"", s, typeName);
++    if (recursiveFindType(origtypes, s, true) == 1) {
++      return 1;
++    }
++  }
++  if (strstr(typeName, " const") == typeName + len - 6) {
++    char * s = strdup(typeName);
++    s[len - 6] = '\0';
++    // tty->print_cr("checking \"%s\" for \"%s\"", s, typeName);
++    if (recursiveFindType(origtypes, s, true) == 1) {
++      return 1;
++    }
++  }
++  if (!isRecurse) {
++    tty->print_cr("type \"%s\" not found", typeName);
++  }
++  return 2;
++}
++
++
+ int
+ VMStructs::findType(const char* typeName) {
+   VMTypeEntry* types = gHotSpotVMTypes;
+ 
+-  while (types->typeName != NULL) {
+-    if (!strcmp(typeName, types->typeName)) {
+-      return 1;
+-    }
+-    ++types;
+-  }
+-  return 0;
++  return recursiveFindType(types, typeName, false);
+ }
+ #endif
+ 
+diff --git a/src/share/vm/runtime/vmStructs.hpp b/src/share/vm/runtime/vmStructs.hpp
+--- openjdk/hotspot/src/share/vm/runtime/vmStructs.hpp
++++ openjdk/hotspot/src/share/vm/runtime/vmStructs.hpp
+@@ -68,7 +68,7 @@
+ typedef struct {
+   const char* typeName;            // The type name containing the given field (example: "Klass")
+   const char* fieldName;           // The field name within the type           (example: "_name")
+-  const char* typeString;          // Quoted name of the type of this field (example: "symbolOopDesc*";
++  const char* typeString;          // Quoted name of the type of this field (example: "Symbol*";
+                                    // parsed in Java to ensure type correctness
+   int32_t  isStatic;               // Indicates whether following field is an offset or an address
+   uint64_t offset;                 // Offset of field within structure; only used for nonstatic fields
+diff --git a/src/share/vm/runtime/vm_operations.cpp b/src/share/vm/runtime/vm_operations.cpp
+--- openjdk/hotspot/src/share/vm/runtime/vm_operations.cpp
++++ openjdk/hotspot/src/share/vm/runtime/vm_operations.cpp
+@@ -23,11 +23,13 @@
+  */
+ 
+ #include "precompiled.hpp"
++#include "classfile/symbolTable.hpp"
+ #include "classfile/vmSymbols.hpp"
+ #include "compiler/compileBroker.hpp"
+ #include "compiler/compilerOracle.hpp"
+ #include "gc_implementation/shared/isGCActiveMark.hpp"
+ #include "memory/resourceArea.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/arguments.hpp"
+ #include "runtime/deoptimization.hpp"
+ #include "runtime/interfaceSupport.hpp"
+@@ -170,6 +172,12 @@
+ 
+ #endif // !PRODUCT
+ 
++void VM_UnlinkSymbols::doit() {
++  JavaThread *thread = (JavaThread *)calling_thread();
++  assert(thread->is_Java_thread(), "must be a Java thread");
++  SymbolTable::unlink();
++}
++
+ void VM_HandleFullCodeCache::doit() {
+   NMethodSweeper::speculative_disconnect_nmethods(_is_full);
+ }
+diff --git a/src/share/vm/runtime/vm_operations.hpp b/src/share/vm/runtime/vm_operations.hpp
+--- openjdk/hotspot/src/share/vm/runtime/vm_operations.hpp
++++ openjdk/hotspot/src/share/vm/runtime/vm_operations.hpp
+@@ -50,6 +50,7 @@
+   template(DeoptimizeFrame)                       \
+   template(DeoptimizeAll)                         \
+   template(ZombieAll)                             \
++  template(UnlinkSymbols)                         \
+   template(HandleFullCodeCache)                   \
+   template(Verify)                                \
+   template(PrintJNI)                              \
+@@ -288,6 +289,14 @@
+ };
+ #endif // PRODUCT
+ 
++class VM_UnlinkSymbols: public VM_Operation {
++ public:
++  VM_UnlinkSymbols() {}
++  VMOp_Type type() const                         { return VMOp_UnlinkSymbols; }
++  void doit();
++  bool allow_nested_vm_operations() const        { return true; }
++};
++
+ class VM_Verify: public VM_Operation {
+  private:
+   KlassHandle _dependee;
+diff --git a/src/share/vm/services/attachListener.cpp b/src/share/vm/services/attachListener.cpp
+--- openjdk/hotspot/src/share/vm/services/attachListener.cpp
++++ openjdk/hotspot/src/share/vm/services/attachListener.cpp
+@@ -43,7 +43,7 @@
+ // Invokes sun.misc.VMSupport.serializePropertiesToByteArray to serialize
+ // the system properties into a byte array.
+ 
+-static klassOop load_and_initialize_klass(symbolHandle sh, TRAPS) {
++static klassOop load_and_initialize_klass(Symbol* sh, TRAPS) {
+   klassOop k = SystemDictionary::resolve_or_fail(sh, true, CHECK_NULL);
+   instanceKlassHandle ik (THREAD, k);
+   if (ik->should_be_initialized()) {
+@@ -52,12 +52,12 @@
+   return ik();
+ }
+ 
+-static jint get_properties(AttachOperation* op, outputStream* out, symbolHandle serializePropertiesMethod) {
++static jint get_properties(AttachOperation* op, outputStream* out, Symbol* serializePropertiesMethod) {
+   Thread* THREAD = Thread::current();
+   HandleMark hm;
+ 
+   // load sun.misc.VMSupport
+-  symbolHandle klass = vmSymbolHandles::sun_misc_VMSupport();
++  Symbol* klass = vmSymbols::sun_misc_VMSupport();
+   klassOop k = load_and_initialize_klass(klass, THREAD);
+   if (HAS_PENDING_EXCEPTION) {
+     java_lang_Throwable::print(PENDING_EXCEPTION, out);
+@@ -71,7 +71,7 @@
+   JavaCallArguments args;
+ 
+ 
+-  symbolHandle signature = vmSymbolHandles::serializePropertiesToByteArray_signature();
++  Symbol* signature = vmSymbols::serializePropertiesToByteArray_signature();
+   JavaCalls::call_static(&result,
+                            ik,
+                            serializePropertiesMethod,
+@@ -99,12 +99,12 @@
+ 
+ // Implementation of "properties" command.
+ static jint get_system_properties(AttachOperation* op, outputStream* out) {
+-  return get_properties(op, out, vmSymbolHandles::serializePropertiesToByteArray_name());
++  return get_properties(op, out, vmSymbols::serializePropertiesToByteArray_name());
+ }
+ 
+ // Implementation of "agent_properties" command.
+ static jint get_agent_properties(AttachOperation* op, outputStream* out) {
+-  return get_properties(op, out, vmSymbolHandles::serializeAgentPropertiesToByteArray_name());
++  return get_properties(op, out, vmSymbols::serializeAgentPropertiesToByteArray_name());
+ }
+ 
+ // Implementation of "datadump" command.
+@@ -430,7 +430,7 @@
+ // Starts the Attach Listener thread
+ void AttachListener::init() {
+   EXCEPTION_MARK;
+-  klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_Thread(), true, CHECK);
++  klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_Thread(), true, CHECK);
+   instanceKlassHandle klass (THREAD, k);
+   instanceHandle thread_oop = klass->allocate_instance_handle(CHECK);
+ 
+@@ -442,8 +442,8 @@
+   JavaValue result(T_VOID);
+   JavaCalls::call_special(&result, thread_oop,
+                        klass,
+-                       vmSymbolHandles::object_initializer_name(),
+-                       vmSymbolHandles::threadgroup_string_void_signature(),
++                       vmSymbols::object_initializer_name(),
++                       vmSymbols::threadgroup_string_void_signature(),
+                        thread_group,
+                        string,
+                        CHECK);
+@@ -452,8 +452,8 @@
+   JavaCalls::call_special(&result,
+                         thread_group,
+                         group,
+-                        vmSymbolHandles::add_method_name(),
+-                        vmSymbolHandles::thread_void_signature(),
++                        vmSymbols::add_method_name(),
++                        vmSymbols::thread_void_signature(),
+                         thread_oop,             // ARG 1
+                         CHECK);
+ 
+diff --git a/src/share/vm/services/classLoadingService.cpp b/src/share/vm/services/classLoadingService.cpp
+--- openjdk/hotspot/src/share/vm/services/classLoadingService.cpp
++++ openjdk/hotspot/src/share/vm/services/classLoadingService.cpp
+@@ -43,7 +43,7 @@
+   {                                                 \
+     char* data = NULL;                              \
+     int len = 0;                                    \
+-    symbolOop name = (clss)->name();                \
++    Symbol* name = (clss)->name();                  \
+     if (name != NULL) {                             \
+       data = (char*)name->bytes();                  \
+       len = name->utf8_length();                    \
+diff --git a/src/share/vm/services/heapDumper.cpp b/src/share/vm/services/heapDumper.cpp
+--- openjdk/hotspot/src/share/vm/services/heapDumper.cpp
++++ openjdk/hotspot/src/share/vm/services/heapDumper.cpp
+@@ -425,6 +425,7 @@
+   void write_u4(u4 x);
+   void write_u8(u8 x);
+   void write_objectID(oop o);
++  void write_symbolID(Symbol* o);
+   void write_classID(Klass* k);
+   void write_id(u4 x);
+ };
+@@ -568,6 +569,15 @@
+ #endif
+ }
+ 
++void DumpWriter::write_symbolID(Symbol* s) {
++  address a = (address)((uintptr_t)s);
++#ifdef _LP64
++  write_u8((u8)a);
++#else
++  write_u4((u4)a);
++#endif
++}
++
+ void DumpWriter::write_id(u4 x) {
+ #ifdef _LP64
+   write_u8((u8) x);
+@@ -592,7 +602,7 @@
+   static void write_header(DumpWriter* writer, hprofTag tag, u4 len);
+ 
+   // returns hprof tag for the given type signature
+-  static hprofTag sig2tag(symbolOop sig);
++  static hprofTag sig2tag(Symbol* sig);
+   // returns hprof tag for the given basic type
+   static hprofTag type2tag(BasicType type);
+ 
+@@ -636,7 +646,7 @@
+ }
+ 
+ // returns hprof tag for the given type signature
+-hprofTag DumperSupport::sig2tag(symbolOop sig) {
++hprofTag DumperSupport::sig2tag(Symbol* sig) {
+   switch (sig->byte_at(0)) {
+     case JVM_SIGNATURE_CLASS    : return HPROF_NORMAL_OBJECT;
+     case JVM_SIGNATURE_ARRAY    : return HPROF_NORMAL_OBJECT;
+@@ -775,7 +785,7 @@
+ 
+   for (FieldStream fld(ikh, false, false); !fld.eos(); fld.next()) {
+     if (!fld.access_flags().is_static()) {
+-      symbolOop sig = fld.signature();
++      Symbol* sig = fld.signature();
+       switch (sig->byte_at(0)) {
+         case JVM_SIGNATURE_CLASS   :
+         case JVM_SIGNATURE_ARRAY   : size += oopSize; break;
+@@ -815,9 +825,9 @@
+   // pass 2 - dump the field descriptors and raw values
+   for (FieldStream fld(ikh, true, true); !fld.eos(); fld.next()) {
+     if (fld.access_flags().is_static()) {
+-      symbolOop sig = fld.signature();
++      Symbol* sig = fld.signature();
+ 
+-      writer->write_objectID(fld.name());   // name
++      writer->write_symbolID(fld.name());   // name
+       writer->write_u1(sig2tag(sig));       // type
+ 
+       // value
+@@ -836,7 +846,7 @@
+ 
+   for (FieldStream fld(ikh, false, false); !fld.eos(); fld.next()) {
+     if (!fld.access_flags().is_static()) {
+-      symbolOop sig = fld.signature();
++      Symbol* sig = fld.signature();
+       address addr = (address)o + fld.offset();
+ 
+       dump_field_value(writer, sig->byte_at(0), addr);
+@@ -860,9 +870,9 @@
+   // pass 2 - dump the field descriptors
+   for (FieldStream fld(ikh, true, true); !fld.eos(); fld.next()) {
+     if (!fld.access_flags().is_static()) {
+-      symbolOop sig = fld.signature();
++      Symbol* sig = fld.signature();
+ 
+-      writer->write_objectID(fld.name());                   // name
++      writer->write_symbolID(fld.name());                   // name
+       writer->write_u1(sig2tag(sig));       // type
+     }
+   }
+@@ -1115,42 +1125,40 @@
+ 
+   write_header(writer, HPROF_FRAME, 4*oopSize + 2*sizeof(u4));
+   writer->write_id(frame_serial_num);               // frame serial number
+-  writer->write_objectID(m->name());                // method's name
+-  writer->write_objectID(m->signature());           // method's signature
++  writer->write_symbolID(m->name());                // method's name
++  writer->write_symbolID(m->signature());           // method's signature
+ 
+   assert(Klass::cast(m->method_holder())->oop_is_instance(), "not instanceKlass");
+-  writer->write_objectID(instanceKlass::cast(m->method_holder())->source_file_name());  // source file name
++  writer->write_symbolID(instanceKlass::cast(m->method_holder())->source_file_name());  // source file name
+   writer->write_u4(class_serial_num);               // class serial number
+   writer->write_u4((u4) line_number);               // line number
+ }
+ 
++
+ // Support class used to generate HPROF_UTF8 records from the entries in the
+ // SymbolTable.
+ 
+-class SymbolTableDumper : public OopClosure {
++class SymbolTableDumper : public SymbolClosure {
+  private:
+   DumpWriter* _writer;
+   DumpWriter* writer() const                { return _writer; }
+  public:
+   SymbolTableDumper(DumpWriter* writer)     { _writer = writer; }
+-  void do_oop(oop* obj_p);
+-  void do_oop(narrowOop* obj_p) { ShouldNotReachHere(); }
++  void do_symbol(Symbol** p);
+ };
+ 
+-void SymbolTableDumper::do_oop(oop* obj_p) {
++void SymbolTableDumper::do_symbol(Symbol** p) {
+   ResourceMark rm;
+-  symbolOop sym = (symbolOop)*obj_p;
+-
++  Symbol* sym = load_symbol(p);
+   int len = sym->utf8_length();
+   if (len > 0) {
+     char* s = sym->as_utf8();
+     DumperSupport::write_header(writer(), HPROF_UTF8, oopSize + len);
+-    writer()->write_objectID(sym);
++    writer()->write_symbolID(sym);
+     writer()->write_raw(s, len);
+   }
+ }
+ 
+-
+ // Support class used to generate HPROF_GC_ROOT_JNI_LOCAL records
+ 
+ class JNILocalsDumper : public OopClosure {
+@@ -1548,8 +1556,8 @@
+     writer()->write_u4(STACK_TRACE_ID);
+ 
+     // class name ID
+-    symbolOop name = klass->name();
+-    writer()->write_objectID(name);
++    Symbol* name = klass->name();
++    writer()->write_symbolID(name);
+ 
+     // write a LOAD_CLASS record for the array type (if it exists)
+     k = klass->array_klass_or_null();
+@@ -1727,7 +1735,7 @@
+ 
+   // HPROF_UTF8 records
+   SymbolTableDumper sym_dumper(writer());
+-  SymbolTable::oops_do(&sym_dumper);
++  SymbolTable::symbols_do(&sym_dumper);
+ 
+   // write HPROF_LOAD_CLASS records
+   SystemDictionary::classes_do(&do_load_class);
+diff --git a/src/share/vm/services/lowMemoryDetector.cpp b/src/share/vm/services/lowMemoryDetector.cpp
+--- openjdk/hotspot/src/share/vm/services/lowMemoryDetector.cpp
++++ openjdk/hotspot/src/share/vm/services/lowMemoryDetector.cpp
+@@ -52,8 +52,8 @@
+   JavaValue result(T_VOID);
+   JavaCalls::call_special(&result, thread_oop,
+                           klass,
+-                          vmSymbolHandles::object_initializer_name(),
+-                          vmSymbolHandles::threadgroup_string_void_signature(),
++                          vmSymbols::object_initializer_name(),
++                          vmSymbols::threadgroup_string_void_signature(),
+                           thread_group,
+                           string,
+                           CHECK);
+@@ -377,8 +377,8 @@
+ 
+     JavaCalls::call_virtual(&result,
+                             sensorKlass,
+-                            vmSymbolHandles::trigger_name(),
+-                            vmSymbolHandles::trigger_method_signature(),
++                            vmSymbols::trigger_name(),
++                            vmSymbols::trigger_method_signature(),
+                             &args,
+                             CHECK);
+   }
+@@ -403,8 +403,8 @@
+     args.push_int((int) count);
+     JavaCalls::call_virtual(&result,
+                             sensorKlass,
+-                            vmSymbolHandles::clear_name(),
+-                            vmSymbolHandles::int_void_signature(),
++                            vmSymbols::clear_name(),
++                            vmSymbols::int_void_signature(),
+                             &args,
+                             CHECK);
+   }
+diff --git a/src/share/vm/services/management.cpp b/src/share/vm/services/management.cpp
+--- openjdk/hotspot/src/share/vm/services/management.cpp
++++ openjdk/hotspot/src/share/vm/services/management.cpp
+@@ -122,7 +122,7 @@
+     // Load and initialize the sun.management.Agent class
+     // invoke startAgent method to start the management server
+     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
+-    klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::sun_management_Agent(),
++    klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::sun_management_Agent(),
+                                                    loader,
+                                                    Handle(),
+                                                    true,
+@@ -132,8 +132,8 @@
+     JavaValue result(T_VOID);
+     JavaCalls::call_static(&result,
+                            ik,
+-                           vmSymbolHandles::startAgent_name(),
+-                           vmSymbolHandles::void_method_signature(),
++                           vmSymbols::startAgent_name(),
++                           vmSymbols::void_method_signature(),
+                            CHECK);
+   }
+ }
+@@ -142,7 +142,7 @@
+   memcpy(support, &_optional_support, sizeof(jmmOptionalSupport));
+ }
+ 
+-klassOop Management::load_and_initialize_klass(symbolHandle sh, TRAPS) {
++klassOop Management::load_and_initialize_klass(Symbol* sh, TRAPS) {
+   klassOop k = SystemDictionary::resolve_or_fail(sh, true, CHECK_NULL);
+   instanceKlassHandle ik (THREAD, k);
+   if (ik->should_be_initialized()) {
+@@ -182,49 +182,49 @@
+ 
+ klassOop Management::java_lang_management_ThreadInfo_klass(TRAPS) {
+   if (_threadInfo_klass == NULL) {
+-    _threadInfo_klass = load_and_initialize_klass(vmSymbolHandles::java_lang_management_ThreadInfo(), CHECK_NULL);
++    _threadInfo_klass = load_and_initialize_klass(vmSymbols::java_lang_management_ThreadInfo(), CHECK_NULL);
+   }
+   return _threadInfo_klass;
+ }
+ 
+ klassOop Management::java_lang_management_MemoryUsage_klass(TRAPS) {
+   if (_memoryUsage_klass == NULL) {
+-    _memoryUsage_klass = load_and_initialize_klass(vmSymbolHandles::java_lang_management_MemoryUsage(), CHECK_NULL);
++    _memoryUsage_klass = load_and_initialize_klass(vmSymbols::java_lang_management_MemoryUsage(), CHECK_NULL);
+   }
+   return _memoryUsage_klass;
+ }
+ 
+ klassOop Management::java_lang_management_MemoryPoolMXBean_klass(TRAPS) {
+   if (_memoryPoolMXBean_klass == NULL) {
+-    _memoryPoolMXBean_klass = load_and_initialize_klass(vmSymbolHandles::java_lang_management_MemoryPoolMXBean(), CHECK_NULL);
++    _memoryPoolMXBean_klass = load_and_initialize_klass(vmSymbols::java_lang_management_MemoryPoolMXBean(), CHECK_NULL);
+   }
+   return _memoryPoolMXBean_klass;
+ }
+ 
+ klassOop Management::java_lang_management_MemoryManagerMXBean_klass(TRAPS) {
+   if (_memoryManagerMXBean_klass == NULL) {
+-    _memoryManagerMXBean_klass = load_and_initialize_klass(vmSymbolHandles::java_lang_management_MemoryManagerMXBean(), CHECK_NULL);
++    _memoryManagerMXBean_klass = load_and_initialize_klass(vmSymbols::java_lang_management_MemoryManagerMXBean(), CHECK_NULL);
+   }
+   return _memoryManagerMXBean_klass;
+ }
+ 
+ klassOop Management::java_lang_management_GarbageCollectorMXBean_klass(TRAPS) {
+   if (_garbageCollectorMXBean_klass == NULL) {
+-      _garbageCollectorMXBean_klass = load_and_initialize_klass(vmSymbolHandles::java_lang_management_GarbageCollectorMXBean(), CHECK_NULL);
++      _garbageCollectorMXBean_klass = load_and_initialize_klass(vmSymbols::java_lang_management_GarbageCollectorMXBean(), CHECK_NULL);
+   }
+   return _garbageCollectorMXBean_klass;
+ }
+ 
+ klassOop Management::sun_management_Sensor_klass(TRAPS) {
+   if (_sensor_klass == NULL) {
+-    _sensor_klass = load_and_initialize_klass(vmSymbolHandles::sun_management_Sensor(), CHECK_NULL);
++    _sensor_klass = load_and_initialize_klass(vmSymbols::sun_management_Sensor(), CHECK_NULL);
+   }
+   return _sensor_klass;
+ }
+ 
+ klassOop Management::sun_management_ManagementFactory_klass(TRAPS) {
+   if (_managementFactory_klass == NULL) {
+-    _managementFactory_klass = load_and_initialize_klass(vmSymbolHandles::sun_management_ManagementFactory(), CHECK_NULL);
++    _managementFactory_klass = load_and_initialize_klass(vmSymbols::sun_management_ManagementFactory(), CHECK_NULL);
+   }
+   return _managementFactory_klass;
+ }
+@@ -290,8 +290,8 @@
+   // Call ThreadInfo constructor with no locked monitors and synchronizers
+   JavaCalls::call_special(&result,
+                           ik,
+-                          vmSymbolHandles::object_initializer_name(),
+-                          vmSymbolHandles::java_lang_management_ThreadInfo_constructor_signature(),
++                          vmSymbols::object_initializer_name(),
++                          vmSymbols::java_lang_management_ThreadInfo_constructor_signature(),
+                           &args,
+                           CHECK_NULL);
+ 
+@@ -325,8 +325,8 @@
+   // Call ThreadInfo constructor with locked monitors and synchronizers
+   JavaCalls::call_special(&result,
+                           ik,
+-                          vmSymbolHandles::object_initializer_name(),
+-                          vmSymbolHandles::java_lang_management_ThreadInfo_with_locks_constructor_signature(),
++                          vmSymbols::object_initializer_name(),
++                          vmSymbols::java_lang_management_ThreadInfo_with_locks_constructor_signature(),
+                           &args,
+                           CHECK_NULL);
+ 
+diff --git a/src/share/vm/services/management.hpp b/src/share/vm/services/management.hpp
+--- openjdk/hotspot/src/share/vm/services/management.hpp
++++ openjdk/hotspot/src/share/vm/services/management.hpp
+@@ -50,7 +50,7 @@
+   static klassOop           _garbageCollectorMXBean_klass;
+   static klassOop           _managementFactory_klass;
+ 
+-  static klassOop load_and_initialize_klass(symbolHandle sh, TRAPS);
++  static klassOop load_and_initialize_klass(Symbol* sh, TRAPS);
+ 
+ public:
+   static void init();
+diff --git a/src/share/vm/services/memoryManager.cpp b/src/share/vm/services/memoryManager.cpp
+--- openjdk/hotspot/src/share/vm/services/memoryManager.cpp
++++ openjdk/hotspot/src/share/vm/services/memoryManager.cpp
+@@ -106,15 +106,15 @@
+     JavaCallArguments args;
+     args.push_oop(mgr_name);    // Argument 1
+ 
+-    symbolHandle method_name;
+-    symbolHandle signature;
++    Symbol* method_name = NULL;
++    Symbol* signature = NULL;
+     if (is_gc_memory_manager()) {
+-      method_name = vmSymbolHandles::createGarbageCollector_name();
+-      signature = vmSymbolHandles::createGarbageCollector_signature();
++      method_name = vmSymbols::createGarbageCollector_name();
++      signature = vmSymbols::createGarbageCollector_signature();
+       args.push_oop(Handle());      // Argument 2 (for future extension)
+     } else {
+-      method_name = vmSymbolHandles::createMemoryManager_name();
+-      signature = vmSymbolHandles::createMemoryManager_signature();
++      method_name = vmSymbols::createMemoryManager_name();
++      signature = vmSymbols::createMemoryManager_signature();
+     }
+ 
+     JavaCalls::call_static(&result,
+diff --git a/src/share/vm/services/memoryPool.cpp b/src/share/vm/services/memoryPool.cpp
+--- openjdk/hotspot/src/share/vm/services/memoryPool.cpp
++++ openjdk/hotspot/src/share/vm/services/memoryPool.cpp
+@@ -89,8 +89,8 @@
+     args.push_oop(pool_name);           // Argument 1
+     args.push_int((int) is_heap());     // Argument 2
+ 
+-    symbolHandle method_name = vmSymbolHandles::createMemoryPool_name();
+-    symbolHandle signature = vmSymbolHandles::createMemoryPool_signature();
++    Symbol* method_name = vmSymbols::createMemoryPool_name();
++    Symbol* signature = vmSymbols::createMemoryPool_signature();
+ 
+     args.push_long(usage_threshold_value);    // Argument 3
+     args.push_long(gc_usage_threshold_value); // Argument 4
+diff --git a/src/share/vm/services/memoryService.cpp b/src/share/vm/services/memoryService.cpp
+--- openjdk/hotspot/src/share/vm/services/memoryService.cpp
++++ openjdk/hotspot/src/share/vm/services/memoryService.cpp
+@@ -619,8 +619,8 @@
+ 
+   JavaCalls::call_special(&result,
+                           ik,
+-                          vmSymbolHandles::object_initializer_name(),
+-                          vmSymbolHandles::long_long_long_long_void_signature(),
++                          vmSymbols::object_initializer_name(),
++                          vmSymbols::long_long_long_long_void_signature(),
+                           &args,
+                           CHECK_NH);
+   return obj;
+diff --git a/src/share/vm/services/threadService.cpp b/src/share/vm/services/threadService.cpp
+--- openjdk/hotspot/src/share/vm/services/threadService.cpp
++++ openjdk/hotspot/src/share/vm/services/threadService.cpp
+@@ -249,7 +249,7 @@
+   // Allocate the resulting StackTraceElement[][] object
+ 
+   ResourceMark rm(THREAD);
+-  klassOop k = SystemDictionary::resolve_or_fail(vmSymbolHandles::java_lang_StackTraceElement_array(), true, CHECK_NH);
++  klassOop k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_StackTraceElement_array(), true, CHECK_NH);
+   objArrayKlassHandle ik (THREAD, k);
+   objArrayOop r = oopFactory::new_objArray(ik(), num_threads, CHECK_NH);
+   objArrayHandle result_obj(THREAD, r);
+diff --git a/src/share/vm/utilities/debug.cpp b/src/share/vm/utilities/debug.cpp
+--- openjdk/hotspot/src/share/vm/utilities/debug.cpp
++++ openjdk/hotspot/src/share/vm/utilities/debug.cpp
+@@ -263,6 +263,27 @@
+ #endif // PRODUCT
+ }
+ 
++void report_out_of_shared_space(SharedSpaceType shared_space) {
++  static const char* name[] = {
++    "permanent generation",
++    "shared read only space",
++    "shared read write space",
++    "shared miscellaneous data space"
++  };
++  static const char* flag[] = {
++    "PermGen",
++    "SharedReadOnlySize",
++    "SharedReadWriteSize",
++    "SharedMiscDataSize"
++  };
++
++   warning("\nThe %s is not large enough\n"
++           "to preload requested classes. Use -XX:%s=\n"
++           "to increase the initial size of %s.\n",
++           name[shared_space], flag[shared_space], name[shared_space]);
++   exit(2);
++}
++
+ void report_java_out_of_memory(const char* message) {
+   static jint out_of_memory_reported = 0;
+ 
+diff --git a/src/share/vm/utilities/debug.hpp b/src/share/vm/utilities/debug.hpp
+--- openjdk/hotspot/src/share/vm/utilities/debug.hpp
++++ openjdk/hotspot/src/share/vm/utilities/debug.hpp
+@@ -176,6 +176,16 @@
+ 
+ void warning(const char* format, ...);
+ 
++// out of shared space reporting
++enum SharedSpaceType {
++  SharedPermGen,
++  SharedReadOnly,
++  SharedReadWrite,
++  SharedMiscData
++};
++
++void report_out_of_shared_space(SharedSpaceType space_type);
++
+ // out of memory reporting
+ void report_java_out_of_memory(const char* message);
+ 
+diff --git a/src/share/vm/utilities/exceptions.cpp b/src/share/vm/utilities/exceptions.cpp
+--- openjdk/hotspot/src/share/vm/utilities/exceptions.cpp
++++ openjdk/hotspot/src/share/vm/utilities/exceptions.cpp
+@@ -102,10 +102,10 @@
+   return false;
+ }
+ 
+-bool Exceptions::special_exception(Thread* thread, const char* file, int line, symbolHandle h_name, const char* message) {
++bool Exceptions::special_exception(Thread* thread, const char* file, int line, Symbol* h_name, const char* message) {
+   // bootstrapping check
+   if (!Universe::is_fully_initialized()) {
+-    if (h_name.is_null()) {
++    if (h_name == NULL) {
+       // atleast an informative message.
+       vm_exit_during_initialization("Exception", message);
+     } else {
+@@ -161,7 +161,7 @@
+ }
+ 
+ 
+-void Exceptions::_throw_msg(Thread* thread, const char* file, int line, symbolHandle h_name, const char* message, Handle h_loader, Handle h_protection_domain) {
++void Exceptions::_throw_msg(Thread* thread, const char* file, int line, Symbol* h_name, const char* message, Handle h_loader, Handle h_protection_domain) {
+   // Check for special boot-strapping/vm-thread handling
+   if (special_exception(thread, file, line, h_name, message)) return;
+   // Create and throw exception
+@@ -171,7 +171,7 @@
+ }
+ 
+ // Throw an exception with a message and a cause
+-void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, symbolHandle h_name, const char* message, Handle h_cause, Handle h_loader, Handle h_protection_domain) {
++void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line, Symbol* h_name, const char* message, Handle h_cause, Handle h_loader, Handle h_protection_domain) {
+   // Check for special boot-strapping/vm-thread handling
+   if (special_exception(thread, file, line, h_name, message)) return;
+   // Create and throw exception and init cause
+@@ -179,18 +179,9 @@
+   _throw(thread, file, line, h_exception, message);
+ }
+ 
+-// This version creates handles and calls the other version
+-void Exceptions::_throw_msg(Thread* thread, const char* file, int line,
+-                            symbolOop name, const char* message) {
+-  symbolHandle h_name(thread, name);
+-  Handle       h_loader(thread, NULL);
+-  Handle       h_protection_domain(thread, NULL);
+-  Exceptions::_throw_msg(thread, file, line, h_name, message, h_loader, h_protection_domain);
+-}
+-
+ // This version already has a handle for name
+ void Exceptions::_throw_msg(Thread* thread, const char* file, int line,
+-                            symbolHandle name, const char* message) {
++                            Symbol* name, const char* message) {
+   Handle       h_loader(thread, NULL);
+   Handle       h_protection_domain(thread, NULL);
+   Exceptions::_throw_msg(thread, file, line, name, message, h_loader, h_protection_domain);
+@@ -198,13 +189,13 @@
+ 
+ // This version already has a handle for name
+ void Exceptions::_throw_msg_cause(Thread* thread, const char* file, int line,
+-                            symbolHandle name, const char* message, Handle cause) {
++                            Symbol* name, const char* message, Handle cause) {
+   Handle       h_loader(thread, NULL);
+   Handle       h_protection_domain(thread, NULL);
+   Exceptions::_throw_msg_cause(thread, file, line, name, message, cause, h_loader, h_protection_domain);
+ }
+ 
+-void Exceptions::_throw_args(Thread* thread, const char* file, int line, symbolHandle h_name, symbolHandle h_signature, JavaCallArguments *args) {
++void Exceptions::_throw_args(Thread* thread, const char* file, int line, Symbol* h_name, Symbol* h_signature, JavaCallArguments *args) {
+   // Check for special boot-strapping/vm-thread handling
+   if (special_exception(thread, file, line, h_name, NULL)) return;
+   // Create and throw exception
+@@ -233,7 +224,7 @@
+   _throw_oop(THREAD, file, line, exception());
+ }
+ 
+-void Exceptions::fthrow(Thread* thread, const char* file, int line, symbolHandle h_name, const char* format, ...) {
++void Exceptions::fthrow(Thread* thread, const char* file, int line, Symbol* h_name, const char* format, ...) {
+   const int max_msg_size = 1024;
+   va_list ap;
+   va_start(ap, format);
+@@ -247,8 +238,8 @@
+ // Creates an exception oop, calls the <init> method with the given signature.
+ // and returns a Handle
+ // Initializes the cause if cause non-null
+-Handle Exceptions::new_exception(Thread *thread, symbolHandle h_name,
+-                                 symbolHandle signature,
++Handle Exceptions::new_exception(Thread *thread, Symbol* h_name,
++                                 Symbol* signature,
+                                  JavaCallArguments *args,
+                                  Handle h_cause, Handle h_loader,
+                                  Handle h_protection_domain) {
+@@ -275,7 +266,7 @@
+         args->set_receiver(h_exception);
+         // Call constructor
+         JavaCalls::call_special(&result, klass,
+-                                         vmSymbolHandles::object_initializer_name(),
++                                         vmSymbols::object_initializer_name(),
+                                          signature,
+                                          args,
+                                          thread);
+@@ -292,8 +283,8 @@
+       args1.set_receiver(h_exception);
+       args1.push_oop(h_cause);
+       JavaCalls::call_virtual(&result1, klass,
+-                                     vmSymbolHandles::initCause_name(),
+-                                     vmSymbolHandles::throwable_throwable_signature(),
++                                     vmSymbols::initCause_name(),
++                                     vmSymbols::throwable_throwable_signature(),
+                                      &args1,
+                                      thread);
+     }
+@@ -309,15 +300,15 @@
+ 
+ // Convenience method. Calls either the <init>() or <init>(String) method when
+ // creating a new exception
+-Handle Exceptions::new_exception(Thread* thread, symbolHandle h_name,
++Handle Exceptions::new_exception(Thread* thread, Symbol* h_name,
+                                  const char* message, Handle h_cause,
+                                  Handle h_loader,
+                                  Handle h_protection_domain,
+                                  ExceptionMsgToUtf8Mode to_utf8_safe) {
+   JavaCallArguments args;
+-  symbolHandle signature;
++  Symbol* signature = NULL;
+   if (message == NULL) {
+-    signature = vmSymbolHandles::void_method_signature();
++    signature = vmSymbols::void_method_signature();
+   } else {
+     // We want to allocate storage, but we can't do that if there's
+     // a pending exception, so we preserve any pending exception
+@@ -348,7 +339,7 @@
+       return incoming_exception;
+     }
+     args.push_oop(msg);
+-    signature = vmSymbolHandles::string_void_signature();
++    signature = vmSymbols::string_void_signature();
+   }
+   return new_exception(thread, h_name, signature, &args, h_cause, h_loader, h_protection_domain);
+ }
+@@ -362,15 +353,14 @@
+ // point is to push this flag down to class java_lang_String since other
+ // classes may need similar functionalities.
+ Handle Exceptions::new_exception(Thread* thread,
+-                                 symbolOop name,
++                                 Symbol* name,
+                                  const char* message,
+                                  ExceptionMsgToUtf8Mode to_utf8_safe) {
+ 
+-  symbolHandle h_name(thread, name);
+   Handle       h_loader(thread, NULL);
+   Handle       h_prot(thread, NULL);
+   Handle       h_cause(thread, NULL);
+-  return Exceptions::new_exception(thread, h_name, message, h_cause, h_loader,
++  return Exceptions::new_exception(thread, name, message, h_cause, h_loader,
+                                    h_prot, to_utf8_safe);
+ }
+ 
+diff --git a/src/share/vm/utilities/exceptions.hpp b/src/share/vm/utilities/exceptions.hpp
+--- openjdk/hotspot/src/share/vm/utilities/exceptions.hpp
++++ openjdk/hotspot/src/share/vm/utilities/exceptions.hpp
+@@ -50,8 +50,7 @@
+ 
+ class Thread;
+ class Handle;
+-class symbolHandle;
+-class symbolOopDesc;
++class Symbol;
+ class JavaCallArguments;
+ 
+ // The ThreadShadow class is a helper class to access the _pending_exception
+@@ -100,7 +99,7 @@
+ 
+ class Exceptions {
+   static bool special_exception(Thread *thread, const char* file, int line, Handle exception);
+-  static bool special_exception(Thread* thread, const char* file, int line, symbolHandle name, const char* message);
++  static bool special_exception(Thread* thread, const char* file, int line, Symbol* name, const char* message);
+  public:
+   // this enum is defined to indicate whether it is safe to
+   // ignore the encoding scheme of the original message string.
+@@ -112,38 +111,36 @@
+   static void _throw_oop(Thread* thread, const char* file, int line, oop exception);
+   static void _throw(Thread* thread, const char* file, int line, Handle exception, const char* msg = NULL);
+   static void _throw_msg(Thread* thread, const char* file, int line,
+-                         symbolHandle name, const char* message, Handle loader,
++                         Symbol* name, const char* message, Handle loader,
+                          Handle protection_domain);
+   static void _throw_msg(Thread* thread, const char* file, int line,
+-                         symbolOop name, const char* message);
+-  static void _throw_msg(Thread* thread, const char* file, int line,
+-                         symbolHandle name, const char* message);
++                         Symbol* name, const char* message);
+   static void _throw_args(Thread* thread, const char* file, int line,
+-                          symbolHandle name, symbolHandle signature,
++                          Symbol* name, Symbol* signature,
+                           JavaCallArguments* args);
+   static void _throw_msg_cause(Thread* thread, const char* file,
+-                         int line, symbolHandle h_name, const char* message,
++                         int line, Symbol* h_name, const char* message,
+                          Handle h_cause, Handle h_loader, Handle h_protection_domain);
+   static void _throw_msg_cause(Thread* thread, const char* file, int line,
+-                            symbolHandle name, const char* message, Handle cause);
++                            Symbol* name, const char* message, Handle cause);
+ 
+   // There is no THROW... macro for this method. Caller should remember
+   // to do a return after calling it.
+-  static void fthrow(Thread* thread, const char* file, int line, symbolHandle name,
++  static void fthrow(Thread* thread, const char* file, int line, Symbol* name,
+                      const char* format, ...);
+ 
+   // Create and initialize a new exception
+-  static Handle new_exception(Thread* thread, symbolHandle name,
+-                              symbolHandle signature, JavaCallArguments* args,
++  static Handle new_exception(Thread* thread, Symbol* name,
++                              Symbol* signature, JavaCallArguments* args,
+                               Handle cause, Handle loader,
+                               Handle protection_domain);
+ 
+-  static Handle new_exception(Thread* thread, symbolHandle name,
++  static Handle new_exception(Thread* thread, Symbol* name,
+                               const char* message, Handle cause, Handle loader,
+                               Handle protection_domain,
+                               ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8);
+ 
+- static Handle new_exception(Thread* thread, symbolOop name,
++ static Handle new_exception(Thread* thread, Symbol* name,
+                              const char* message,
+                              ExceptionMsgToUtf8Mode to_utf8_safe = safe_to_utf8);
+ 
+diff --git a/src/share/vm/utilities/hashtable.cpp b/src/share/vm/utilities/hashtable.cpp
+--- openjdk/hotspot/src/share/vm/utilities/hashtable.cpp
++++ openjdk/hotspot/src/share/vm/utilities/hashtable.cpp
+@@ -33,8 +33,9 @@
+ #include "utilities/hashtable.hpp"
+ #include "utilities/hashtable.inline.hpp"
+ 
++
+ HS_DTRACE_PROBE_DECL4(hs_private, hashtable__new_entry,
+-  void*, unsigned int, oop, void*);
++  void*, unsigned int, void*, void*);
+ 
+ // This is a generic hashtable, designed to be used for the symbol
+ // and string tables.
+@@ -69,67 +70,16 @@
+ }
+ 
+ 
+-HashtableEntry* Hashtable::new_entry(unsigned int hashValue, oop obj) {
+-  HashtableEntry* entry;
+-  entry = (HashtableEntry*)BasicHashtable::new_entry(hashValue);
+-  entry->set_literal(obj);   // clears literal string field
++template <class T> HashtableEntry<T>* Hashtable<T>::new_entry(unsigned int hashValue, T obj) {
++  HashtableEntry<T>* entry;
++
++  entry = (HashtableEntry<T>*)BasicHashtable::new_entry(hashValue);
++  entry->set_literal(obj);
+   HS_DTRACE_PROBE4(hs_private, hashtable__new_entry,
+     this, hashValue, obj, entry);
+   return entry;
+ }
+ 
+-
+-// GC support
+-
+-void Hashtable::unlink(BoolObjectClosure* is_alive) {
+-  // Readers of the table are unlocked, so we should only be removing
+-  // entries at a safepoint.
+-  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
+-  for (int i = 0; i < table_size(); ++i) {
+-    HashtableEntry** p = bucket_addr(i);
+-    HashtableEntry* entry = bucket(i);
+-    while (entry != NULL) {
+-      // Shared entries are normally at the end of the bucket and if we run into
+-      // a shared entry, then there is nothing more to remove. However, if we
+-      // have rehashed the table, then the shared entries are no longer at the
+-      // end of the bucket.
+-      if (entry->is_shared() && !use_alternate_hashcode()) {
+-        break;
+-      }
+-      assert(entry->literal() != NULL, "just checking");
+-      if (entry->is_shared() || is_alive->do_object_b(entry->literal())) {
+-        p = entry->next_addr();
+-      } else {
+-        *p = entry->next();
+-        free_entry(entry);
+-      }
+-      entry = (HashtableEntry*)HashtableEntry::make_ptr(*p);
+-    }
+-  }
+-}
+-
+-
+-void Hashtable::oops_do(OopClosure* f) {
+-  for (int i = 0; i < table_size(); ++i) {
+-    HashtableEntry** p = bucket_addr(i);
+-    HashtableEntry* entry = bucket(i);
+-    while (entry != NULL) {
+-      f->do_oop(entry->literal_addr());
+-
+-      // Did the closure remove the literal from the table?
+-      if (entry->literal() == NULL) {
+-        assert(!entry->is_shared(), "immutable hashtable entry?");
+-        *p = entry->next();
+-        free_entry(entry);
+-      } else {
+-        p = entry->next_addr();
+-      }
+-      entry = (HashtableEntry*)HashtableEntry::make_ptr(*p);
+-    }
+-  }
+-}
+-
+-
+ // Check to see if the hashtable is unbalanced.  The caller set a flag to
+ // rehash at the next safepoint.  If this bucket is 60 times greater than the
+ // expected average bucket length, it's an unbalanced hashtable.
+@@ -253,11 +203,7 @@
+                               *p != NULL;
+                                p = (*p)->next_addr()) {
+       if (*top + entry_size() > end) {
+-        warning("\nThe shared miscellaneous data space is not large "
+-                "enough to \npreload requested classes.  Use "
+-                "-XX:SharedMiscDataSize= to increase \nthe initial "
+-                "size of the miscellaneous data space.\n");
+-        exit(2);
++        report_out_of_shared_space(SharedMiscData);
+       }
+       *p = (BasicHashtableEntry*)memcpy(*top, *p, entry_size());
+       *top += entry_size();
+@@ -278,15 +224,15 @@
+ 
+ // Reverse the order of elements in the hash buckets.
+ 
+-void Hashtable::reverse(void* boundary) {
++template <class T> void Hashtable<T>::reverse(void* boundary) {
+ 
+   for (int i = 0; i < table_size(); ++i) {
+-    HashtableEntry* high_list = NULL;
+-    HashtableEntry* low_list = NULL;
+-    HashtableEntry* last_low_entry = NULL;
+-    HashtableEntry* p = bucket(i);
++    HashtableEntry<T>* high_list = NULL;
++    HashtableEntry<T>* low_list = NULL;
++    HashtableEntry<T>* last_low_entry = NULL;
++    HashtableEntry<T>* p = bucket(i);
+     while (p != NULL) {
+-      HashtableEntry* next = p->next();
++      HashtableEntry<T>* next = p->next();
+       if ((void*)p->literal() >= boundary) {
+         p->set_next(high_list);
+         high_list = p;
+@@ -320,11 +266,7 @@
+   *top += sizeof(intptr_t);
+ 
+   if (*top + len > end) {
+-    warning("\nThe shared miscellaneous data space is not large "
+-            "enough to \npreload requested classes.  Use "
+-            "-XX:SharedMiscDataSize= to increase \nthe initial "
+-            "size of the miscellaneous data space.\n");
+-    exit(2);
++    report_out_of_shared_space(SharedMiscData);
+   }
+   _buckets = (HashtableBucket*)memcpy(*top, _buckets, len);
+   *top += len;
+@@ -333,11 +275,11 @@
+ 
+ #ifndef PRODUCT
+ 
+-void Hashtable::print() {
++template <class T> void Hashtable<T>::print() {
+   ResourceMark rm;
+ 
+   for (int i = 0; i < table_size(); i++) {
+-    HashtableEntry* entry = bucket(i);
++    HashtableEntry<T>* entry = bucket(i);
+     while(entry != NULL) {
+       tty->print("%d : ", i);
+       entry->literal()->print();
+@@ -374,3 +316,10 @@
+ }
+ 
+ #endif
++
++// Explicitly instantiate these types
++template class Hashtable<constantPoolOop>;
++template class Hashtable<Symbol*>;
++template class Hashtable<klassOop>;
++template class Hashtable<oop>;
++
+diff --git a/src/share/vm/utilities/hashtable.hpp b/src/share/vm/utilities/hashtable.hpp
+--- openjdk/hotspot/src/share/vm/utilities/hashtable.hpp
++++ openjdk/hotspot/src/share/vm/utilities/hashtable.hpp
+@@ -27,7 +27,7 @@
+ 
+ #include "memory/allocation.hpp"
+ #include "oops/oop.hpp"
+-#include "oops/symbolOop.hpp"
++#include "oops/symbol.hpp"
+ #include "runtime/handles.hpp"
+ 
+ // This is a generic hashtable, designed to be used for the symbol
+@@ -96,16 +96,16 @@
+ 
+ 
+ 
+-class HashtableEntry : public BasicHashtableEntry {
++template <class T> class HashtableEntry : public BasicHashtableEntry {
+   friend class VMStructs;
+ private:
+-  oop               _literal;          // ref to item in table.
++  T               _literal;          // ref to item in table.
+ 
+ public:
+   // Literal
+-  oop literal() const                   { return _literal; }
+-  oop* literal_addr()                   { return &_literal; }
+-  void set_literal(oop s)               { _literal = s; }
++  T literal() const                   { return _literal; }
++  T* literal_addr()                   { return &_literal; }
++  void set_literal(T s)               { _literal = s; }
+ 
+   HashtableEntry* next() const {
+     return (HashtableEntry*)BasicHashtableEntry::next();
+@@ -159,6 +159,8 @@
+   // Reverse the order of elements in each of the buckets.
+   void reverse();
+ 
++  static unsigned int hash_symbol(const char* s, int len);
++
+ private:
+   // Instance variables
+   int               _table_size;
+@@ -233,7 +235,7 @@
+ };
+ 
+ 
+-class Hashtable : public BasicHashtable {
++template <class T> class Hashtable : public BasicHashtable {
+   friend class VMStructs;
+ 
+ public:
+@@ -244,16 +246,9 @@
+                    HashtableBucket* buckets, int number_of_entries)
+     : BasicHashtable(table_size, entry_size, buckets, number_of_entries), _seed(0) { }
+ 
+-  // Invoke "f->do_oop" on the locations of all oops in the table.
+-  void oops_do(OopClosure* f);
+-
+   // Debugging
+   void print()               PRODUCT_RETURN;
+ 
+-  // GC support
+-  //   Delete pointers to otherwise-unreachable objects.
+-  void unlink(BoolObjectClosure* cl);
+-
+   // Reverse the order of elements in each of the buckets. Hashtable
+   // entries which refer to objects at a lower address than 'boundary'
+   // are separated from those which refer to objects at higher
+@@ -262,25 +257,25 @@
+ 
+ protected:
+ 
+-  unsigned int compute_hash(symbolHandle name) {
++  unsigned int compute_hash(Symbol* name) {
+     return (unsigned int) name->identity_hash();
+   }
+ 
+-  int index_for(symbolHandle name) {
++  int index_for(Symbol* name) {
+     return hash_to_index(compute_hash(name));
+   }
+ 
+   // Table entry management
+-  HashtableEntry* new_entry(unsigned int hashValue, oop obj);
++  HashtableEntry<T>* new_entry(unsigned int hashValue, T obj);
+ 
+   // The following method is MT-safe and may be used with caution.
+-  HashtableEntry* bucket(int i) {
+-    return (HashtableEntry*)BasicHashtable::bucket(i);
++  HashtableEntry<T>* bucket(int i) {
++    return (HashtableEntry<T>*)BasicHashtable::bucket(i);
+   }
+ 
+   // The following method is not MT-safe and must be done under lock.
+-  HashtableEntry** bucket_addr(int i) {
+-    return (HashtableEntry**)BasicHashtable::bucket_addr(i);
++  HashtableEntry<T>** bucket_addr(int i) {
++    return (HashtableEntry<T>**)BasicHashtable::bucket_addr(i);
+   }
+ 
+   // Function to move these elements into the new table.
+@@ -298,18 +293,18 @@
+ 
+ //  Verions of hashtable where two handles are used to compute the index.
+ 
+-class TwoOopHashtable : public Hashtable {
++template <class T> class TwoOopHashtable : public Hashtable<T> {
+   friend class VMStructs;
+ protected:
+   TwoOopHashtable(int table_size, int entry_size)
+-    : Hashtable(table_size, entry_size) {}
++    : Hashtable<T>(table_size, entry_size) {}
+ 
+   TwoOopHashtable(int table_size, int entry_size, HashtableBucket* t,
+                   int number_of_entries)
+-    : Hashtable(table_size, entry_size, t, number_of_entries) {}
++    : Hashtable<T>(table_size, entry_size, t, number_of_entries) {}
+ 
+ public:
+-  unsigned int compute_hash(symbolHandle name, Handle loader) {
++  unsigned int compute_hash(Symbol* name, Handle loader) {
+     // Be careful with identity_hash(), it can safepoint and if this
+     // were one expression, the compiler could choose to unhandle each
+     // oop before calling identity_hash() for either of them.  If the first
+@@ -319,7 +314,7 @@
+     return name_hash ^ loader_hash;
+   }
+ 
+-  int index_for(symbolHandle name, Handle loader) {
++  int index_for(Symbol* name, Handle loader) {
+     return hash_to_index(compute_hash(name, loader));
+   }
+ };
+diff --git a/src/share/vm/utilities/utf8.cpp b/src/share/vm/utilities/utf8.cpp
+--- openjdk/hotspot/src/share/vm/utilities/utf8.cpp
++++ openjdk/hotspot/src/share/vm/utilities/utf8.cpp
+@@ -164,7 +164,7 @@
+ 
+ // Returns NULL if 'c' it not found. This only works as long
+ // as 'c' is an ASCII character
+-jbyte* UTF8::strrchr(jbyte* base, int length, jbyte c) {
++const jbyte* UTF8::strrchr(const jbyte* base, int length, jbyte c) {
+   assert(length >= 0, "sanity check");
+   assert(c >= 0, "does not work for non-ASCII characters");
+   // Skip backwards in string until 'c' is found or end is reached
+@@ -172,7 +172,7 @@
+   return (length < 0) ? NULL : &base[length];
+ }
+ 
+-bool UTF8::equal(jbyte* base1, int length1, jbyte* base2, int length2) {
++bool UTF8::equal(const jbyte* base1, int length1, const jbyte* base2, int length2) {
+   // Length must be the same
+   if (length1 != length2) return false;
+   for (int i = 0; i < length1; i++) {
+diff --git a/src/share/vm/utilities/utf8.hpp b/src/share/vm/utilities/utf8.hpp
+--- openjdk/hotspot/src/share/vm/utilities/utf8.hpp
++++ openjdk/hotspot/src/share/vm/utilities/utf8.hpp
+@@ -51,8 +51,8 @@
+   static char* next_character(const char* str, jint* value);
+ 
+   // Utility methods
+-  static jbyte* strrchr(jbyte* base, int length, jbyte c);
+-  static bool   equal(jbyte* base1, int length1, jbyte* base2, int length2);
++  static const jbyte* strrchr(const jbyte* base, int length, jbyte c);
++  static bool   equal(const jbyte* base1, int length1, const jbyte* base2,int length2);
+   static bool   is_supplementary_character(const unsigned char* str);
+   static jint   get_supplementary_character(const unsigned char* str);
+ };
+diff --git a/src/share/vm/utilities/xmlstream.cpp b/src/share/vm/utilities/xmlstream.cpp
+--- openjdk/hotspot/src/share/vm/utilities/xmlstream.cpp
++++ openjdk/hotspot/src/share/vm/utilities/xmlstream.cpp
+@@ -422,17 +422,17 @@
+   klass->name()->print_symbol_on(out());
+ }
+ 
+-void xmlStream::name(symbolHandle name) {
++void xmlStream::name(const Symbol* name) {
+   assert_if_no_error(inside_attrs(), "printing attributes");
+-  if (name.is_null())  return;
++  if (name == NULL)  return;
+   print_raw(" name='");
+   name_text(name);
+   print_raw("'");
+ }
+ 
+-void xmlStream::name_text(symbolHandle name) {
++void xmlStream::name_text(const Symbol* name) {
+   assert_if_no_error(inside_attrs(), "printing attributes");
+-  if (name.is_null())  return;
++  if (name == NULL)  return;
+   //name->print_short_name(text());
+   name->print_symbol_on(text());
+ }
+@@ -455,8 +455,6 @@
+     method_text(methodOop(x()));
+   else if (x->is_klass())
+     klass_text(klassOop(x()));
+-  else if (x->is_symbol())
+-    name_text(symbolOop(x()));
+   else
+     x->print_value_on(text());
+ }
+diff --git a/src/share/vm/utilities/xmlstream.hpp b/src/share/vm/utilities/xmlstream.hpp
+--- openjdk/hotspot/src/share/vm/utilities/xmlstream.hpp
++++ openjdk/hotspot/src/share/vm/utilities/xmlstream.hpp
+@@ -139,13 +139,13 @@
+   void          stamp();                 // stamp='1.234'
+   void          method(methodHandle m);  // method='k n s' ...
+   void          klass(KlassHandle k);    // klass='name'
+-  void          name(symbolHandle s);    // name='name'
++  void          name(const Symbol* s);   // name='name'
+   void          object(const char* attr, Handle val);
+ 
+   // print the text alone (sans ''):
+   void          method_text(methodHandle m);
+   void          klass_text(KlassHandle k);    // klass='name'
+-  void          name_text(symbolHandle s);    // name='name'
++  void          name_text(const Symbol* s);   // name='name'
+   void          object_text(Handle x);
+ 
+   /*  Example uses:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/7006270-regressions.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,299 @@
+# HG changeset patch
+# User bpatel
+# Date 1292276687 28800
+# Node ID 445134ee98c84b6d139fab0f9a9d8718c686c63b
+# Parent  5761891cfee48bc9382dd68e5e1bf164cff9bfbf
+7006270: Several javadoc regression tests are failing on windows
+Reviewed-by: jjg
+
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java b/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassWriterImpl.java
+@@ -239,7 +239,7 @@
+             Type superclass = Util.getFirstVisibleSuperClass(classDoc,
+                     configuration());
+             if (superclass != null) {
+-                pre.addContent("\n");
++                pre.addContent(DocletConstants.NL);
+                 pre.addContent("extends ");
+                 Content link = new RawHtml(getLink(new LinkInfoImpl(
+                         LinkInfoImpl.CONTEXT_CLASS_SIGNATURE_PARENT_NAME,
+@@ -257,7 +257,7 @@
+                     continue;
+                 }
+                 if (counter == 0) {
+-                    pre.addContent("\n");
++                    pre.addContent(DocletConstants.NL);
+                     pre.addContent(isInterface? "extends " : "implements ");
+                 } else {
+                     pre.addContent(", ");
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
+@@ -144,11 +144,12 @@
+             !configuration.nohelp) {
+             HelpWriter.generate(configuration);
+         }
+-        // If a stylesheet file is not specified, copy the default stylesheet.
++        // If a stylesheet file is not specified, copy the default stylesheet
++        // and replace newline with platform-specific newline.
+         if (configuration.stylesheetfile.length() == 0) {
+             Util.copyFile(configuration, "stylesheet.css", Util.RESOURCESDIR,
+                     (configdestdir.isEmpty()) ?
+-                        System.getProperty("user.dir") : configdestdir, false);
++                        System.getProperty("user.dir") : configdestdir, false, true);
+         }
+     }
+ 
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java
+@@ -216,15 +216,15 @@
+     public Content getAllClassesLinkScript(String id) {
+         HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
+         script.addAttr(HtmlAttr.TYPE, "text/javascript");
+-        String scriptCode = "<!--\n" +
+-                "  allClassesLink = document.getElementById(\"" + id + "\");\n" +
+-                "  if(window==top) {\n" +
+-                "    allClassesLink.style.display = \"block\";\n" +
+-                "  }\n" +
+-                "  else {\n" +
+-                "    allClassesLink.style.display = \"none\";\n" +
+-                "  }\n" +
+-                "  //-->\n";
++        String scriptCode = "<!--" + DocletConstants.NL +
++                "  allClassesLink = document.getElementById(\"" + id + "\");" + DocletConstants.NL +
++                "  if(window==top) {" + DocletConstants.NL +
++                "    allClassesLink.style.display = \"block\";" + DocletConstants.NL +
++                "  }" + DocletConstants.NL +
++                "  else {" + DocletConstants.NL +
++                "    allClassesLink.style.display = \"none\";" + DocletConstants.NL +
++                "  }" + DocletConstants.NL +
++                "  //-->" + DocletConstants.NL;
+         Content scriptContent = new RawHtml(scriptCode);
+         script.addContent(scriptContent);
+         Content div = HtmlTree.DIV(script);
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/Comment.java
+@@ -82,9 +82,9 @@
+      */
+     public void write(StringBuilder contentBuilder) {
+         if (!endsWithNewLine(contentBuilder))
+-            contentBuilder.append("\n");
++            contentBuilder.append(DocletConstants.NL);
+         contentBuilder.append("<!-- ");
+         contentBuilder.append(commentText);
+-        contentBuilder.append(" -->\n");
++        contentBuilder.append(" -->" + DocletConstants.NL);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/DocType.java
+@@ -48,7 +48,7 @@
+      */
+     private DocType(String type, String dtd) {
+         docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 " + type +
+-                "//EN\" \"" + dtd + "\">\n";
++                "//EN\" \"" + dtd + "\">" + DocletConstants.NL;
+     }
+ 
+      /**
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlTree.java
+@@ -753,7 +753,7 @@
+      */
+     public void write(StringBuilder contentBuilder) {
+         if (!isInline() && !endsWithNewLine(contentBuilder))
+-            contentBuilder.append("\n");
++            contentBuilder.append(DocletConstants.NL);
+         String tagString = htmlTag.toString();
+         contentBuilder.append("<" + tagString);
+         Iterator<HtmlAttr> iterator = attrs.keySet().iterator();
+@@ -772,6 +772,6 @@
+         if (htmlTag.endTagRequired())
+             contentBuilder.append("</" + tagString + ">");
+         if (!isInline())
+-            contentBuilder.append("\n");
++            contentBuilder.append(DocletConstants.NL);
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+@@ -287,11 +287,11 @@
+         HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
+         if(winTitle != null && winTitle.length() > 0) {
+             script.addAttr(HtmlAttr.TYPE, "text/javascript");
+-            String scriptCode = "<!--\n" +
+-                    "    if (location.href.indexOf('is-external=true') == -1) {\n" +
+-                    "        parent.document.title=\"" + winTitle + "\";\n" +
+-                    "    }\n" +
+-                    "//-->\n";
++            String scriptCode = "<!--" + DocletConstants.NL +
++                    "    if (location.href.indexOf('is-external=true') == -1) {" + DocletConstants.NL +
++                    "        parent.document.title=\"" + winTitle + "\";" + DocletConstants.NL +
++                    "    }" + DocletConstants.NL +
++                    "//-->" + DocletConstants.NL;
+             RawHtml scriptContent = new RawHtml(scriptCode);
+             script.addContent(scriptContent);
+         }
+@@ -306,15 +306,15 @@
+     protected Content getFramesetJavaScript(){
+         HtmlTree script = new HtmlTree(HtmlTag.SCRIPT);
+         script.addAttr(HtmlAttr.TYPE, "text/javascript");
+-        String scriptCode = "\n    targetPage = \"\" + window.location.search;\n" +
+-                "    if (targetPage != \"\" && targetPage != \"undefined\")\n" +
+-                "        targetPage = targetPage.substring(1);\n" +
+-                "    if (targetPage.indexOf(\":\") != -1)\n" +
+-                "        targetPage = \"undefined\";\n" +
+-                "    function loadFrames() {\n" +
+-                "        if (targetPage != \"\" && targetPage != \"undefined\")\n" +
+-                "             top.classFrame.location = top.targetPage;\n" +
+-                "    }\n";
++        String scriptCode = DocletConstants.NL + "    targetPage = \"\" + window.location.search;" + DocletConstants.NL +
++                "    if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
++                "        targetPage = targetPage.substring(1);" + DocletConstants.NL +
++                "    if (targetPage.indexOf(\":\") != -1)" + DocletConstants.NL +
++                "        targetPage = \"undefined\";" + DocletConstants.NL +
++                "    function loadFrames() {" + DocletConstants.NL +
++                "        if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
++                "             top.classFrame.location = top.targetPage;" + DocletConstants.NL +
++                "    }" + DocletConstants.NL;
+         RawHtml scriptContent = new RawHtml(scriptCode);
+         script.addContent(scriptContent);
+         return script;
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/Content.java
+@@ -101,6 +101,6 @@
+      */
+     public boolean endsWithNewLine(StringBuilder contentBuilder) {
+         return ((contentBuilder.length() == 0) ||
+-                (contentBuilder.substring(contentBuilder.length() - 1).equals("\n")));
++                (contentBuilder.toString().endsWith(DocletConstants.NL)));
+     }
+ }
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java
+@@ -211,14 +211,14 @@
+         try {
+             while ((len = input.read(bytearr)) != -1) {
+                 output.write(bytearr, 0, len);
+-            }
++                }
+         } catch (FileNotFoundException exc) {
+         } catch (SecurityException exc) {
+-        } finally {
++            } finally {
+             input.close();
+             output.close();
++            }
+         }
+-    }
+ 
+     /**
+      * Copy the given directory contents from the source package directory
+@@ -330,7 +330,7 @@
+             String resourcefile, boolean overwrite) {
+         String destresourcesdir = configuration.destDirName + RESOURCESDIR;
+         copyFile(configuration, resourcefile, RESOURCESDIR, destresourcesdir,
+-                overwrite);
++                overwrite, false);
+     }
+ 
+     /**
+@@ -345,23 +345,46 @@
+      * @param overwrite A flag to indicate whether the file in the
+      *                  destination directory will be overwritten if
+      *                  it already exists.
++     * @param replaceNewLine true if the newline needs to be replaced with platform-
++     *                  specific newline.
+      */
+     public static void copyFile(Configuration configuration, String file, String source,
+-            String destination, boolean overwrite) {
++            String destination, boolean overwrite, boolean replaceNewLine) {
+         DirectoryManager.createDirectory(configuration, destination);
+         File destfile = new File(destination, file);
+         if(destfile.exists() && (! overwrite)) return;
+         try {
+             InputStream in = Configuration.class.getResourceAsStream(
+-                source + DirectoryManager.URL_FILE_SEPARATOR + file);
++                    source + DirectoryManager.URL_FILE_SEPARATOR + file);
+             if(in==null) return;
+             OutputStream out = new FileOutputStream(destfile);
+-            byte[] buf = new byte[2048];
+-            int n;
+-            while((n = in.read(buf))>0) out.write(buf,0,n);
+-            in.close();
+-            out.close();
+-        } catch(Throwable t) {}
++            try {
++                if (!replaceNewLine) {
++                    byte[] buf = new byte[2048];
++                    int n;
++                    while((n = in.read(buf))>0) out.write(buf,0,n);
++                } else {
++                    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
++                    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
++                    try {
++                        String line;
++                        while ((line = reader.readLine()) != null) {
++                            writer.write(line);
++                            writer.write(DocletConstants.NL);
++                        }
++                    } finally {
++                        reader.close();
++                        writer.close();
++                    }
++                }
++            } finally {
++                in.close();
++                out.close();
++            }
++        } catch (IOException ie) {
++            ie.printStackTrace();
++            throw new DocletAbortException();
++        }
+     }
+ 
+     /**
+diff --git a/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java b/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java
+--- openjdk/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java
++++ openjdk/langtools/test/com/sun/javadoc/testHtmlDocument/TestHtmlDocument.java
+@@ -44,6 +44,7 @@
+     private static final String BUGID = "6851834";
+     private static final String BUGNAME = "TestHtmlDocument";
+     private static final String FS = System.getProperty("file.separator");
++    private static final String LS = System.getProperty("line.separator");
+     private static String srcdir = System.getProperty("test.src", ".");
+ 
+     // Entry point
+@@ -143,13 +144,17 @@
+             System.out.println("\nFILE DOES NOT EXIST: " + filename);
+         }
+         BufferedReader in = new BufferedReader(new FileReader(file));
++        StringBuilder fileString = new StringBuilder();
+         // Create an array of characters the size of the file
+-        char[] allChars = new char[(int)file.length()];
+-        // Read the characters into the allChars array
+-        in.read(allChars, 0, (int)file.length());
+-        in.close();
+-        // Convert to a string
+-        String allCharsString = new String(allChars);
+-        return allCharsString;
++        try {
++            String line;
++            while ((line = in.readLine()) != null) {
++                fileString.append(line);
++                fileString.append(LS);
++            }
++        } finally {
++            in.close();
++        }
++        return fileString.toString();
+     }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/7008809-report_class_in_arraystoreexception.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,189 @@
+# HG changeset patch
+# User never
+# Date 1295904858 28800
+# Node ID f44f27f80f2caf315f0f56cd63b5beb46908051e
+# Parent  afb96a923f7f2da64e711455257a024c100e8e2e
+7008809: should report the class in ArrayStoreExceptions from compiled code
+Reviewed-by: iveresov, twisti
+
+diff --git a/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp b/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp
+--- openjdk/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp
++++ openjdk/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -129,27 +129,6 @@
+ }
+ 
+ 
+-// Implementation of ArrayStoreExceptionStub
+-
+-ArrayStoreExceptionStub::ArrayStoreExceptionStub(CodeEmitInfo* info):
+-  _info(info) {
+-}
+-
+-
+-void ArrayStoreExceptionStub::emit_code(LIR_Assembler* ce) {
+-  __ bind(_entry);
+-  __ call(Runtime1::entry_for(Runtime1::throw_array_store_exception_id), relocInfo::runtime_call_type);
+-  __ delayed()->nop();
+-  ce->add_call_info_here(_info);
+-  ce->verify_oop_map(_info);
+-#ifdef ASSERT
+-  __ should_not_reach_here();
+-#endif
+-}
+-
+-
+-
+-
+ // Implementation of NewInstanceStub
+ 
+ NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) {
+diff --git a/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp b/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp
+--- openjdk/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp
++++ openjdk/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp
+@@ -710,7 +710,7 @@
+     case throw_array_store_exception_id:
+       {
+         __ set_info("throw_array_store_exception", dont_gc_arguments);
+-        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), false);
++        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true);
+       }
+       break;
+ 
+diff --git a/src/cpu/x86/vm/c1_CodeStubs_x86.cpp b/src/cpu/x86/vm/c1_CodeStubs_x86.cpp
+--- openjdk/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp
++++ openjdk/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -414,20 +414,6 @@
+ }
+ 
+ 
+-ArrayStoreExceptionStub::ArrayStoreExceptionStub(CodeEmitInfo* info):
+-  _info(info) {
+-}
+-
+-
+-void ArrayStoreExceptionStub::emit_code(LIR_Assembler* ce) {
+-  assert(__ rsp_offset() == 0, "frame size should be fixed");
+-  __ bind(_entry);
+-  __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_array_store_exception_id)));
+-  ce->add_call_info_here(_info);
+-  debug_only(__ should_not_reach_here());
+-}
+-
+-
+ void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
+   //---------------slow case: call to native-----------------
+   __ bind(_entry);
+diff --git a/src/cpu/x86/vm/c1_Runtime1_x86.cpp b/src/cpu/x86/vm/c1_Runtime1_x86.cpp
+--- openjdk/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp
++++ openjdk/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp
+@@ -1337,7 +1337,7 @@
+       { StubFrame f(sasm, "throw_array_store_exception", dont_gc_arguments);
+         // tos + 0: link
+         //     + 1: return address
+-        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), false);
++        oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true);
+       }
+       break;
+ 
+diff --git a/src/share/vm/c1/c1_CodeStubs.hpp b/src/share/vm/c1/c1_CodeStubs.hpp
+--- openjdk/hotspot/src/share/vm/c1/c1_CodeStubs.hpp
++++ openjdk/hotspot/src/share/vm/c1/c1_CodeStubs.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -476,18 +476,12 @@
+ 
+ 
+ 
+-class ArrayStoreExceptionStub: public CodeStub {
++class ArrayStoreExceptionStub: public SimpleExceptionStub {
+  private:
+   CodeEmitInfo* _info;
+ 
+  public:
+-  ArrayStoreExceptionStub(CodeEmitInfo* info);
+-  virtual void emit_code(LIR_Assembler* emit);
+-  virtual CodeEmitInfo* info() const             { return _info; }
+-  virtual bool is_exception_throw_stub() const   { return true; }
+-  virtual void visit(LIR_OpVisitState* visitor) {
+-    visitor->do_slow_case(_info);
+-  }
++  ArrayStoreExceptionStub(LIR_Opr obj, CodeEmitInfo* info): SimpleExceptionStub(Runtime1::throw_array_store_exception_id, obj, info) {}
+ #ifndef PRODUCT
+   virtual void print_name(outputStream* out) const { out->print("ArrayStoreExceptionStub"); }
+ #endif // PRODUCT
+diff --git a/src/share/vm/c1/c1_LIR.cpp b/src/share/vm/c1/c1_LIR.cpp
+--- openjdk/hotspot/src/share/vm/c1/c1_LIR.cpp
++++ openjdk/hotspot/src/share/vm/c1/c1_LIR.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -396,7 +396,7 @@
+   , _should_profile(false)
+ {
+   if (code == lir_store_check) {
+-    _stub = new ArrayStoreExceptionStub(info_for_exception);
++    _stub = new ArrayStoreExceptionStub(object, info_for_exception);
+     assert(info_for_exception != NULL, "store_check throws exceptions");
+   } else {
+     ShouldNotReachHere();
+diff --git a/src/share/vm/c1/c1_Runtime1.cpp b/src/share/vm/c1/c1_Runtime1.cpp
+--- openjdk/hotspot/src/share/vm/c1/c1_Runtime1.cpp
++++ openjdk/hotspot/src/share/vm/c1/c1_Runtime1.cpp
+@@ -339,8 +339,10 @@
+ JRT_END
+ 
+ 
+-JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* thread))
+-  THROW(vmSymbolHandles::java_lang_ArrayStoreException());
++JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* thread, oopDesc* obj))
++  ResourceMark rm(thread);
++  const char* klass_name = Klass::cast(obj->klass())->external_name();
++  SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayStoreException(), klass_name);
+ JRT_END
+ 
+ 
+diff --git a/src/share/vm/c1/c1_Runtime1.hpp b/src/share/vm/c1/c1_Runtime1.hpp
+--- openjdk/hotspot/src/share/vm/c1/c1_Runtime1.hpp
++++ openjdk/hotspot/src/share/vm/c1/c1_Runtime1.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -143,9 +143,9 @@
+   static void throw_index_exception(JavaThread* thread, int index);
+   static void throw_div0_exception(JavaThread* thread);
+   static void throw_null_pointer_exception(JavaThread* thread);
+-  static void throw_class_cast_exception(JavaThread* thread, oopDesc* obect);
++  static void throw_class_cast_exception(JavaThread* thread, oopDesc* object);
+   static void throw_incompatible_class_change_error(JavaThread* thread);
+-  static void throw_array_store_exception(JavaThread* thread);
++  static void throw_array_store_exception(JavaThread* thread, oopDesc* object);
+ 
+   static void monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock);
+   static void monitorexit (JavaThread* thread, BasicObjectLock* lock);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/7014851-unused_parallel_compaction_code.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,810 @@
+# HG changeset patch
+# User andrew
+# Date 1371822953 18000
+# Node ID 81575d3cbd95714395c022a7f7ca622bab432b2b
+# Parent  cdce92891bfbc17372d8e5d5d2cccf319cf73589
+7014851: Remove unused parallel compaction code
+Summary: Removed.
+Reviewed-by: jcoomes, brutisso
+
+diff --git a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp
+--- openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp
++++ openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -1196,11 +1196,6 @@
+   static inline void adjust_pointer(oop* p)       { adjust_pointer(p, false); }
+   static inline void adjust_pointer(narrowOop* p) { adjust_pointer(p, false); }
+ 
+-  template <class T>
+-  static inline void adjust_pointer(T* p,
+-                                    HeapWord* beg_addr,
+-                                    HeapWord* end_addr);
+-
+   // Reference Processing
+   static ReferenceProcessor* const ref_processor() { return _ref_processor; }
+ 
+@@ -1408,15 +1403,6 @@
+   return ((HeapWord*) k) >= dense_prefix(perm_space_id);
+ }
+ 
+-template <class T>
+-inline void PSParallelCompact::adjust_pointer(T* p,
+-                                              HeapWord* beg_addr,
+-                                              HeapWord* end_addr) {
+-  if (is_in((HeapWord*)p, beg_addr, end_addr)) {
+-    adjust_pointer(p);
+-  }
+-}
+-
+ #ifdef ASSERT
+ inline void
+ PSParallelCompact::check_new_location(HeapWord* old_addr, HeapWord* new_addr)
+diff --git a/src/share/vm/oops/arrayKlassKlass.cpp b/src/share/vm/oops/arrayKlassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/arrayKlassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/arrayKlassKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -144,27 +144,6 @@
+   }
+   return klassKlass::oop_update_pointers(cm, obj);
+ }
+-
+-int
+-arrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                     HeapWord* beg_addr, HeapWord* end_addr) {
+-  assert(obj->is_klass(), "must be klass");
+-  arrayKlass* ak = arrayKlass::cast(klassOop(obj));
+-
+-  oop* p;
+-  p = ak->adr_component_mirror();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  p = ak->adr_lower_dimension();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  p = ak->adr_higher_dimension();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-
+-  {
+-    HandleMark hm;
+-    ak->vtable()->oop_update_pointers(cm, beg_addr, end_addr);
+-  }
+-  return klassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
+-}
+ #endif // SERIALGC
+ 
+ // Printing
+diff --git a/src/share/vm/oops/compiledICHolderKlass.cpp b/src/share/vm/oops/compiledICHolderKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/compiledICHolderKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/compiledICHolderKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -145,21 +145,6 @@
+   PSParallelCompact::adjust_pointer(c->adr_holder_klass());
+   return c->object_size();
+ }
+-
+-int compiledICHolderKlass::oop_update_pointers(ParCompactionManager* cm,
+-                                               oop obj,
+-                                               HeapWord* beg_addr,
+-                                               HeapWord* end_addr) {
+-  assert(obj->is_compiledICHolder(), "must be compiledICHolder");
+-  compiledICHolderOop c = compiledICHolderOop(obj);
+-
+-  oop* p;
+-  p = c->adr_holder_method();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  p = c->adr_holder_klass();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  return c->object_size();
+-}
+ #endif // SERIALGC
+ 
+ // Printing
+diff --git a/src/share/vm/oops/constMethodKlass.cpp b/src/share/vm/oops/constMethodKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/constMethodKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/constMethodKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -184,21 +184,6 @@
+   }
+   return cm_oop->object_size();
+ }
+-
+-int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                          HeapWord* beg_addr,
+-                                          HeapWord* end_addr) {
+-  assert(obj->is_constMethod(), "should be constMethod");
+-  constMethodOop cm_oop = constMethodOop(obj);
+-
+-  oop* const beg_oop = MAX2((oop*)beg_addr, cm_oop->oop_block_beg());
+-  oop* const end_oop = MIN2((oop*)end_addr, cm_oop->oop_block_end());
+-  for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
+-    PSParallelCompact::adjust_pointer(cur_oop);
+-  }
+-
+-  return cm_oop->object_size();
+-}
+ #endif // SERIALGC
+ 
+ // Printing
+diff --git a/src/share/vm/oops/constantPoolKlass.cpp b/src/share/vm/oops/constantPoolKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/constantPoolKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/constantPoolKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -271,40 +271,6 @@
+   return cp->object_size();
+ }
+ 
+-int
+-constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                       HeapWord* beg_addr, HeapWord* end_addr) {
+-  assert (obj->is_constantPool(), "obj must be constant pool");
+-  constantPoolOop cp = (constantPoolOop) obj;
+-
+-  // If the tags array is null we are in the middle of allocating this constant
+-  // pool.
+-  if (cp->tags() != NULL) {
+-    oop* base = (oop*)cp->base();
+-    oop* const beg_oop = MAX2((oop*)beg_addr, base);
+-    oop* const end_oop = MIN2((oop*)end_addr, base + cp->length());
+-    const size_t beg_idx = pointer_delta(beg_oop, base, sizeof(oop*));
+-    const size_t end_idx = pointer_delta(end_oop, base, sizeof(oop*));
+-    for (size_t cur_idx = beg_idx; cur_idx < end_idx; ++cur_idx, ++base) {
+-      if (cp->is_pointer_entry(int(cur_idx))) {
+-        PSParallelCompact::adjust_pointer(base);
+-      }
+-    }
+-  }
+-
+-  oop* p;
+-  p = cp->tags_addr();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  p = cp->cache_addr();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  p = cp->operands_addr();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  p = cp->pool_holder_addr();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-
+-  return cp->object_size();
+-}
+-
+ void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
+   assert(obj->is_constantPool(), "should be constant pool");
+   constantPoolOop cp = (constantPoolOop) obj;
+diff --git a/src/share/vm/oops/cpCacheKlass.cpp b/src/share/vm/oops/cpCacheKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/cpCacheKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/cpCacheKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -216,25 +216,6 @@
+ 
+   return cache->object_size();
+ }
+-
+-int
+-constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                            HeapWord* beg_addr,
+-                                            HeapWord* end_addr) {
+-  assert(obj->is_constantPoolCache(), "obj must be constant pool cache");
+-  constantPoolCacheOop cache = (constantPoolCacheOop)obj;
+-
+-  // Iteration over constant pool cache instance variables
+-  oop* p;
+-  p = (oop*)cache->constant_pool_addr();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-
+-  // Iteration over constant pool cache entries
+-  for (int i = 0; i < cache->length(); ++i) {
+-    cache->entry_at(i)->update_pointers(beg_addr, end_addr);
+-  }
+-  return cache->object_size();
+-}
+ #endif // SERIALGC
+ 
+ void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) {
+diff --git a/src/share/vm/oops/cpCacheOop.cpp b/src/share/vm/oops/cpCacheOop.cpp
+--- openjdk/hotspot/src/share/vm/oops/cpCacheOop.cpp
++++ openjdk/hotspot/src/share/vm/oops/cpCacheOop.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -364,16 +364,6 @@
+     PSParallelCompact::adjust_pointer((oop*)&_f2);
+   }
+ }
+-
+-void ConstantPoolCacheEntry::update_pointers(HeapWord* beg_addr,
+-                                             HeapWord* end_addr) {
+-  assert(in_words(size()) == 4, "check code below - may need adjustment");
+-  // field[1] is always oop or NULL
+-  PSParallelCompact::adjust_pointer((oop*)&_f1, beg_addr, end_addr);
+-  if (is_vfinal()) {
+-    PSParallelCompact::adjust_pointer((oop*)&_f2, beg_addr, end_addr);
+-  }
+-}
+ #endif // SERIALGC
+ 
+ // RedefineClasses() API support:
+diff --git a/src/share/vm/oops/cpCacheOop.hpp b/src/share/vm/oops/cpCacheOop.hpp
+--- openjdk/hotspot/src/share/vm/oops/cpCacheOop.hpp
++++ openjdk/hotspot/src/share/vm/oops/cpCacheOop.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -287,7 +287,6 @@
+ #endif // SERIALGC
+ 
+   void update_pointers();
+-  void update_pointers(HeapWord* beg_addr, HeapWord* end_addr);
+ 
+   // RedefineClasses() API support:
+   // If this constantPoolCacheEntry refers to old_method then update it
+diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -1792,15 +1792,6 @@
+   return size_helper();
+ }
+ 
+-int instanceKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                       HeapWord* beg_addr, HeapWord* end_addr) {
+-  InstanceKlass_BOUNDED_OOP_MAP_ITERATE( \
+-    obj, beg_addr, end_addr, \
+-    PSParallelCompact::adjust_pointer(p), \
+-    assert_nothing)
+-  return size_helper();
+-}
+-
+ #endif // SERIALGC
+ 
+ // This klass is alive but the implementor link is not followed/updated.
+diff --git a/src/share/vm/oops/instanceKlass.hpp b/src/share/vm/oops/instanceKlass.hpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlass.hpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlass.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+diff --git a/src/share/vm/oops/instanceKlassKlass.cpp b/src/share/vm/oops/instanceKlassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+diff --git a/src/share/vm/oops/instanceRefKlass.cpp b/src/share/vm/oops/instanceRefKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/instanceRefKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/instanceRefKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -344,33 +344,6 @@
+   }
+   return size_helper();
+ }
+-
+-
+-template <class T> void
+-specialized_oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                HeapWord* beg_addr, HeapWord* end_addr) {
+-  T* p;
+-  T* referent_addr = p = (T*)java_lang_ref_Reference::referent_addr(obj);
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  T* next_addr = p = (T*)java_lang_ref_Reference::next_addr(obj);
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  T* discovered_addr = p = (T*)java_lang_ref_Reference::discovered_addr(obj);
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  debug_only(trace_reference_gc("instanceRefKlass::oop_update_ptrs", obj,
+-                                referent_addr, next_addr, discovered_addr);)
+-}
+-
+-int
+-instanceRefKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                      HeapWord* beg_addr, HeapWord* end_addr) {
+-  instanceKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
+-  if (UseCompressedOops) {
+-    specialized_oop_update_pointers<narrowOop>(cm, obj, beg_addr, end_addr);
+-  } else {
+-    specialized_oop_update_pointers<oop>(cm, obj, beg_addr, end_addr);
+-  }
+-  return size_helper();
+-}
+ #endif // SERIALGC
+ 
+ void instanceRefKlass::update_nonstatic_oop_maps(klassOop k) {
+diff --git a/src/share/vm/oops/klassKlass.cpp b/src/share/vm/oops/klassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/klassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/klassKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -198,19 +198,6 @@
+ 
+   return oop_size(obj);
+ }
+-
+-int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                    HeapWord* beg_addr, HeapWord* end_addr) {
+-  Klass* k = Klass::cast(klassOop(obj));
+-
+-  oop* const beg_oop = MAX2((oop*)beg_addr, k->oop_block_beg());
+-  oop* const end_oop = MIN2((oop*)end_addr, k->oop_block_end());
+-  for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
+-    PSParallelCompact::adjust_pointer(cur_oop);
+-  }
+-
+-  return oop_size(obj);
+-}
+ #endif // SERIALGC
+ 
+ 
+diff --git a/src/share/vm/oops/klassPS.hpp b/src/share/vm/oops/klassPS.hpp
+--- openjdk/hotspot/src/share/vm/oops/klassPS.hpp
++++ openjdk/hotspot/src/share/vm/oops/klassPS.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -37,17 +37,13 @@
+    objects that do (or may) cross chunk boundaries; it updates only those   \
+    oops that are in the region [beg_addr, end_addr).  */                    \
+   virtual void oop_follow_contents(ParCompactionManager* cm, oop obj);      \
+-  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj);      \
+-  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj,       \
+-                                   HeapWord* beg_addr, HeapWord* end_addr);
++  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj);
+ 
+ // Pure virtual version for klass.hpp
+ #define PARALLEL_GC_DECLS_PV \
+   virtual void oop_push_contents(PSPromotionManager* pm, oop obj) = 0;      \
+   virtual void oop_follow_contents(ParCompactionManager* cm, oop obj) = 0;  \
+-  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj) = 0;  \
+-  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj,       \
+-                                   HeapWord* beg_addr, HeapWord* end_addr) = 0;
++  virtual int  oop_update_pointers(ParCompactionManager* cm, oop obj) = 0;
+ #else  // SERIALGC
+ #define PARALLEL_GC_DECLS
+ #define PARALLEL_GC_DECLS_PV
+diff --git a/src/share/vm/oops/klassVtable.cpp b/src/share/vm/oops/klassVtable.cpp
+--- openjdk/hotspot/src/share/vm/oops/klassVtable.cpp
++++ openjdk/hotspot/src/share/vm/oops/klassVtable.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -677,25 +677,6 @@
+     PSParallelCompact::adjust_pointer(adr_method_at(i));
+   }
+ }
+-
+-void klassVtable::oop_update_pointers(ParCompactionManager* cm,
+-                                      HeapWord* beg_addr, HeapWord* end_addr) {
+-  const int n = length();
+-  const int entry_size = vtableEntry::size();
+-
+-  int beg_idx = 0;
+-  HeapWord* const method_0 = (HeapWord*)adr_method_at(0);
+-  if (beg_addr > method_0) {
+-    // it's safe to use cast, as we have guarantees on vtable size to be sane
+-    beg_idx = int((pointer_delta(beg_addr, method_0) + entry_size - 1) / entry_size);
+-  }
+-
+-  oop* const beg_oop = adr_method_at(beg_idx);
+-  oop* const end_oop = MIN2((oop*)end_addr, adr_method_at(n));
+-  for (oop* cur_oop = beg_oop; cur_oop < end_oop; cur_oop += entry_size) {
+-    PSParallelCompact::adjust_pointer(cur_oop);
+-  }
+-}
+ #endif // SERIALGC
+ 
+ // Iterators
+@@ -820,25 +801,6 @@
+     ime++;
+   }
+ }
+-
+-void klassItable::oop_update_pointers(ParCompactionManager* cm,
+-                                      HeapWord* beg_addr, HeapWord* end_addr) {
+-  // offset table
+-  itableOffsetEntry* ioe = offset_entry(0);
+-  for(int i = 0; i < _size_offset_table; i++) {
+-    oop* p = (oop*)&ioe->_interface;
+-    PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-    ioe++;
+-  }
+-
+-  // method table
+-  itableMethodEntry* ime = method_entry(0);
+-  for(int j = 0; j < _size_method_table; j++) {
+-    oop* p = (oop*)&ime->_method;
+-    PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-    ime++;
+-  }
+-}
+ #endif // SERIALGC
+ 
+ // Iterators
+diff --git a/src/share/vm/oops/klassVtable.hpp b/src/share/vm/oops/klassVtable.hpp
+--- openjdk/hotspot/src/share/vm/oops/klassVtable.hpp
++++ openjdk/hotspot/src/share/vm/oops/klassVtable.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -99,8 +99,6 @@
+   // Parallel Old
+   void oop_follow_contents(ParCompactionManager* cm);
+   void oop_update_pointers(ParCompactionManager* cm);
+-  void oop_update_pointers(ParCompactionManager* cm,
+-                           HeapWord* beg_addr, HeapWord* end_addr);
+ #endif // SERIALGC
+ 
+   // Iterators
+@@ -295,8 +293,6 @@
+   // Parallel Old
+   void oop_follow_contents(ParCompactionManager* cm);
+   void oop_update_pointers(ParCompactionManager* cm);
+-  void oop_update_pointers(ParCompactionManager* cm,
+-                           HeapWord* beg_addr, HeapWord* end_addr);
+ #endif // SERIALGC
+ 
+   // Iterators
+diff --git a/src/share/vm/oops/methodDataKlass.cpp b/src/share/vm/oops/methodDataKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/methodDataKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/methodDataKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -188,25 +188,6 @@
+   }
+   return m->object_size();
+ }
+-
+-int
+-methodDataKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                     HeapWord* beg_addr, HeapWord* end_addr) {
+-  assert(obj->is_methodData(), "should be method data");
+-
+-  oop* p;
+-  methodDataOop m = methodDataOop(obj);
+-
+-  p = m->adr_method();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-
+-  ResourceMark rm;
+-  ProfileData* data;
+-  for (data = m->first_data(); m->is_valid(data); data = m->next_data(data)) {
+-    data->update_pointers(beg_addr, end_addr);
+-  }
+-  return m->object_size();
+-}
+ #endif // SERIALGC
+ 
+ #ifndef PRODUCT
+diff --git a/src/share/vm/oops/methodDataOop.cpp b/src/share/vm/oops/methodDataOop.cpp
+--- openjdk/hotspot/src/share/vm/oops/methodDataOop.cpp
++++ openjdk/hotspot/src/share/vm/oops/methodDataOop.cpp
+@@ -271,17 +271,6 @@
+     }
+   }
+ }
+-
+-void ReceiverTypeData::update_pointers(HeapWord* beg_addr, HeapWord* end_addr) {
+-  // The loop bounds could be computed based on beg_addr/end_addr and the
+-  // boundary test hoisted outside the loop (see klassVTable for an example);
+-  // however, row_limit() is small enough (2) to make that less efficient.
+-  for (uint row = 0; row < row_limit(); row++) {
+-    if (receiver_unchecked(row) != NULL) {
+-      PSParallelCompact::adjust_pointer(adr_receiver(row), beg_addr, end_addr);
+-    }
+-  }
+-}
+ #endif // SERIALGC
+ 
+ #ifndef PRODUCT
+diff --git a/src/share/vm/oops/methodDataOop.hpp b/src/share/vm/oops/methodDataOop.hpp
+--- openjdk/hotspot/src/share/vm/oops/methodDataOop.hpp
++++ openjdk/hotspot/src/share/vm/oops/methodDataOop.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -452,7 +452,6 @@
+   // Parallel old support
+   virtual void follow_contents(ParCompactionManager* cm) {}
+   virtual void update_pointers() {}
+-  virtual void update_pointers(HeapWord* beg_addr, HeapWord* end_addr) {}
+ #endif // SERIALGC
+ 
+   // CI translation: ProfileData can represent both MethodDataOop data
+@@ -748,7 +747,6 @@
+   // Parallel old support
+   virtual void follow_contents(ParCompactionManager* cm);
+   virtual void update_pointers();
+-  virtual void update_pointers(HeapWord* beg_addr, HeapWord* end_addr);
+ #endif // SERIALGC
+ 
+   oop* adr_receiver(uint row) {
+diff --git a/src/share/vm/oops/methodKlass.cpp b/src/share/vm/oops/methodKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/methodKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/methodKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -214,27 +214,6 @@
+ #endif // COMPILER2
+   return m->object_size();
+ }
+-
+-int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                     HeapWord* beg_addr, HeapWord* end_addr) {
+-  assert(obj->is_method(), "should be method");
+-
+-  oop* p;
+-  methodOop m = methodOop(obj);
+-
+-  p = m->adr_constMethod();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  p = m->adr_constants();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-
+-#ifdef COMPILER2
+-  if (m->method_data() != NULL) {
+-    p = m->adr_method_data();
+-    PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  }
+-#endif // COMPILER2
+-  return m->object_size();
+-}
+ #endif // SERIALGC
+ 
+ #ifndef PRODUCT
+diff --git a/src/share/vm/oops/objArrayKlass.cpp b/src/share/vm/oops/objArrayKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/objArrayKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/objArrayKlass.cpp
+@@ -470,16 +470,6 @@
+   ObjArrayKlass_OOP_ITERATE(a, p, PSParallelCompact::adjust_pointer(p))
+   return a->object_size();
+ }
+-
+-int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                       HeapWord* beg_addr, HeapWord* end_addr) {
+-  assert (obj->is_objArray(), "obj must be obj array");
+-  objArrayOop a = objArrayOop(obj);
+-  ObjArrayKlass_BOUNDED_OOP_ITERATE( \
+-     a, p, beg_addr, end_addr, \
+-     PSParallelCompact::adjust_pointer(p))
+-  return a->object_size();
+-}
+ #endif // SERIALGC
+ 
+ // JVM support
+diff --git a/src/share/vm/oops/objArrayKlassKlass.cpp b/src/share/vm/oops/objArrayKlassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -272,22 +272,6 @@
+ 
+   return arrayKlassKlass::oop_update_pointers(cm, obj);
+ }
+-
+-int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                            HeapWord* beg_addr,
+-                                            HeapWord* end_addr) {
+-  assert(obj->is_klass(), "must be klass");
+-  assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array");
+-
+-  oop* p;
+-  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
+-  p = oak->element_klass_addr();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-  p = oak->bottom_klass_addr();
+-  PSParallelCompact::adjust_pointer(p, beg_addr, end_addr);
+-
+-  return arrayKlassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
+-}
+ #endif // SERIALGC
+ 
+ #ifndef PRODUCT
+diff --git a/src/share/vm/oops/oop.hpp b/src/share/vm/oops/oop.hpp
+--- openjdk/hotspot/src/share/vm/oops/oop.hpp
++++ openjdk/hotspot/src/share/vm/oops/oop.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -318,13 +318,6 @@
+ 
+   // Parallel Old
+   void update_contents(ParCompactionManager* cm);
+-  void update_contents(ParCompactionManager* cm,
+-                       HeapWord* begin_limit,
+-                       HeapWord* end_limit);
+-  void update_contents(ParCompactionManager* cm,
+-                       klassOop old_klass,
+-                       HeapWord* begin_limit,
+-                       HeapWord* end_limit);
+ 
+   void follow_contents(ParCompactionManager* cm);
+   void follow_header(ParCompactionManager* cm);
+@@ -365,7 +358,6 @@
+ #ifndef SERIALGC
+   // Parallel old
+   void update_header();
+-  void update_header(HeapWord* beg_addr, HeapWord* end_addr);
+ #endif // SERIALGC
+ 
+   // mark-sweep support
+diff --git a/src/share/vm/oops/oop.pcgc.inline.hpp b/src/share/vm/oops/oop.pcgc.inline.hpp
+--- openjdk/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp
++++ openjdk/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -57,41 +57,6 @@
+   // Else skip it.  The typeArrayKlass in the header never needs scavenging.
+ }
+ 
+-inline void oopDesc::update_contents(ParCompactionManager* cm,
+-                                     HeapWord* begin_limit,
+-                                     HeapWord* end_limit) {
+-  // The klass field must be updated before anything else
+-  // can be done.
+-  debug_only(klassOopDesc* original_klass = klass());
+-
+-  update_contents(cm, klass(), begin_limit, end_limit);
+-}
+-
+-inline void oopDesc::update_contents(ParCompactionManager* cm,
+-                                     klassOop old_klass,
+-                                     HeapWord* begin_limit,
+-                                     HeapWord* end_limit) {
+-
+-  klassOop updated_klass =
+-    PSParallelCompact::summary_data().calc_new_klass(old_klass);
+-
+-  // Needs to be boundary aware for the 64 bit case
+-  // update_header();
+-  // The klass has moved.  Is the location of the klass
+-  // within the limits?
+-  if ((((HeapWord*)&_metadata._klass) >= begin_limit) &&
+-      (((HeapWord*)&_metadata._klass) < end_limit)) {
+-    set_klass(updated_klass);
+-  }
+-
+-  Klass* klass = updated_klass->klass_part();
+-  if (!klass->oop_is_typeArray()) {
+-    // It might contain oops beyond the header, so take the virtual call.
+-    klass->oop_update_pointers(cm, this, begin_limit, end_limit);
+-  }
+-  // Else skip it.  The typeArrayKlass in the header never needs scavenging.
+-}
+-
+ inline void oopDesc::follow_contents(ParCompactionManager* cm) {
+   assert (PSParallelCompact::mark_bitmap()->is_marked(this),
+     "should be marked");
+@@ -140,13 +105,4 @@
+   }
+ }
+ 
+-inline void oopDesc::update_header(HeapWord* beg_addr, HeapWord* end_addr) {
+-  if (UseCompressedOops) {
+-    PSParallelCompact::adjust_pointer(compressed_klass_addr(),
+-                                      beg_addr, end_addr);
+-  } else {
+-    PSParallelCompact::adjust_pointer(klass_addr(), beg_addr, end_addr);
+-  }
+-}
+-
+ #endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP
+diff --git a/src/share/vm/oops/typeArrayKlass.cpp b/src/share/vm/oops/typeArrayKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/typeArrayKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/typeArrayKlass.cpp
+@@ -250,13 +250,6 @@
+   assert(obj->is_typeArray(),"must be a type array");
+   return typeArrayOop(obj)->object_size();
+ }
+-
+-int
+-typeArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                    HeapWord* beg_addr, HeapWord* end_addr) {
+-  assert(obj->is_typeArray(),"must be a type array");
+-  return typeArrayOop(obj)->object_size();
+-}
+ #endif // SERIALGC
+ 
+ void typeArrayKlass::initialize(TRAPS) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/7017732-move_static_fields_to_class.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,3079 @@
+# HG changeset patch
+# User andrew
+# Date 1371742382 18000
+# Node ID af33d9cd440e2851eaffb819d67f86b42c6a8030
+# Parent  fee3c2ed387b0a925f81448c93265b4c30e0a8d6
+7017732: move static fields into Class to prepare for perm gen removal
+Reviewed-by: kvn, coleenp, twisti, stefank
+
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/jdi/FieldImpl.java b/agent/src/share/classes/sun/jvm/hotspot/jdi/FieldImpl.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/FieldImpl.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/FieldImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -62,7 +62,7 @@
+ 
+     // get the value of static field
+     ValueImpl getValue() {
+-        return getValue(saField.getFieldHolder());
++        return getValue(saField.getFieldHolder().getJavaMirror());
+     }
+ 
+     // get the value of this Field from a specific Oop
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -87,7 +87,7 @@
+     innerClasses         = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize());
+     nonstaticFieldSize   = new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize());
+     staticFieldSize      = new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize());
+-    staticOopFieldSize   = new CIntField(type.getCIntegerField("_static_oop_field_size"), Oop.getHeaderSize());
++    staticOopFieldCount   = new CIntField(type.getCIntegerField("_static_oop_field_count"), Oop.getHeaderSize());
+     nonstaticOopMapSize  = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize());
+     isMarkedDependent    = new CIntField(type.getCIntegerField("_is_marked_dependent"), Oop.getHeaderSize());
+     initState            = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize());
+@@ -140,7 +140,7 @@
+   private static OopField  innerClasses;
+   private static CIntField nonstaticFieldSize;
+   private static CIntField staticFieldSize;
+-  private static CIntField staticOopFieldSize;
++  private static CIntField staticOopFieldCount;
+   private static CIntField nonstaticOopMapSize;
+   private static CIntField isMarkedDependent;
+   private static CIntField initState;
+@@ -261,8 +261,7 @@
+   public Symbol    getSourceDebugExtension(){ return (Symbol)       sourceDebugExtension.getValue(this); }
+   public TypeArray getInnerClasses()        { return (TypeArray)    innerClasses.getValue(this); }
+   public long      getNonstaticFieldSize()  { return                nonstaticFieldSize.getValue(this); }
+-  public long      getStaticFieldSize()     { return                staticFieldSize.getValue(this); }
+-  public long      getStaticOopFieldSize()  { return                staticOopFieldSize.getValue(this); }
++  public long      getStaticOopFieldCount() { return                staticOopFieldCount.getValue(this); }
+   public long      getNonstaticOopMapSize() { return                nonstaticOopMapSize.getValue(this); }
+   public boolean   getIsMarkedDependent()   { return                isMarkedDependent.getValue(this) != 0; }
+   public long      getVtableLen()           { return                vtableLen.getValue(this); }
+@@ -454,7 +453,7 @@
+       visitor.doOop(innerClasses, true);
+       visitor.doCInt(nonstaticFieldSize, true);
+       visitor.doCInt(staticFieldSize, true);
+-      visitor.doCInt(staticOopFieldSize, true);
++      visitor.doCInt(staticOopFieldCount, true);
+       visitor.doCInt(nonstaticOopMapSize, true);
+       visitor.doCInt(isMarkedDependent, true);
+       visitor.doCInt(initState, true);
+@@ -693,7 +692,7 @@
+   public long getObjectSize() {
+     long bodySize =    alignObjectOffset(getVtableLen() * getHeap().getOopSize())
+                      + alignObjectOffset(getItableLen() * getHeap().getOopSize())
+-                     + (getStaticFieldSize() + getNonstaticOopMapSize()) * getHeap().getOopSize();
++                     + (getNonstaticOopMapSize()) * getHeap().getOopSize();
+     return alignObjectSize(headerSize + bodySize);
+   }
+ 
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java b/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -40,7 +40,12 @@
+     super(holder, fieldArrayIndex);
+   }
+ 
+-  public int getValue(Oop obj) { return obj.getHandle().getJIntAt(getOffset()); }
++  public int getValue(Oop obj) {
++    if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
++      throw new InternalError(obj.toString());
++    }
++    return obj.getHandle().getJIntAt(getOffset());
++  }
+   public void setValue(Oop obj, int value) throws MutationException {
+     // Fix this: setJIntAt is missing in Address
+   }
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/OopField.java b/agent/src/share/classes/sun/jvm/hotspot/oops/OopField.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopField.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopField.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -41,11 +41,17 @@
+   }
+ 
+   public Oop getValue(Oop obj) {
++    if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
++      throw new InternalError();
++    }
+     return obj.getHeap().newOop(getValueAsOopHandle(obj));
+   }
+ 
+   /** Debugging support */
+   public OopHandle getValueAsOopHandle(Oop obj) {
++    if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
++      throw new InternalError(obj.toString());
++    }
+     return obj.getHandle().getOopHandleAt(getOffset());
+   }
+ 
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java b/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -274,13 +274,7 @@
+        // hc_klass is a HotSpot magic field and hence we can't
+        // find it from InstanceKlass for java.lang.Class.
+        TypeDataBase db = VM.getVM().getTypeDataBase();
+-       int hcKlassOffset = (int) Instance.getHeaderSize();
+-       try {
+-          hcKlassOffset += (db.lookupIntConstant("java_lang_Class::hc_klass_offset").intValue() *
+-                           VM.getVM().getHeapOopSize());
+-       } catch (RuntimeException re) {
+-          // ignore, currently java_lang_Class::hc_klass_offset is zero
+-       }
++       int hcKlassOffset = (int) db.lookupType("java_lang_Class").getCIntegerField("klass_offset").getValue();
+        if (VM.getVM().isCompressedOopsEnabled()) {
+          hcKlassField = new NarrowOopField(new NamedFieldIdentifier("hc_klass"), hcKlassOffset, true);
+        } else {
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java b/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -839,13 +839,13 @@
+   }
+ 
+   private void readSystemProperties() {
+-     InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
++     final InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
+      systemKls.iterate(new DefaultOopVisitor() {
+                                ObjectReader objReader = new ObjectReader();
+                                public void doOop(sun.jvm.hotspot.oops.OopField field, boolean isVMField) {
+                                   if (field.getID().getName().equals("props")) {
+                                      try {
+-                                        sysProps = (Properties) objReader.readObject(field.getValue(getObj()));
++                                        sysProps = (Properties) objReader.readObject(field.getValue(systemKls.getJavaMirror()));
+                                      } catch (Exception e) {
+                                         if (Assert.ASSERTS_ENABLED) {
+                                            e.printStackTrace();
+diff --git a/agent/test/jdi/sasanity.sh b/agent/test/jdi/sasanity.sh
+--- openjdk/hotspot/agent/test/jdi/sasanity.sh
++++ openjdk/hotspot/agent/test/jdi/sasanity.sh
+@@ -43,6 +43,7 @@
+ fi
+ 
+ jdk=$1
++shift
+ OS=`uname`
+ 
+ if [ "$OS" != "Linux" ]; then
+@@ -68,7 +69,7 @@
+ 
+ tmp=/tmp/sagsetup
+ rm -f $tmp
+-$jdk/bin/java sagtarg > $tmp &
++$jdk/bin/java $* sagtarg > $tmp &
+ pid=$!
+ while [ ! -s $tmp ] ; do
+   # Kludge alert!
+diff --git a/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp b/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp
+--- openjdk/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp
++++ openjdk/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp
+@@ -322,7 +322,8 @@
+     // thread.
+     assert(_obj != noreg, "must be a valid register");
+     assert(_oop_index >= 0, "must have oop index");
+-    __ ld_ptr(_obj, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc), G3);
++    __ ld_ptr(_obj, java_lang_Class::klass_offset_in_bytes(), G3);
++    __ ld_ptr(G3, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc), G3);
+     __ cmp(G2_thread, G3);
+     __ br(Assembler::notEqual, false, Assembler::pn, call_patch);
+     __ delayed()->nop();
+diff --git a/src/cpu/sparc/vm/dump_sparc.cpp b/src/cpu/sparc/vm/dump_sparc.cpp
+--- openjdk/hotspot/src/cpu/sparc/vm/dump_sparc.cpp
++++ openjdk/hotspot/src/cpu/sparc/vm/dump_sparc.cpp
+@@ -80,13 +80,19 @@
+     for (int j = 0; j < num_virtuals; ++j) {
+       dummy_vtable[num_virtuals * i + j] = (void*)masm->pc();
+       __ save(SP, -256, SP);
++      int offset = (i << 8) + j;
++      Register src = G0;
++      if (!Assembler::is_simm13(offset)) {
++        __ sethi(offset, L0);
++        src = L0;
++        offset = offset & ((1 << 10) - 1);
++      }
+       __ brx(Assembler::always, false, Assembler::pt, common_code);
+ 
+       // Load L0 with a value indicating vtable/offset pair.
+       // -- bits[ 7..0]  (8 bits) which virtual method in table?
+-      // -- bits[12..8]  (5 bits) which virtual method table?
+-      // -- must fit in 13-bit instruction immediate field.
+-      __ delayed()->set((i << 8) + j, L0);
++      // -- bits[13..8]  (6 bits) which virtual method table?
++      __ delayed()->or3(src, offset, L0);
+     }
+   }
+ 
+diff --git a/src/cpu/x86/vm/c1_CodeStubs_x86.cpp b/src/cpu/x86/vm/c1_CodeStubs_x86.cpp
+--- openjdk/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp
++++ openjdk/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp
+@@ -313,10 +313,13 @@
+     }
+     assert(_obj != noreg, "must be a valid register");
+     Register tmp = rax;
+-    if (_obj == tmp) tmp = rbx;
++    Register tmp2 = rbx;
+     __ push(tmp);
++    __ push(tmp2);
++    __ movptr(tmp2, Address(_obj, java_lang_Class::klass_offset_in_bytes()));
+     __ get_thread(tmp);
+-    __ cmpptr(tmp, Address(_obj, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc)));
++    __ cmpptr(tmp, Address(tmp2, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc)));
++    __ pop(tmp2);
+     __ pop(tmp);
+     __ jcc(Assembler::notEqual, call_patch);
+ 
+diff --git a/src/cpu/zero/vm/cppInterpreter_zero.cpp b/src/cpu/zero/vm/cppInterpreter_zero.cpp
+--- openjdk/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
++++ openjdk/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+  * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+@@ -281,7 +281,7 @@
+ 
+     if (method->is_static()) {
+       istate->set_oop_temp(
+-        method->constants()->pool_holder()->klass_part()->java_mirror());
++        method->constants()->pool_holder()->java_mirror());
+       mirror = istate->oop_temp_addr();
+       *(dst++) = &mirror;
+     }
+@@ -667,7 +667,7 @@
+       (BasicObjectLock *) stack->alloc(monitor_words * wordSize);
+     oop object;
+     if (method->is_static())
+-      object = method->constants()->pool_holder()->klass_part()->java_mirror();
++      object = method->constants()->pool_holder()->java_mirror();
+     else
+       object = (oop) locals[0];
+     monitor->set_obj(object);
+diff --git a/src/share/vm/c1/c1_GraphBuilder.cpp b/src/share/vm/c1/c1_GraphBuilder.cpp
+--- openjdk/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
++++ openjdk/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
+@@ -1468,9 +1468,9 @@
+     // so, the is_initialized flag should be suffiect.
+     if (state_before != NULL) {
+       // build a patching constant
+-      obj = new Constant(new ClassConstant(holder), state_before);
++      obj = new Constant(new InstanceConstant(holder->java_mirror()), state_before);
+     } else {
+-      obj = new Constant(new ClassConstant(holder));
++      obj = new Constant(new InstanceConstant(holder->java_mirror()));
+     }
+   }
+ 
+diff --git a/src/share/vm/c1/c1_Runtime1.cpp b/src/share/vm/c1/c1_Runtime1.cpp
+--- openjdk/hotspot/src/share/vm/c1/c1_Runtime1.cpp
++++ openjdk/hotspot/src/share/vm/c1/c1_Runtime1.cpp
+@@ -807,7 +807,7 @@
+         { klassOop klass = resolve_field_return_klass(caller_method, bci, CHECK);
+           // Save a reference to the class that has to be checked for initialization
+           init_klass = KlassHandle(THREAD, klass);
+-          k = klass;
++          k = klass->java_mirror();
+         }
+         break;
+       case Bytecodes::_new:
+diff --git a/src/share/vm/ci/ciCPCache.cpp b/src/share/vm/ci/ciCPCache.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciCPCache.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciCPCache.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -46,8 +46,7 @@
+ // ciCPCache::is_f1_null_at
+ bool ciCPCache::is_f1_null_at(int index) {
+   VM_ENTRY_MARK;
+-  oop f1 = entry_at(index)->f1();
+-  return (f1 == NULL);
++  return entry_at(index)->is_f1_null();
+ }
+ 
+ 
+diff --git a/src/share/vm/ci/ciField.cpp b/src/share/vm/ci/ciField.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciField.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciField.cpp
+@@ -224,36 +224,38 @@
+       }
+     }
+ 
++    Handle mirror = k->java_mirror();
++
+     _is_constant = true;
+     switch(type()->basic_type()) {
+     case T_BYTE:
+-      _constant_value = ciConstant(type()->basic_type(), k->byte_field(_offset));
++      _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset));
+       break;
+     case T_CHAR:
+-      _constant_value = ciConstant(type()->basic_type(), k->char_field(_offset));
++      _constant_value = ciConstant(type()->basic_type(), mirror->char_field(_offset));
+       break;
+     case T_SHORT:
+-      _constant_value = ciConstant(type()->basic_type(), k->short_field(_offset));
++      _constant_value = ciConstant(type()->basic_type(), mirror->short_field(_offset));
+       break;
+     case T_BOOLEAN:
+-      _constant_value = ciConstant(type()->basic_type(), k->bool_field(_offset));
++      _constant_value = ciConstant(type()->basic_type(), mirror->bool_field(_offset));
+       break;
+     case T_INT:
+-      _constant_value = ciConstant(type()->basic_type(), k->int_field(_offset));
++      _constant_value = ciConstant(type()->basic_type(), mirror->int_field(_offset));
+       break;
+     case T_FLOAT:
+-      _constant_value = ciConstant(k->float_field(_offset));
++      _constant_value = ciConstant(mirror->float_field(_offset));
+       break;
+     case T_DOUBLE:
+-      _constant_value = ciConstant(k->double_field(_offset));
++      _constant_value = ciConstant(mirror->double_field(_offset));
+       break;
+     case T_LONG:
+-      _constant_value = ciConstant(k->long_field(_offset));
++      _constant_value = ciConstant(mirror->long_field(_offset));
+       break;
+     case T_OBJECT:
+     case T_ARRAY:
+       {
+-        oop o = k->obj_field(_offset);
++        oop o = mirror->obj_field(_offset);
+ 
+         // A field will be "constant" if it is known always to be
+         // a non-null reference to an instance of a particular class,
+diff --git a/src/share/vm/ci/ciInstance.cpp b/src/share/vm/ci/ciInstance.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciInstance.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciInstance.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -138,3 +138,9 @@
+   st->print(" type=");
+   klass()->print(st);
+ }
++
++
++ciKlass* ciInstance::java_lang_Class_klass() {
++  VM_ENTRY_MARK;
++  return CURRENT_ENV->get_object(java_lang_Class::as_klassOop(get_oop()))->as_klass();
++}
+diff --git a/src/share/vm/ci/ciInstance.hpp b/src/share/vm/ci/ciInstance.hpp
+--- openjdk/hotspot/src/share/vm/ci/ciInstance.hpp
++++ openjdk/hotspot/src/share/vm/ci/ciInstance.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -64,6 +64,8 @@
+ 
+   // Constant value of a field at the specified offset.
+   ciConstant field_value_by_offset(int field_offset);
++
++  ciKlass* java_lang_Class_klass();
+ };
+ 
+ #endif // SHARE_VM_CI_CIINSTANCE_HPP
+diff --git a/src/share/vm/ci/ciInstanceKlass.cpp b/src/share/vm/ci/ciInstanceKlass.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciInstanceKlass.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciInstanceKlass.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -84,7 +84,6 @@
+     if (h_k() != SystemDictionary::Object_klass()) {
+       super();
+     }
+-    java_mirror();
+     //compute_nonstatic_fields();  // done outside of constructor
+   }
+ 
+@@ -319,6 +318,9 @@
+ // Get the instance of java.lang.Class corresponding to this klass.
+ // Cache it on this->_java_mirror.
+ ciInstance* ciInstanceKlass::java_mirror() {
++  if (is_shared()) {
++    return ciKlass::java_mirror();
++  }
+   if (_java_mirror == NULL) {
+     _java_mirror = ciKlass::java_mirror();
+   }
+diff --git a/src/share/vm/ci/ciObjectFactory.cpp b/src/share/vm/ci/ciObjectFactory.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciObjectFactory.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciObjectFactory.cpp
+@@ -653,7 +653,7 @@
+   if (key->is_perm() && _non_perm_count == 0) {
+     return emptyBucket;
+   } else if (key->is_instance()) {
+-    if (key->klass() == SystemDictionary::Class_klass()) {
++    if (key->klass() == SystemDictionary::Class_klass() && JavaObjectsInPerm) {
+       // class mirror instances are always perm
+       return emptyBucket;
+     }
+diff --git a/src/share/vm/classfile/classFileParser.cpp b/src/share/vm/classfile/classFileParser.cpp
+--- openjdk/hotspot/src/share/vm/classfile/classFileParser.cpp
++++ openjdk/hotspot/src/share/vm/classfile/classFileParser.cpp
+@@ -37,6 +37,7 @@
+ #include "memory/universe.inline.hpp"
+ #include "oops/constantPoolOop.hpp"
+ #include "oops/instanceKlass.hpp"
++#include "oops/instanceMirrorKlass.hpp"
+ #include "oops/klass.inline.hpp"
+ #include "oops/klassOop.hpp"
+ #include "oops/klassVtable.hpp"
+@@ -2737,8 +2738,8 @@
+ }
+ 
+ 
+-void ClassFileParser::java_lang_Class_fix_pre(objArrayHandle* methods_ptr,
+-  FieldAllocationCount *fac_ptr, TRAPS) {
++void ClassFileParser::java_lang_Class_fix_pre(int* nonstatic_field_size,
++                                              FieldAllocationCount *fac_ptr) {
+   // Add fake fields for java.lang.Class instances
+   //
+   // This is not particularly nice. We should consider adding a
+@@ -2755,10 +2756,13 @@
+   // versions because when the offsets are computed at bootstrap
+   // time we don't know yet which version of the JDK we're running in.
+ 
+-  // The values below are fake but will force two non-static oop fields and
++  // The values below are fake but will force three non-static oop fields and
+   // a corresponding non-static oop map block to be allocated.
+   const int extra = java_lang_Class::number_of_fake_oop_fields;
+   fac_ptr->nonstatic_oop_count += extra;
++
++  // Reserve some leading space for fake ints
++  *nonstatic_field_size += align_size_up(java_lang_Class::hc_number_of_fake_int_fields * BytesPerInt, heapOopSize) / heapOopSize;
+ }
+ 
+ 
+@@ -3167,9 +3171,7 @@
+     int next_nonstatic_field_offset;
+ 
+     // Calculate the starting byte offsets
+-    next_static_oop_offset      = (instanceKlass::header_size() +
+-                                  align_object_offset(vtable_size) +
+-                                  align_object_offset(itable_size)) * wordSize;
++    next_static_oop_offset      = instanceMirrorKlass::offset_of_static_fields();
+     next_static_double_offset   = next_static_oop_offset +
+                                   (fac.static_oop_count * heapOopSize);
+     if ( fac.static_double_count &&
+@@ -3519,7 +3521,7 @@
+     }
+ 
+     // We can now create the basic klassOop for this klass
+-    klassOop ik = oopFactory::new_instanceKlass(vtable_size, itable_size,
++    klassOop ik = oopFactory::new_instanceKlass(name, vtable_size, itable_size,
+                                                 static_field_size,
+                                                 total_oop_map_count,
+                                                 rt, CHECK_(nullHandle));
+@@ -3541,7 +3543,7 @@
+     this_klass->set_class_loader(class_loader());
+     this_klass->set_nonstatic_field_size(nonstatic_field_size);
+     this_klass->set_has_nonstatic_fields(has_nonstatic_fields);
+-    this_klass->set_static_oop_field_size(fac.static_oop_count);
++    this_klass->set_static_oop_field_count(fac.static_oop_count);
+     cp->set_pool_holder(this_klass());
+     this_klass->set_constants(cp());
+     this_klass->set_local_interfaces(local_interfaces());
+@@ -3601,9 +3603,6 @@
+     // Make sure this is the end of class file stream
+     guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
+ 
+-    // Initialize static fields
+-    this_klass->do_local_static_fields(&initialize_static_field, CHECK_(nullHandle));
+-
+     // VerifyOops believes that once this has been set, the object is completely loaded.
+     // Compute transitive closure of interfaces this class implements
+     this_klass->set_transitive_interfaces(transitive_interfaces());
+@@ -3637,6 +3636,9 @@
+       check_illegal_static_method(this_klass, CHECK_(nullHandle));
+     }
+ 
++    // Allocate mirror and initialize static fields
++    java_lang_Class::create_mirror(this_klass, CHECK_(nullHandle));
++
+     ClassLoadingService::notify_class_loaded(instanceKlass::cast(this_klass()),
+                                              false /* not shared class */);
+ 
+diff --git a/src/share/vm/classfile/classFileParser.hpp b/src/share/vm/classfile/classFileParser.hpp
+--- openjdk/hotspot/src/share/vm/classfile/classFileParser.hpp
++++ openjdk/hotspot/src/share/vm/classfile/classFileParser.hpp
+@@ -153,11 +153,12 @@
+   // Add the "discovered" field to java.lang.ref.Reference if
+   // it does not exist.
+   void java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr,
+-    constantPoolHandle cp, FieldAllocationCount *fac_ptr, TRAPS);
++                                       constantPoolHandle cp,
++                                       FieldAllocationCount *fac_ptr, TRAPS);
+   // Adjust the field allocation counts for java.lang.Class to add
+   // fake fields.
+-  void java_lang_Class_fix_pre(objArrayHandle* methods_ptr,
+-    FieldAllocationCount *fac_ptr, TRAPS);
++  void java_lang_Class_fix_pre(int* nonstatic_field_size,
++                               FieldAllocationCount *fac_ptr);
+   // Adjust the next_nonstatic_oop_offset to place the fake fields
+   // before any Java fields.
+   void java_lang_Class_fix_post(int* next_nonstatic_oop_offset);
+diff --git a/src/share/vm/classfile/javaClasses.cpp b/src/share/vm/classfile/javaClasses.cpp
+--- openjdk/hotspot/src/share/vm/classfile/javaClasses.cpp
++++ openjdk/hotspot/src/share/vm/classfile/javaClasses.cpp
+@@ -33,6 +33,7 @@
+ #include "memory/resourceArea.hpp"
+ #include "memory/universe.inline.hpp"
+ #include "oops/instanceKlass.hpp"
++#include "oops/instanceMirrorKlass.hpp"
+ #include "oops/klass.hpp"
+ #include "oops/klassOop.hpp"
+ #include "oops/methodOop.hpp"
+@@ -391,6 +392,75 @@
+   }
+ }
+ 
++static void initialize_static_field(fieldDescriptor* fd, TRAPS) {
++  Handle mirror (THREAD, fd->field_holder()->java_mirror());
++  assert(mirror.not_null() && fd->is_static(), "just checking");
++  if (fd->has_initial_value()) {
++    BasicType t = fd->field_type();
++    switch (t) {
++      case T_BYTE:
++        mirror()->byte_field_put(fd->offset(), fd->int_initial_value());
++              break;
++      case T_BOOLEAN:
++        mirror()->bool_field_put(fd->offset(), fd->int_initial_value());
++              break;
++      case T_CHAR:
++        mirror()->char_field_put(fd->offset(), fd->int_initial_value());
++              break;
++      case T_SHORT:
++        mirror()->short_field_put(fd->offset(), fd->int_initial_value());
++              break;
++      case T_INT:
++        mirror()->int_field_put(fd->offset(), fd->int_initial_value());
++        break;
++      case T_FLOAT:
++        mirror()->float_field_put(fd->offset(), fd->float_initial_value());
++        break;
++      case T_DOUBLE:
++        mirror()->double_field_put(fd->offset(), fd->double_initial_value());
++        break;
++      case T_LONG:
++        mirror()->long_field_put(fd->offset(), fd->long_initial_value());
++        break;
++      case T_OBJECT:
++        {
++          #ifdef ASSERT
++          TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
++          assert(fd->signature() == sym, "just checking");
++          #endif
++          oop string = fd->string_initial_value(CHECK);
++          mirror()->obj_field_put(fd->offset(), string);
++        }
++        break;
++      default:
++        THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
++                  "Illegal ConstantValue attribute in class file");
++    }
++  }
++}
++
++
++// During bootstrap, java.lang.Class wasn't loaded so static field
++// offsets were computed without the size added it.  Go back and
++// update all the static field offsets to included the size.
++static void fixup_static_field(fieldDescriptor* fd, TRAPS) {
++  if (fd->is_static()) {
++    int real_offset = fd->offset() + instanceMirrorKlass::offset_of_static_fields();
++    typeArrayOop fields = instanceKlass::cast(fd->field_holder())->fields();
++    fields->short_at_put(fd->index() + instanceKlass::low_offset,  extract_low_short_from_int(real_offset));
++    fields->short_at_put(fd->index() + instanceKlass::high_offset, extract_high_short_from_int(real_offset));
++  }
++}
++
++void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
++  assert(instanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
++
++  if (k->oop_is_instance()) {
++    // Fixup the offsets
++    instanceKlass::cast(k())->do_local_static_fields(&fixup_static_field, CHECK);
++  }
++  create_mirror(k, CHECK);
++}
+ 
+ oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) {
+   assert(k->java_mirror() == NULL, "should only assign mirror once");
+@@ -400,12 +470,17 @@
+   // class is put into the system dictionary.
+   int computed_modifiers = k->compute_modifier_flags(CHECK_0);
+   k->set_modifier_flags(computed_modifiers);
+-  if (SystemDictionary::Class_klass_loaded()) {
++  if (SystemDictionary::Class_klass_loaded() && (k->oop_is_instance() || k->oop_is_javaArray())) {
+     // Allocate mirror (java.lang.Class instance)
+-    Handle mirror = instanceKlass::cast(SystemDictionary::Class_klass())->allocate_permanent_instance(CHECK_0);
++    Handle mirror = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK_0);
+     // Setup indirections
+     mirror->obj_field_put(klass_offset,  k());
+     k->set_java_mirror(mirror());
++
++    instanceMirrorKlass* mk = instanceMirrorKlass::cast(mirror->klass());
++    java_lang_Class::set_oop_size(mirror(), mk->instance_size(k));
++    java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror()));
++
+     // It might also have a component mirror.  This mirror must already exist.
+     if (k->oop_is_javaArray()) {
+       Handle comp_mirror;
+@@ -428,6 +503,9 @@
+         arrayKlass::cast(k->as_klassOop())->set_component_mirror(comp_mirror());
+         set_array_klass(comp_mirror(), k->as_klassOop());
+       }
++    } else if (k->oop_is_instance()) {
++      // Initialize static fields
++      instanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, CHECK_NULL);
+     }
+     return mirror();
+   } else {
+@@ -436,21 +514,46 @@
+ }
+ 
+ 
++
++int  java_lang_Class::oop_size(oop java_class) {
++  assert(oop_size_offset != 0, "must be set");
++  return java_class->int_field(oop_size_offset);
++}
++void java_lang_Class::set_oop_size(oop java_class, int size) {
++  assert(oop_size_offset != 0, "must be set");
++  java_class->int_field_put(oop_size_offset, size);
++}
++int  java_lang_Class::static_oop_field_count(oop java_class) {
++  assert(static_oop_field_count_offset != 0, "must be set");
++  return java_class->int_field(static_oop_field_count_offset);
++}
++void java_lang_Class::set_static_oop_field_count(oop java_class, int size) {
++  assert(static_oop_field_count_offset != 0, "must be set");
++  java_class->int_field_put(static_oop_field_count_offset, size);
++}
++
++
++
++
+ oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
+   // This should be improved by adding a field at the Java level or by
+   // introducing a new VM klass (see comment in ClassFileParser)
+-  oop java_class = instanceKlass::cast(SystemDictionary::Class_klass())->allocate_permanent_instance(CHECK_0);
++  oop java_class = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance((oop)NULL, CHECK_0);
+   if (type != T_VOID) {
+     klassOop aklass = Universe::typeArrayKlassObj(type);
+     assert(aklass != NULL, "correct bootstrap");
+     set_array_klass(java_class, aklass);
+   }
++  instanceMirrorKlass* mk = instanceMirrorKlass::cast(SystemDictionary::Class_klass());
++  java_lang_Class::set_oop_size(java_class, mk->instance_size(oop(NULL)));
++  java_lang_Class::set_static_oop_field_count(java_class, 0);
+   return java_class;
+ }
+ 
+ 
+ klassOop java_lang_Class::as_klassOop(oop java_class) {
+   //%note memory_2
++  assert(java_lang_Class::is_instance(java_class), "must be a Class object");
+   klassOop k = klassOop(java_class->obj_field(klass_offset));
+   assert(k == NULL || k->is_klass(), "type check");
+   return k;
+@@ -2145,7 +2248,7 @@
+ // Support for java_lang_ref_Reference
+ oop java_lang_ref_Reference::pending_list_lock() {
+   instanceKlass* ik = instanceKlass::cast(SystemDictionary::Reference_klass());
+-  char *addr = (((char *)ik->start_of_static_fields()) + static_lock_offset);
++  address addr = ik->static_field_addr(static_lock_offset);
+   if (UseCompressedOops) {
+     return oopDesc::load_decode_heap_oop((narrowOop *)addr);
+   } else {
+@@ -2155,7 +2258,7 @@
+ 
+ HeapWord *java_lang_ref_Reference::pending_list_addr() {
+   instanceKlass* ik = instanceKlass::cast(SystemDictionary::Reference_klass());
+-  char *addr = (((char *)ik->start_of_static_fields()) + static_pending_offset);
++  address addr = ik->static_field_addr(static_pending_offset);
+   // XXX This might not be HeapWord aligned, almost rather be char *.
+   return (HeapWord*)addr;
+ }
+@@ -2178,16 +2281,14 @@
+ 
+ jlong java_lang_ref_SoftReference::clock() {
+   instanceKlass* ik = instanceKlass::cast(SystemDictionary::SoftReference_klass());
+-  int offset = ik->offset_of_static_fields() + static_clock_offset;
+-
+-  return SystemDictionary::SoftReference_klass()->long_field(offset);
++  jlong* offset = (jlong*)ik->static_field_addr(static_clock_offset);
++  return *offset;
+ }
+ 
+ void java_lang_ref_SoftReference::set_clock(jlong value) {
+   instanceKlass* ik = instanceKlass::cast(SystemDictionary::SoftReference_klass());
+-  int offset = ik->offset_of_static_fields() + static_clock_offset;
+-
+-  SystemDictionary::SoftReference_klass()->long_field_put(offset, value);
++  jlong* offset = (jlong*)ik->static_field_addr(static_clock_offset);
++  *offset = value;
+ }
+ 
+ 
+@@ -2647,26 +2748,18 @@
+ 
+ 
+ // Support for java_lang_System
+-
+-void java_lang_System::compute_offsets() {
+-  assert(offset_of_static_fields == 0, "offsets should be initialized only once");
+-
+-  instanceKlass* ik = instanceKlass::cast(SystemDictionary::System_klass());
+-  offset_of_static_fields = ik->offset_of_static_fields();
++int java_lang_System::in_offset_in_bytes() {
++  return (instanceMirrorKlass::offset_of_static_fields() + static_in_offset);
+ }
+ 
+-int java_lang_System::in_offset_in_bytes() {
+-  return (offset_of_static_fields + static_in_offset);
++
++int java_lang_System::out_offset_in_bytes() {
++  return (instanceMirrorKlass::offset_of_static_fields() + static_out_offset);
+ }
+ 
+ 
+-int java_lang_System::out_offset_in_bytes() {
+-  return (offset_of_static_fields + static_out_offset);
+-}
+-
+-
+ int java_lang_System::err_offset_in_bytes() {
+-  return (offset_of_static_fields + static_err_offset);
++  return (instanceMirrorKlass::offset_of_static_fields() + static_err_offset);
+ }
+ 
+ 
+@@ -2688,6 +2781,8 @@
+ int java_lang_Class::array_klass_offset;
+ int java_lang_Class::resolved_constructor_offset;
+ int java_lang_Class::number_of_fake_oop_fields;
++int java_lang_Class::oop_size_offset;
++int java_lang_Class::static_oop_field_count_offset;
+ int java_lang_Throwable::backtrace_offset;
+ int java_lang_Throwable::detailMessage_offset;
+ int java_lang_Throwable::cause_offset;
+@@ -2731,7 +2826,6 @@
+ int java_lang_ref_SoftReference::timestamp_offset;
+ int java_lang_ref_SoftReference::static_clock_offset;
+ int java_lang_ClassLoader::parent_offset;
+-int java_lang_System::offset_of_static_fields;
+ int java_lang_System::static_in_offset;
+ int java_lang_System::static_out_offset;
+ int java_lang_System::static_err_offset;
+@@ -2849,10 +2943,19 @@
+   java_lang_String::count_offset  = java_lang_String::offset_offset + sizeof (jint);
+   java_lang_String::hash_offset   = java_lang_String::count_offset + sizeof (jint);
+ 
+-  // Do the Class Class
+-  java_lang_Class::klass_offset = java_lang_Class::hc_klass_offset * x + header;
+-  java_lang_Class::array_klass_offset = java_lang_Class::hc_array_klass_offset * x + header;
+-  java_lang_Class::resolved_constructor_offset = java_lang_Class::hc_resolved_constructor_offset * x + header;
++  {
++    // Do the Class Class
++    int offset = header;
++    java_lang_Class::oop_size_offset = header;
++    offset += BytesPerInt;
++    java_lang_Class::static_oop_field_count_offset = offset;
++    offset = align_size_up(offset + BytesPerInt, x);
++    java_lang_Class::klass_offset = offset;
++    offset += x;
++    java_lang_Class::array_klass_offset = offset;
++    offset += x;
++    java_lang_Class::resolved_constructor_offset = offset;
++  }
+ 
+   // This is NOT an offset
+   java_lang_Class::number_of_fake_oop_fields = java_lang_Class::hc_number_of_fake_oop_fields;
+@@ -2910,7 +3013,6 @@
+ void JavaClasses::compute_offsets() {
+ 
+   java_lang_Class::compute_offsets();
+-  java_lang_System::compute_offsets();
+   java_lang_Thread::compute_offsets();
+   java_lang_ThreadGroup::compute_offsets();
+   if (EnableMethodHandles) {
+@@ -2995,10 +3097,10 @@
+     tty->print_cr("Static field %s.%s appears to be nonstatic", klass_name, field_name);
+     return false;
+   }
+-  if (fd.offset() == hardcoded_offset + h_klass->offset_of_static_fields()) {
++  if (fd.offset() == hardcoded_offset + instanceMirrorKlass::offset_of_static_fields()) {
+     return true;
+   } else {
+-    tty->print_cr("Offset of static field %s.%s is hardcoded as %d but should really be %d.", klass_name, field_name, hardcoded_offset, fd.offset() - h_klass->offset_of_static_fields());
++    tty->print_cr("Offset of static field %s.%s is hardcoded as %d but should really be %d.", klass_name, field_name, hardcoded_offset, fd.offset() - instanceMirrorKlass::offset_of_static_fields());
+     return false;
+   }
+ }
+diff --git a/src/share/vm/classfile/javaClasses.hpp b/src/share/vm/classfile/javaClasses.hpp
+--- openjdk/hotspot/src/share/vm/classfile/javaClasses.hpp
++++ openjdk/hotspot/src/share/vm/classfile/javaClasses.hpp
+@@ -162,10 +162,8 @@
+   // The fake offsets are added by the class loader when java.lang.Class is loaded
+ 
+   enum {
+-    hc_klass_offset                = 0,
+-    hc_array_klass_offset          = 1,
+-    hc_resolved_constructor_offset = 2,
+-    hc_number_of_fake_oop_fields   = 3
++    hc_number_of_fake_oop_fields   = 3,
++    hc_number_of_fake_int_fields   = 2
+   };
+ 
+   static int klass_offset;
+@@ -173,6 +171,9 @@
+   static int array_klass_offset;
+   static int number_of_fake_oop_fields;
+ 
++  static int oop_size_offset;
++  static int static_oop_field_count_offset;
++
+   static void compute_offsets();
+   static bool offsets_computed;
+   static int classRedefinedCount_offset;
+@@ -181,6 +182,7 @@
+  public:
+   // Instance creation
+   static oop  create_mirror(KlassHandle k, TRAPS);
++  static void fixup_mirror(KlassHandle k, TRAPS);
+   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
+   // Conversion
+   static klassOop as_klassOop(oop java_class);
+@@ -215,6 +217,12 @@
+   static void set_classRedefinedCount(oop the_class_mirror, int value);
+   // Support for parallelCapable field
+   static bool parallelCapable(oop the_class_mirror);
++
++  static int oop_size(oop java_class);
++  static void set_oop_size(oop java_class, int size);
++  static int static_oop_field_count(oop java_class);
++  static void set_static_oop_field_count(oop java_class, int size);
++
+   // Debugging
+   friend class JavaClasses;
+   friend class instanceKlass;   // verification code accesses offsets
+diff --git a/src/share/vm/code/codeCache.cpp b/src/share/vm/code/codeCache.cpp
+--- openjdk/hotspot/src/share/vm/code/codeCache.cpp
++++ openjdk/hotspot/src/share/vm/code/codeCache.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+diff --git a/src/share/vm/code/nmethod.cpp b/src/share/vm/code/nmethod.cpp
+--- openjdk/hotspot/src/share/vm/code/nmethod.cpp
++++ openjdk/hotspot/src/share/vm/code/nmethod.cpp
+@@ -654,6 +654,9 @@
+     _pc_desc_cache.reset_to(NULL);
+ 
+     code_buffer->copy_oops_to(this);
++    if (ScavengeRootsInCode && detect_scavenge_root_oops()) {
++      CodeCache::add_scavenge_root_nmethod(this);
++    }
+     debug_only(verify_scavenge_root_oops());
+     CodeCache::commit(this);
+   }
+diff --git a/src/share/vm/interpreter/bytecodeInterpreter.cpp b/src/share/vm/interpreter/bytecodeInterpreter.cpp
+--- openjdk/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
++++ openjdk/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
+@@ -650,7 +650,7 @@
+           // oop rcvr = locals[0].j.r;
+           oop rcvr;
+           if (METHOD->is_static()) {
+-            rcvr = METHOD->constants()->pool_holder()->klass_part()->java_mirror();
++            rcvr = METHOD->constants()->pool_holder()->java_mirror();
+           } else {
+             rcvr = LOCALS_OBJECT(0);
+             VERIFY_OOP(rcvr);
+@@ -2105,8 +2105,8 @@
+             break;
+ 
+           case JVM_CONSTANT_Class:
+-            VERIFY_OOP(constants->resolved_klass_at(index)->klass_part()->java_mirror());
+-            SET_STACK_OBJECT(constants->resolved_klass_at(index)->klass_part()->java_mirror(), 0);
++            VERIFY_OOP(constants->resolved_klass_at(index)->java_mirror());
++            SET_STACK_OBJECT(constants->resolved_klass_at(index)->java_mirror(), 0);
+             break;
+ 
+           case JVM_CONSTANT_UnresolvedString:
+diff --git a/src/share/vm/interpreter/interpreterRuntime.cpp b/src/share/vm/interpreter/interpreterRuntime.cpp
+--- openjdk/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
++++ openjdk/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
+@@ -112,7 +112,7 @@
+ 
+   if (tag.is_unresolved_klass() || tag.is_klass()) {
+     klassOop klass = pool->klass_at(index, CHECK);
+-    oop java_class = klass->klass_part()->java_mirror();
++    oop java_class = klass->java_mirror();
+     thread->set_vm_result(java_class);
+   } else {
+ #ifdef ASSERT
+@@ -974,7 +974,8 @@
+ ConstantPoolCacheEntry *cp_entry))
+ 
+   // check the access_flags for the field in the klass
+-  instanceKlass* ik = instanceKlass::cast((klassOop)cp_entry->f1());
++
++  instanceKlass* ik = instanceKlass::cast(java_lang_Class::as_klassOop(cp_entry->f1()));
+   typeArrayOop fields = ik->fields();
+   int index = cp_entry->field_index();
+   assert(index < fields->length(), "holders field index is out of range");
+@@ -1000,7 +1001,7 @@
+     // non-static field accessors have an object, but we need a handle
+     h_obj = Handle(thread, obj);
+   }
+-  instanceKlassHandle h_cp_entry_f1(thread, (klassOop)cp_entry->f1());
++  instanceKlassHandle h_cp_entry_f1(thread, java_lang_Class::as_klassOop(cp_entry->f1()));
+   jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_cp_entry_f1, cp_entry->f2(), is_static);
+   JvmtiExport::post_field_access(thread, method(thread), bcp(thread), h_cp_entry_f1, h_obj, fid);
+ IRT_END
+@@ -1008,7 +1009,7 @@
+ IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread,
+   oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value))
+ 
+-  klassOop k = (klassOop)cp_entry->f1();
++  klassOop k = java_lang_Class::as_klassOop(cp_entry->f1());
+ 
+   // check the access_flags for the field in the klass
+   instanceKlass* ik = instanceKlass::cast(k);
+diff --git a/src/share/vm/memory/compactingPermGenGen.hpp b/src/share/vm/memory/compactingPermGenGen.hpp
+--- openjdk/hotspot/src/share/vm/memory/compactingPermGenGen.hpp
++++ openjdk/hotspot/src/share/vm/memory/compactingPermGenGen.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -108,7 +108,7 @@
+ public:
+ 
+   enum {
+-    vtbl_list_size = 16, // number of entries in the shared space vtable list.
++    vtbl_list_size = 17, // number of entries in the shared space vtable list.
+     num_virtuals = 200   // number of virtual methods in Klass (or
+                          // subclass) objects, or greater.
+   };
+diff --git a/src/share/vm/memory/oopFactory.cpp b/src/share/vm/memory/oopFactory.cpp
+--- openjdk/hotspot/src/share/vm/memory/oopFactory.cpp
++++ openjdk/hotspot/src/share/vm/memory/oopFactory.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -118,12 +118,12 @@
+ }
+ 
+ 
+-klassOop oopFactory::new_instanceKlass(int vtable_len, int itable_len,
++klassOop oopFactory::new_instanceKlass(Symbol* name, int vtable_len, int itable_len,
+                                        int static_field_size,
+                                        unsigned int nonstatic_oop_map_count,
+                                        ReferenceType rt, TRAPS) {
+   instanceKlassKlass* ikk = instanceKlassKlass::cast(Universe::instanceKlassKlassObj());
+-  return ikk->allocate_instance_klass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_count, rt, CHECK_NULL);
++  return ikk->allocate_instance_klass(name, vtable_len, itable_len, static_field_size, nonstatic_oop_map_count, rt, CHECK_NULL);
+ }
+ 
+ 
+diff --git a/src/share/vm/memory/oopFactory.hpp b/src/share/vm/memory/oopFactory.hpp
+--- openjdk/hotspot/src/share/vm/memory/oopFactory.hpp
++++ openjdk/hotspot/src/share/vm/memory/oopFactory.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -101,7 +101,8 @@
+                                                     TRAPS);
+ 
+   // Instance classes
+-  static klassOop        new_instanceKlass(int vtable_len, int itable_len,
++  static klassOop        new_instanceKlass(Symbol* name,
++                                           int vtable_len, int itable_len,
+                                            int static_field_size,
+                                            unsigned int nonstatic_oop_map_count,
+                                            ReferenceType rt, TRAPS);
+diff --git a/src/share/vm/memory/universe.cpp b/src/share/vm/memory/universe.cpp
+--- openjdk/hotspot/src/share/vm/memory/universe.cpp
++++ openjdk/hotspot/src/share/vm/memory/universe.cpp
+@@ -51,6 +51,7 @@
+ #include "oops/cpCacheKlass.hpp"
+ #include "oops/cpCacheOop.hpp"
+ #include "oops/instanceKlass.hpp"
++#include "oops/instanceMirrorKlass.hpp"
+ #include "oops/instanceKlassKlass.hpp"
+ #include "oops/instanceRefKlass.hpp"
+ #include "oops/klassKlass.hpp"
+@@ -535,6 +536,7 @@
+   { objArrayKlassKlass o;     add_vtable(list, &n, &o, count); }
+   { instanceKlassKlass o;     add_vtable(list, &n, &o, count); }
+   { instanceKlass o;          add_vtable(list, &n, &o, count); }
++  { instanceMirrorKlass o;    add_vtable(list, &n, &o, count); }
+   { instanceRefKlass o;       add_vtable(list, &n, &o, count); }
+   { typeArrayKlassKlass o;    add_vtable(list, &n, &o, count); }
+   { symbolKlass o;            add_vtable(list, &n, &o, count); }
+@@ -557,7 +559,7 @@
+       KlassHandle k(THREAD, klassOop(obj));
+       // We will never reach the CATCH below since Exceptions::_throw will cause
+       // the VM to exit if an exception is thrown during initialization
+-      java_lang_Class::create_mirror(k, CATCH);
++      java_lang_Class::fixup_mirror(k, CATCH);
+       // This call unconditionally creates a new mirror for k,
+       // and links in k's component_mirror field if k is an array.
+       // If k is an objArray, k's element type must already have
+@@ -615,6 +617,10 @@
+   // walk over permanent objects created so far (mostly classes) and fixup their mirrors. Note
+   // that the number of objects allocated at this point is very small.
+   assert(SystemDictionary::Class_klass_loaded(), "java.lang.Class should be loaded");
++
++  // Cache the start of the static fields
++  instanceMirrorKlass::init_offset_of_static_fields();
++
+   FixupMirrorClosure blk;
+   Universe::heap()->permanent_object_iterate(&blk);
+ }
+diff --git a/src/share/vm/oops/arrayKlassKlass.cpp b/src/share/vm/oops/arrayKlassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/arrayKlassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/arrayKlassKlass.cpp
+@@ -28,6 +28,13 @@
+ #include "oops/arrayKlassKlass.hpp"
+ #include "oops/oop.inline.hpp"
+ #include "runtime/handles.inline.hpp"
++#ifndef SERIALGC
++#include "gc_implementation/parNew/parOopClosures.inline.hpp"
++#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
++#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
++#include "memory/cardTableRS.hpp"
++#include "oops/oop.pcgc.inline.hpp"
++#endif
+ 
+ 
+ klassOop arrayKlassKlass::create_klass(TRAPS) {
+@@ -104,9 +111,12 @@
+ int arrayKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
+   assert(obj->is_klass(), "must be klass");
+   arrayKlass* ak = arrayKlass::cast(klassOop(obj));
+-  blk->do_oop(ak->adr_component_mirror());
+-  blk->do_oop(ak->adr_lower_dimension());
+-  blk->do_oop(ak->adr_higher_dimension());
++  oop* addr = ak->adr_component_mirror();
++  if (mr.contains(addr)) blk->do_oop(addr);
++  addr = ak->adr_lower_dimension();
++  if (mr.contains(addr)) blk->do_oop(addr);
++  addr = ak->adr_higher_dimension();
++  if (mr.contains(addr)) blk->do_oop(addr);
+   ak->vtable()->oop_oop_iterate_m(blk, mr);
+   return klassKlass::oop_oop_iterate_m(obj, blk, mr);
+ }
+@@ -114,6 +124,12 @@
+ #ifndef SERIALGC
+ void arrayKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
+   assert(obj->blueprint()->oop_is_arrayKlass(),"must be an array klass");
++  arrayKlass* ak = arrayKlass::cast(klassOop(obj));
++  oop* p = ak->adr_component_mirror();
++  if (PSScavenge::should_scavenge(p)) {
++    pm->claim_or_forward_depth(p);
++  }
++  klassKlass::oop_push_contents(pm, obj);
+ }
+ 
+ int arrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
+diff --git a/src/share/vm/oops/constantPoolOop.cpp b/src/share/vm/oops/constantPoolOop.cpp
+--- openjdk/hotspot/src/share/vm/oops/constantPoolOop.cpp
++++ openjdk/hotspot/src/share/vm/oops/constantPoolOop.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -477,7 +477,7 @@
+     {
+       klassOop resolved = klass_at_impl(this_oop, index, CHECK_NULL);
+       // ldc wants the java mirror.
+-      result_oop = resolved->klass_part()->java_mirror();
++      result_oop = resolved->java_mirror();
+       break;
+     }
+ 
+diff --git a/src/share/vm/oops/cpCacheKlass.cpp b/src/share/vm/oops/cpCacheKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/cpCacheKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/cpCacheKlass.cpp
+@@ -185,22 +185,18 @@
+ void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
+                                                oop obj) {
+   assert(obj->is_constantPoolCache(), "should be constant pool");
+-  if (EnableInvokeDynamic) {
++  if (ScavengeRootsInCode) {
+     constantPoolCacheOop cache = (constantPoolCacheOop)obj;
+     // during a scavenge, it is safe to inspect my pool, since it is perm
+     constantPoolOop pool = cache->constant_pool();
+     assert(pool->is_constantPool(), "should be constant pool");
+-    if (pool->has_invokedynamic()) {
+-      for (int i = 0; i < cache->length(); i++) {
+-        ConstantPoolCacheEntry* e = cache->entry_at(i);
+-        oop* p = (oop*)&e->_f1;
+-        if (e->is_secondary_entry()) {
+-          if (PSScavenge::should_scavenge(p))
+-            pm->claim_or_forward_depth(p);
+-          assert(!(e->is_vfinal() && PSScavenge::should_scavenge((oop*)&e->_f2)),
+-                 "no live oops here");
+-        }
+-      }
++    for (int i = 0; i < cache->length(); i++) {
++      ConstantPoolCacheEntry* e = cache->entry_at(i);
++      oop* p = (oop*)&e->_f1;
++      if (PSScavenge::should_scavenge(p))
++        pm->claim_or_forward_depth(p);
++      assert(!(e->is_vfinal() && PSScavenge::should_scavenge((oop*)&e->_f2)),
++             "no live oops here");
+     }
+   }
+ }
+diff --git a/src/share/vm/oops/cpCacheOop.cpp b/src/share/vm/oops/cpCacheOop.cpp
+--- openjdk/hotspot/src/share/vm/oops/cpCacheOop.cpp
++++ openjdk/hotspot/src/share/vm/oops/cpCacheOop.cpp
+@@ -133,7 +133,7 @@
+                                        TosState field_type,
+                                        bool is_final,
+                                        bool is_volatile) {
+-  set_f1(field_holder());
++  set_f1(field_holder()->java_mirror());
+   set_f2(field_offset);
+   // The field index is used by jvm/ti and is the index into fields() array
+   // in holder instanceKlass.  This is scaled by instanceKlass::next_offset.
+diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlass.cpp
+@@ -37,6 +37,7 @@
+ #include "memory/oopFactory.hpp"
+ #include "memory/permGen.hpp"
+ #include "oops/instanceKlass.hpp"
++#include "oops/instanceMirrorKlass.hpp"
+ #include "oops/instanceOop.hpp"
+ #include "oops/methodOop.hpp"
+ #include "oops/objArrayKlassKlass.hpp"
+@@ -649,6 +650,7 @@
+ }
+ 
+ instanceOop instanceKlass::allocate_instance(TRAPS) {
++  assert(!oop_is_instanceMirror(), "wrong allocation path");
+   bool has_finalizer_flag = has_finalizer(); // Query before possible GC
+   int size = size_helper();  // Query before forming handle.
+ 
+@@ -669,6 +671,7 @@
+   // instances so simply disallow finalizable perm objects.  This can
+   // be relaxed if a need for it is found.
+   assert(!has_finalizer(), "perm objects not allowed to have finalizers");
++  assert(!oop_is_instanceMirror(), "wrong allocation path");
+   int size = size_helper();  // Query before forming handle.
+   KlassHandle h_k(THREAD, as_klassOop());
+   instanceOop i = (instanceOop)
+@@ -891,6 +894,7 @@
+   }
+ }
+ 
++
+ void instanceKlass::do_local_static_fields(FieldClosure* cl) {
+   fieldDescriptor fd;
+   int length = fields()->length();
+@@ -1602,36 +1606,6 @@
+ // The following macros call specialized macros, passing either oop or
+ // narrowOop as the specialization type.  These test the UseCompressedOops
+ // flag.
+-#define InstanceKlass_OOP_ITERATE(start_p, count,    \
+-                                  do_oop, assert_fn) \
+-{                                                    \
+-  if (UseCompressedOops) {                           \
+-    InstanceKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \
+-      start_p, count,                                \
+-      do_oop, assert_fn)                             \
+-  } else {                                           \
+-    InstanceKlass_SPECIALIZED_OOP_ITERATE(oop,       \
+-      start_p, count,                                \
+-      do_oop, assert_fn)                             \
+-  }                                                  \
+-}
+-
+-#define InstanceKlass_BOUNDED_OOP_ITERATE(start_p, count, low, high,    \
+-                                          do_oop, assert_fn) \
+-{                                                            \
+-  if (UseCompressedOops) {                                   \
+-    InstanceKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop, \
+-      start_p, count,                                        \
+-      low, high,                                             \
+-      do_oop, assert_fn)                                     \
+-  } else {                                                   \
+-    InstanceKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop,       \
+-      start_p, count,                                        \
+-      low, high,                                             \
+-      do_oop, assert_fn)                                     \
+-  }                                                          \
+-}
+-
+ #define InstanceKlass_OOP_MAP_ITERATE(obj, do_oop, assert_fn)            \
+ {                                                                        \
+   /* Compute oopmap block range. The common case                         \
+@@ -1704,46 +1678,6 @@
+   }                                                                      \
+ }
+ 
+-void instanceKlass::follow_static_fields() {
+-  InstanceKlass_OOP_ITERATE( \
+-    start_of_static_fields(), static_oop_field_size(), \
+-    MarkSweep::mark_and_push(p), \
+-    assert_is_in_closed_subset)
+-}
+-
+-#ifndef SERIALGC
+-void instanceKlass::follow_static_fields(ParCompactionManager* cm) {
+-  InstanceKlass_OOP_ITERATE( \
+-    start_of_static_fields(), static_oop_field_size(), \
+-    PSParallelCompact::mark_and_push(cm, p), \
+-    assert_is_in)
+-}
+-#endif // SERIALGC
+-
+-void instanceKlass::adjust_static_fields() {
+-  InstanceKlass_OOP_ITERATE( \
+-    start_of_static_fields(), static_oop_field_size(), \
+-    MarkSweep::adjust_pointer(p), \
+-    assert_nothing)
+-}
+-
+-#ifndef SERIALGC
+-void instanceKlass::update_static_fields() {
+-  InstanceKlass_OOP_ITERATE( \
+-    start_of_static_fields(), static_oop_field_size(), \
+-    PSParallelCompact::adjust_pointer(p), \
+-    assert_nothing)
+-}
+-
+-void instanceKlass::update_static_fields(HeapWord* beg_addr, HeapWord* end_addr) {
+-  InstanceKlass_BOUNDED_OOP_ITERATE( \
+-    start_of_static_fields(), static_oop_field_size(), \
+-    beg_addr, end_addr, \
+-    PSParallelCompact::adjust_pointer(p), \
+-    assert_nothing )
+-}
+-#endif // SERIALGC
+-
+ void instanceKlass::oop_follow_contents(oop obj) {
+   assert(obj != NULL, "can't follow the content of NULL object");
+   obj->follow_header();
+@@ -1830,22 +1764,6 @@
+ ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
+ #endif // !SERIALGC
+ 
+-void instanceKlass::iterate_static_fields(OopClosure* closure) {
+-    InstanceKlass_OOP_ITERATE( \
+-      start_of_static_fields(), static_oop_field_size(), \
+-      closure->do_oop(p), \
+-      assert_is_in_reserved)
+-}
+-
+-void instanceKlass::iterate_static_fields(OopClosure* closure,
+-                                          MemRegion mr) {
+-  InstanceKlass_BOUNDED_OOP_ITERATE( \
+-    start_of_static_fields(), static_oop_field_size(), \
+-    mr.start(), mr.end(), \
+-    (closure)->do_oop_v(p), \
+-    assert_is_in_closed_subset)
+-}
+-
+ int instanceKlass::oop_adjust_pointers(oop obj) {
+   int size = size_helper();
+   InstanceKlass_OOP_MAP_ITERATE( \
+@@ -1883,21 +1801,6 @@
+   return size_helper();
+ }
+ 
+-void instanceKlass::push_static_fields(PSPromotionManager* pm) {
+-  InstanceKlass_OOP_ITERATE( \
+-    start_of_static_fields(), static_oop_field_size(), \
+-    if (PSScavenge::should_scavenge(p)) { \
+-      pm->claim_or_forward_depth(p); \
+-    }, \
+-    assert_nothing )
+-}
+-
+-void instanceKlass::copy_static_fields(ParCompactionManager* cm) {
+-  InstanceKlass_OOP_ITERATE( \
+-    start_of_static_fields(), static_oop_field_size(), \
+-    PSParallelCompact::adjust_pointer(p), \
+-    assert_is_in)
+-}
+ #endif // SERIALGC
+ 
+ // This klass is alive but the implementor link is not followed/updated.
+@@ -1992,6 +1895,11 @@
+   }
+ }
+ 
++address instanceKlass::static_field_addr(int offset) {
++  return (address)(offset + instanceMirrorKlass::offset_of_static_fields() + (intptr_t)java_mirror());
++}
++
++
+ const char* instanceKlass::signature_name() const {
+   const char* src = (const char*) (name()->as_C_string());
+   const int src_length = (int)strlen(src);
+@@ -2359,7 +2267,7 @@
+ 
+ void FieldPrinter::do_field(fieldDescriptor* fd) {
+   _st->print(BULLET);
+-   if (fd->is_static() || (_obj == NULL)) {
++   if (_obj == NULL) {
+      fd->print_on(_st);
+      _st->cr();
+    } else {
+@@ -2389,8 +2297,8 @@
+   }
+ 
+   st->print_cr(BULLET"---- fields (total size %d words):", oop_size(obj));
+-  FieldPrinter print_nonstatic_field(st, obj);
+-  do_nonstatic_fields(&print_nonstatic_field);
++  FieldPrinter print_field(st, obj);
++  do_nonstatic_fields(&print_field);
+ 
+   if (as_klassOop() == SystemDictionary::Class_klass()) {
+     st->print(BULLET"signature: ");
+@@ -2408,6 +2316,12 @@
+     st->print(BULLET"fake entry for array: ");
+     array_klass->print_value_on(st);
+     st->cr();
++    st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj));
++    st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj));
++    klassOop real_klass = java_lang_Class::as_klassOop(obj);
++    if (real_klass && real_klass->klass_part()->oop_is_instance()) {
++      instanceKlass::cast(real_klass)->do_local_static_fields(&print_field);
++    }
+   } else if (as_klassOop() == SystemDictionary::MethodType_klass()) {
+     st->print(BULLET"signature: ");
+     java_dyn_MethodType::print_signature(obj, st);
+@@ -2550,7 +2464,7 @@
+ 
+ 
+ void JNIid::verify(klassOop holder) {
+-  int first_field_offset  = instanceKlass::cast(holder)->offset_of_static_fields();
++  int first_field_offset  = instanceMirrorKlass::offset_of_static_fields();
+   int end_field_offset;
+   end_field_offset = first_field_offset + (instanceKlass::cast(holder)->static_field_size() * wordSize);
+ 
+diff --git a/src/share/vm/oops/instanceKlass.hpp b/src/share/vm/oops/instanceKlass.hpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlass.hpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlass.hpp
+@@ -75,8 +75,6 @@
+ //    [Java vtable length         ]
+ //    [oop map cache (stack maps) ]
+ //    [EMBEDDED Java vtable             ] size in words = vtable_len
+-//    [EMBEDDED static oop fields       ] size in words = static_oop_fields_size
+-//    [         static non-oop fields   ] size in words = static_field_size - static_oop_fields_size
+ //    [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
+ //
+ //    The embedded nonstatic oop-map blocks are short pairs (offset, length) indicating
+@@ -226,7 +224,7 @@
+   // (including inherited fields but after header_size()).
+   int             _nonstatic_field_size;
+   int             _static_field_size;    // number words used by static fields (oop and non-oop) in this klass
+-  int             _static_oop_field_size;// number of static oop fields in this klass
++  int             _static_oop_field_count;// number of static oop fields in this klass
+   int             _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
+   bool            _is_marked_dependent;  // used for marking during flushing and deoptimization
+   bool            _rewritten;            // methods rewritten.
+@@ -277,8 +275,8 @@
+   int static_field_size() const            { return _static_field_size; }
+   void set_static_field_size(int size)     { _static_field_size = size; }
+ 
+-  int static_oop_field_size() const        { return _static_oop_field_size; }
+-  void set_static_oop_field_size(int size) { _static_oop_field_size = size; }
++  int static_oop_field_count() const        { return _static_oop_field_count; }
++  void set_static_oop_field_count(int size) { _static_oop_field_count = size; }
+ 
+   // Java vtable
+   int  vtable_length() const               { return _vtable_len; }
+@@ -651,6 +649,7 @@
+ 
+   // Casting from klassOop
+   static instanceKlass* cast(klassOop k) {
++    assert(k->is_klass(), "must be");
+     Klass* kp = k->klass_part();
+     assert(kp->null_vtbl() || kp->oop_is_instance_slow(), "cast to instanceKlass");
+     return (instanceKlass*) kp;
+@@ -658,7 +657,7 @@
+ 
+   // Sizing (in words)
+   static int header_size()            { return align_object_offset(oopDesc::header_size() + sizeof(instanceKlass)/HeapWordSize); }
+-  int object_size() const             { return object_size(align_object_offset(vtable_length()) + align_object_offset(itable_length()) + static_field_size() + nonstatic_oop_map_size()); }
++  int object_size() const             { return object_size(align_object_offset(vtable_length()) + align_object_offset(itable_length()) + nonstatic_oop_map_size()); }
+   static int vtable_start_offset()    { return header_size(); }
+   static int vtable_length_offset()   { return oopDesc::header_size() + offset_of(instanceKlass, _vtable_len) / HeapWordSize; }
+   static int object_size(int extra)   { return align_object_size(header_size() + extra); }
+@@ -667,20 +666,12 @@
+   intptr_t* start_of_itable() const        { return start_of_vtable() + align_object_offset(vtable_length()); }
+   int  itable_offset_in_words() const { return start_of_itable() - (intptr_t*)as_klassOop(); }
+ 
+-  // Static field offset is an offset into the Heap, should be converted by
+-  // based on UseCompressedOop for traversal
+-  HeapWord* start_of_static_fields() const {
+-    return (HeapWord*)(start_of_itable() + align_object_offset(itable_length()));
+-  }
+-
+   intptr_t* end_of_itable() const          { return start_of_itable() + itable_length(); }
+ 
+-  int offset_of_static_fields() const {
+-    return (intptr_t)start_of_static_fields() - (intptr_t)as_klassOop();
+-  }
++  address static_field_addr(int offset);
+ 
+   OopMapBlock* start_of_nonstatic_oop_maps() const {
+-    return (OopMapBlock*) (start_of_static_fields() + static_field_size());
++    return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length()));
+   }
+ 
+   // Allocation profiling support
+@@ -710,8 +701,6 @@
+ 
+   // Garbage collection
+   void oop_follow_contents(oop obj);
+-  void follow_static_fields();
+-  void adjust_static_fields();
+   int  oop_adjust_pointers(oop obj);
+   bool object_is_parsable() const { return _init_state != unparsable_by_gc; }
+        // Value of _init_state must be zero (unparsable_by_gc) when klass field is set.
+@@ -723,17 +712,6 @@
+   // Parallel Scavenge and Parallel Old
+   PARALLEL_GC_DECLS
+ 
+-#ifndef SERIALGC
+-  // Parallel Scavenge
+-  void push_static_fields(PSPromotionManager* pm);
+-
+-  // Parallel Old
+-  void follow_static_fields(ParCompactionManager* cm);
+-  void copy_static_fields(ParCompactionManager* cm);
+-  void update_static_fields();
+-  void update_static_fields(HeapWord* beg_addr, HeapWord* end_addr);
+-#endif // SERIALGC
+-
+   // Naming
+   const char* signature_name() const;
+ 
+@@ -762,9 +740,6 @@
+   ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
+ #endif // !SERIALGC
+ 
+-  void iterate_static_fields(OopClosure* closure);
+-  void iterate_static_fields(OopClosure* closure, MemRegion mr);
+-
+ private:
+   // initialization state
+ #ifdef ASSERT
+@@ -921,6 +896,10 @@
+   // Identifier lookup
+   JNIid* find(int offset);
+ 
++  bool find_local_field(fieldDescriptor* fd) {
++    return instanceKlass::cast(holder())->find_local_field_from_offset(offset(), true, fd);
++  }
++
+   // Garbage collection support
+   oop* holder_addr() { return (oop*)&_holder; }
+   void oops_do(OopClosure* f);
+diff --git a/src/share/vm/oops/instanceKlassKlass.cpp b/src/share/vm/oops/instanceKlassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
+@@ -31,6 +31,7 @@
+ #include "memory/gcLocker.hpp"
+ #include "oops/constantPoolOop.hpp"
+ #include "oops/instanceKlass.hpp"
++#include "oops/instanceMirrorKlass.hpp"
+ #include "oops/instanceKlassKlass.hpp"
+ #include "oops/instanceRefKlass.hpp"
+ #include "oops/objArrayKlassKlass.hpp"
+@@ -86,7 +87,6 @@
+   assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass");
+ 
+   instanceKlass* ik = instanceKlass::cast(klassOop(obj));
+-  ik->follow_static_fields();
+   {
+     HandleMark hm;
+     ik->vtable()->oop_follow_contents();
+@@ -130,7 +130,6 @@
+   assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass");
+ 
+   instanceKlass* ik = instanceKlass::cast(klassOop(obj));
+-  ik->follow_static_fields(cm);
+   ik->vtable()->oop_follow_contents(cm);
+   ik->itable()->oop_follow_contents(cm);
+ 
+@@ -174,7 +173,6 @@
+   // Don't call size() or oop_size() since that is a virtual call.
+   int size = ik->object_size();
+ 
+-  ik->iterate_static_fields(blk);
+   ik->vtable()->oop_oop_iterate(blk);
+   ik->itable()->oop_oop_iterate(blk);
+ 
+@@ -218,7 +216,6 @@
+   // Don't call size() or oop_size() since that is a virtual call.
+   int size = ik->object_size();
+ 
+-  ik->iterate_static_fields(blk, mr);
+   ik->vtable()->oop_oop_iterate_m(blk, mr);
+   ik->itable()->oop_oop_iterate_m(blk, mr);
+ 
+@@ -281,7 +278,6 @@
+   assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass");
+ 
+   instanceKlass* ik = instanceKlass::cast(klassOop(obj));
+-  ik->adjust_static_fields();
+   ik->vtable()->oop_adjust_pointers();
+   ik->itable()->oop_adjust_pointers();
+ 
+@@ -318,7 +314,6 @@
+ #ifndef SERIALGC
+ void instanceKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
+   instanceKlass* ik = instanceKlass::cast(klassOop(obj));
+-  ik->push_static_fields(pm);
+ 
+   oop* loader_addr = ik->adr_class_loader();
+   if (PSScavenge::should_scavenge(loader_addr)) {
+@@ -354,7 +349,6 @@
+          "must be instance klass");
+ 
+   instanceKlass* ik = instanceKlass::cast(klassOop(obj));
+-  ik->update_static_fields();
+   ik->vtable()->oop_update_pointers(cm);
+   ik->itable()->oop_update_pointers(cm);
+ 
+@@ -403,22 +397,28 @@
+ #endif // SERIALGC
+ 
+ klassOop
+-instanceKlassKlass::allocate_instance_klass(int vtable_len, int itable_len,
++instanceKlassKlass::allocate_instance_klass(Symbol* name, int vtable_len, int itable_len,
+                                             int static_field_size,
+                                             unsigned nonstatic_oop_map_count,
+                                             ReferenceType rt, TRAPS) {
+ 
+   const int nonstatic_oop_map_size =
+     instanceKlass::nonstatic_oop_map_size(nonstatic_oop_map_count);
+-  int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + static_field_size + nonstatic_oop_map_size);
++  int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + nonstatic_oop_map_size);
+ 
+   // Allocation
+   KlassHandle h_this_klass(THREAD, as_klassOop());
+   KlassHandle k;
+   if (rt == REF_NONE) {
+-    // regular klass
+-    instanceKlass o;
+-    k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
++    if (name != vmSymbols::java_lang_Class()) {
++      // regular klass
++      instanceKlass o;
++      k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
++    } else {
++      // Class
++      instanceMirrorKlass o;
++      k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
++    }
+   } else {
+     // reference klass
+     instanceRefKlass o;
+@@ -453,7 +453,7 @@
+     ik->set_source_file_name(NULL);
+     ik->set_source_debug_extension(NULL);
+     ik->set_inner_classes(NULL);
+-    ik->set_static_oop_field_size(0);
++    ik->set_static_oop_field_count(0);
+     ik->set_nonstatic_field_size(0);
+     ik->set_is_marked_dependent(false);
+     ik->set_init_state(instanceKlass::allocated);
+@@ -487,9 +487,6 @@
+     // To get verify to work - must be set to partial loaded before first GC point.
+     k()->set_partially_loaded();
+   }
+-
+-  // GC can happen here
+-  java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
+   return k();
+ }
+ 
+@@ -611,13 +608,6 @@
+   FieldPrinter print_nonstatic_field(st);
+   ik->do_nonstatic_fields(&print_nonstatic_field);
+ 
+-  st->print(BULLET"static oop maps:     ");
+-  if (ik->static_oop_field_size() > 0) {
+-    int first_offset = ik->offset_of_static_fields();
+-    st->print("%d-%d", first_offset, first_offset + ik->static_oop_field_size() - 1);
+-  }
+-  st->cr();
+-
+   st->print(BULLET"non-static oop maps: ");
+   OopMapBlock* map     = ik->start_of_nonstatic_oop_maps();
+   OopMapBlock* end_map = map + ik->nonstatic_oop_map_count();
+@@ -675,7 +665,6 @@
+ 
+     // Verify static fields
+     VerifyFieldClosure blk;
+-    ik->iterate_static_fields(&blk);
+ 
+     // Verify vtables
+     if (ik->is_linked()) {
+diff --git a/src/share/vm/oops/instanceKlassKlass.hpp b/src/share/vm/oops/instanceKlassKlass.hpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.hpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -41,7 +41,8 @@
+   // Allocation
+   DEFINE_ALLOCATE_PERMANENT(instanceKlassKlass);
+   static klassOop create_klass(TRAPS);
+-  klassOop allocate_instance_klass(int vtable_len,
++  klassOop allocate_instance_klass(Symbol* name,
++                                   int vtable_len,
+                                    int itable_len,
+                                    int static_field_size,
+                                    unsigned int nonstatic_oop_map_count,
+diff --git a/src/share/vm/oops/instanceMirrorKlass.cpp b/src/share/vm/oops/instanceMirrorKlass.cpp
+new file mode 100644
+--- /dev/null
++++ openjdk/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp
+@@ -0,0 +1,313 @@
++/*
++ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ *
++ */
++
++#include "precompiled.hpp"
++#include "classfile/javaClasses.hpp"
++#include "classfile/systemDictionary.hpp"
++#include "gc_implementation/shared/markSweep.inline.hpp"
++#include "gc_interface/collectedHeap.inline.hpp"
++#include "memory/genOopClosures.inline.hpp"
++#include "memory/oopFactory.hpp"
++#include "memory/permGen.hpp"
++#include "oops/instanceKlass.hpp"
++#include "oops/instanceMirrorKlass.hpp"
++#include "oops/instanceOop.hpp"
++#include "oops/oop.inline.hpp"
++#include "oops/symbol.hpp"
++#include "runtime/handles.inline.hpp"
++#ifndef SERIALGC
++#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
++#include "gc_implementation/g1/g1OopClosures.inline.hpp"
++#include "gc_implementation/g1/g1RemSet.inline.hpp"
++#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
++#include "gc_implementation/parNew/parOopClosures.inline.hpp"
++#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
++#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
++#include "oops/oop.pcgc.inline.hpp"
++#endif
++
++int instanceMirrorKlass::_offset_of_static_fields = 0;
++
++#ifdef ASSERT
++template <class T> void assert_is_in(T *p) {
++  T heap_oop = oopDesc::load_heap_oop(p);
++  if (!oopDesc::is_null(heap_oop)) {
++    oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
++    assert(Universe::heap()->is_in(o), "should be in heap");
++  }
++}
++template <class T> void assert_is_in_closed_subset(T *p) {
++  T heap_oop = oopDesc::load_heap_oop(p);
++  if (!oopDesc::is_null(heap_oop)) {
++    oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
++    assert(Universe::heap()->is_in_closed_subset(o), "should be in closed");
++  }
++}
++template <class T> void assert_is_in_reserved(T *p) {
++  T heap_oop = oopDesc::load_heap_oop(p);
++  if (!oopDesc::is_null(heap_oop)) {
++    oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
++    assert(Universe::heap()->is_in_reserved(o), "should be in reserved");
++  }
++}
++template <class T> void assert_nothing(T *p) {}
++
++#else
++template <class T> void assert_is_in(T *p) {}
++template <class T> void assert_is_in_closed_subset(T *p) {}
++template <class T> void assert_is_in_reserved(T *p) {}
++template <class T> void assert_nothing(T *p) {}
++#endif // ASSERT
++
++#define InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE( \
++  T, start_p, count, do_oop,                         \
++  assert_fn)                                         \
++{                                                    \
++  T* p         = (T*)(start_p);                      \
++  T* const end = p + (count);                        \
++  while (p < end) {                                  \
++    (assert_fn)(p);                                  \
++    do_oop;                                          \
++    ++p;                                             \
++  }                                                  \
++}
++
++#define InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE( \
++  T, start_p, count, low, high,                              \
++  do_oop, assert_fn)                                         \
++{                                                            \
++  T* const l = (T*)(low);                                    \
++  T* const h = (T*)(high);                                   \
++  assert(mask_bits((intptr_t)l, sizeof(T)-1) == 0 &&         \
++         mask_bits((intptr_t)h, sizeof(T)-1) == 0,           \
++         "bounded region must be properly aligned");         \
++  T* p       = (T*)(start_p);                                \
++  T* end     = p + (count);                                  \
++  if (p < l) p = l;                                          \
++  if (end > h) end = h;                                      \
++  while (p < end) {                                          \
++    (assert_fn)(p);                                          \
++    do_oop;                                                  \
++    ++p;                                                     \
++  }                                                          \
++}
++
++
++#define InstanceMirrorKlass_OOP_ITERATE(start_p, count,    \
++                                  do_oop, assert_fn)       \
++{                                                          \
++  if (UseCompressedOops) {                                 \
++    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \
++      start_p, count,                                      \
++      do_oop, assert_fn)                                   \
++  } else {                                                 \
++    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE(oop,       \
++      start_p, count,                                      \
++      do_oop, assert_fn)                                   \
++  }                                                        \
++}
++
++// The following macros call specialized macros, passing either oop or
++// narrowOop as the specialization type.  These test the UseCompressedOops
++// flag.
++#define InstanceMirrorKlass_BOUNDED_OOP_ITERATE(start_p, count, low, high, \
++                                          do_oop, assert_fn)               \
++{                                                                          \
++  if (UseCompressedOops) {                                                 \
++    InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop,         \
++      start_p, count,                                                      \
++      low, high,                                                           \
++      do_oop, assert_fn)                                                   \
++  } else {                                                                 \
++    InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop,               \
++      start_p, count,                                                      \
++      low, high,                                                           \
++      do_oop, assert_fn)                                                   \
++  }                                                                        \
++}
++
++
++void instanceMirrorKlass::oop_follow_contents(oop obj) {
++  instanceKlass::oop_follow_contents(obj);
++  InstanceMirrorKlass_OOP_ITERATE(                                                    \
++    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
++    MarkSweep::mark_and_push(p),                                                      \
++    assert_is_in_closed_subset)
++}
++
++#ifndef SERIALGC
++void instanceMirrorKlass::oop_follow_contents(ParCompactionManager* cm,
++                                              oop obj) {
++  instanceKlass::oop_follow_contents(cm, obj);
++  InstanceMirrorKlass_OOP_ITERATE(                                                    \
++    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
++    PSParallelCompact::mark_and_push(cm, p),                                          \
++    assert_is_in)
++}
++#endif // SERIALGC
++
++int instanceMirrorKlass::oop_adjust_pointers(oop obj) {
++  int size = oop_size(obj);
++  instanceKlass::oop_adjust_pointers(obj);
++  InstanceMirrorKlass_OOP_ITERATE(                                                    \
++    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
++    MarkSweep::adjust_pointer(p),                                                     \
++    assert_nothing)
++  return size;
++}
++
++#define InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(T, nv_suffix)                \
++  InstanceMirrorKlass_OOP_ITERATE(                                                    \
++    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
++      (closure)->do_oop##nv_suffix(p),                                                \
++    assert_is_in_closed_subset)                                                       \
++  return oop_size(obj);                                                               \
++
++#define InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(T, nv_suffix, mr)         \
++  InstanceMirrorKlass_BOUNDED_OOP_ITERATE(                                            \
++    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
++    mr.start(), mr.end(),                                                             \
++      (closure)->do_oop##nv_suffix(p),                                                \
++    assert_is_in_closed_subset)                                                       \
++  return oop_size(obj);                                                               \
++
++
++// Macro to define instanceMirrorKlass::oop_oop_iterate for virtual/nonvirtual for
++// all closures.  Macros calling macros above for each oop size.
++
++#define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)           \
++                                                                                      \
++int instanceMirrorKlass::                                                             \
++oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) {                        \
++  /* Get size before changing pointers */                                             \
++  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);      \
++                                                                                      \
++  instanceKlass::oop_oop_iterate##nv_suffix(obj, closure);                            \
++                                                                                      \
++  if (UseCompressedOops) {                                                            \
++    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(narrowOop, nv_suffix);           \
++  } else {                                                                            \
++    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(oop, nv_suffix);                 \
++  }                                                                                   \
++}
++
++#ifndef SERIALGC
++#define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \
++                                                                                      \
++int instanceMirrorKlass::                                                             \
++oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) {              \
++  /* Get size before changing pointers */                                             \
++  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);      \
++                                                                                      \
++  instanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure);                  \
++                                                                                      \
++  if (UseCompressedOops) {                                                            \
++    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(narrowOop, nv_suffix);           \
++  } else {                                                                            \
++    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(oop, nv_suffix);                 \
++  }                                                                                   \
++}
++#endif // !SERIALGC
++
++
++#define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix)         \
++                                                                                      \
++int instanceMirrorKlass::                                                             \
++oop_oop_iterate##nv_suffix##_m(oop obj,                                               \
++                               OopClosureType* closure,                               \
++                               MemRegion mr) {                                        \
++  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);      \
++                                                                                      \
++  instanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr);                    \
++  if (UseCompressedOops) {                                                            \
++    InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, mr);    \
++  } else {                                                                            \
++    InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, mr);          \
++  }                                                                                   \
++}
++
++ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN)
++ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN)
++#ifndef SERIALGC
++ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
++ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
++#endif // SERIALGC
++ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m)
++ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m)
++
++#ifndef SERIALGC
++void instanceMirrorKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
++  instanceKlass::oop_push_contents(pm, obj);
++  InstanceMirrorKlass_OOP_ITERATE(                                            \
++    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\
++    if (PSScavenge::should_scavenge(p)) {                                     \
++      pm->claim_or_forward_depth(p);                                          \
++    },                                                                        \
++    assert_nothing )
++}
++
++int instanceMirrorKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
++  instanceKlass::oop_update_pointers(cm, obj);
++  InstanceMirrorKlass_OOP_ITERATE(                                            \
++    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\
++    PSParallelCompact::adjust_pointer(p),                                     \
++    assert_nothing)
++  return oop_size(obj);
++}
++#endif // SERIALGC
++
++int instanceMirrorKlass::instance_size(KlassHandle k) {
++  if (k() != NULL && k->oop_is_instance()) {
++    return align_object_size(size_helper() + instanceKlass::cast(k())->static_field_size());
++  }
++  return size_helper();
++}
++
++instanceOop instanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) {
++  // Query before forming handle.
++  int size = instance_size(k);
++  KlassHandle h_k(THREAD, as_klassOop());
++  instanceOop i;
++
++  if (JavaObjectsInPerm) {
++    i = (instanceOop) CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
++  } else {
++    assert(ScavengeRootsInCode > 0, "must be");
++    i = (instanceOop) CollectedHeap::obj_allocate(h_k, size, CHECK_NULL);
++  }
++
++  return i;
++}
++
++int instanceMirrorKlass::oop_size(oop obj) const {
++  return java_lang_Class::oop_size(obj);
++}
++
++int instanceMirrorKlass::compute_static_oop_field_count(oop obj) {
++  klassOop k = java_lang_Class::as_klassOop(obj);
++  if (k != NULL && k->klass_part()->oop_is_instance()) {
++    return instanceKlass::cast(k)->static_oop_field_count();
++  }
++  return 0;
++}
+diff --git a/src/share/vm/oops/instanceMirrorKlass.hpp b/src/share/vm/oops/instanceMirrorKlass.hpp
+new file mode 100644
+--- /dev/null
++++ openjdk/hotspot/src/share/vm/oops/instanceMirrorKlass.hpp
+@@ -0,0 +1,110 @@
++/*
++ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ *
++ */
++
++#ifndef SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
++#define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
++
++#include "oops/instanceKlass.hpp"
++
++// An instanceMirrorKlass is a specialized instanceKlass for
++// java.lang.Class instances.  These instances are special because
++// they contain the static fields of the class in addition to the
++// normal fields of Class.  This means they are variable sized
++// instances and need special logic for computing their size and for
++// iteration of their oops.
++
++
++class instanceMirrorKlass: public instanceKlass {
++ private:
++  static int _offset_of_static_fields;
++
++ public:
++  // Type testing
++  bool oop_is_instanceMirror() const             { return true; }
++
++  // Casting from klassOop
++  static instanceMirrorKlass* cast(klassOop k) {
++    assert(k->klass_part()->oop_is_instanceMirror(), "cast to instanceMirrorKlass");
++    return (instanceMirrorKlass*) k->klass_part();
++  }
++
++  // Returns the size of the instance including the extra static fields.
++  virtual int oop_size(oop obj) const;
++
++  // Static field offset is an offset into the Heap, should be converted by
++  // based on UseCompressedOop for traversal
++  static HeapWord* start_of_static_fields(oop obj) {
++    return (HeapWord*)((intptr_t)obj + offset_of_static_fields());
++  }
++
++  static void init_offset_of_static_fields() {
++    // Cache the offset of the static fields in the Class instance
++    assert(_offset_of_static_fields == 0, "once");
++    _offset_of_static_fields = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
++  }
++
++  static int offset_of_static_fields() {
++    return _offset_of_static_fields;
++  }
++
++  int compute_static_oop_field_count(oop obj);
++
++  // Given a Klass return the size of the instance
++  int instance_size(KlassHandle k);
++
++  // allocation
++  DEFINE_ALLOCATE_PERMANENT(instanceMirrorKlass);
++  instanceOop allocate_instance(KlassHandle k, TRAPS);
++
++  // Garbage collection
++  int  oop_adjust_pointers(oop obj);
++  void oop_follow_contents(oop obj);
++
++  // Parallel Scavenge and Parallel Old
++  PARALLEL_GC_DECLS
++
++  int oop_oop_iterate(oop obj, OopClosure* blk) {
++    return oop_oop_iterate_v(obj, blk);
++  }
++  int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
++    return oop_oop_iterate_v_m(obj, blk, mr);
++  }
++
++#define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)           \
++  int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);                       \
++  int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);
++
++  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
++  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
++
++#ifndef SERIALGC
++#define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \
++  int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);
++
++  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
++  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
++#endif // !SERIALGC
++};
++
++#endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
+diff --git a/src/share/vm/oops/klass.hpp b/src/share/vm/oops/klass.hpp
+--- openjdk/hotspot/src/share/vm/oops/klass.hpp
++++ openjdk/hotspot/src/share/vm/oops/klass.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -576,6 +576,7 @@
+  public:
+   // type testing operations
+   virtual bool oop_is_instance_slow()       const { return false; }
++  virtual bool oop_is_instanceMirror()      const { return false; }
+   virtual bool oop_is_instanceRef()         const { return false; }
+   virtual bool oop_is_array()               const { return false; }
+   virtual bool oop_is_objArray_slow()       const { return false; }
+@@ -811,4 +812,8 @@
+ #endif
+ };
+ 
++
++inline oop klassOopDesc::java_mirror() const                        { return klass_part()->java_mirror(); }
++
++
+ #endif // SHARE_VM_OOPS_KLASS_HPP
+diff --git a/src/share/vm/oops/klassKlass.cpp b/src/share/vm/oops/klassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/klassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/klassKlass.cpp
+@@ -42,6 +42,10 @@
+ #include "oops/typeArrayKlass.hpp"
+ #include "runtime/handles.inline.hpp"
+ #ifndef SERIALGC
++#include "gc_implementation/parNew/parOopClosures.inline.hpp"
++#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
++#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
++#include "memory/cardTableRS.hpp"
+ #include "oops/oop.pcgc.inline.hpp"
+ #endif
+ 
+@@ -182,6 +186,12 @@
+ 
+ #ifndef SERIALGC
+ void klassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
++  Klass* k = Klass::cast(klassOop(obj));
++
++  oop* p = k->adr_java_mirror();
++  if (PSScavenge::should_scavenge(p)) {
++    pm->claim_or_forward_depth(p);
++  }
+ }
+ 
+ int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
+@@ -253,7 +263,7 @@
+ 
+   if (k->java_mirror() != NULL || (k->oop_is_instance() && instanceKlass::cast(klassOop(obj))->is_loaded())) {
+     guarantee(k->java_mirror() != NULL,          "should be allocated");
+-    guarantee(k->java_mirror()->is_perm(),       "should be in permspace");
++    guarantee(k->java_mirror()->is_perm() || !JavaObjectsInPerm,       "should be in permspace");
+     guarantee(k->java_mirror()->is_instance(),   "should be instance");
+   }
+   if (k->name() != NULL) {
+diff --git a/src/share/vm/oops/klassOop.hpp b/src/share/vm/oops/klassOop.hpp
+--- openjdk/hotspot/src/share/vm/oops/klassOop.hpp
++++ openjdk/hotspot/src/share/vm/oops/klassOop.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -45,7 +45,73 @@
+   static int klass_part_offset_in_bytes()        { return sizeof(klassOopDesc); }
+ 
+   // returns the Klass part containing dispatching behavior
+-  Klass* klass_part()                            { return (Klass*)((address)this + klass_part_offset_in_bytes()); }
++  Klass* klass_part() const                      { return (Klass*)((address)this + klass_part_offset_in_bytes()); }
++
++  // Convenience wrapper
++  inline oop java_mirror() const;
++
++ private:
++  // These have no implementation since klassOop should never be accessed in this fashion
++  oop obj_field(int offset) const;
++  void obj_field_put(int offset, oop value);
++  void obj_field_raw_put(int offset, oop value);
++
++  jbyte byte_field(int offset) const;
++  void byte_field_put(int offset, jbyte contents);
++
++  jchar char_field(int offset) const;
++  void char_field_put(int offset, jchar contents);
++
++  jboolean bool_field(int offset) const;
++  void bool_field_put(int offset, jboolean contents);
++
++  jint int_field(int offset) const;
++  void int_field_put(int offset, jint contents);
++
++  jshort short_field(int offset) const;
++  void short_field_put(int offset, jshort contents);
++
++  jlong long_field(int offset) const;
++  void long_field_put(int offset, jlong contents);
++
++  jfloat float_field(int offset) const;
++  void float_field_put(int offset, jfloat contents);
++
++  jdouble double_field(int offset) const;
++  void double_field_put(int offset, jdouble contents);
++
++  address address_field(int offset) const;
++  void address_field_put(int offset, address contents);
++
++  oop obj_field_acquire(int offset) const;
++  void release_obj_field_put(int offset, oop value);
++
++  jbyte byte_field_acquire(int offset) const;
++  void release_byte_field_put(int offset, jbyte contents);
++
++  jchar char_field_acquire(int offset) const;
++  void release_char_field_put(int offset, jchar contents);
++
++  jboolean bool_field_acquire(int offset) const;
++  void release_bool_field_put(int offset, jboolean contents);
++
++  jint int_field_acquire(int offset) const;
++  void release_int_field_put(int offset, jint contents);
++
++  jshort short_field_acquire(int offset) const;
++  void release_short_field_put(int offset, jshort contents);
++
++  jlong long_field_acquire(int offset) const;
++  void release_long_field_put(int offset, jlong contents);
++
++  jfloat float_field_acquire(int offset) const;
++  void release_float_field_put(int offset, jfloat contents);
++
++  jdouble double_field_acquire(int offset) const;
++  void release_double_field_put(int offset, jdouble contents);
++
++  address address_field_acquire(int offset) const;
++  void release_address_field_put(int offset, address contents);
+ };
+ 
+ #endif // SHARE_VM_OOPS_KLASSOOP_HPP
+diff --git a/src/share/vm/oops/klassVtable.cpp b/src/share/vm/oops/klassVtable.cpp
+--- openjdk/hotspot/src/share/vm/oops/klassVtable.cpp
++++ openjdk/hotspot/src/share/vm/oops/klassVtable.cpp
+@@ -1134,7 +1134,7 @@
+   itableOffsetEntry* ioe = (itableOffsetEntry*)klass->start_of_itable();
+   itableMethodEntry* ime = (itableMethodEntry*)(ioe + nof_interfaces);
+   intptr_t* end               = klass->end_of_itable();
+-  assert((oop*)(ime + nof_methods) <= (oop*)klass->start_of_static_fields(), "wrong offset calculation (1)");
++  assert((oop*)(ime + nof_methods) <= (oop*)klass->start_of_nonstatic_oop_maps(), "wrong offset calculation (1)");
+   assert((oop*)(end) == (oop*)(ime + nof_methods),                      "wrong offset calculation (2)");
+ 
+   // Visit all interfaces and initialize itable offset table
+diff --git a/src/share/vm/oops/objArrayKlassKlass.cpp b/src/share/vm/oops/objArrayKlassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp
+@@ -31,6 +31,13 @@
+ #include "oops/objArrayKlassKlass.hpp"
+ #include "oops/oop.inline.hpp"
+ #include "oops/oop.inline2.hpp"
++#ifndef SERIALGC
++#include "gc_implementation/parNew/parOopClosures.inline.hpp"
++#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
++#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
++#include "memory/cardTableRS.hpp"
++#include "oops/oop.pcgc.inline.hpp"
++#endif
+ 
+ klassOop objArrayKlassKlass::create_klass(TRAPS) {
+   objArrayKlassKlass o;
+@@ -232,12 +239,23 @@
+   addr = oak->bottom_klass_addr();
+   if (mr.contains(addr)) blk->do_oop(addr);
+ 
+-  return arrayKlassKlass::oop_oop_iterate(obj, blk);
++  return arrayKlassKlass::oop_oop_iterate_m(obj, blk, mr);
+ }
+ 
+ #ifndef SERIALGC
+ void objArrayKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
+   assert(obj->blueprint()->oop_is_objArrayKlass(),"must be an obj array klass");
++  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
++  oop* p = oak->element_klass_addr();
++  if (PSScavenge::should_scavenge(p)) {
++    pm->claim_or_forward_depth(p);
++  }
++  p = oak->bottom_klass_addr();
++  if (PSScavenge::should_scavenge(p)) {
++    pm->claim_or_forward_depth(p);
++  }
++
++  arrayKlassKlass::oop_push_contents(pm, obj);
+ }
+ 
+ int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
+@@ -299,7 +317,7 @@
+ // Verification
+ 
+ void objArrayKlassKlass::oop_verify_on(oop obj, outputStream* st) {
+-  klassKlass::oop_verify_on(obj, st);
++  arrayKlassKlass::oop_verify_on(obj, st);
+   objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
+   guarantee(oak->element_klass()->is_perm(),  "should be in permspace");
+   guarantee(oak->element_klass()->is_klass(), "should be klass");
+diff --git a/src/share/vm/oops/oop.hpp b/src/share/vm/oops/oop.hpp
+--- openjdk/hotspot/src/share/vm/oops/oop.hpp
++++ openjdk/hotspot/src/share/vm/oops/oop.hpp
+@@ -124,6 +124,7 @@
+ 
+   // type test operations (inlined in oop.inline.h)
+   bool is_instance()           const;
++  bool is_instanceMirror()     const;
+   bool is_instanceRef()        const;
+   bool is_array()              const;
+   bool is_objArray()           const;
+diff --git a/src/share/vm/oops/oop.inline.hpp b/src/share/vm/oops/oop.inline.hpp
+--- openjdk/hotspot/src/share/vm/oops/oop.inline.hpp
++++ openjdk/hotspot/src/share/vm/oops/oop.inline.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -135,6 +135,7 @@
+ inline bool oopDesc::is_a(klassOop k)        const { return blueprint()->is_subtype_of(k); }
+ 
+ inline bool oopDesc::is_instance()           const { return blueprint()->oop_is_instance(); }
++inline bool oopDesc::is_instanceMirror()     const { return blueprint()->oop_is_instanceMirror(); }
+ inline bool oopDesc::is_instanceRef()        const { return blueprint()->oop_is_instanceRef(); }
+ inline bool oopDesc::is_array()              const { return blueprint()->oop_is_array(); }
+ inline bool oopDesc::is_objArray()           const { return blueprint()->oop_is_objArray(); }
+@@ -394,7 +395,7 @@
+ 
+ inline int oopDesc::size_given_klass(Klass* klass)  {
+   int lh = klass->layout_helper();
+-  int s  = lh >> LogHeapWordSize;  // deliver size scaled by wordSize
++  int s;
+ 
+   // lh is now a value computed at class initialization that may hint
+   // at the size.  For instances, this is positive and equal to the
+@@ -407,7 +408,13 @@
+   // alive or dead.  So the speed here is equal in importance to the
+   // speed of allocation.
+ 
+-  if (lh <= Klass::_lh_neutral_value) {
++  if (lh > Klass::_lh_neutral_value) {
++    if (!Klass::layout_helper_needs_slow_path(lh)) {
++      s = lh >> LogHeapWordSize;  // deliver size scaled by wordSize
++    } else {
++      s = klass->oop_size(this);
++    }
++  } else if (lh <= Klass::_lh_neutral_value) {
+     // The most common case is instances; fall through if so.
+     if (lh < Klass::_lh_neutral_value) {
+       // Second most common case is arrays.  We have to fetch the
+diff --git a/src/share/vm/oops/oopsHierarchy.hpp b/src/share/vm/oops/oopsHierarchy.hpp
+--- openjdk/hotspot/src/share/vm/oops/oopsHierarchy.hpp
++++ openjdk/hotspot/src/share/vm/oops/oopsHierarchy.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -176,6 +176,7 @@
+ 
+ class Klass;
+ class   instanceKlass;
++class     instanceMirrorKlass;
+ class     instanceRefKlass;
+ class   methodKlass;
+ class   constMethodKlass;
+diff --git a/src/share/vm/opto/compile.cpp b/src/share/vm/opto/compile.cpp
+--- openjdk/hotspot/src/share/vm/opto/compile.cpp
++++ openjdk/hotspot/src/share/vm/opto/compile.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -1196,11 +1196,15 @@
+   // Oop pointers need some flattening
+   const TypeInstPtr *to = tj->isa_instptr();
+   if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) {
++    ciInstanceKlass *k = to->klass()->as_instance_klass();
+     if( ptr == TypePtr::Constant ) {
+-      // No constant oop pointers (such as Strings); they alias with
+-      // unknown strings.
+-      assert(!is_known_inst, "not scalarizable allocation");
+-      tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
++      if (to->klass() != ciEnv::current()->Class_klass() ||
++          offset < k->size_helper() * wordSize) {
++        // No constant oop pointers (such as Strings); they alias with
++        // unknown strings.
++        assert(!is_known_inst, "not scalarizable allocation");
++        tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
++      }
+     } else if( is_known_inst ) {
+       tj = to; // Keep NotNull and klass_is_exact for instance type
+     } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) {
+@@ -1210,7 +1214,6 @@
+       tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
+     }
+     // Canonicalize the holder of this field
+-    ciInstanceKlass *k = to->klass()->as_instance_klass();
+     if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) {
+       // First handle header references such as a LoadKlassNode, even if the
+       // object's klass is unloaded at compile time (4965979).
+@@ -1218,9 +1221,13 @@
+         tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset);
+       }
+     } else if (offset < 0 || offset >= k->size_helper() * wordSize) {
+-      to = NULL;
+-      tj = TypeOopPtr::BOTTOM;
+-      offset = tj->offset();
++      // Static fields are in the space above the normal instance
++      // fields in the java.lang.Class instance.
++      if (to->klass() != ciEnv::current()->Class_klass()) {
++        to = NULL;
++        tj = TypeOopPtr::BOTTOM;
++        offset = tj->offset();
++      }
+     } else {
+       ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset);
+       if (!k->equals(canonical_holder) || tj->offset() != offset) {
+@@ -1393,7 +1400,7 @@
+ 
+ 
+ //--------------------------------find_alias_type------------------------------
+-Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create) {
++Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create, ciField* original_field) {
+   if (_AliasLevel == 0)
+     return alias_type(AliasIdxBot);
+ 
+@@ -1458,22 +1465,28 @@
+     // but the base pointer type is not distinctive enough to identify
+     // references into JavaThread.)
+ 
+-    // Check for final instance fields.
++    // Check for final fields.
+     const TypeInstPtr* tinst = flat->isa_instptr();
+     if (tinst && tinst->offset() >= instanceOopDesc::base_offset_in_bytes()) {
+-      ciInstanceKlass *k = tinst->klass()->as_instance_klass();
+-      ciField* field = k->get_field_by_offset(tinst->offset(), false);
++      ciField* field;
++      if (tinst->const_oop() != NULL &&
++          tinst->klass() == ciEnv::current()->Class_klass() &&
++          tinst->offset() >= (tinst->klass()->as_instance_klass()->size_helper() * wordSize)) {
++        // static field
++        ciInstanceKlass* k = tinst->const_oop()->as_instance()->java_lang_Class_klass()->as_instance_klass();
++        field = k->get_field_by_offset(tinst->offset(), true);
++      } else {
++        ciInstanceKlass *k = tinst->klass()->as_instance_klass();
++        field = k->get_field_by_offset(tinst->offset(), false);
++      }
++      assert(field == NULL ||
++             original_field == NULL ||
++             (field->holder() == original_field->holder() &&
++              field->offset() == original_field->offset() &&
++              field->is_static() == original_field->is_static()), "wrong field?");
+       // Set field() and is_rewritable() attributes.
+       if (field != NULL)  alias_type(idx)->set_field(field);
+     }
+-    const TypeKlassPtr* tklass = flat->isa_klassptr();
+-    // Check for final static fields.
+-    if (tklass && tklass->klass()->is_instance_klass()) {
+-      ciInstanceKlass *k = tklass->klass()->as_instance_klass();
+-      ciField* field = k->get_field_by_offset(tklass->offset(), true);
+-      // Set field() and is_rewritable() attributes.
+-      if (field != NULL)   alias_type(idx)->set_field(field);
+-    }
+   }
+ 
+   // Fill the cache for next time.
+@@ -1496,10 +1509,10 @@
+ Compile::AliasType* Compile::alias_type(ciField* field) {
+   const TypeOopPtr* t;
+   if (field->is_static())
+-    t = TypeKlassPtr::make(field->holder());
++    t = TypeInstPtr::make(field->holder()->java_mirror());
+   else
+     t = TypeOopPtr::make_from_klass_raw(field->holder());
+-  AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()));
++  AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()), field);
+   assert(field->is_final() == !atp->is_rewritable(), "must get the rewritable bits correct");
+   return atp;
+ }
+@@ -1516,7 +1529,7 @@
+   if (adr_type == NULL)             return true;
+   if (adr_type == TypePtr::BOTTOM)  return true;
+ 
+-  return find_alias_type(adr_type, true) != NULL;
++  return find_alias_type(adr_type, true, NULL) != NULL;
+ }
+ 
+ //-----------------------------must_alias--------------------------------------
+diff --git a/src/share/vm/opto/compile.hpp b/src/share/vm/opto/compile.hpp
+--- openjdk/hotspot/src/share/vm/opto/compile.hpp
++++ openjdk/hotspot/src/share/vm/opto/compile.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -596,7 +596,7 @@
+   }
+ 
+   AliasType*        alias_type(int                idx)  { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
+-  AliasType*        alias_type(const TypePtr* adr_type) { return find_alias_type(adr_type, false); }
++  AliasType*        alias_type(const TypePtr* adr_type, ciField* field = NULL) { return find_alias_type(adr_type, false, field); }
+   bool         have_alias_type(const TypePtr* adr_type);
+   AliasType*        alias_type(ciField*         field);
+ 
+@@ -835,7 +835,7 @@
+   void grow_alias_types();
+   AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
+   const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
+-  AliasType* find_alias_type(const TypePtr* adr_type, bool no_create);
++  AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field);
+ 
+   void verify_top(Node*) const PRODUCT_RETURN;
+ 
+diff --git a/src/share/vm/opto/parse.hpp b/src/share/vm/opto/parse.hpp
+--- openjdk/hotspot/src/share/vm/opto/parse.hpp
++++ openjdk/hotspot/src/share/vm/opto/parse.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -483,8 +483,8 @@
+   bool static_field_ok_in_clinit(ciField *field, ciMethod *method);
+ 
+   // common code for actually performing the load or store
+-  void do_get_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field);
+-  void do_put_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field);
++  void do_get_xxx(Node* obj, ciField* field, bool is_field);
++  void do_put_xxx(Node* obj, ciField* field, bool is_field);
+ 
+   // loading from a constant field or the constant pool
+   // returns false if push failed (non-perm field constants only, not ldcs)
+diff --git a/src/share/vm/opto/parse3.cpp b/src/share/vm/opto/parse3.cpp
+--- openjdk/hotspot/src/share/vm/opto/parse3.cpp
++++ openjdk/hotspot/src/share/vm/opto/parse3.cpp
+@@ -112,29 +112,31 @@
+     // Compile-time detect of null-exception?
+     if (stopped())  return;
+ 
++#ifdef ASSERT
+     const TypeInstPtr *tjp = TypeInstPtr::make(TypePtr::NotNull, iter().get_declared_field_holder());
+     assert(_gvn.type(obj)->higher_equal(tjp), "cast_up is no longer needed");
++#endif
+ 
+     if (is_get) {
+       --_sp;  // pop receiver before getting
+-      do_get_xxx(tjp, obj, field, is_field);
++      do_get_xxx(obj, field, is_field);
+     } else {
+-      do_put_xxx(tjp, obj, field, is_field);
++      do_put_xxx(obj, field, is_field);
+       --_sp;  // pop receiver after putting
+     }
+   } else {
+-    const TypeKlassPtr* tkp = TypeKlassPtr::make(field_holder);
+-    obj = _gvn.makecon(tkp);
++    const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
++    obj = _gvn.makecon(tip);
+     if (is_get) {
+-      do_get_xxx(tkp, obj, field, is_field);
++      do_get_xxx(obj, field, is_field);
+     } else {
+-      do_put_xxx(tkp, obj, field, is_field);
++      do_put_xxx(obj, field, is_field);
+     }
+   }
+ }
+ 
+ 
+-void Parse::do_get_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field) {
++void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
+   // Does this field have a constant value?  If so, just push the value.
+   if (field->is_constant()) {
+     if (field->is_static()) {
+@@ -231,7 +233,7 @@
+   }
+ }
+ 
+-void Parse::do_put_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field) {
++void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
+   bool is_vol = field->is_volatile();
+   // If reference is volatile, prevent following memory ops from
+   // floating down past the volatile write.  Also prevents commoning
+diff --git a/src/share/vm/opto/type.cpp b/src/share/vm/opto/type.cpp
+--- openjdk/hotspot/src/share/vm/opto/type.cpp
++++ openjdk/hotspot/src/share/vm/opto/type.cpp
+@@ -32,6 +32,7 @@
+ #include "memory/oopFactory.hpp"
+ #include "memory/resourceArea.hpp"
+ #include "oops/instanceKlass.hpp"
++#include "oops/instanceMirrorKlass.hpp"
+ #include "oops/klassKlass.hpp"
+ #include "oops/objArrayKlass.hpp"
+ #include "oops/typeArrayKlass.hpp"
+@@ -2241,43 +2242,49 @@
+     } else if (this->isa_aryptr()) {
+       _is_ptr_to_narrowoop = (klass()->is_obj_array_klass() &&
+                              _offset != arrayOopDesc::length_offset_in_bytes());
+-    } else if (klass() == ciEnv::current()->Class_klass() &&
+-               (_offset == java_lang_Class::klass_offset_in_bytes() ||
+-                _offset == java_lang_Class::array_klass_offset_in_bytes())) {
+-      // Special hidden fields from the Class.
+-      assert(this->isa_instptr(), "must be an instance ptr.");
+-      _is_ptr_to_narrowoop = true;
+     } else if (klass()->is_instance_klass()) {
+       ciInstanceKlass* ik = klass()->as_instance_klass();
+       ciField* field = NULL;
+       if (this->isa_klassptr()) {
+-        // Perm objects don't use compressed references, except for
+-        // static fields which are currently compressed.
+-        field = ik->get_field_by_offset(_offset, true);
+-        if (field != NULL) {
+-          BasicType basic_elem_type = field->layout_type();
+-          _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
+-                                  basic_elem_type == T_ARRAY);
+-        }
++        // Perm objects don't use compressed references
+       } else if (_offset == OffsetBot || _offset == OffsetTop) {
+         // unsafe access
+         _is_ptr_to_narrowoop = true;
+       } else { // exclude unsafe ops
+         assert(this->isa_instptr(), "must be an instance ptr.");
+-        // Field which contains a compressed oop references.
+-        field = ik->get_field_by_offset(_offset, false);
+-        if (field != NULL) {
++
++        if (klass() == ciEnv::current()->Class_klass() &&
++            (_offset == java_lang_Class::klass_offset_in_bytes() ||
++             _offset == java_lang_Class::array_klass_offset_in_bytes())) {
++          // Special hidden fields from the Class.
++          assert(this->isa_instptr(), "must be an instance ptr.");
++          _is_ptr_to_narrowoop = true;
++        } else if (klass() == ciEnv::current()->Class_klass() &&
++                   _offset >= instanceMirrorKlass::offset_of_static_fields()) {
++          // Static fields
++          assert(o != NULL, "must be constant");
++          ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
++          ciField* field = k->get_field_by_offset(_offset, true);
++          assert(field != NULL, "missing field");
+           BasicType basic_elem_type = field->layout_type();
+           _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
+                                   basic_elem_type == T_ARRAY);
+-        } else if (klass()->equals(ciEnv::current()->Object_klass())) {
+-          // Compile::find_alias_type() cast exactness on all types to verify
+-          // that it does not affect alias type.
+-          _is_ptr_to_narrowoop = true;
+         } else {
+-          // Type for the copy start in LibraryCallKit::inline_native_clone().
+-          assert(!klass_is_exact(), "only non-exact klass");
+-          _is_ptr_to_narrowoop = true;
++          // Instance fields which contains a compressed oop references.
++          field = ik->get_field_by_offset(_offset, false);
++          if (field != NULL) {
++            BasicType basic_elem_type = field->layout_type();
++            _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
++                                    basic_elem_type == T_ARRAY);
++          } else if (klass()->equals(ciEnv::current()->Object_klass())) {
++            // Compile::find_alias_type() cast exactness on all types to verify
++            // that it does not affect alias type.
++            _is_ptr_to_narrowoop = true;
++          } else {
++            // Type for the copy start in LibraryCallKit::inline_native_clone().
++            assert(!klass_is_exact(), "only non-exact klass");
++            _is_ptr_to_narrowoop = true;
++          }
+         }
+       }
+     }
+diff --git a/src/share/vm/prims/jni.cpp b/src/share/vm/prims/jni.cpp
+--- openjdk/hotspot/src/share/vm/prims/jni.cpp
++++ openjdk/hotspot/src/share/vm/prims/jni.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -1865,7 +1865,7 @@
+     // Static field. The fieldID a JNIid specifying the field holder and the offset within the klassOop.
+     JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID);
+     assert(id->is_static_field_id(), "invalid static field id");
+-    found = instanceKlass::cast(id->holder())->find_local_field_from_offset(id->offset(), true, &fd);
++    found = id->find_local_field(&fd);
+   } else {
+     // Non-static field. The fieldID is really the offset of the field within the instanceOop.
+     int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID);
+@@ -1915,9 +1915,7 @@
+   JNIid* id = instanceKlass::cast(fd.field_holder())->jni_id_for(fd.offset());
+   debug_only(id->set_is_static_field_id();)
+ 
+-  debug_only(int first_offset = instanceKlass::cast(fd.field_holder())->offset_of_static_fields();)
+-  debug_only(int end_offset = first_offset + (instanceKlass::cast(fd.field_holder())->static_field_size() * wordSize);)
+-  assert(id->offset() >= first_offset && id->offset() < end_offset, "invalid static field offset");
++  debug_only(id->verify(fd.field_holder()));
+ 
+   ret = jfieldIDWorkaround::to_static_jfieldID(id);
+   return ret;
+@@ -1937,7 +1935,7 @@
+   if (JvmtiExport::should_post_field_access()) {
+     JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true);
+   }
+-  jobject ret = JNIHandles::make_local(id->holder()->obj_field(id->offset()));
++  jobject ret = JNIHandles::make_local(id->holder()->java_mirror()->obj_field(id->offset()));
+   DTRACE_PROBE1(hotspot_jni, GetStaticObjectField__return, ret);
+   return ret;
+ JNI_END
+@@ -1959,7 +1957,7 @@
+   if (JvmtiExport::should_post_field_access()) { \
+     JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \
+   } \
+-  ret = id->holder()-> Fieldname##_field (id->offset()); \
++  ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \
+   return ret;\
+ JNI_END
+ 
+@@ -1985,7 +1983,7 @@
+     field_value.l = value;
+     JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, 'L', (jvalue *)&field_value);
+   }
+-  id->holder()->obj_field_put(id->offset(), JNIHandles::resolve(value));
++  id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value));
+   DTRACE_PROBE(hotspot_jni, SetStaticObjectField__return);
+ JNI_END
+ 
+@@ -2008,7 +2006,7 @@
+     field_value.unionType = value; \
+     JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \
+   } \
+-  id->holder()-> Fieldname##_field_put (id->offset(), value); \
++  id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \
+   DTRACE_PROBE(hotspot_jni, SetStatic##Result##Field__return);\
+ JNI_END
+ 
+diff --git a/src/share/vm/prims/jniCheck.cpp b/src/share/vm/prims/jniCheck.cpp
+--- openjdk/hotspot/src/share/vm/prims/jniCheck.cpp
++++ openjdk/hotspot/src/share/vm/prims/jniCheck.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -218,8 +218,7 @@
+     ReportJNIFatalError(thr, fatal_wrong_static_field);
+ 
+   /* check for proper field type */
+-  if (!instanceKlass::cast(f_oop)->find_local_field_from_offset(
+-          id->offset(), true, &fd))
++  if (!id->find_local_field(&fd))
+     ReportJNIFatalError(thr, fatal_static_field_not_found);
+   if ((fd.field_type() != ftype) &&
+       !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
+diff --git a/src/share/vm/prims/jvm.cpp b/src/share/vm/prims/jvm.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvm.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvm.cpp
+@@ -1877,7 +1877,7 @@
+     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index");
+   }
+   klassOop k = cp->klass_at(index, CHECK_NULL);
+-  return (jclass) JNIHandles::make_local(k->klass_part()->java_mirror());
++  return (jclass) JNIHandles::make_local(k->java_mirror());
+ }
+ JVM_END
+ 
+@@ -1893,7 +1893,7 @@
+   }
+   klassOop k = constantPoolOopDesc::klass_at_if_loaded(cp, index);
+   if (k == NULL) return NULL;
+-  return (jclass) JNIHandles::make_local(k->klass_part()->java_mirror());
++  return (jclass) JNIHandles::make_local(k->java_mirror());
+ }
+ JVM_END
+ 
+diff --git a/src/share/vm/prims/jvmtiEnvBase.cpp b/src/share/vm/prims/jvmtiEnvBase.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -616,9 +616,7 @@
+   bool found = false;
+   if (jfieldIDWorkaround::is_static_jfieldID(field)) {
+     JNIid* id = jfieldIDWorkaround::from_static_jfieldID(field);
+-    int offset = id->offset();
+-    klassOop holder = id->holder();
+-    found = instanceKlass::cast(holder)->find_local_field_from_offset(offset, true, fd);
++    found = id->find_local_field(fd);
+   } else {
+     // Non-static field. The fieldID is really the offset of the field within the object.
+     int offset = jfieldIDWorkaround::from_instance_jfieldID(k, field);
+diff --git a/src/share/vm/prims/jvmtiTagMap.cpp b/src/share/vm/prims/jvmtiTagMap.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
+@@ -27,6 +27,7 @@
+ #include "classfile/systemDictionary.hpp"
+ #include "classfile/vmSymbols.hpp"
+ #include "jvmtifiles/jvmtiEnv.hpp"
++#include "oops/instanceMirrorKlass.hpp"
+ #include "oops/objArrayKlass.hpp"
+ #include "oops/oop.inline2.hpp"
+ #include "prims/jvmtiEventController.hpp"
+@@ -2594,6 +2595,11 @@
+     if (o->is_klass()) {
+       klassOop k = (klassOop)o;
+       o = Klass::cast(k)->java_mirror();
++      if (o == NULL) {
++        // Classes without mirrors don't correspond to real Java
++        // classes so just ignore them.
++        return;
++      }
+     } else {
+ 
+       // SystemDictionary::always_strong_oops_do reports the application
+@@ -2834,10 +2840,10 @@
+ 
+ // verify that a static oop field is in range
+ static inline bool verify_static_oop(instanceKlass* ik,
+-                                     klassOop k, int offset) {
+-  address obj_p = (address)k + offset;
+-  address start = (address)ik->start_of_static_fields();
+-  address end = start + (ik->static_oop_field_size() * heapOopSize);
++                                     oop mirror, int offset) {
++  address obj_p = (address)mirror + offset;
++  address start = (address)instanceMirrorKlass::start_of_static_fields(mirror);
++  address end = start + (java_lang_Class::static_oop_field_count(mirror) * heapOopSize);
+   assert(end >= start, "sanity check");
+ 
+   if (obj_p >= start && obj_p < end) {
+@@ -2938,8 +2944,8 @@
+       ClassFieldDescriptor* field = field_map->field_at(i);
+       char type = field->field_type();
+       if (!is_primitive_field_type(type)) {
+-        oop fld_o = k->obj_field(field->field_offset());
+-        assert(verify_static_oop(ik, k, field->field_offset()), "sanity check");
++        oop fld_o = mirror->obj_field(field->field_offset());
++        assert(verify_static_oop(ik, mirror, field->field_offset()), "sanity check");
+         if (fld_o != NULL) {
+           int slot = field->field_index();
+           if (!CallbackInvoker::report_static_field_reference(mirror, fld_o, slot)) {
+diff --git a/src/share/vm/prims/unsafe.cpp b/src/share/vm/prims/unsafe.cpp
+--- openjdk/hotspot/src/share/vm/prims/unsafe.cpp
++++ openjdk/hotspot/src/share/vm/prims/unsafe.cpp
+@@ -686,7 +686,7 @@
+     THROW_0(vmSymbols::java_lang_IllegalArgumentException());
+   }
+ 
+-  return JNIHandles::make_local(env, java_lang_Class::as_klassOop(mirror));
++  return JNIHandles::make_local(env, mirror);
+ UNSAFE_END
+ 
+ //@deprecated
+@@ -704,7 +704,7 @@
+   if (clazz == NULL) {
+     THROW_0(vmSymbols::java_lang_NullPointerException());
+   }
+-  return JNIHandles::make_local(env, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz)));
++  return JNIHandles::make_local(env, JNIHandles::resolve_non_null(clazz));
+ UNSAFE_END
+ 
+ UNSAFE_ENTRY(void, Unsafe_EnsureClassInitialized(JNIEnv *env, jobject unsafe, jobject clazz))
+diff --git a/src/share/vm/runtime/arguments.cpp b/src/share/vm/runtime/arguments.cpp
+--- openjdk/hotspot/src/share/vm/runtime/arguments.cpp
++++ openjdk/hotspot/src/share/vm/runtime/arguments.cpp
+@@ -2973,6 +2973,12 @@
+       }
+     }
+   }
++  if (!JavaObjectsInPerm && ScavengeRootsInCode == 0) {
++    if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
++      warning("forcing ScavengeRootsInCode non-zero because JavaObjectsInPerm is false");
++    }
++    ScavengeRootsInCode = 1;
++  }
+ 
+   // Parse JavaVMInitArgs structure passed in, as well as JAVA_TOOL_OPTIONS and _JAVA_OPTIONS
+   jint result = parse_vm_init_args(args);
+diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp
+--- openjdk/hotspot/src/share/vm/runtime/globals.hpp
++++ openjdk/hotspot/src/share/vm/runtime/globals.hpp
+@@ -1184,6 +1184,11 @@
+           "Decay time (in milliseconds) to re-enable bulk rebiasing of a "  \
+           "type after previous bulk rebias")                                \
+                                                                             \
++  develop(bool, JavaObjectsInPerm, false,                                   \
++          "controls whether Classes and interned Strings are allocated"     \
++          "in perm.  This purely intended to allow debugging issues"        \
++          "in production.")                                                 \
++                                                                            \
+   /* tracing */                                                             \
+                                                                             \
+   notproduct(bool, TraceRuntimeCalls, false,                                \
+diff --git a/src/share/vm/runtime/reflection.cpp b/src/share/vm/runtime/reflection.cpp
+--- openjdk/hotspot/src/share/vm/runtime/reflection.cpp
++++ openjdk/hotspot/src/share/vm/runtime/reflection.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -649,7 +649,7 @@
+       if (TraceClassResolution) {
+         trace_class_resolution(k);
+       }
+-      return k->klass_part()->java_mirror();
++      return k->java_mirror();
+   };
+ }
+ 
+diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp
+--- openjdk/hotspot/src/share/vm/runtime/thread.cpp
++++ openjdk/hotspot/src/share/vm/runtime/thread.cpp
+@@ -3182,7 +3182,7 @@
+         fieldDescriptor fd;
+         // Possible we might not find this field; if so, don't break
+         if (ik->find_local_field(vmSymbols::frontCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
+-          k()->bool_field_put(fd.offset(), true);
++          k()->java_mirror()->bool_field_put(fd.offset(), true);
+         }
+       }
+ 
+@@ -3198,7 +3198,7 @@
+           fieldDescriptor fd;
+           // Possible we might not find this field: if so, silently don't break
+           if (ik->find_local_field(vmSymbols::stringCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
+-            k()->bool_field_put(fd.offset(), true);
++            k()->java_mirror()->bool_field_put(fd.offset(), true);
+           }
+         }
+       }
+diff --git a/src/share/vm/runtime/vmStructs.cpp b/src/share/vm/runtime/vmStructs.cpp
+--- openjdk/hotspot/src/share/vm/runtime/vmStructs.cpp
++++ openjdk/hotspot/src/share/vm/runtime/vmStructs.cpp
+@@ -251,7 +251,7 @@
+   nonstatic_field(instanceKlass,               _inner_classes,                                typeArrayOop)                          \
+   nonstatic_field(instanceKlass,               _nonstatic_field_size,                         int)                                   \
+   nonstatic_field(instanceKlass,               _static_field_size,                            int)                                   \
+-  nonstatic_field(instanceKlass,               _static_oop_field_size,                        int)                                   \
++  nonstatic_field(instanceKlass,               _static_oop_field_count,                       int)                                   \
+   nonstatic_field(instanceKlass,               _nonstatic_oop_map_size,                       int)                                   \
+   nonstatic_field(instanceKlass,               _is_marked_dependent,                          bool)                                  \
+   nonstatic_field(instanceKlass,               _minor_version,                                u2)                                    \
+@@ -928,6 +928,15 @@
+   static_field(Arguments,                      _num_jvm_args,                                 int)                                   \
+   static_field(Arguments,                      _java_command,                                 char*)                                 \
+                                                                                                                                      \
++  /*********************************/                                                                                                \
++  /* java_lang_Class fields        */                                                                                                \
++  /*********************************/                                                                                                \
++                                                                                                                                     \
++  static_field(java_lang_Class,                klass_offset,                                  int)                                   \
++  static_field(java_lang_Class,                resolved_constructor_offset,                   int)                                   \
++  static_field(java_lang_Class,                array_klass_offset,                            int)                                   \
++  static_field(java_lang_Class,                oop_size_offset,                               int)                                   \
++  static_field(java_lang_Class,                static_oop_field_count_offset,                 int)                                   \
+                                                                                                                                      \
+   /************************/                                                                                                         \
+   /* Miscellaneous fields */                                                                                                         \
+@@ -1410,6 +1419,7 @@
+   declare_toplevel_type(intptr_t*)                                        \
+    declare_unsigned_integer_type(InvocationCounter) /* FIXME: wrong type (not integer) */ \
+   declare_toplevel_type(JavaThread*)                                      \
++  declare_toplevel_type(java_lang_Class)                                  \
+   declare_toplevel_type(jbyte*)                                           \
+   declare_toplevel_type(jbyte**)                                          \
+   declare_toplevel_type(jint*)                                            \
+@@ -1696,15 +1706,6 @@
+                                                                           \
+   declare_constant(ConstantPoolCacheEntry::tosBits)                       \
+                                                                           \
+-  /*********************************/                                     \
+-  /* java_lang_Class field offsets */                                     \
+-  /*********************************/                                     \
+-                                                                          \
+-  declare_constant(java_lang_Class::hc_klass_offset)                      \
+-  declare_constant(java_lang_Class::hc_array_klass_offset)                \
+-  declare_constant(java_lang_Class::hc_resolved_constructor_offset)       \
+-  declare_constant(java_lang_Class::hc_number_of_fake_oop_fields)         \
+-                                                                          \
+   /***************************************/                               \
+   /* java_lang_Thread::ThreadStatus enum */                               \
+   /***************************************/                               \
+diff --git a/src/share/vm/shark/sharkNativeWrapper.cpp b/src/share/vm/shark/sharkNativeWrapper.cpp
+--- openjdk/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp
++++ openjdk/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp
+@@ -101,7 +101,7 @@
+     builder()->CreateStore(
+       builder()->CreateInlineOop(
+         JNIHandles::make_local(
+-          target()->method_holder()->klass_part()->java_mirror())),
++          target()->method_holder()->java_mirror())),
+       oop_tmp_slot());
+ 
+     param_types.push_back(box_type);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/7036747-elfstringtable.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,130 @@
+# HG changeset patch
+# User zgu
+# Date 1303909797 14400
+# Node ID fee3c2ed387b0a925f81448c93265b4c30e0a8d6
+# Parent  d521fcfccc58dce20f41178374292f2b8430686c
+7036747: 7017009 reappeared, problem with ElfStringTable
+Summary: Created new "new" operator for CHeapObj that allows malloc to fail without causing fatal error. Also replaced "HeapAllocate" with "os::malloc" in decoder code to allow decoder to handle low memory scenario.
+Reviewed-by: coleenp, dholmes
+
+diff --git a/src/share/vm/memory/allocation.cpp b/src/share/vm/memory/allocation.cpp
+--- openjdk/hotspot/src/share/vm/memory/allocation.cpp
++++ openjdk/hotspot/src/share/vm/memory/allocation.cpp
+@@ -44,6 +44,14 @@
+   return (void *) AllocateHeap(size, "CHeapObj-new");
+ }
+ 
++void* CHeapObj::operator new (size_t size, const std::nothrow_t&  nothrow_constant) {
++  char* p = (char*) os::malloc(size);
++#ifdef ASSERT
++  if (PrintMallocFree) trace_heap_malloc(size, "CHeapObj-new", p);
++#endif
++  return p;
++}
++
+ void CHeapObj::operator delete(void* p){
+  FreeHeap(p);
+ }
+diff --git a/src/share/vm/memory/allocation.hpp b/src/share/vm/memory/allocation.hpp
+--- openjdk/hotspot/src/share/vm/memory/allocation.hpp
++++ openjdk/hotspot/src/share/vm/memory/allocation.hpp
+@@ -34,6 +34,8 @@
+ #include "opto/c2_globals.hpp"
+ #endif
+ 
++#include <new>
++
+ #define ARENA_ALIGN_M1 (((size_t)(ARENA_AMALLOC_ALIGNMENT)) - 1)
+ #define ARENA_ALIGN_MASK (~((size_t)ARENA_ALIGN_M1))
+ #define ARENA_ALIGN(x) ((((size_t)(x)) + ARENA_ALIGN_M1) & ARENA_ALIGN_MASK)
+@@ -105,6 +107,7 @@
+ class CHeapObj ALLOCATION_SUPER_CLASS_SPEC {
+  public:
+   void* operator new(size_t size);
++  void* operator new (size_t size, const std::nothrow_t&  nothrow_constant);
+   void  operator delete(void* p);
+   void* new_array(size_t size);
+ };
+diff --git a/src/share/vm/utilities/elfFile.cpp b/src/share/vm/utilities/elfFile.cpp
+--- openjdk/hotspot/src/share/vm/utilities/elfFile.cpp
++++ openjdk/hotspot/src/share/vm/utilities/elfFile.cpp
+@@ -29,6 +29,7 @@
+ #include <string.h>
+ #include <stdio.h>
+ #include <limits.h>
++#include <new>
+ 
+ #include "memory/allocation.inline.hpp"
+ #include "utilities/decoder.hpp"
+@@ -46,7 +47,7 @@
+   m_status = Decoder::no_error;
+ 
+   int len = strlen(filepath) + 1;
+-  m_filepath = NEW_C_HEAP_ARRAY(char, len);
++  m_filepath = (const char*)os::malloc(len * sizeof(char));
+   if (m_filepath != NULL) {
+     strcpy((char*)m_filepath, filepath);
+     m_file = fopen(filepath, "r");
+@@ -74,7 +75,7 @@
+   }
+ 
+   if (m_filepath != NULL) {
+-    FREE_C_HEAP_ARRAY(char, m_filepath);
++    os::free((void*)m_filepath);
+   }
+ 
+   if (m_next != NULL) {
+@@ -120,14 +121,14 @@
+       }
+       // string table
+       if (shdr.sh_type == SHT_STRTAB) {
+-        ElfStringTable* table = new ElfStringTable(m_file, shdr, index);
++        ElfStringTable* table = new (std::nothrow) ElfStringTable(m_file, shdr, index);
+         if (table == NULL) {
+           m_status = Decoder::out_of_memory;
+           return false;
+         }
+         add_string_table(table);
+       } else if (shdr.sh_type == SHT_SYMTAB || shdr.sh_type == SHT_DYNSYM) {
+-        ElfSymbolTable* table = new ElfSymbolTable(m_file, shdr);
++        ElfSymbolTable* table = new (std::nothrow) ElfSymbolTable(m_file, shdr);
+         if (table == NULL) {
+           m_status = Decoder::out_of_memory;
+           return false;
+diff --git a/src/share/vm/utilities/elfStringTable.cpp b/src/share/vm/utilities/elfStringTable.cpp
+--- openjdk/hotspot/src/share/vm/utilities/elfStringTable.cpp
++++ openjdk/hotspot/src/share/vm/utilities/elfStringTable.cpp
+@@ -27,6 +27,7 @@
+ #ifndef _WINDOWS
+ 
+ #include "memory/allocation.inline.hpp"
++#include "runtime/os.hpp"
+ #include "utilities/elfStringTable.hpp"
+ 
+ // We will try to load whole string table into memory if we can.
+@@ -41,14 +42,14 @@
+ 
+   // try to load the string table
+   long cur_offset = ftell(file);
+-  m_table = (char*)NEW_C_HEAP_ARRAY(char, shdr.sh_size);
++  m_table = (char*)os::malloc(sizeof(char) * shdr.sh_size);
+   if (m_table != NULL) {
+     // if there is an error, mark the error
+     if (fseek(file, shdr.sh_offset, SEEK_SET) ||
+       fread((void*)m_table, shdr.sh_size, 1, file) != 1 ||
+       fseek(file, cur_offset, SEEK_SET)) {
+       m_status = Decoder::file_invalid;
+-      FREE_C_HEAP_ARRAY(char, m_table);
++      os::free((void*)m_table);
+       m_table = NULL;
+     }
+   } else {
+@@ -58,7 +59,7 @@
+ 
+ ElfStringTable::~ElfStringTable() {
+   if (m_table != NULL) {
+-    FREE_C_HEAP_ARRAY(char, m_table);
++    os::free((void*)m_table);
+   }
+ 
+   if (m_next != NULL) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/7086585-flexible_field_injection.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,3424 @@
+# HG changeset patch
+# User andrew
+# Date 1371750221 18000
+# Node ID f105c2b7da46999930ae40ac8661a56d6ce1c5cd
+# Parent  f44f27f80f2caf315f0f56cd63b5beb46908051e
+7086585: make Java field injection more flexible
+Reviewed-by: jrose, twisti, kvn, coleenp
+
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java b/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/Field.java
+@@ -39,28 +39,20 @@
+ 
+   /** Constructor for fields that are named in an InstanceKlass's
+       fields array (i.e., named, non-VM fields) */
+-  Field(InstanceKlass holder, int fieldArrayIndex) {
++  Field(InstanceKlass holder, int fieldIndex) {
+     this.holder = holder;
+-    this.fieldArrayIndex = fieldArrayIndex;
++    this.fieldIndex = fieldIndex;
+ 
+-    ConstantPool cp      = holder.getConstants();
+-    TypeArray fields     = holder.getFields();
+-    short access         = fields.getShortAt(fieldArrayIndex + InstanceKlass.ACCESS_FLAGS_OFFSET);
+-    short nameIndex      = fields.getShortAt(fieldArrayIndex + InstanceKlass.NAME_INDEX_OFFSET);
+-    short signatureIndex = fields.getShortAt(fieldArrayIndex + InstanceKlass.SIGNATURE_INDEX_OFFSET);
+-    offset               = VM.getVM().buildIntFromShorts(fields.getShortAt(fieldArrayIndex + InstanceKlass.LOW_OFFSET),
+-                                                         fields.getShortAt(fieldArrayIndex + InstanceKlass.HIGH_OFFSET));
+-    short genericSignatureIndex = fields.getShortAt(fieldArrayIndex + InstanceKlass.GENERIC_SIGNATURE_INDEX_OFFSET);
+-    Symbol name = cp.getSymbolAt(nameIndex);
++    offset               = holder.getFieldOffset(fieldIndex);
++    genericSignature     = holder.getFieldGenericSignature(fieldIndex);
++
++    Symbol name          = holder.getFieldName(fieldIndex);
+     id          = new NamedFieldIdentifier(name.asString());
+-    signature   = cp.getSymbolAt(signatureIndex);
+-    if (genericSignatureIndex != 0)  {
+-       genericSignature = cp.getSymbolAt(genericSignatureIndex);
+-    } else {
+-       genericSignature = null;
+-    }
+ 
++    signature            = holder.getFieldSignature(fieldIndex);
+     fieldType   = new FieldType(signature);
++
++    short access         = holder.getFieldAccessFlags(fieldIndex);
+     accessFlags = new AccessFlags(access);
+   }
+ 
+@@ -73,7 +65,7 @@
+   private Symbol          signature;
+   private Symbol          genericSignature;
+   private AccessFlags     accessFlags;
+-  private int             fieldArrayIndex;
++  private int             fieldIndex;
+ 
+   /** Returns the byte offset of the field within the object or klass */
+   public long getOffset() { return offset; }
+@@ -101,8 +93,8 @@
+   /** (Named, non-VM fields only) Returns the index in the fields
+       TypeArray for this field. Equivalent to the "index" in the VM's
+       fieldDescriptors. */
+-  public int getFieldArrayIndex() {
+-    return fieldArrayIndex;
++  public int getFieldIndex() {
++    return fieldIndex;
+   }
+ 
+   /** (Named, non-VM fields only) Retrieves the access flags. */
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
+@@ -51,7 +51,7 @@
+   public static int LOW_OFFSET;
+   public static int HIGH_OFFSET;
+   public static int GENERIC_SIGNATURE_INDEX_OFFSET;
+-  public static int NEXT_OFFSET;
++  public static int FIELD_SLOTS;
+   public static int IMPLEMENTORS_LIMIT;
+ 
+   // ClassState constants
+@@ -78,6 +78,7 @@
+       implementors[i]    = new OopField(type.getOopField("_implementors[0]"), arrayOffset);
+     }
+     fields               = new OopField(type.getOopField("_fields"), Oop.getHeaderSize());
++    javaFieldsCount      = new CIntField(type.getCIntegerField("_java_fields_count"), Oop.getHeaderSize());
+     constants            = new OopField(type.getOopField("_constants"), Oop.getHeaderSize());
+     classLoader          = new OopField(type.getOopField("_class_loader"), Oop.getHeaderSize());
+     protectionDomain     = new OopField(type.getOopField("_protection_domain"), Oop.getHeaderSize());
+@@ -100,14 +101,14 @@
+     headerSize           = alignObjectOffset(Oop.getHeaderSize() + type.getSize());
+ 
+     // read field offset constants
+-    ACCESS_FLAGS_OFFSET = db.lookupIntConstant("instanceKlass::access_flags_offset").intValue();
+-    NAME_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::name_index_offset").intValue();
+-    SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::signature_index_offset").intValue();
+-    INITVAL_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::initval_index_offset").intValue();
+-    LOW_OFFSET = db.lookupIntConstant("instanceKlass::low_offset").intValue();
+-    HIGH_OFFSET = db.lookupIntConstant("instanceKlass::high_offset").intValue();
+-    GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::generic_signature_offset").intValue();
+-    NEXT_OFFSET = db.lookupIntConstant("instanceKlass::next_offset").intValue();
++    ACCESS_FLAGS_OFFSET            = db.lookupIntConstant("FieldInfo::access_flags_offset").intValue();
++    NAME_INDEX_OFFSET              = db.lookupIntConstant("FieldInfo::name_index_offset").intValue();
++    SIGNATURE_INDEX_OFFSET         = db.lookupIntConstant("FieldInfo::signature_index_offset").intValue();
++    INITVAL_INDEX_OFFSET           = db.lookupIntConstant("FieldInfo::initval_index_offset").intValue();
++    LOW_OFFSET                     = db.lookupIntConstant("FieldInfo::low_offset").intValue();
++    HIGH_OFFSET                    = db.lookupIntConstant("FieldInfo::high_offset").intValue();
++    GENERIC_SIGNATURE_INDEX_OFFSET = db.lookupIntConstant("FieldInfo::generic_signature_offset").intValue();
++    FIELD_SLOTS                    = db.lookupIntConstant("FieldInfo::field_slots").intValue();
+     // read ClassState constants
+     CLASS_STATE_UNPARSABLE_BY_GC = db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue();
+     CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue();
+@@ -131,6 +132,7 @@
+   private static CIntField nofImplementors;
+   private static OopField[] implementors;
+   private static OopField  fields;
++  private static CIntField javaFieldsCount;
+   private static OopField  constants;
+   private static OopField  classLoader;
+   private static OopField  protectionDomain;
+@@ -243,6 +245,34 @@
+ 
+   public static long getHeaderSize() { return headerSize; }
+ 
++  public short getFieldAccessFlags(int index) {
++    return getFields().getShortAt(index * FIELD_SLOTS + ACCESS_FLAGS_OFFSET);
++  }
++
++  public Symbol getFieldName(int index) {
++    int nameIndex = getFields().getShortAt(index * FIELD_SLOTS + NAME_INDEX_OFFSET);
++    return getConstants().getSymbolAt(nameIndex);
++  }
++
++  public Symbol getFieldSignature(int index) {
++    int signatureIndex = getFields().getShortAt(index * FIELD_SLOTS + SIGNATURE_INDEX_OFFSET);
++    return getConstants().getSymbolAt(signatureIndex);
++  }
++
++  public Symbol getFieldGenericSignature(int index) {
++    short genericSignatureIndex = getFields().getShortAt(index * FIELD_SLOTS + GENERIC_SIGNATURE_INDEX_OFFSET);
++    if (genericSignatureIndex != 0)  {
++      return getConstants().getSymbolAt(genericSignatureIndex);
++    }
++    return null;
++  }
++
++  public int getFieldOffset(int index) {
++    TypeArray fields = getFields();
++    return VM.getVM().buildIntFromShorts(fields.getShortAt(index * FIELD_SLOTS + LOW_OFFSET),
++                                         fields.getShortAt(index * FIELD_SLOTS + HIGH_OFFSET));
++  }
++
+   // Accessors for declared fields
+   public Klass     getArrayKlasses()        { return (Klass)        arrayKlasses.getValue(this); }
+   public ObjArray  getMethods()             { return (ObjArray)     methods.getValue(this); }
+@@ -253,6 +283,8 @@
+   public Klass     getImplementor()         { return (Klass)        implementors[0].getValue(this); }
+   public Klass     getImplementor(int i)    { return (Klass)        implementors[i].getValue(this); }
+   public TypeArray getFields()              { return (TypeArray)    fields.getValue(this); }
++  public int       getJavaFieldsCount()     { return                (int) javaFieldsCount.getValue(this); }
++  public int       getAllFieldsCount()      { return                (int)getFields().getLength(); }
+   public ConstantPool getConstants()        { return (ConstantPool) constants.getValue(this); }
+   public Oop       getClassLoader()         { return                classLoader.getValue(this); }
+   public Oop       getProtectionDomain()    { return                protectionDomain.getValue(this); }
+@@ -461,8 +493,8 @@
+     }
+ 
+     TypeArray fields = getFields();
+-    int length = (int) fields.getLength();
+-    for (int index = 0; index < length; index += NEXT_OFFSET) {
++    int length = getJavaFieldsCount();
++    for (int index = 0; index < length; index += FIELD_SLOTS) {
+       short accessFlags    = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
+       short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
+       FieldType   type   = new FieldType(getConstants().getSymbolAt(signatureIndex));
+@@ -483,8 +515,8 @@
+     }
+     TypeArray fields = getFields();
+ 
+-    int length = (int) fields.getLength();
+-    for (int index = 0; index < length; index += NEXT_OFFSET) {
++    int length = getJavaFieldsCount();
++    for (int index = 0; index < length; index += FIELD_SLOTS) {
+       short accessFlags    = fields.getShortAt(index + ACCESS_FLAGS_OFFSET);
+       short signatureIndex = fields.getShortAt(index + SIGNATURE_INDEX_OFFSET);
+ 
+@@ -499,9 +531,9 @@
+   /** Field access by name. */
+   public Field findLocalField(Symbol name, Symbol sig) {
+     TypeArray fields = getFields();
+-    int n = (int) fields.getLength();
++    int length = (int) fields.getLength();
+     ConstantPool cp = getConstants();
+-    for (int i = 0; i < n; i += NEXT_OFFSET) {
++    for (int i = 0; i < length; i += FIELD_SLOTS) {
+       int nameIndex = fields.getShortAt(i + NAME_INDEX_OFFSET);
+       int sigIndex  = fields.getShortAt(i + SIGNATURE_INDEX_OFFSET);
+       Symbol f_name = cp.getSymbolAt(nameIndex);
+@@ -594,9 +626,9 @@
+         // not including inherited fields.
+         TypeArray fields = getFields();
+ 
+-        int length = (int) fields.getLength();
+-        List immediateFields = new ArrayList(length / NEXT_OFFSET);
+-        for (int index = 0; index < length; index += NEXT_OFFSET) {
++        int length = getJavaFieldsCount();
++        List immediateFields = new ArrayList(length);
++        for (int index = 0; index < length; index += FIELD_SLOTS) {
+             immediateFields.add(getFieldByIndex(index));
+         }
+ 
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java b/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/jcore/ClassWriter.java
+@@ -381,15 +381,15 @@
+ 
+     protected void writeFields() throws IOException {
+         TypeArray fields = klass.getFields();
+-        final int length = (int) fields.getLength();
++        final int length = klass.getJavaFieldsCount();
+ 
+         // write number of fields
+-        dos.writeShort((short) (length / InstanceKlass.NEXT_OFFSET) );
++        dos.writeShort((short) (length / InstanceKlass.FIELD_SLOTS) );
+ 
+         if (DEBUG) debugMessage("number of fields = "
+-                                + length/InstanceKlass.NEXT_OFFSET);
++                                + length/InstanceKlass.FIELD_SLOTS);
+ 
+-        for (int index = 0; index < length; index += InstanceKlass.NEXT_OFFSET) {
++        for (int index = 0; index < length; index += InstanceKlass.FIELD_SLOTS) {
+             short accessFlags    = fields.getShortAt(index + InstanceKlass.ACCESS_FLAGS_OFFSET);
+             dos.writeShort(accessFlags & (short) JVM_RECOGNIZED_FIELD_MODIFIERS);
+ 
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java b/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/soql/SOQL.java
+@@ -150,16 +150,13 @@
+             }
+ 
+             // list immediate fields only
+-            TypeArray fields = klass.getFields();
+-            int numFields = (int) fields.getLength();
++            int numFields = klass.getJavaFieldsCount();
+             ConstantPool cp = klass.getConstants();
+             out.println("fields");
+             if (numFields != 0) {
+-               for (int f = 0; f < numFields; f += InstanceKlass.NEXT_OFFSET) {
+-                 int nameIndex = fields.getShortAt(f + InstanceKlass.NAME_INDEX_OFFSET);
+-                 int sigIndex  = fields.getShortAt(f + InstanceKlass.SIGNATURE_INDEX_OFFSET);
+-                 Symbol f_name = cp.getSymbolAt(nameIndex);
+-                 Symbol f_sig  = cp.getSymbolAt(sigIndex);
++              for (int f = 0; f < numFields; f++){
++                 Symbol f_name = klass.getFieldName(f);
++                 Symbol f_sig  = klass.getFieldSignature(f);
+                  StringBuffer sigBuf = new StringBuffer();
+                  new SignatureConverter(f_sig, sigBuf).dispatchField();
+                  out.print('\t');
+diff --git a/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java b/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java
+--- openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java
++++ openjdk/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java
+@@ -1117,20 +1117,15 @@
+                 InstanceKlass kls = (InstanceKlass) obj;
+                 buf.append(" " + kls.getName().asString() + "={");
+                 int flen = ov.fieldsSize();
+-
+-                TypeArray klfields = kls.getFields();
+-                int klen = (int) klfields.getLength();
+-
+-                ConstantPool cp = kls.getConstants();
++                int klen = kls.getJavaFieldsCount();
+                 int findex = 0;
+-                for (int index = 0; index < klen; index += kls.NEXT_OFFSET) {
+-                    int accsFlags = klfields.getShortAt(index + kls.ACCESS_FLAGS_OFFSET);
+-                    int nameIndex = klfields.getShortAt(index + kls.NAME_INDEX_OFFSET);
++                for (int index = 0; index < klen; index++) {
++                    int accsFlags = kls.getFieldAccessFlags(index);
++                    Symbol f_name = kls.getFieldName(index);
+                     AccessFlags access = new AccessFlags(accsFlags);
+                     if (!access.isStatic()) {
+                         ScopeValue svf = ov.getFieldAt(findex++);
+                         String    fstr = scopeValueAsString(sd, svf);
+-                        Symbol f_name  = cp.getSymbolAt(nameIndex);
+                         buf.append(" [" + f_name.asString() + " :"+ index + "]=(#" + fstr + ")");
+                     }
+                 }
+@@ -1820,13 +1815,11 @@
+ 
+    protected String genHTMLListForFields(InstanceKlass klass) {
+       Formatter buf = new Formatter(genHTML);
+-      TypeArray fields = klass.getFields();
+-      int numFields = (int) fields.getLength();
+-      ConstantPool cp = klass.getConstants();
++      int numFields = klass.getJavaFieldsCount();
+       if (numFields != 0) {
+          buf.h3("Fields");
+          buf.beginList();
+-         for (int f = 0; f < numFields; f += InstanceKlass.NEXT_OFFSET) {
++         for (int f = 0; f < numFields; f++) {
+            sun.jvm.hotspot.oops.Field field = klass.getFieldByIndex(f);
+            String f_name = ((NamedFieldIdentifier)field.getID()).getName();
+            Symbol f_sig  = field.getSignature();
+diff --git a/agent/test/jdi/sasanity.sh b/agent/test/jdi/sasanity.sh
+--- openjdk/hotspot/agent/test/jdi/sasanity.sh
++++ openjdk/hotspot/agent/test/jdi/sasanity.sh
+@@ -76,5 +76,5 @@
+   sleep 2
+ done
+ 
+-$jdk/bin/java -showversion ${OPTIONS} -classpath $javacp SASanityChecker $pid
++$jdk/bin/java -showversion ${OPTIONS} -classpath $javacp $* SASanityChecker $pid
+ kill -9 $pid
+diff --git a/src/cpu/sparc/vm/assembler_sparc.cpp b/src/cpu/sparc/vm/assembler_sparc.cpp
+--- openjdk/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp
++++ openjdk/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp
+@@ -3186,15 +3186,10 @@
+                                                 Register temp_reg) {
+   assert_different_registers(vmslots_reg, mh_reg, temp_reg);
+   // load mh.type.form.vmslots
+-  if (java_dyn_MethodHandle::vmslots_offset_in_bytes() != 0) {
+-    // hoist vmslots into every mh to avoid dependent load chain
+-    ld(           Address(mh_reg,    delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg)),   vmslots_reg);
+-  } else {
+-    Register temp2_reg = vmslots_reg;
+-    load_heap_oop(Address(mh_reg,    delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)),      temp2_reg);
+-    load_heap_oop(Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)),        temp2_reg);
+-    ld(           Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg);
+-  }
++  Register temp2_reg = vmslots_reg;
++  load_heap_oop(Address(mh_reg,    delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)),      temp2_reg);
++  load_heap_oop(Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)),        temp2_reg);
++  ld(           Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg);
+ }
+ 
+ 
+@@ -4918,4 +4913,3 @@
+   // Caller should set it:
+   // add(G0, 1, result); // equals
+ }
+-
+diff --git a/src/cpu/x86/vm/assembler_x86.cpp b/src/cpu/x86/vm/assembler_x86.cpp
+--- openjdk/hotspot/src/cpu/x86/vm/assembler_x86.cpp
++++ openjdk/hotspot/src/cpu/x86/vm/assembler_x86.cpp
+@@ -7806,15 +7806,10 @@
+                                                 Register temp_reg) {
+   assert_different_registers(vmslots_reg, mh_reg, temp_reg);
+   // load mh.type.form.vmslots
+-  if (java_dyn_MethodHandle::vmslots_offset_in_bytes() != 0) {
+-    // hoist vmslots into every mh to avoid dependent load chain
+-    movl(vmslots_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg)));
+-  } else {
+-    Register temp2_reg = vmslots_reg;
+-    load_heap_oop(temp2_reg, Address(mh_reg,    delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)));
+-    load_heap_oop(temp2_reg, Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)));
+-    movl(vmslots_reg, Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)));
+-  }
++  Register temp2_reg = vmslots_reg;
++  load_heap_oop(temp2_reg, Address(mh_reg,    delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)));
++  load_heap_oop(temp2_reg, Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)));
++  movl(vmslots_reg, Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)));
+ }
+ 
+ 
+diff --git a/src/share/vm/ci/ciInstanceKlass.cpp b/src/share/vm/ci/ciInstanceKlass.cpp
+--- openjdk/hotspot/src/share/vm/ci/ciInstanceKlass.cpp
++++ openjdk/hotspot/src/share/vm/ci/ciInstanceKlass.cpp
+@@ -31,6 +31,7 @@
+ #include "memory/allocation.hpp"
+ #include "memory/allocation.inline.hpp"
+ #include "oops/oop.inline.hpp"
++#include "oops/fieldStreams.hpp"
+ #include "runtime/fieldDescriptor.hpp"
+ 
+ // ciInstanceKlass
+@@ -411,7 +412,7 @@
+     VM_ENTRY_MARK;
+     ciEnv* curEnv = ciEnv::current();
+     instanceKlass* ik = get_instanceKlass();
+-    int max_n_fields = ik->fields()->length()/instanceKlass::next_offset;
++    int max_n_fields = ik->java_fields_count();
+ 
+     Arena* arena = curEnv->arena();
+     _non_static_fields =
+@@ -475,23 +476,6 @@
+   // Now sort them by offset, ascending.
+   // (In principle, they could mix with superclass fields.)
+   fields->sort(sort_field_by_offset);
+-#ifdef ASSERT
+-  int last_offset = instanceOopDesc::base_offset_in_bytes();
+-  for (int i = 0; i < fields->length(); i++) {
+-    ciField* field = fields->at(i);
+-    int offset = field->offset_in_bytes();
+-    int size   = (field->_type == NULL) ? heapOopSize : field->size_in_bytes();
+-    assert(last_offset <= offset, err_msg("no field overlap: %d <= %d", last_offset, offset));
+-    if (last_offset > (int)sizeof(oopDesc))
+-      assert((offset - last_offset) < BytesPerLong, "no big holes");
+-    // Note:  Two consecutive T_BYTE fields will be separated by wordSize-1
+-    // padding bytes if one of them is declared by a superclass.
+-    // This is a minor inefficiency classFileParser.cpp.
+-    last_offset = offset + size;
+-  }
+-  assert(last_offset <= (int)instanceOopDesc::base_offset_in_bytes() + fsize, "no overflow");
+-#endif
+-
+   _nonstatic_fields = fields;
+   return flen;
+ }
+@@ -504,33 +488,29 @@
+   int flen = 0;
+   GrowableArray<ciField*>* fields = NULL;
+   instanceKlass* k = get_instanceKlass();
+-  typeArrayOop fields_array = k->fields();
+-  for (int pass = 0; pass <= 1; pass++) {
+-    for (int i = 0, alen = fields_array->length(); i < alen; i += instanceKlass::next_offset) {
+-      fieldDescriptor fd;
+-      fd.initialize(k->as_klassOop(), i);
+-      if (fd.is_static())  continue;
+-      if (pass == 0) {
+-        flen += 1;
+-      } else {
+-        ciField* field = new (arena) ciField(&fd);
+-        fields->append(field);
+-      }
+-    }
++  for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
++    if (fs.access_flags().is_static())  continue;
++    flen += 1;
++  }
+ 
+-    // Between passes, allocate the array:
+-    if (pass == 0) {
+-      if (flen == 0) {
+-        return NULL;  // return nothing if none are locally declared
+-      }
+-      if (super_fields != NULL) {
+-        flen += super_fields->length();
+-      }
+-      fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
+-      if (super_fields != NULL) {
+-        fields->appendAll(super_fields);
+-      }
+-    }
++  // allocate the array:
++  if (flen == 0) {
++    return NULL;  // return nothing if none are locally declared
++  }
++  if (super_fields != NULL) {
++    flen += super_fields->length();
++  }
++  fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
++  if (super_fields != NULL) {
++    fields->appendAll(super_fields);
++  }
++
++  for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
++    if (fs.access_flags().is_static())  continue;
++    fieldDescriptor fd;
++    fd.initialize(k->as_klassOop(), fs.index());
++    ciField* field = new (arena) ciField(&fd);
++    fields->append(field);
+   }
+   assert(fields->length() == flen, "sanity");
+   return fields;
+diff --git a/src/share/vm/classfile/classFileParser.cpp b/src/share/vm/classfile/classFileParser.cpp
+--- openjdk/hotspot/src/share/vm/classfile/classFileParser.cpp
++++ openjdk/hotspot/src/share/vm/classfile/classFileParser.cpp
+@@ -36,6 +36,7 @@
+ #include "memory/oopFactory.hpp"
+ #include "memory/universe.inline.hpp"
+ #include "oops/constantPoolOop.hpp"
++#include "oops/fieldStreams.hpp"
+ #include "oops/instanceKlass.hpp"
+ #include "oops/instanceMirrorKlass.hpp"
+ #include "oops/klass.inline.hpp"
+@@ -1004,42 +1005,98 @@
+   STATIC_BYTE,          // Boolean, Byte, char
+   STATIC_SHORT,         // shorts
+   STATIC_WORD,          // ints
+-  STATIC_DOUBLE,        // long or double
+-  STATIC_ALIGNED_DOUBLE,// aligned long or double
++  STATIC_DOUBLE,        // aligned long or double
+   NONSTATIC_OOP,
+   NONSTATIC_BYTE,
+   NONSTATIC_SHORT,
+   NONSTATIC_WORD,
+   NONSTATIC_DOUBLE,
+-  NONSTATIC_ALIGNED_DOUBLE
++  MAX_FIELD_ALLOCATION_TYPE,
++  BAD_ALLOCATION_TYPE = -1
+ };
+ 
+-
+-struct FieldAllocationCount {
+-  unsigned int static_oop_count;
+-  unsigned int static_byte_count;
+-  unsigned int static_short_count;
+-  unsigned int static_word_count;
+-  unsigned int static_double_count;
+-  unsigned int nonstatic_oop_count;
+-  unsigned int nonstatic_byte_count;
+-  unsigned int nonstatic_short_count;
+-  unsigned int nonstatic_word_count;
+-  unsigned int nonstatic_double_count;
++static FieldAllocationType _basic_type_to_atype[2 * (T_CONFLICT + 1)] = {
++  BAD_ALLOCATION_TYPE, // 0
++  BAD_ALLOCATION_TYPE, // 1
++  BAD_ALLOCATION_TYPE, // 2
++  BAD_ALLOCATION_TYPE, // 3
++  NONSTATIC_BYTE ,     // T_BOOLEAN  =  4,
++  NONSTATIC_SHORT,     // T_CHAR     =  5,
++  NONSTATIC_WORD,      // T_FLOAT    =  6,
++  NONSTATIC_DOUBLE,    // T_DOUBLE   =  7,
++  NONSTATIC_BYTE,      // T_BYTE     =  8,
++  NONSTATIC_SHORT,     // T_SHORT    =  9,
++  NONSTATIC_WORD,      // T_INT      = 10,
++  NONSTATIC_DOUBLE,    // T_LONG     = 11,
++  NONSTATIC_OOP,       // T_OBJECT   = 12,
++  NONSTATIC_OOP,       // T_ARRAY    = 13,
++  BAD_ALLOCATION_TYPE, // T_VOID     = 14,
++  BAD_ALLOCATION_TYPE, // T_ADDRESS  = 15,
++  BAD_ALLOCATION_TYPE, // T_NARROWOOP= 16,
++  BAD_ALLOCATION_TYPE, // T_CONFLICT = 17,
++  BAD_ALLOCATION_TYPE, // 0
++  BAD_ALLOCATION_TYPE, // 1
++  BAD_ALLOCATION_TYPE, // 2
++  BAD_ALLOCATION_TYPE, // 3
++  STATIC_BYTE ,        // T_BOOLEAN  =  4,
++  STATIC_SHORT,        // T_CHAR     =  5,
++  STATIC_WORD,          // T_FLOAT    =  6,
++  STATIC_DOUBLE,       // T_DOUBLE   =  7,
++  STATIC_BYTE,         // T_BYTE     =  8,
++  STATIC_SHORT,        // T_SHORT    =  9,
++  STATIC_WORD,         // T_INT      = 10,
++  STATIC_DOUBLE,       // T_LONG     = 11,
++  STATIC_OOP,          // T_OBJECT   = 12,
++  STATIC_OOP,          // T_ARRAY    = 13,
++  BAD_ALLOCATION_TYPE, // T_VOID     = 14,
++  BAD_ALLOCATION_TYPE, // T_ADDRESS  = 15,
++  BAD_ALLOCATION_TYPE, // T_NARROWOOP= 16,
++  BAD_ALLOCATION_TYPE, // T_CONFLICT = 17,
+ };
+ 
+-typeArrayHandle ClassFileParser::parse_fields(constantPoolHandle cp, bool is_interface,
+-                                              struct FieldAllocationCount *fac,
+-                                              objArrayHandle* fields_annotations, TRAPS) {
++static FieldAllocationType basic_type_to_atype(bool is_static, BasicType type) {
++  assert(type >= T_BOOLEAN && type < T_VOID, "only allowable values");
++  FieldAllocationType result = _basic_type_to_atype[type + (is_static ? (T_CONFLICT + 1) : 0)];
++  assert(result != BAD_ALLOCATION_TYPE, "bad type");
++  return result;
++}
++
++class FieldAllocationCount: public ResourceObj {
++ public:
++  unsigned int count[MAX_FIELD_ALLOCATION_TYPE];
++
++  FieldAllocationCount() {
++    for (int i = 0; i < MAX_FIELD_ALLOCATION_TYPE; i++) {
++      count[i] = 0;
++    }
++  }
++
++  FieldAllocationType update(bool is_static, BasicType type) {
++    FieldAllocationType atype = basic_type_to_atype(is_static, type);
++    count[atype]++;
++    return atype;
++  }
++};
++
++
++typeArrayHandle ClassFileParser::parse_fields(Symbol* class_name,
++                                              constantPoolHandle cp, bool is_interface,
++                                              FieldAllocationCount *fac,
++                                              objArrayHandle* fields_annotations,
++                                              int* java_fields_count_ptr, TRAPS) {
+   ClassFileStream* cfs = stream();
+   typeArrayHandle nullHandle;
+   cfs->guarantee_more(2, CHECK_(nullHandle));  // length
+   u2 length = cfs->get_u2_fast();
++  *java_fields_count_ptr = length;
++
++  int num_injected = 0;
++  InjectedField* injected = JavaClasses::get_injected(class_name, &num_injected);
++
+   // Tuples of shorts [access, name index, sig index, initial value index, byte offset, generic signature index]
+-  typeArrayOop new_fields = oopFactory::new_permanent_shortArray(length*instanceKlass::next_offset, CHECK_(nullHandle));
++  typeArrayOop new_fields = oopFactory::new_permanent_shortArray((length + num_injected) * FieldInfo::field_slots, CHECK_(nullHandle));
+   typeArrayHandle fields(THREAD, new_fields);
+ 
+-  int index = 0;
+   typeArrayHandle field_annotations;
+   for (int n = 0; n < length; n++) {
+     cfs->guarantee_more(8, CHECK_(nullHandle));  // access_flags, name_index, descriptor_index, attributes_count
+@@ -1090,93 +1147,77 @@
+       }
+     }
+ 
+-    fields->short_at_put(index++, access_flags.as_short());
+-    fields->short_at_put(index++, name_index);
+-    fields->short_at_put(index++, signature_index);
+-    fields->short_at_put(index++, constantvalue_index);
++    FieldInfo* field = FieldInfo::from_field_array(fields(), n);
++    field->initialize(access_flags.as_short(),
++                      name_index,
++                      signature_index,
++                      constantvalue_index,
++                      generic_signature_index,
++                      0);
++
++    BasicType type = cp->basic_type_for_signature_at(signature_index);
+ 
+     // Remember how many oops we encountered and compute allocation type
+-    BasicType type = cp->basic_type_for_signature_at(signature_index);
+-    FieldAllocationType atype;
+-    if ( is_static ) {
+-      switch ( type ) {
+-        case  T_BOOLEAN:
+-        case  T_BYTE:
+-          fac->static_byte_count++;
+-          atype = STATIC_BYTE;
+-          break;
+-        case  T_LONG:
+-        case  T_DOUBLE:
+-          if (Universe::field_type_should_be_aligned(type)) {
+-            atype = STATIC_ALIGNED_DOUBLE;
+-          } else {
+-            atype = STATIC_DOUBLE;
+-          }
+-          fac->static_double_count++;
+-          break;
+-        case  T_CHAR:
+-        case  T_SHORT:
+-          fac->static_short_count++;
+-          atype = STATIC_SHORT;
+-          break;
+-        case  T_FLOAT:
+-        case  T_INT:
+-          fac->static_word_count++;
+-          atype = STATIC_WORD;
+-          break;
+-        case  T_ARRAY:
+-        case  T_OBJECT:
+-          fac->static_oop_count++;
+-          atype = STATIC_OOP;
+-          break;
+-        case  T_ADDRESS:
+-        case  T_VOID:
+-        default:
+-          assert(0, "bad field type");
+-      }
+-    } else {
+-      switch ( type ) {
+-        case  T_BOOLEAN:
+-        case  T_BYTE:
+-          fac->nonstatic_byte_count++;
+-          atype = NONSTATIC_BYTE;
+-          break;
+-        case  T_LONG:
+-        case  T_DOUBLE:
+-          if (Universe::field_type_should_be_aligned(type)) {
+-            atype = NONSTATIC_ALIGNED_DOUBLE;
+-          } else {
+-            atype = NONSTATIC_DOUBLE;
+-          }
+-          fac->nonstatic_double_count++;
+-          break;
+-        case  T_CHAR:
+-        case  T_SHORT:
+-          fac->nonstatic_short_count++;
+-          atype = NONSTATIC_SHORT;
+-          break;
+-        case  T_FLOAT:
+-        case  T_INT:
+-          fac->nonstatic_word_count++;
+-          atype = NONSTATIC_WORD;
+-          break;
+-        case  T_ARRAY:
+-        case  T_OBJECT:
+-          fac->nonstatic_oop_count++;
+-          atype = NONSTATIC_OOP;
+-          break;
+-        case  T_ADDRESS:
+-        case  T_VOID:
+-        default:
+-          assert(0, "bad field type");
+-      }
+-    }
++    FieldAllocationType atype = fac->update(is_static, type);
+ 
+     // The correct offset is computed later (all oop fields will be located together)
+     // We temporarily store the allocation type in the offset field
+-    fields->short_at_put(index++, atype);
+-    fields->short_at_put(index++, 0);  // Clear out high word of byte offset
+-    fields->short_at_put(index++, generic_signature_index);
++    field->set_offset(atype);
++  }
++
++  if (num_injected != 0) {
++    int index = length;
++    for (int n = 0; n < num_injected; n++) {
++      // Check for duplicates
++      if (injected[n].may_be_java) {
++        Symbol* name      = injected[n].name();
++        Symbol* signature = injected[n].signature();
++        bool duplicate = false;
++        for (int i = 0; i < length; i++) {
++          FieldInfo* f = FieldInfo::from_field_array(fields(), i);
++          if (name      == cp->symbol_at(f->name_index()) &&
++              signature == cp->symbol_at(f->signature_index())) {
++            // Symbol is desclared in Java so skip this one
++            duplicate = true;
++            break;
++          }
++        }
++        if (duplicate) {
++          // These will be removed from the field array at the end
++          continue;
++        }
++      }
++
++      // Injected field
++      FieldInfo* field = FieldInfo::from_field_array(fields(), index);
++      field->initialize(JVM_ACC_FIELD_INTERNAL,
++                        injected[n].name_index,
++                        injected[n].signature_index,
++                        0,
++                        0,
++                        0);
++
++      BasicType type = FieldType::basic_type(injected[n].signature());
++
++      // Remember how many oops we encountered and compute allocation type
++      FieldAllocationType atype = fac->update(false, type);
++
++      // The correct offset is computed later (all oop fields will be located together)
++      // We temporarily store the allocation type in the offset field
++      field->set_offset(atype);
++      index++;
++    }
++
++    if (index < length + num_injected) {
++      // sometimes injected fields already exist in the Java source so
++      // the fields array could be too long.  In that case trim the
++      // fields array.
++      new_fields = oopFactory::new_permanent_shortArray(index * FieldInfo::field_slots, CHECK_(nullHandle));
++      for (int i = 0; i < index * FieldInfo::field_slots; i++) {
++        new_fields->short_at_put(i, fields->short_at(i));
++      }
++      fields = new_fields;
++    }
+   }
+ 
+   if (_need_verify && length > 1) {
+@@ -1188,11 +1229,9 @@
+     bool dup = false;
+     {
+       debug_only(No_Safepoint_Verifier nsv;)
+-      for (int i = 0; i < length*instanceKlass::next_offset; i += instanceKlass::next_offset) {
+-        int name_index = fields->ushort_at(i + instanceKlass::name_index_offset);
+-        Symbol* name = cp->symbol_at(name_index);
+-        int sig_index = fields->ushort_at(i + instanceKlass::signature_index_offset);
+-        Symbol* sig = cp->symbol_at(sig_index);
++      for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) {
++        Symbol* name = fs.name();
++        Symbol* sig = fs.signature();
+         // If no duplicates, add name/signature in hashtable names_and_sigs.
+         if (!put_after_lookup(name, sig, names_and_sigs)) {
+           dup = true;
+@@ -2647,227 +2686,6 @@
+ }
+ 
+ 
+-void ClassFileParser::java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr,
+-  constantPoolHandle cp, FieldAllocationCount *fac_ptr, TRAPS) {
+-  // This code is for compatibility with earlier jdk's that do not
+-  // have the "discovered" field in java.lang.ref.Reference.  For 1.5
+-  // the check for the "discovered" field should issue a warning if
+-  // the field is not found.  For 1.6 this code should be issue a
+-  // fatal error if the "discovered" field is not found.
+-  //
+-  // Increment fac.nonstatic_oop_count so that the start of the
+-  // next type of non-static oops leaves room for the fake oop.
+-  // Do not increment next_nonstatic_oop_offset so that the
+-  // fake oop is place after the java.lang.ref.Reference oop
+-  // fields.
+-  //
+-  // Check the fields in java.lang.ref.Reference for the "discovered"
+-  // field.  If it is not present, artifically create a field for it.
+-  // This allows this VM to run on early JDK where the field is not
+-  // present.
+-  int reference_sig_index = 0;
+-  int reference_name_index = 0;
+-  int reference_index = 0;
+-  int extra = java_lang_ref_Reference::number_of_fake_oop_fields;
+-  const int n = (*fields_ptr)()->length();
+-  for (int i = 0; i < n; i += instanceKlass::next_offset ) {
+-    int name_index =
+-    (*fields_ptr)()->ushort_at(i + instanceKlass::name_index_offset);
+-    int sig_index  =
+-      (*fields_ptr)()->ushort_at(i + instanceKlass::signature_index_offset);
+-    Symbol* f_name = cp->symbol_at(name_index);
+-    Symbol* f_sig  = cp->symbol_at(sig_index);
+-    if (f_sig == vmSymbols::reference_signature() && reference_index == 0) {
+-      // Save the index for reference signature for later use.
+-      // The fake discovered field does not entries in the
+-      // constant pool so the index for its signature cannot
+-      // be extracted from the constant pool.  It will need
+-      // later, however.  It's signature is vmSymbols::reference_signature()
+-      // so same an index for that signature.
+-      reference_sig_index = sig_index;
+-      reference_name_index = name_index;
+-      reference_index = i;
+-    }
+-    if (f_name == vmSymbols::reference_discovered_name() &&
+-      f_sig == vmSymbols::reference_signature()) {
+-      // The values below are fake but will force extra
+-      // non-static oop fields and a corresponding non-static
+-      // oop map block to be allocated.
+-      extra = 0;
+-      break;
+-    }
+-  }
+-  if (extra != 0) {
+-    fac_ptr->nonstatic_oop_count += extra;
+-    // Add the additional entry to "fields" so that the klass
+-    // contains the "discoverd" field and the field will be initialized
+-    // in instances of the object.
+-    int fields_with_fix_length = (*fields_ptr)()->length() +
+-      instanceKlass::next_offset;
+-    typeArrayOop ff = oopFactory::new_permanent_shortArray(
+-                                                fields_with_fix_length, CHECK);
+-    typeArrayHandle fields_with_fix(THREAD, ff);
+-
+-    // Take everything from the original but the length.
+-    for (int idx = 0; idx < (*fields_ptr)->length(); idx++) {
+-      fields_with_fix->ushort_at_put(idx, (*fields_ptr)->ushort_at(idx));
+-    }
+-
+-    // Add the fake field at the end.
+-    int i = (*fields_ptr)->length();
+-    // There is no name index for the fake "discovered" field nor
+-    // signature but a signature is needed so that the field will
+-    // be properly initialized.  Use one found for
+-    // one of the other reference fields. Be sure the index for the
+-    // name is 0.  In fieldDescriptor::initialize() the index of the
+-    // name is checked.  That check is by passed for the last nonstatic
+-    // oop field in a java.lang.ref.Reference which is assumed to be
+-    // this artificial "discovered" field.  An assertion checks that
+-    // the name index is 0.
+-    assert(reference_index != 0, "Missing signature for reference");
+-
+-    int j;
+-    for (j = 0; j < instanceKlass::next_offset; j++) {
+-      fields_with_fix->ushort_at_put(i + j,
+-        (*fields_ptr)->ushort_at(reference_index +j));
+-    }
+-    // Clear the public access flag and set the private access flag.
+-    short flags;
+-    flags =
+-      fields_with_fix->ushort_at(i + instanceKlass::access_flags_offset);
+-    assert(!(flags & JVM_RECOGNIZED_FIELD_MODIFIERS), "Unexpected access flags set");
+-    flags = flags & (~JVM_ACC_PUBLIC);
+-    flags = flags | JVM_ACC_PRIVATE;
+-    AccessFlags access_flags;
+-    access_flags.set_flags(flags);
+-    assert(!access_flags.is_public(), "Failed to clear public flag");
+-    assert(access_flags.is_private(), "Failed to set private flag");
+-    fields_with_fix->ushort_at_put(i + instanceKlass::access_flags_offset,
+-      flags);
+-
+-    assert(fields_with_fix->ushort_at(i + instanceKlass::name_index_offset)
+-      == reference_name_index, "The fake reference name is incorrect");
+-    assert(fields_with_fix->ushort_at(i + instanceKlass::signature_index_offset)
+-      == reference_sig_index, "The fake reference signature is incorrect");
+-    // The type of the field is stored in the low_offset entry during
+-    // parsing.
+-    assert(fields_with_fix->ushort_at(i + instanceKlass::low_offset) ==
+-      NONSTATIC_OOP, "The fake reference type is incorrect");
+-
+-    // "fields" is allocated in the permanent generation.  Disgard
+-    // it and let it be collected.
+-    (*fields_ptr) = fields_with_fix;
+-  }
+-  return;
+-}
+-
+-
+-void ClassFileParser::java_lang_Class_fix_pre(int* nonstatic_field_size,
+-                                              FieldAllocationCount *fac_ptr) {
+-  // Add fake fields for java.lang.Class instances
+-  //
+-  // This is not particularly nice. We should consider adding a
+-  // private transient object field at the Java level to
+-  // java.lang.Class. Alternatively we could add a subclass of
+-  // instanceKlass which provides an accessor and size computer for
+-  // this field, but that appears to be more code than this hack.
+-  //
+-  // NOTE that we wedge these in at the beginning rather than the
+-  // end of the object because the Class layout changed between JDK
+-  // 1.3 and JDK 1.4 with the new reflection implementation; some
+-  // nonstatic oop fields were added at the Java level. The offsets
+-  // of these fake fields can't change between these two JDK
+-  // versions because when the offsets are computed at bootstrap
+-  // time we don't know yet which version of the JDK we're running in.
+-
+-  // The values below are fake but will force three non-static oop fields and
+-  // a corresponding non-static oop map block to be allocated.
+-  const int extra = java_lang_Class::number_of_fake_oop_fields;
+-  fac_ptr->nonstatic_oop_count += extra;
+-
+-  // Reserve some leading space for fake ints
+-  *nonstatic_field_size += align_size_up(java_lang_Class::hc_number_of_fake_int_fields * BytesPerInt, heapOopSize) / heapOopSize;
+-}
+-
+-
+-void ClassFileParser::java_lang_Class_fix_post(int* next_nonstatic_oop_offset_ptr) {
+-  // Cause the extra fake fields in java.lang.Class to show up before
+-  // the Java fields for layout compatibility between 1.3 and 1.4
+-  // Incrementing next_nonstatic_oop_offset here advances the
+-  // location where the real java fields are placed.
+-  const int extra = java_lang_Class::number_of_fake_oop_fields;
+-  (*next_nonstatic_oop_offset_ptr) += (extra * heapOopSize);
+-}
+-
+-
+-// Force MethodHandle.vmentry to be an unmanaged pointer.
+-// There is no way for a classfile to express this, so we must help it.
+-void ClassFileParser::java_dyn_MethodHandle_fix_pre(constantPoolHandle cp,
+-                                                    typeArrayHandle fields,
+-                                                    FieldAllocationCount *fac_ptr,
+-                                                    TRAPS) {
+-  // Add fake fields for java.dyn.MethodHandle instances
+-  //
+-  // This is not particularly nice, but since there is no way to express
+-  // a native wordSize field in Java, we must do it at this level.
+-
+-  if (!EnableMethodHandles)  return;
+-
+-  int word_sig_index = 0;
+-  const int cp_size = cp->length();
+-  for (int index = 1; index < cp_size; index++) {
+-    if (cp->tag_at(index).is_utf8() &&
+-        cp->symbol_at(index) == vmSymbols::machine_word_signature()) {
+-      word_sig_index = index;
+-      break;
+-    }
+-  }
+-
+-  if (word_sig_index == 0)
+-    THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
+-              "missing I or J signature (for vmentry) in java.dyn.MethodHandle");
+-
+-  // Find vmentry field and change the signature.
+-  bool found_vmentry = false;
+-  for (int i = 0; i < fields->length(); i += instanceKlass::next_offset) {
+-    int name_index = fields->ushort_at(i + instanceKlass::name_index_offset);
+-    int sig_index  = fields->ushort_at(i + instanceKlass::signature_index_offset);
+-    int acc_flags  = fields->ushort_at(i + instanceKlass::access_flags_offset);
+-    Symbol* f_name = cp->symbol_at(name_index);
+-    Symbol* f_sig  = cp->symbol_at(sig_index);
+-    if (f_name == vmSymbols::vmentry_name() && (acc_flags & JVM_ACC_STATIC) == 0) {
+-      if (f_sig == vmSymbols::machine_word_signature()) {
+-        // If the signature of vmentry is already changed, we're done.
+-        found_vmentry = true;
+-        break;
+-      }
+-      else if (f_sig == vmSymbols::byte_signature()) {
+-        // Adjust the field type from byte to an unmanaged pointer.
+-        assert(fac_ptr->nonstatic_byte_count > 0, "");
+-        fac_ptr->nonstatic_byte_count -= 1;
+-
+-        fields->ushort_at_put(i + instanceKlass::signature_index_offset, word_sig_index);
+-        assert(wordSize == longSize || wordSize == jintSize, "ILP32 or LP64");
+-        if (wordSize == longSize)  fac_ptr->nonstatic_double_count += 1;
+-        else                       fac_ptr->nonstatic_word_count   += 1;
+-
+-        FieldAllocationType atype = (FieldAllocationType) fields->ushort_at(i + instanceKlass::low_offset);
+-        assert(atype == NONSTATIC_BYTE, "");
+-        FieldAllocationType new_atype = (wordSize == longSize) ? NONSTATIC_DOUBLE : NONSTATIC_WORD;
+-        fields->ushort_at_put(i + instanceKlass::low_offset, new_atype);
+-
+-        found_vmentry = true;
+-        break;
+-      }
+-    }
+-  }
+-
+-  if (!found_vmentry)
+-    THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
+-              "missing vmentry byte field in java.dyn.MethodHandle");
+-}
+-
+-
+ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
+                                                     Handle class_loader,
+                                                     Handle protection_domain,
+@@ -3080,10 +2898,13 @@
+       local_interfaces = parse_interfaces(cp, itfs_len, class_loader, protection_domain, _class_name, CHECK_(nullHandle));
+     }
+ 
++    int java_fields_count = 0;
+     // Fields (offsets are filled in later)
+-    struct FieldAllocationCount fac = {0,0,0,0,0,0,0,0,0,0};
++    FieldAllocationCount fac;
+     objArrayHandle fields_annotations;
+-    typeArrayHandle fields = parse_fields(cp, access_flags.is_interface(), &fac, &fields_annotations, CHECK_(nullHandle));
++    typeArrayHandle fields = parse_fields(class_name, cp, access_flags.is_interface(), &fac, &fields_annotations,
++                                          &java_fields_count,
++                                          CHECK_(nullHandle));
+     // Methods
+     bool has_final_method = false;
+     AccessFlags promoted_flags;
+@@ -3201,50 +3022,33 @@
+     // Calculate the starting byte offsets
+     next_static_oop_offset      = instanceMirrorKlass::offset_of_static_fields();
+     next_static_double_offset   = next_static_oop_offset +
+-                                  (fac.static_oop_count * heapOopSize);
+-    if ( fac.static_double_count &&
++                                  (fac.count[STATIC_OOP] * heapOopSize);
++    if ( fac.count[STATIC_DOUBLE] &&
+          (Universe::field_type_should_be_aligned(T_DOUBLE) ||
+           Universe::field_type_should_be_aligned(T_LONG)) ) {
+       next_static_double_offset = align_size_up(next_static_double_offset, BytesPerLong);
+     }
+ 
+     next_static_word_offset     = next_static_double_offset +
+-                                  (fac.static_double_count * BytesPerLong);
++                                  (fac.count[STATIC_DOUBLE] * BytesPerLong);
+     next_static_short_offset    = next_static_word_offset +
+-                                  (fac.static_word_count * BytesPerInt);
++                                  (fac.count[STATIC_WORD] * BytesPerInt);
+     next_static_byte_offset     = next_static_short_offset +
+-                                  (fac.static_short_count * BytesPerShort);
++                                  (fac.count[STATIC_SHORT] * BytesPerShort);
+     next_static_type_offset     = align_size_up((next_static_byte_offset +
+-                                  fac.static_byte_count ), wordSize );
++                                  fac.count[STATIC_BYTE] ), wordSize );
+     static_field_size           = (next_static_type_offset -
+                                   next_static_oop_offset) / wordSize;
++
+     first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
+                                    nonstatic_field_size * heapOopSize;
+     next_nonstatic_field_offset = first_nonstatic_field_offset;
+ 
+-    // Add fake fields for java.lang.Class instances (also see below)
+-    if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
+-      java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle));
+-    }
+-
+-    // adjust the vmentry field declaration in java.dyn.MethodHandle
+-    if (EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
+-      java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
+-    }
+-
+-    // Add a fake "discovered" field if it is not present
+-    // for compatibility with earlier jdk's.
+-    if (class_name == vmSymbols::java_lang_ref_Reference()
+-      && class_loader.is_null()) {
+-      java_lang_ref_Reference_fix_pre(&fields, cp, &fac, CHECK_(nullHandle));
+-    }
+-    // end of "discovered" field compactibility fix
+-
+-    unsigned int nonstatic_double_count = fac.nonstatic_double_count;
+-    unsigned int nonstatic_word_count   = fac.nonstatic_word_count;
+-    unsigned int nonstatic_short_count  = fac.nonstatic_short_count;
+-    unsigned int nonstatic_byte_count   = fac.nonstatic_byte_count;
+-    unsigned int nonstatic_oop_count    = fac.nonstatic_oop_count;
++    unsigned int nonstatic_double_count = fac.count[NONSTATIC_DOUBLE];
++    unsigned int nonstatic_word_count   = fac.count[NONSTATIC_WORD];
++    unsigned int nonstatic_short_count  = fac.count[NONSTATIC_SHORT];
++    unsigned int nonstatic_byte_count   = fac.count[NONSTATIC_BYTE];
++    unsigned int nonstatic_oop_count    = fac.count[NONSTATIC_OOP];
+ 
+     bool super_has_nonstatic_fields =
+             (super_klass() != NULL && super_klass->has_nonstatic_fields());
+@@ -3264,20 +3068,7 @@
+     nonstatic_oop_counts  = NEW_RESOURCE_ARRAY_IN_THREAD(
+               THREAD, unsigned int, nonstatic_oop_count + 1);
+ 
+-    // Add fake fields for java.lang.Class instances (also see above).
+-    // FieldsAllocationStyle and CompactFields values will be reset to default.
+-    if(class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
+-      java_lang_Class_fix_post(&next_nonstatic_field_offset);
+-      nonstatic_oop_offsets[0] = first_nonstatic_field_offset;
+-      const uint fake_oop_count = (next_nonstatic_field_offset -
+-                                   first_nonstatic_field_offset) / heapOopSize;
+-      nonstatic_oop_counts[0] = fake_oop_count;
+-      nonstatic_oop_map_count = 1;
+-      nonstatic_oop_count -= fake_oop_count;
+-      first_nonstatic_oop_offset = first_nonstatic_field_offset;
+-    } else {
+-      first_nonstatic_oop_offset = 0; // will be set for first oop field
+-    }
++    first_nonstatic_oop_offset = 0; // will be set for first oop field
+ 
+ #ifndef PRODUCT
+     if( PrintCompactFieldsSavings ) {
+@@ -3432,10 +3223,9 @@
+     // Iterate over fields again and compute correct offsets.
+     // The field allocation type was temporarily stored in the offset slot.
+     // oop fields are located before non-oop fields (static and non-static).
+-    int len = fields->length();
+-    for (int i = 0; i < len; i += instanceKlass::next_offset) {
++    for (AllFieldStream fs(fields, cp); !fs.done(); fs.next()) {
+       int real_offset;
+-      FieldAllocationType atype = (FieldAllocationType) fields->ushort_at(i + instanceKlass::low_offset);
++      FieldAllocationType atype = (FieldAllocationType) fs.offset();
+       switch (atype) {
+         case STATIC_OOP:
+           real_offset = next_static_oop_offset;
+@@ -3453,7 +3243,6 @@
+           real_offset = next_static_word_offset;
+           next_static_word_offset += BytesPerInt;
+           break;
+-        case STATIC_ALIGNED_DOUBLE:
+         case STATIC_DOUBLE:
+           real_offset = next_static_double_offset;
+           next_static_double_offset += BytesPerLong;
+@@ -3515,7 +3304,6 @@
+             next_nonstatic_word_offset += BytesPerInt;
+           }
+           break;
+-        case NONSTATIC_ALIGNED_DOUBLE:
+         case NONSTATIC_DOUBLE:
+           real_offset = next_nonstatic_double_offset;
+           next_nonstatic_double_offset += BytesPerLong;
+@@ -3523,8 +3311,7 @@
+         default:
+           ShouldNotReachHere();
+       }
+-      fields->short_at_put(i + instanceKlass::low_offset,  extract_low_short_from_int(real_offset));
+-      fields->short_at_put(i + instanceKlass::high_offset, extract_high_short_from_int(real_offset));
++      fs.set_offset(real_offset);
+     }
+ 
+     // Size of instances
+@@ -3571,12 +3358,12 @@
+     this_klass->set_class_loader(class_loader());
+     this_klass->set_nonstatic_field_size(nonstatic_field_size);
+     this_klass->set_has_nonstatic_fields(has_nonstatic_fields);
+-    this_klass->set_static_oop_field_count(fac.static_oop_count);
++    this_klass->set_static_oop_field_count(fac.count[STATIC_OOP]);
+     cp->set_pool_holder(this_klass());
+     error_handler.set_in_error(false);   // turn off error handler for cp
+     this_klass->set_constants(cp());
+     this_klass->set_local_interfaces(local_interfaces());
+-    this_klass->set_fields(fields());
++    this_klass->set_fields(fields(), java_fields_count);
+     this_klass->set_methods(methods());
+     if (has_final_method) {
+       this_klass->set_has_final_method();
+diff --git a/src/share/vm/classfile/classFileParser.hpp b/src/share/vm/classfile/classFileParser.hpp
+--- openjdk/hotspot/src/share/vm/classfile/classFileParser.hpp
++++ openjdk/hotspot/src/share/vm/classfile/classFileParser.hpp
+@@ -33,6 +33,9 @@
+ #include "utilities/accessFlags.hpp"
+ 
+ class TempNewSymbol;
++class FieldAllocationCount;
++
++
+ // Parser for for .class files
+ //
+ // The bytes describing the class file structure is read from a Stream object
+@@ -84,9 +87,11 @@
+                               bool* is_synthetic_addr,
+                               u2* generic_signature_index_addr,
+                               typeArrayHandle* field_annotations, TRAPS);
+-  typeArrayHandle parse_fields(constantPoolHandle cp, bool is_interface,
+-                               struct FieldAllocationCount *fac,
+-                               objArrayHandle* fields_annotations, TRAPS);
++  typeArrayHandle parse_fields(Symbol* class_name,
++                               constantPoolHandle cp, bool is_interface,
++                               FieldAllocationCount *fac,
++                               objArrayHandle* fields_annotations,
++                               int* java_fields_count_ptr, TRAPS);
+ 
+   // Method parsing
+   methodHandle parse_method(constantPoolHandle cp, bool is_interface,
+@@ -150,25 +155,6 @@
+   objArrayHandle compute_transitive_interfaces(instanceKlassHandle super,
+                                                objArrayHandle local_ifs, TRAPS);
+ 
+-  // Special handling for certain classes.
+-  // Add the "discovered" field to java.lang.ref.Reference if
+-  // it does not exist.
+-  void java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr,
+-                                       constantPoolHandle cp,
+-                                       FieldAllocationCount *fac_ptr, TRAPS);
+-  // Adjust the field allocation counts for java.lang.Class to add
+-  // fake fields.
+-  void java_lang_Class_fix_pre(int* nonstatic_field_size,
+-                               FieldAllocationCount *fac_ptr);
+-  // Adjust the next_nonstatic_oop_offset to place the fake fields
+-  // before any Java fields.
+-  void java_lang_Class_fix_post(int* next_nonstatic_oop_offset);
+-  // Adjust the field allocation counts for java.dyn.MethodHandle to add
+-  // a fake address (void*) field.
+-  void java_dyn_MethodHandle_fix_pre(constantPoolHandle cp,
+-                                     typeArrayHandle fields,
+-                                     FieldAllocationCount *fac_ptr, TRAPS);
+-
+   // Format checker methods
+   void classfile_parse_error(const char* msg, TRAPS);
+   void classfile_parse_error(const char* msg, int index, TRAPS);
+diff --git a/src/share/vm/classfile/javaClasses.cpp b/src/share/vm/classfile/javaClasses.cpp
+--- openjdk/hotspot/src/share/vm/classfile/javaClasses.cpp
++++ openjdk/hotspot/src/share/vm/classfile/javaClasses.cpp
+@@ -32,6 +32,7 @@
+ #include "memory/oopFactory.hpp"
+ #include "memory/resourceArea.hpp"
+ #include "memory/universe.inline.hpp"
++#include "oops/fieldStreams.hpp"
+ #include "oops/instanceKlass.hpp"
+ #include "oops/instanceMirrorKlass.hpp"
+ #include "oops/klass.hpp"
+@@ -57,6 +58,49 @@
+ # include "thread_windows.inline.hpp"
+ #endif
+ 
++#define INJECTED_FIELD_COMPUTE_OFFSET(klass, name, signature, may_be_java)    \
++  klass::_##name##_offset = JavaClasses::compute_injected_offset(JavaClasses::klass##_##name##_enum);
++
++#define DECLARE_INJECTED_FIELD(klass, name, signature, may_be_java)           \
++  { SystemDictionary::WK_KLASS_ENUM_NAME(klass), vmSymbols::VM_SYMBOL_ENUM_NAME(name##_name), vmSymbols::VM_SYMBOL_ENUM_NAME(signature), may_be_java },
++
++InjectedField JavaClasses::_injected_fields[] = {
++  ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD)
++};
++
++int JavaClasses::compute_injected_offset(InjectedFieldID id) {
++  return _injected_fields[id].compute_offset();
++}
++
++
++InjectedField* JavaClasses::get_injected(Symbol* class_name, int* field_count) {
++  *field_count = 0;
++
++  vmSymbols::SID sid = vmSymbols::find_sid(class_name);
++  if (sid == vmSymbols::NO_SID) {
++    // Only well known classes can inject fields
++    return NULL;
++  }
++
++  int count = 0;
++  int start = -1;
++
++#define LOOKUP_INJECTED_FIELD(klass, name, signature, may_be_java) \
++  if (sid == vmSymbols::VM_SYMBOL_ENUM_NAME(klass)) {              \
++    count++;                                                       \
++    if (start == -1) start = klass##_##name##_enum;                \
++  }
++  ALL_INJECTED_FIELDS(LOOKUP_INJECTED_FIELD);
++#undef LOOKUP_INJECTED_FIELD
++
++  if (start != -1) {
++    *field_count = count;
++    return _injected_fields + start;
++  }
++  return NULL;
++}
++
++
+ static bool find_field(instanceKlass* ik,
+                        Symbol* name_symbol, Symbol* signature_symbol,
+                        fieldDescriptor* fd,
+@@ -440,24 +484,19 @@
+ }
+ 
+ 
+-// During bootstrap, java.lang.Class wasn't loaded so static field
+-// offsets were computed without the size added it.  Go back and
+-// update all the static field offsets to included the size.
+-static void fixup_static_field(fieldDescriptor* fd, TRAPS) {
+-  if (fd->is_static()) {
+-    int real_offset = fd->offset() + instanceMirrorKlass::offset_of_static_fields();
+-    typeArrayOop fields = instanceKlass::cast(fd->field_holder())->fields();
+-    fields->short_at_put(fd->index() + instanceKlass::low_offset,  extract_low_short_from_int(real_offset));
+-    fields->short_at_put(fd->index() + instanceKlass::high_offset, extract_high_short_from_int(real_offset));
+-  }
+-}
+-
+ void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
+   assert(instanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
+ 
+   if (k->oop_is_instance()) {
+-    // Fixup the offsets
+-    instanceKlass::cast(k())->do_local_static_fields(&fixup_static_field, CHECK);
++    // During bootstrap, java.lang.Class wasn't loaded so static field
++    // offsets were computed without the size added it.  Go back and
++    // update all the static field offsets to included the size.
++    for (JavaFieldStream fs(instanceKlass::cast(k())); !fs.done(); fs.next()) {
++      if (fs.access_flags().is_static()) {
++        int real_offset = fs.offset() + instanceMirrorKlass::offset_of_static_fields();
++        fs.set_offset(real_offset);
++      }
++    }
+   }
+   create_mirror(k, CHECK);
+ }
+@@ -474,7 +513,7 @@
+     // Allocate mirror (java.lang.Class instance)
+     Handle mirror = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK_0);
+     // Setup indirections
+-    mirror->obj_field_put(klass_offset,  k());
++    mirror->obj_field_put(_klass_offset,  k());
+     k->set_java_mirror(mirror());
+ 
+     instanceMirrorKlass* mk = instanceMirrorKlass::cast(mirror->klass());
+@@ -516,25 +555,22 @@
+ 
+ 
+ int  java_lang_Class::oop_size(oop java_class) {
+-  assert(oop_size_offset != 0, "must be set");
+-  return java_class->int_field(oop_size_offset);
++  assert(_oop_size_offset != 0, "must be set");
++  return java_class->int_field(_oop_size_offset);
+ }
+ void java_lang_Class::set_oop_size(oop java_class, int size) {
+-  assert(oop_size_offset != 0, "must be set");
+-  java_class->int_field_put(oop_size_offset, size);
++  assert(_oop_size_offset != 0, "must be set");
++  java_class->int_field_put(_oop_size_offset, size);
+ }
+ int  java_lang_Class::static_oop_field_count(oop java_class) {
+-  assert(static_oop_field_count_offset != 0, "must be set");
+-  return java_class->int_field(static_oop_field_count_offset);
++  assert(_static_oop_field_count_offset != 0, "must be set");
++  return java_class->int_field(_static_oop_field_count_offset);
+ }
+ void java_lang_Class::set_static_oop_field_count(oop java_class, int size) {
+-  assert(static_oop_field_count_offset != 0, "must be set");
+-  java_class->int_field_put(static_oop_field_count_offset, size);
++  assert(_static_oop_field_count_offset != 0, "must be set");
++  java_class->int_field_put(_static_oop_field_count_offset, size);
+ }
+ 
+-
+-
+-
+ oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
+   // This should be improved by adding a field at the Java level or by
+   // introducing a new VM klass (see comment in ClassFileParser)
+@@ -554,7 +590,7 @@
+ klassOop java_lang_Class::as_klassOop(oop java_class) {
+   //%note memory_2
+   assert(java_lang_Class::is_instance(java_class), "must be a Class object");
+-  klassOop k = klassOop(java_class->obj_field(klass_offset));
++  klassOop k = klassOop(java_class->obj_field(_klass_offset));
+   assert(k == NULL || k->is_klass(), "type check");
+   return k;
+ }
+@@ -610,7 +646,7 @@
+ 
+ 
+ klassOop java_lang_Class::array_klass(oop java_class) {
+-  klassOop k = klassOop(java_class->obj_field(array_klass_offset));
++  klassOop k = klassOop(java_class->obj_field(_array_klass_offset));
+   assert(k == NULL || k->is_klass() && Klass::cast(k)->oop_is_javaArray(), "should be array klass");
+   return k;
+ }
+@@ -618,12 +654,12 @@
+ 
+ void java_lang_Class::set_array_klass(oop java_class, klassOop klass) {
+   assert(klass->is_klass() && Klass::cast(klass)->oop_is_javaArray(), "should be array klass");
+-  java_class->obj_field_put(array_klass_offset, klass);
++  java_class->obj_field_put(_array_klass_offset, klass);
+ }
+ 
+ 
+ methodOop java_lang_Class::resolved_constructor(oop java_class) {
+-  oop constructor = java_class->obj_field(resolved_constructor_offset);
++  oop constructor = java_class->obj_field(_resolved_constructor_offset);
+   assert(constructor == NULL || constructor->is_method(), "should be method");
+   return methodOop(constructor);
+ }
+@@ -631,21 +667,21 @@
+ 
+ void java_lang_Class::set_resolved_constructor(oop java_class, methodOop constructor) {
+   assert(constructor->is_method(), "should be method");
+-  java_class->obj_field_put(resolved_constructor_offset, constructor);
++  java_class->obj_field_put(_resolved_constructor_offset, constructor);
+ }
+ 
+ 
+ bool java_lang_Class::is_primitive(oop java_class) {
+   // should assert:
+   //assert(java_lang_Class::is_instance(java_class), "must be a Class object");
+-  klassOop k = klassOop(java_class->obj_field(klass_offset));
++  klassOop k = klassOop(java_class->obj_field(_klass_offset));
+   return k == NULL;
+ }
+ 
+ 
+ BasicType java_lang_Class::primitive_type(oop java_class) {
+   assert(java_lang_Class::is_primitive(java_class), "just checking");
+-  klassOop ak = klassOop(java_class->obj_field(array_klass_offset));
++  klassOop ak = klassOop(java_class->obj_field(_array_klass_offset));
+   BasicType type = T_VOID;
+   if (ak != NULL) {
+     // Note: create_basic_type_mirror above initializes ak to a non-null value.
+@@ -680,34 +716,18 @@
+ 
+ bool java_lang_Class::offsets_computed = false;
+ int  java_lang_Class::classRedefinedCount_offset = -1;
+-int  java_lang_Class::parallelCapable_offset = -1;
+ 
+ void java_lang_Class::compute_offsets() {
+   assert(!offsets_computed, "offsets should be initialized only once");
+   offsets_computed = true;
+ 
+-  klassOop k = SystemDictionary::Class_klass();
++  klassOop klass_oop = SystemDictionary::Class_klass();
+   // The classRedefinedCount field is only present starting in 1.5,
+   // so don't go fatal.
+   compute_optional_offset(classRedefinedCount_offset,
+-    k, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature());
+-
+-  // The field indicating parallelCapable (parallelLockMap) is only present starting in 7,
+-  klassOop k1 = SystemDictionary::ClassLoader_klass();
+-  compute_optional_offset(parallelCapable_offset,
+-    k1, vmSymbols::parallelCapable_name(), vmSymbols::concurrenthashmap_signature());
+-}
+-
+-// For class loader classes, parallelCapable defined
+-// based on non-null field
+-// Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it
+-bool java_lang_Class::parallelCapable(oop class_loader) {
+-  if (!JDK_Version::is_gte_jdk17x_version()
+-     || parallelCapable_offset == -1) {
+-     // Default for backward compatibility is false
+-     return false;
+-  }
+-  return (class_loader->obj_field(parallelCapable_offset) != NULL);
++                          klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature());
++
++  CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
+ }
+ 
+ int java_lang_Class::classRedefinedCount(oop the_class_mirror) {
+@@ -2605,6 +2625,7 @@
+     compute_optional_offset(_erasedType_offset, k, vmSymbols::erasedType_name(), vmSymbols::java_dyn_MethodType_signature(), true);
+     compute_optional_offset(_genericInvoker_offset, k, vmSymbols::genericInvoker_name(), vmSymbols::java_dyn_MethodHandle_signature(), true);
+     if (_genericInvoker_offset == 0)  _genericInvoker_offset = -1;  // set to explicit "empty" value
++    METHODTYPEFORM_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
+   }
+ }
+ 
+@@ -2722,6 +2743,18 @@
+ 
+ 
+ // Support for java_lang_ClassLoader
++bool java_lang_ClassLoader::offsets_computed = false;
++int  java_lang_ClassLoader::parallelCapable_offset = -1;
++
++void java_lang_ClassLoader::compute_offsets() {
++  assert(!offsets_computed, "offsets should be initialized only once");
++  offsets_computed = true;
++
++  // The field indicating parallelCapable (parallelLockMap) is only present starting in 7,
++  klassOop k1 = SystemDictionary::ClassLoader_klass();
++  compute_optional_offset(parallelCapable_offset,
++    k1, vmSymbols::parallelCapable_name(), vmSymbols::concurrenthashmap_signature());
++}
+ 
+ oop java_lang_ClassLoader::parent(oop loader) {
+   assert(loader->is_oop(), "loader must be oop");
+@@ -2729,6 +2762,18 @@
+ }
+ 
+ 
++// For class loader classes, parallelCapable defined
++// based on non-null field
++// Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it
++bool java_lang_ClassLoader::parallelCapable(oop class_loader) {
++  if (!JDK_Version::is_gte_jdk17x_version()
++     || parallelCapable_offset == -1) {
++     // Default for backward compatibility is false
++     return false;
++  }
++  return (class_loader->obj_field(parallelCapable_offset) != NULL);
++}
++
+ bool java_lang_ClassLoader::is_trusted_loader(oop loader) {
+   // Fix for 4474172; see evaluation for more details
+   loader = non_reflection_class_loader(loader);
+@@ -2787,12 +2832,11 @@
+ int java_lang_String::offset_offset;
+ int java_lang_String::count_offset;
+ int java_lang_String::hash_offset;
+-int java_lang_Class::klass_offset;
+-int java_lang_Class::array_klass_offset;
+-int java_lang_Class::resolved_constructor_offset;
+-int java_lang_Class::number_of_fake_oop_fields;
+-int java_lang_Class::oop_size_offset;
+-int java_lang_Class::static_oop_field_count_offset;
++int java_lang_Class::_klass_offset;
++int java_lang_Class::_array_klass_offset;
++int java_lang_Class::_resolved_constructor_offset;
++int java_lang_Class::_oop_size_offset;
++int java_lang_Class::_static_oop_field_count_offset;
+ int java_lang_Throwable::backtrace_offset;
+ int java_lang_Throwable::detailMessage_offset;
+ int java_lang_Throwable::cause_offset;
+@@ -2905,20 +2949,20 @@
+ 
+ 
+ void java_nio_Buffer::compute_offsets() {
+-  klassOop k = SystemDictionary::java_nio_Buffer_klass();
++  klassOop k = SystemDictionary::nio_Buffer_klass();
+   assert(k != NULL, "must be loaded in 1.4+");
+   compute_offset(_limit_offset, k, vmSymbols::limit_name(), vmSymbols::int_signature());
+ }
+ 
+ // Support for intrinsification of sun.misc.AtomicLongCSImpl.attemptUpdate
+ int sun_misc_AtomicLongCSImpl::value_offset() {
+-  assert(SystemDictionary::sun_misc_AtomicLongCSImpl_klass() != NULL, "can't call this");
++  assert(SystemDictionary::AtomicLongCSImpl_klass() != NULL, "can't call this");
+   return _value_offset;
+ }
+ 
+ 
+ void sun_misc_AtomicLongCSImpl::compute_offsets() {
+-  klassOop k = SystemDictionary::sun_misc_AtomicLongCSImpl_klass();
++  klassOop k = SystemDictionary::AtomicLongCSImpl_klass();
+   // If this class is not present, its value field offset won't be referenced.
+   if (k != NULL) {
+     compute_offset(_value_offset, k, vmSymbols::value_name(), vmSymbols::long_signature());
+@@ -2953,23 +2997,6 @@
+   java_lang_String::count_offset  = java_lang_String::offset_offset + sizeof (jint);
+   java_lang_String::hash_offset   = java_lang_String::count_offset + sizeof (jint);
+ 
+-  {
+-    // Do the Class Class
+-    int offset = header;
+-    java_lang_Class::oop_size_offset = header;
+-    offset += BytesPerInt;
+-    java_lang_Class::static_oop_field_count_offset = offset;
+-    offset = align_size_up(offset + BytesPerInt, x);
+-    java_lang_Class::klass_offset = offset;
+-    offset += x;
+-    java_lang_Class::array_klass_offset = offset;
+-    offset += x;
+-    java_lang_Class::resolved_constructor_offset = offset;
+-  }
+-
+-  // This is NOT an offset
+-  java_lang_Class::number_of_fake_oop_fields = java_lang_Class::hc_number_of_fake_oop_fields;
+-
+   // Throwable Class
+   java_lang_Throwable::backtrace_offset  = java_lang_Throwable::hc_backtrace_offset  * x + header;
+   java_lang_Throwable::detailMessage_offset = java_lang_Throwable::hc_detailMessage_offset * x + header;
+@@ -3021,8 +3048,8 @@
+ 
+ // Compute non-hard-coded field offsets of all the classes in this file
+ void JavaClasses::compute_offsets() {
+-
+-  java_lang_Class::compute_offsets();
++  // java_lang_Class::compute_offsets was called earlier in bootstrap
++  java_lang_ClassLoader::compute_offsets();
+   java_lang_Thread::compute_offsets();
+   java_lang_ThreadGroup::compute_offsets();
+   if (EnableMethodHandles) {
+@@ -3249,6 +3276,23 @@
+ 
+ #endif // PRODUCT
+ 
++int InjectedField::compute_offset() {
++  klassOop klass_oop = klass();
++  for (AllFieldStream fs(instanceKlass::cast(klass_oop)); !fs.done(); fs.next()) {
++    if (!may_be_java && !fs.access_flags().is_internal()) {
++      // Only look at injected fields
++      continue;
++    }
++    if (fs.name() == name() && fs.signature() == signature()) {
++      return fs.offset();
++    }
++  }
++  ResourceMark rm;
++  tty->print_cr("Invalid layout of %s at %s", instanceKlass::cast(klass_oop)->external_name(), name()->as_C_string());
++  fatal("Invalid layout of preloaded class");
++  return -1;
++}
++
+ void javaClasses_init() {
+   JavaClasses::compute_offsets();
+   JavaClasses::check_offsets();
+diff --git a/src/share/vm/classfile/javaClasses.hpp b/src/share/vm/classfile/javaClasses.hpp
+--- openjdk/hotspot/src/share/vm/classfile/javaClasses.hpp
++++ openjdk/hotspot/src/share/vm/classfile/javaClasses.hpp
+@@ -156,30 +156,32 @@
+ 
+ // Interface to java.lang.Class objects
+ 
++#define CLASS_INJECTED_FIELDS(macro)                                       \
++  macro(java_lang_Class, klass,                  object_signature,  false) \
++  macro(java_lang_Class, resolved_constructor,   object_signature,  false) \
++  macro(java_lang_Class, array_klass,            object_signature,  false) \
++  macro(java_lang_Class, oop_size,               int_signature,     false) \
++  macro(java_lang_Class, static_oop_field_count, int_signature,     false)
++
+ class java_lang_Class : AllStatic {
+-   friend class VMStructs;
++  friend class VMStructs;
++
+  private:
+   // The fake offsets are added by the class loader when java.lang.Class is loaded
+ 
+-  enum {
+-    hc_number_of_fake_oop_fields   = 3,
+-    hc_number_of_fake_int_fields   = 2
+-  };
++  static int _klass_offset;
++  static int _resolved_constructor_offset;
++  static int _array_klass_offset;
+ 
+-  static int klass_offset;
+-  static int resolved_constructor_offset;
+-  static int array_klass_offset;
+-  static int number_of_fake_oop_fields;
++  static int _oop_size_offset;
++  static int _static_oop_field_count_offset;
+ 
+-  static int oop_size_offset;
+-  static int static_oop_field_count_offset;
+-
+-  static void compute_offsets();
+   static bool offsets_computed;
+   static int classRedefinedCount_offset;
+-  static int parallelCapable_offset;
+ 
+  public:
++  static void compute_offsets();
++
+   // Instance creation
+   static oop  create_mirror(KlassHandle k, TRAPS);
+   static void fixup_mirror(KlassHandle k, TRAPS);
+@@ -209,14 +211,12 @@
+   static klassOop array_klass(oop java_class);
+   static void set_array_klass(oop java_class, klassOop klass);
+   // compiler support for class operations
+-  static int klass_offset_in_bytes() { return klass_offset; }
+-  static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; }
+-  static int array_klass_offset_in_bytes() { return array_klass_offset; }
++  static int klass_offset_in_bytes()                { return _klass_offset; }
++  static int resolved_constructor_offset_in_bytes() { return _resolved_constructor_offset; }
++  static int array_klass_offset_in_bytes()          { return _array_klass_offset; }
+   // Support for classRedefinedCount field
+   static int classRedefinedCount(oop the_class_mirror);
+   static void set_classRedefinedCount(oop the_class_mirror, int value);
+-  // Support for parallelCapable field
+-  static bool parallelCapable(oop the_class_mirror);
+ 
+   static int oop_size(oop java_class);
+   static void set_oop_size(oop java_class, int size);
+@@ -828,16 +828,19 @@
+ 
+ // Interface to java.dyn.MethodHandle objects
+ 
++#define METHODHANDLE_INJECTED_FIELDS(macro)                               \
++  macro(java_dyn_MethodHandle, vmentry,  intptr_signature, false) \
++  macro(java_dyn_MethodHandle, vmtarget, object_signature, true)
++
+ class MethodHandleEntry;
+ 
+ class java_dyn_MethodHandle: AllStatic {
+   friend class JavaClasses;
+ 
+  private:
+-  static int _vmentry_offset;           // assembly code trampoline for MH
+-  static int _vmtarget_offset;          // class-specific target reference
++  static int _vmentry_offset;            // assembly code trampoline for MH
++  static int _vmtarget_offset;           // class-specific target reference
+   static int _type_offset;              // the MethodType of this MH
+-  static int _vmslots_offset;           // OPTIONAL hoisted type.form.vmslots
+ 
+   static void compute_offsets();
+ 
+@@ -853,8 +856,6 @@
+   static void       set_vmentry(oop mh, MethodHandleEntry* data);
+ 
+   static int            vmslots(oop mh);
+-  static void      init_vmslots(oop mh);
+-  static int    compute_vmslots(oop mh);
+ 
+   // Testers
+   static bool is_subclass(klassOop klass) {
+@@ -868,14 +869,15 @@
+   static int type_offset_in_bytes()             { return _type_offset; }
+   static int vmtarget_offset_in_bytes()         { return _vmtarget_offset; }
+   static int vmentry_offset_in_bytes()          { return _vmentry_offset; }
+-  static int vmslots_offset_in_bytes()          { return _vmslots_offset; }
+ };
+ 
++#define DIRECTMETHODHANDLE_INJECTED_FIELDS(macro)                          \
++  macro(java_dyn_DirectMethodHandle, vmindex, int_signature, true)
++
+ class sun_dyn_DirectMethodHandle: public java_dyn_MethodHandle {
+   friend class JavaClasses;
+ 
+  private:
+-  //         _vmtarget_offset;          // method   or class      or interface
+   static int _vmindex_offset;           // negative or vtable idx or itable idx
+   static void compute_offsets();
+ 
+@@ -977,6 +979,9 @@
+ // Interface to sun.dyn.MemberName objects
+ // (These are a private interface for Java code to query the class hierarchy.)
+ 
++#define MEMBERNAME_INJECTED_FIELDS(macro)                              \
++  macro(sun_dyn_MemberName, vmtarget, object_signature, true)
++
+ class sun_dyn_MemberName: AllStatic {
+   friend class JavaClasses;
+ 
+@@ -1084,6 +1089,10 @@
+   static int form_offset_in_bytes()             { return _form_offset; }
+ };
+ 
++#define METHODTYPEFORM_INJECTED_FIELDS(macro)                              \
++  macro(java_dyn_MethodTypeForm, vmslots,  int_signature,    true) \
++  macro(java_dyn_MethodTypeForm, vmlayout, object_signature, true)
++
+ class java_dyn_MethodTypeForm: AllStatic {
+   friend class JavaClasses;
+ 
+@@ -1097,6 +1106,8 @@
+  public:
+   // Accessors
+   static int            vmslots(oop mtform);
++  static void       set_vmslots(oop mtform, int vmslots);
++
+   static oop            erasedType(oop mtform);
+   static oop            genericInvoker(oop mtform);
+ 
+@@ -1114,8 +1125,6 @@
+ 
+ private:
+   static int _target_offset;
+-  static int _caller_method_offset;
+-  static int _caller_bci_offset;
+ 
+   static void compute_offsets();
+ 
+@@ -1124,12 +1133,6 @@
+   static oop            target(oop site);
+   static void       set_target(oop site, oop target);
+ 
+-  static oop            caller_method(oop site);
+-  static void       set_caller_method(oop site, oop ref);
+-
+-  static jint           caller_bci(oop site);
+-  static void       set_caller_bci(oop site, jint bci);
+-
+   // Testers
+   static bool is_subclass(klassOop klass) {
+     return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass());
+@@ -1140,8 +1143,6 @@
+ 
+   // Accessors for code generation:
+   static int target_offset_in_bytes()           { return _target_offset; }
+-  static int caller_method_offset_in_bytes()    { return _caller_method_offset; }
+-  static int caller_bci_offset_in_bytes()       { return _caller_bci_offset; }
+ };
+ 
+ 
+@@ -1175,11 +1176,18 @@
+    hc_parent_offset = 0
+   };
+ 
++  static bool offsets_computed;
+   static int parent_offset;
++  static int parallelCapable_offset;
++
++  static void compute_offsets();
+ 
+  public:
+   static oop parent(oop loader);
+ 
++  // Support for parallelCapable field
++  static bool parallelCapable(oop the_class_mirror);
++
+   static bool is_trusted_loader(oop loader);
+ 
+   // Fix for 4474172
+@@ -1308,17 +1316,71 @@
+   static oop  get_owner_threadObj(oop obj);
+ };
+ 
++// Use to declare fields that need to be injected into Java classes
++// for the JVM to use.  The name_index and signature_index are
++// declared in vmSymbols.  The may_be_java flag is used to declare
++// fields that might already exist in Java but should be injected if
++// they don't.  Otherwise the field is unconditionally injected and
++// the JVM uses the injected one.  This is to ensure that name
++// collisions don't occur.  In general may_be_java should be false
++// unless there's a good reason.
++
++class InjectedField {
++ public:
++  const SystemDictionary::WKID klass_id;
++  const vmSymbols::SID name_index;
++  const vmSymbols::SID signature_index;
++  const bool           may_be_java;
++
++
++  klassOop klass() const    { return SystemDictionary::well_known_klass(klass_id); }
++  Symbol* name() const      { return lookup_symbol(name_index); }
++  Symbol* signature() const { return lookup_symbol(signature_index); }
++
++  int compute_offset();
++
++  // Find the Symbol for this index
++  static Symbol* lookup_symbol(int symbol_index) {
++    return vmSymbols::symbol_at((vmSymbols::SID)symbol_index);
++  }
++};
++
++#define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \
++  klass##_##name##_enum,
++
++#define ALL_INJECTED_FIELDS(macro)          \
++  CLASS_INJECTED_FIELDS(macro)              \
++  METHODHANDLE_INJECTED_FIELDS(macro)       \
++  DIRECTMETHODHANDLE_INJECTED_FIELDS(macro) \
++  MEMBERNAME_INJECTED_FIELDS(macro)         \
++  METHODTYPEFORM_INJECTED_FIELDS(macro)
++
+ // Interface to hard-coded offset checking
+ 
+ class JavaClasses : AllStatic {
+  private:
++
++  static InjectedField _injected_fields[];
++
+   static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
+   static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
+   static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
++
+  public:
++  enum InjectedFieldID {
++    ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM)
++    MAX_enum
++  };
++
++  static int compute_injected_offset(InjectedFieldID id);
++
+   static void compute_hard_coded_offsets();
+   static void compute_offsets();
+   static void check_offsets() PRODUCT_RETURN;
++
++  static InjectedField* get_injected(Symbol* class_name, int* field_count);
+ };
+ 
++#undef DECLARE_INJECTED_FIELD_ENUM
++
+ #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP
+diff --git a/src/share/vm/classfile/systemDictionary.cpp b/src/share/vm/classfile/systemDictionary.cpp
+--- openjdk/hotspot/src/share/vm/classfile/systemDictionary.cpp
++++ openjdk/hotspot/src/share/vm/classfile/systemDictionary.cpp
+@@ -125,13 +125,13 @@
+ bool SystemDictionary::is_parallelCapable(Handle class_loader) {
+   if (UnsyncloadClass || class_loader.is_null()) return true;
+   if (AlwaysLockClassLoader) return false;
+-  return java_lang_Class::parallelCapable(class_loader());
++  return java_lang_ClassLoader::parallelCapable(class_loader());
+ }
+ // ----------------------------------------------------------------------------
+ // ParallelDefineClass flag does not apply to bootclass loader
+ bool SystemDictionary::is_parallelDefine(Handle class_loader) {
+    if (class_loader.is_null()) return false;
+-   if (AllowParallelDefineClass && java_lang_Class::parallelCapable(class_loader())) {
++   if (AllowParallelDefineClass && java_lang_ClassLoader::parallelCapable(class_loader())) {
+      return true;
+    }
+    return false;
+@@ -1280,7 +1280,7 @@
+                                                     Symbol* class_name,
+                                                     TRAPS) {
+ 
+-  klassOop dlm = SystemDictionary::sun_jkernel_DownloadManager_klass();
++  klassOop dlm = SystemDictionary::DownloadManager_klass();
+   instanceKlassHandle nk;
+ 
+   // If download manager class isn't loaded just return.
+@@ -1941,7 +1941,7 @@
+   // first do Object, String, Class
+   initialize_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);
+ 
+-  debug_only(instanceKlass::verify_class_klass_nonstatic_oop_maps(WK_KLASS(Class_klass)));
++  java_lang_Class::compute_offsets();
+ 
+   // Fixup mirrors for classes loaded before java.lang.Class.
+   // These calls iterate over the objects currently in the perm gen
+@@ -1999,7 +1999,7 @@
+   //_box_klasses[T_ARRAY]   = WK_KLASS(object_klass);
+ 
+ #ifdef KERNEL
+-  if (sun_jkernel_DownloadManager_klass() == NULL) {
++  if (DownloadManager_klass() == NULL) {
+     warning("Cannot find sun/jkernel/DownloadManager");
+   }
+ #endif // KERNEL
+@@ -2740,7 +2740,7 @@
+       class_size += ik->local_interfaces()->size();
+       class_size += ik->transitive_interfaces()->size();
+       // We do not have to count implementors, since we only store one!
+-      class_size += ik->fields()->size();
++      class_size += ik->all_fields_count() * FieldInfo::field_slots;
+     }
+   }
+ 
+diff --git a/src/share/vm/classfile/systemDictionary.hpp b/src/share/vm/classfile/systemDictionary.hpp
+--- openjdk/hotspot/src/share/vm/classfile/systemDictionary.hpp
++++ openjdk/hotspot/src/share/vm/classfile/systemDictionary.hpp
+@@ -133,15 +133,15 @@
+   template(reflect_Method_klass,         java_lang_reflect_Method,       Pre) \
+   template(reflect_Constructor_klass,    java_lang_reflect_Constructor,  Pre) \
+                                                                               \
+-  /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */ \
+-  /* Universe::is_gte_jdk14x_version() is not set up by this point. */        \
+-  /* It's okay if this turns out to be NULL in non-1.4 JDKs. */               \
+-  template(reflect_MagicAccessorImpl_klass,          sun_reflect_MagicAccessorImpl,  Opt) \
+-  template(reflect_MethodAccessorImpl_klass, sun_reflect_MethodAccessorImpl, Opt_Only_JDK14NewRef) \
+-  template(reflect_ConstructorAccessorImpl_klass, sun_reflect_ConstructorAccessorImpl, Opt_Only_JDK14NewRef) \
+-  template(reflect_DelegatingClassLoader_klass, sun_reflect_DelegatingClassLoader, Opt) \
+-  template(reflect_ConstantPool_klass,  sun_reflect_ConstantPool,       Opt_Only_JDK15) \
+-  template(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15) \
++  /* NOTE: needed too early in bootstrapping process to have checks based on JDK version */                              \
++  /* Universe::is_gte_jdk14x_version() is not set up by this point. */                                                   \
++  /* It's okay if this turns out to be NULL in non-1.4 JDKs. */                                                          \
++  template(reflect_MagicAccessorImpl_klass,             sun_reflect_MagicAccessorImpl,             Opt)                  \
++  template(reflect_MethodAccessorImpl_klass,            sun_reflect_MethodAccessorImpl,            Opt_Only_JDK14NewRef) \
++  template(reflect_ConstructorAccessorImpl_klass,       sun_reflect_ConstructorAccessorImpl,       Opt_Only_JDK14NewRef) \
++  template(reflect_DelegatingClassLoader_klass,         sun_reflect_DelegatingClassLoader,         Opt)                  \
++  template(reflect_ConstantPool_klass,                  sun_reflect_ConstantPool,                  Opt_Only_JDK15)       \
++  template(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15)       \
+                                                                               \
+   /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
+   template(MethodHandle_klass,           java_dyn_MethodHandle,          Opt) \
+@@ -165,14 +165,14 @@
+   template(StackTraceElement_klass,      java_lang_StackTraceElement,    Opt) \
+   /* Universe::is_gte_jdk14x_version() is not set up by this point. */        \
+   /* It's okay if this turns out to be NULL in non-1.4 JDKs. */               \
+-  template(java_nio_Buffer_klass,        java_nio_Buffer,                Opt) \
++  template(nio_Buffer_klass,             java_nio_Buffer,                Opt) \
+                                                                               \
+   /* If this class isn't present, it won't be referenced. */                  \
+-  template(sun_misc_AtomicLongCSImpl_klass, sun_misc_AtomicLongCSImpl,   Opt) \
++  template(AtomicLongCSImpl_klass,       sun_misc_AtomicLongCSImpl,   Opt)    \
+                                                                               \
+-  template(sun_jkernel_DownloadManager_klass, sun_jkernel_DownloadManager, Opt_Kernel) \
++  template(DownloadManager_klass,        sun_jkernel_DownloadManager, Opt_Kernel) \
+                                                                               \
+-  template(sun_misc_PostVMInitHook_klass, sun_misc_PostVMInitHook, Opt)       \
++  template(PostVMInitHook_klass,         sun_misc_PostVMInitHook, Opt)        \
+                                                                               \
+   /* Preload boxing klasses */                                                \
+   template(Boolean_klass,                java_lang_Boolean,              Pre) \
+@@ -196,7 +196,7 @@
+   enum WKID {
+     NO_WKID = 0,
+ 
+-    #define WK_KLASS_ENUM(name, ignore_s, ignore_o) WK_KLASS_ENUM_NAME(name),
++    #define WK_KLASS_ENUM(name, symbol, ignore_o) WK_KLASS_ENUM_NAME(name), WK_KLASS_ENUM_NAME(symbol) = WK_KLASS_ENUM_NAME(name),
+     WK_KLASSES_DO(WK_KLASS_ENUM)
+     #undef WK_KLASS_ENUM
+ 
+@@ -421,11 +421,16 @@
+   }
+ 
+ public:
+-  #define WK_KLASS_DECLARE(name, ignore_symbol, option) \
++  #define WK_KLASS_DECLARE(name, symbol, option) \
+     static klassOop name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); }
+   WK_KLASSES_DO(WK_KLASS_DECLARE);
+   #undef WK_KLASS_DECLARE
+ 
++  static klassOop well_known_klass(WKID id) {
++    assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
++    return _well_known_klasses[id];
++  }
++
+   // Local definition for direct access to the private array:
+   #define WK_KLASS(name) _well_known_klasses[SystemDictionary::WK_KLASS_ENUM_NAME(name)]
+ 
+diff --git a/src/share/vm/classfile/vmSymbols.hpp b/src/share/vm/classfile/vmSymbols.hpp
+--- openjdk/hotspot/src/share/vm/classfile/vmSymbols.hpp
++++ openjdk/hotspot/src/share/vm/classfile/vmSymbols.hpp
+@@ -258,8 +258,8 @@
+   template(linkMethodHandleConstant_signature, "(Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/String;Ljava/lang/Object;)Ljava/dyn/MethodHandle;") \
+   template(makeDynamicCallSite_name,                  "makeDynamicCallSite")                      \
+   template(makeDynamicCallSite_signature, "(Ljava/dyn/MethodHandle;Ljava/lang/String;Ljava/dyn/MethodType;Ljava/lang/Object;Lsun/dyn/MemberName;I)Ljava/dyn/CallSite;") \
+-  NOT_LP64(  do_alias(machine_word_signature,         int_signature)  )                           \
+-  LP64_ONLY( do_alias(machine_word_signature,         long_signature) )                           \
++  NOT_LP64(  do_alias(intptr_signature,               int_signature)  )                           \
++  LP64_ONLY( do_alias(intptr_signature,               long_signature) )                           \
+                                                                                                   \
+   /* common method and field names */                                                             \
+   template(object_initializer_name,                   "<init>")                                   \
+@@ -356,6 +356,11 @@
+   template(erasedType_name,                           "erasedType")                               \
+   template(genericInvoker_name,                       "genericInvoker")                           \
+   template(append_name,                               "append")                                   \
++  template(klass_name,                                "klass")                                    \
++  template(resolved_constructor_name,                 "resolved_constructor")                     \
++  template(array_klass_name,                          "array_klass")                              \
++  template(oop_size_name,                             "oop_size")                                 \
++  template(static_oop_field_count_name,               "static_oop_field_count")                   \
+                                                                                                   \
+   /* non-intrinsic name/signature pairs: */                                                       \
+   template(register_method_name,                      "register")                                 \
+diff --git a/src/share/vm/interpreter/interpreterRuntime.cpp b/src/share/vm/interpreter/interpreterRuntime.cpp
+--- openjdk/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
++++ openjdk/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
+@@ -976,11 +976,8 @@
+   // check the access_flags for the field in the klass
+ 
+   instanceKlass* ik = instanceKlass::cast(java_lang_Class::as_klassOop(cp_entry->f1()));
+-  typeArrayOop fields = ik->fields();
+   int index = cp_entry->field_index();
+-  assert(index < fields->length(), "holders field index is out of range");
+-  // bail out if field accesses are not watched
+-  if ((fields->ushort_at(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return;
++  if ((ik->field_access_flags(index) & JVM_ACC_FIELD_ACCESS_WATCHED) == 0) return;
+ 
+   switch(cp_entry->flag_state()) {
+     case btos:    // fall through
+@@ -1013,11 +1010,9 @@
+ 
+   // check the access_flags for the field in the klass
+   instanceKlass* ik = instanceKlass::cast(k);
+-  typeArrayOop fields = ik->fields();
+   int index = cp_entry->field_index();
+-  assert(index < fields->length(), "holders field index is out of range");
+   // bail out if field modifications are not watched
+-  if ((fields->ushort_at(index) & JVM_ACC_FIELD_MODIFICATION_WATCHED) == 0) return;
++  if ((ik->field_access_flags(index) & JVM_ACC_FIELD_MODIFICATION_WATCHED) == 0) return;
+ 
+   char sig_type = '\0';
+ 
+diff --git a/src/share/vm/oops/cpCacheOop.cpp b/src/share/vm/oops/cpCacheOop.cpp
+--- openjdk/hotspot/src/share/vm/oops/cpCacheOop.cpp
++++ openjdk/hotspot/src/share/vm/oops/cpCacheOop.cpp
+@@ -128,17 +128,13 @@
+ void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code,
+                                        Bytecodes::Code put_code,
+                                        KlassHandle field_holder,
+-                                       int orig_field_index,
++                                       int field_index,
+                                        int field_offset,
+                                        TosState field_type,
+                                        bool is_final,
+                                        bool is_volatile) {
+   set_f1(field_holder()->java_mirror());
+   set_f2(field_offset);
+-  // The field index is used by jvm/ti and is the index into fields() array
+-  // in holder instanceKlass.  This is scaled by instanceKlass::next_offset.
+-  assert((orig_field_index % instanceKlass::next_offset) == 0, "wierd index");
+-  const int field_index = orig_field_index / instanceKlass::next_offset;
+   assert(field_index <= field_index_mask,
+          "field index does not fit in low flag bits");
+   set_flags(as_flags(field_type, is_final, false, is_volatile, false, false) |
+@@ -149,7 +145,7 @@
+ }
+ 
+ int  ConstantPoolCacheEntry::field_index() const {
+-  return (_flags & field_index_mask) * instanceKlass::next_offset;
++  return (_flags & field_index_mask);
+ }
+ 
+ void ConstantPoolCacheEntry::set_method(Bytecodes::Code invoke_code,
+diff --git a/src/share/vm/oops/fieldInfo.hpp b/src/share/vm/oops/fieldInfo.hpp
+new file mode 100644
+--- /dev/null
++++ openjdk/hotspot/src/share/vm/oops/fieldInfo.hpp
+@@ -0,0 +1,132 @@
++/*
++ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ *
++ */
++
++#ifndef SHARE_VM_OOPS_FIELDINFO_HPP
++#define SHARE_VM_OOPS_FIELDINFO_HPP
++
++#include "oops/typeArrayOop.hpp"
++#include "classfile/vmSymbols.hpp"
++
++// This class represents the field information contained in the fields
++// array of an instanceKlass.  Currently it's laid on top an array of
++// Java shorts but in the future it could simply be used as a real
++// array type.  FieldInfo generally shouldn't be used directly.
++// Fields should be queried either through instanceKlass or through
++// the various FieldStreams.
++class FieldInfo VALUE_OBJ_CLASS_SPEC {
++  friend class fieldDescriptor;
++  friend class JavaFieldStream;
++  friend class ClassFileParser;
++
++ public:
++  // fields
++  // Field info extracted from the class file and stored
++  // as an array of 7 shorts
++  enum FieldOffset {
++    access_flags_offset      = 0,
++    name_index_offset        = 1,
++    signature_index_offset   = 2,
++    initval_index_offset     = 3,
++    low_offset               = 4,
++    high_offset              = 5,
++    generic_signature_offset = 6,
++    field_slots              = 7
++  };
++
++ private:
++  u2 _shorts[field_slots];
++
++  void set_name_index(u2 val)                    { _shorts[name_index_offset] = val;         }
++  void set_signature_index(u2 val)               { _shorts[signature_index_offset] = val;    }
++  void set_initval_index(u2 val)                 { _shorts[initval_index_offset] = val;      }
++  void set_generic_signature_index(u2 val)       { _shorts[generic_signature_offset] = val;  }
++
++  u2 name_index() const                          { return _shorts[name_index_offset];        }
++  u2 signature_index() const                     { return _shorts[signature_index_offset];   }
++  u2 initval_index() const                       { return _shorts[initval_index_offset];     }
++  u2 generic_signature_index() const             { return _shorts[generic_signature_offset]; }
++
++ public:
++  static FieldInfo* from_field_array(typeArrayOop fields, int index) {
++    return ((FieldInfo*)fields->short_at_addr(index * field_slots));
++  }
++
++  void initialize(u2 access_flags,
++                  u2 name_index,
++                  u2 signature_index,
++                  u2 initval_index,
++                  u2 generic_signature_index,
++                  u4 offset) {
++    _shorts[access_flags_offset] = access_flags;
++    _shorts[name_index_offset] = name_index;
++    _shorts[signature_index_offset] = signature_index;
++    _shorts[initval_index_offset] = initval_index;
++    _shorts[generic_signature_offset] = generic_signature_index;
++    set_offset(offset);
++  }
++
++  u2 access_flags() const                        { return _shorts[access_flags_offset];            }
++  u4 offset() const                              { return build_int_from_shorts(_shorts[low_offset], _shorts[high_offset]); }
++
++  Symbol* name(constantPoolHandle cp) const {
++    int index = name_index();
++    if (is_internal()) {
++      return lookup_symbol(index);
++    }
++    return cp->symbol_at(index);
++  }
++
++  Symbol* signature(constantPoolHandle cp) const {
++    int index = signature_index();
++    if (is_internal()) {
++      return lookup_symbol(index);
++    }
++    return cp->symbol_at(index);
++  }
++
++  Symbol* generic_signature(constantPoolHandle cp) const {
++    int index = generic_signature_index();
++    if (index == 0) {
++      return NULL;
++    }
++    return cp->symbol_at(index);
++  }
++
++  void set_access_flags(u2 val)                  { _shorts[access_flags_offset] = val;             }
++  void set_offset(u4 val)                        {
++    _shorts[low_offset] = extract_low_short_from_int(val);
++    _shorts[high_offset] = extract_high_short_from_int(val);
++  }
++
++  bool is_internal() const {
++    return (access_flags() & JVM_ACC_FIELD_INTERNAL) != 0;
++  }
++
++  Symbol* lookup_symbol(int symbol_index) const {
++    assert(is_internal(), "only internal fields");
++    return vmSymbols::symbol_at((vmSymbols::SID)symbol_index);
++  }
++};
++
++#endif // SHARE_VM_OOPS_FIELDINFO_HPP
+diff --git a/src/share/vm/oops/fieldStreams.hpp b/src/share/vm/oops/fieldStreams.hpp
+new file mode 100644
+--- /dev/null
++++ openjdk/hotspot/src/share/vm/oops/fieldStreams.hpp
+@@ -0,0 +1,174 @@
++/*
++ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ *
++ */
++
++#ifndef SHARE_VM_OOPS_FIELDSTREAMS_HPP
++#define SHARE_VM_OOPS_FIELDSTREAMS_HPP
++
++#include "oops/instanceKlass.hpp"
++#include "oops/fieldInfo.hpp"
++
++// The is the base class for iteration over the fields array
++// describing the declared fields in the class.  Several subclasses
++// are provided depending on the kind of iteration required.  The
++// JavaFieldStream is for iterating over regular Java fields and it
++// generally the preferred iterator.  InternalFieldStream only
++// iterates over fields that have been injected by the JVM.
++// AllFieldStream exposes all fields and should only be used in rare
++// cases.
++class FieldStreamBase : public StackObj {
++ protected:
++  typeArrayHandle     _fields;
++  constantPoolHandle  _constants;
++  int                 _index;
++  int                 _limit;
++
++  FieldInfo* field() const { return FieldInfo::from_field_array(_fields(), _index); }
++
++  FieldStreamBase(typeArrayHandle fields, constantPoolHandle constants, int start, int limit) {
++    _fields = fields;
++    _constants = constants;
++    _index = start;
++    _limit = limit;
++  }
++
++  FieldStreamBase(typeArrayHandle fields, constantPoolHandle constants) {
++    _fields = fields;
++    _constants = constants;
++    _index = 0;
++    _limit = fields->length() / FieldInfo::field_slots;
++  }
++
++ public:
++  FieldStreamBase(instanceKlass* klass) {
++    _fields = klass->fields();
++    _constants = klass->constants();
++    _index = 0;
++    _limit = klass->java_fields_count();
++  }
++  FieldStreamBase(instanceKlassHandle klass) {
++    _fields = klass->fields();
++    _constants = klass->constants();
++    _index = 0;
++    _limit = klass->java_fields_count();
++  }
++
++  // accessors
++  int index() const                 { return _index; }
++
++  void next() { _index += 1; }
++  bool done() const { return _index >= _limit; }
++
++  // Accessors for current field
++  AccessFlags access_flags() const {
++    AccessFlags flags;
++    flags.set_flags(field()->access_flags());
++    return flags;
++  }
++
++  void set_access_flags(u2 flags) const {
++    field()->set_access_flags(flags);
++  }
++
++  void set_access_flags(AccessFlags flags) const {
++    set_access_flags(flags.as_short());
++  }
++
++  Symbol* name() const {
++    return field()->name(_constants);
++  }
++
++  Symbol* signature() const {
++    return field()->signature(_constants);
++  }
++
++  Symbol* generic_signature() const {
++    return field()->generic_signature(_constants);
++  }
++
++  int offset() const {
++    return field()->offset();
++  }
++
++  void set_offset(int offset) {
++    field()->set_offset(offset);
++  }
++};
++
++// Iterate over only the internal fields
++class JavaFieldStream : public FieldStreamBase {
++ public:
++  JavaFieldStream(instanceKlass* k):      FieldStreamBase(k->fields(), k->constants(), 0, k->java_fields_count()) {}
++  JavaFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants(), 0, k->java_fields_count()) {}
++
++  int name_index() const {
++    assert(!field()->is_internal(), "regular only");
++    return field()->name_index();
++  }
++  void set_name_index(int index) {
++    assert(!field()->is_internal(), "regular only");
++    field()->set_name_index(index);
++  }
++  int signature_index() const {
++    assert(!field()->is_internal(), "regular only");
++    return field()->signature_index();
++  }
++  void set_signature_index(int index) {
++    assert(!field()->is_internal(), "regular only");
++    field()->set_signature_index(index);
++  }
++  int generic_signature_index() const {
++    assert(!field()->is_internal(), "regular only");
++    return field()->generic_signature_index();
++  }
++  void set_generic_signature_index(int index) {
++    assert(!field()->is_internal(), "regular only");
++    field()->set_generic_signature_index(index);
++  }
++  int initval_index() const {
++    assert(!field()->is_internal(), "regular only");
++    return field()->initval_index();
++  }
++  void set_initval_index(int index) {
++    assert(!field()->is_internal(), "regular only");
++    return field()->set_initval_index(index);
++  }
++};
++
++
++// Iterate over only the internal fields
++class InternalFieldStream : public FieldStreamBase {
++ public:
++  InternalFieldStream(instanceKlass* k):      FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), k->all_fields_count()) {}
++  InternalFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants(), k->java_fields_count(), k->all_fields_count()) {}
++};
++
++
++class AllFieldStream : public FieldStreamBase {
++ public:
++  AllFieldStream(typeArrayHandle fields, constantPoolHandle constants): FieldStreamBase(fields, constants) {}
++  AllFieldStream(instanceKlass* k):      FieldStreamBase(k->fields(), k->constants()) {}
++  AllFieldStream(instanceKlassHandle k): FieldStreamBase(k->fields(), k->constants()) {}
++};
++
++#endif // SHARE_VM_OOPS_FIELDSTREAMS_HPP
+diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlass.cpp
+@@ -36,6 +36,7 @@
+ #include "memory/genOopClosures.inline.hpp"
+ #include "memory/oopFactory.hpp"
+ #include "memory/permGen.hpp"
++#include "oops/fieldStreams.hpp"
+ #include "oops/instanceKlass.hpp"
+ #include "oops/instanceMirrorKlass.hpp"
+ #include "oops/instanceOop.hpp"
+@@ -774,14 +775,11 @@
+ 
+ 
+ bool instanceKlass::find_local_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
+-  const int n = fields()->length();
+-  for (int i = 0; i < n; i += next_offset ) {
+-    int name_index = fields()->ushort_at(i + name_index_offset);
+-    int sig_index  = fields()->ushort_at(i + signature_index_offset);
+-    Symbol* f_name = constants()->symbol_at(name_index);
+-    Symbol* f_sig  = constants()->symbol_at(sig_index);
++  for (JavaFieldStream fs(as_klassOop()); !fs.done(); fs.next()) {
++    Symbol* f_name = fs.name();
++    Symbol* f_sig  = fs.signature();
+     if (f_name == name && f_sig == sig) {
+-      fd->initialize(as_klassOop(), i);
++      fd->initialize(as_klassOop(), fs.index());
+       return true;
+     }
+   }
+@@ -795,11 +793,10 @@
+   closure->do_symbol(&_source_file_name);
+   closure->do_symbol(&_source_debug_extension);
+ 
+-  const int n = fields()->length();
+-  for (int i = 0; i < n; i += next_offset ) {
+-    int name_index = fields()->ushort_at(i + name_index_offset);
++  for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
++    int name_index = fs.name_index();
+     closure->do_symbol(constants()->symbol_at_addr(name_index));
+-    int sig_index  = fields()->ushort_at(i + signature_index_offset);
++    int sig_index  = fs.signature_index();
+     closure->do_symbol(constants()->symbol_at_addr(sig_index));
+   }
+ }
+@@ -864,10 +861,9 @@
+ 
+ 
+ bool instanceKlass::find_local_field_from_offset(int offset, bool is_static, fieldDescriptor* fd) const {
+-  int length = fields()->length();
+-  for (int i = 0; i < length; i += next_offset) {
+-    if (offset_from_fields( i ) == offset) {
+-      fd->initialize(as_klassOop(), i);
++  for (JavaFieldStream fs(as_klassOop()); !fs.done(); fs.next()) {
++    if (fs.offset() == offset) {
++      fd->initialize(as_klassOop(), fs.index());
+       if (fd->is_static() == is_static) return true;
+     }
+   }
+@@ -898,11 +894,12 @@
+ 
+ 
+ void instanceKlass::do_local_static_fields(FieldClosure* cl) {
+-  fieldDescriptor fd;
+-  int length = fields()->length();
+-  for (int i = 0; i < length; i += next_offset) {
+-    fd.initialize(as_klassOop(), i);
+-    if (fd.is_static()) cl->do_field(&fd);
++  for (JavaFieldStream fs(this); !fs.done(); fs.next()) {
++    if (fs.access_flags().is_static()) {
++      fieldDescriptor fd;
++      fd.initialize(as_klassOop(), fs.index());
++      cl->do_field(&fd);
++    }
+   }
+ }
+ 
+@@ -914,11 +911,12 @@
+ 
+ 
+ void instanceKlass::do_local_static_fields_impl(instanceKlassHandle this_oop, void f(fieldDescriptor* fd, TRAPS), TRAPS) {
+-  fieldDescriptor fd;
+-  int length = this_oop->fields()->length();
+-  for (int i = 0; i < length; i += next_offset) {
+-    fd.initialize(this_oop(), i);
+-    if (fd.is_static()) { f(&fd, CHECK); } // Do NOT remove {}! (CHECK macro expands into several statements)
++  for (JavaFieldStream fs(this_oop()); !fs.done(); fs.next()) {
++    if (fs.access_flags().is_static()) {
++      fieldDescriptor fd;
++      fd.initialize(this_oop(), fs.index());
++      f(&fd, CHECK);
++    }
+   }
+ }
+ 
+@@ -933,11 +931,11 @@
+     super->do_nonstatic_fields(cl);
+   }
+   fieldDescriptor fd;
+-  int length = fields()->length();
++  int length = java_fields_count();
+   // In DebugInfo nonstatic fields are sorted by offset.
+   int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1));
+   int j = 0;
+-  for (int i = 0; i < length; i += next_offset) {
++  for (int i = 0; i < length; i += 1) {
+     fd.initialize(as_klassOop(), i);
+     if (!fd.is_static()) {
+       fields_sorted[j + 0] = fd.offset();
+@@ -2412,43 +2410,6 @@
+   oop_oop_iterate(obj, &blk);
+ }
+ 
+-#ifndef PRODUCT
+-
+-void instanceKlass::verify_class_klass_nonstatic_oop_maps(klassOop k) {
+-  // This verification code is disabled.  JDK_Version::is_gte_jdk14x_version()
+-  // cannot be called since this function is called before the VM is
+-  // able to determine what JDK version is running with.
+-  // The check below always is false since 1.4.
+-  return;
+-
+-  // This verification code temporarily disabled for the 1.4
+-  // reflection implementation since java.lang.Class now has
+-  // Java-level instance fields. Should rewrite this to handle this
+-  // case.
+-  if (!(JDK_Version::is_gte_jdk14x_version() && UseNewReflection)) {
+-    // Verify that java.lang.Class instances have a fake oop field added.
+-    instanceKlass* ik = instanceKlass::cast(k);
+-
+-    // Check that we have the right class
+-    static bool first_time = true;
+-    guarantee(k == SystemDictionary::Class_klass() && first_time, "Invalid verify of maps");
+-    first_time = false;
+-    const int extra = java_lang_Class::number_of_fake_oop_fields;
+-    guarantee(ik->nonstatic_field_size() == extra, "just checking");
+-    guarantee(ik->nonstatic_oop_map_count() == 1, "just checking");
+-    guarantee(ik->size_helper() == align_object_size(instanceOopDesc::header_size() + extra), "just checking");
+-
+-    // Check that the map is (2,extra)
+-    int offset = java_lang_Class::klass_offset;
+-
+-    OopMapBlock* map = ik->start_of_nonstatic_oop_maps();
+-    guarantee(map->offset() == offset && map->count() == (unsigned int) extra,
+-              "sanity");
+-  }
+-}
+-
+-#endif // ndef PRODUCT
+-
+ // JNIid class for jfieldIDs only
+ // Note to reviewers:
+ // These JNI functions are just moved over to column 1 and not changed
+diff --git a/src/share/vm/oops/instanceKlass.hpp b/src/share/vm/oops/instanceKlass.hpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlass.hpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlass.hpp
+@@ -27,6 +27,7 @@
+ 
+ #include "oops/constMethodOop.hpp"
+ #include "oops/constantPoolOop.hpp"
++#include "oops/fieldInfo.hpp"
+ #include "oops/instanceOop.hpp"
+ #include "oops/klassOop.hpp"
+ #include "oops/klassVtable.hpp"
+@@ -230,6 +231,7 @@
+   int             _static_field_size;    // number words used by static fields (oop and non-oop) in this klass
+   int             _static_oop_field_count;// number of static oop fields in this klass
+   int             _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
++  int             _java_fields_count;    // The number of declared Java fields
+   bool            _is_marked_dependent;  // used for marking during flushing and deoptimization
+   bool            _rewritten;            // methods rewritten.
+   bool            _has_nonstatic_fields; // for sizing with UseCompressedOops
+@@ -309,28 +311,29 @@
+   objArrayOop transitive_interfaces() const     { return _transitive_interfaces; }
+   void set_transitive_interfaces(objArrayOop a) { oop_store_without_check((oop*) &_transitive_interfaces, (oop) a); }
+ 
+-  // fields
+-  // Field info extracted from the class file and stored
+-  // as an array of 7 shorts
+-  enum FieldOffset {
+-    access_flags_offset    = 0,
+-    name_index_offset      = 1,
+-    signature_index_offset = 2,
+-    initval_index_offset   = 3,
+-    low_offset             = 4,
+-    high_offset            = 5,
+-    generic_signature_offset = 6,
+-    next_offset            = 7
+-  };
++ private:
++  friend class fieldDescriptor;
++  FieldInfo* field(int index) const { return FieldInfo::from_field_array(_fields, index); }
++
++ public:
++  int     field_offset      (int index) const { return field(index)->offset(); }
++  int     field_access_flags(int index) const { return field(index)->access_flags(); }
++  Symbol* field_name        (int index) const { return field(index)->name(constants()); }
++  Symbol* field_signature   (int index) const { return field(index)->signature(constants()); }
++
++  // Number of Java declared fields
++  int java_fields_count() const           { return _java_fields_count; }
++
++  // Number of fields including any injected fields
++  int all_fields_count() const            { return _fields->length() / sizeof(FieldInfo::field_slots); }
+ 
+   typeArrayOop fields() const              { return _fields; }
+-  int offset_from_fields( int index ) const {
+-    return build_int_from_shorts( fields()->ushort_at(index + low_offset),
+-                                  fields()->ushort_at(index + high_offset) );
++
++  void set_fields(typeArrayOop f, int java_fields_count) {
++    oop_store_without_check((oop*) &_fields, (oop) f);
++    _java_fields_count = java_fields_count;
+   }
+ 
+-  void set_fields(typeArrayOop f)          { oop_store_without_check((oop*) &_fields, (oop) f); }
+-
+   // inner classes
+   typeArrayOop inner_classes() const       { return _inner_classes; }
+   void set_inner_classes(typeArrayOop f)   { oop_store_without_check((oop*) &_inner_classes, (oop) f); }
+@@ -846,10 +849,6 @@
+   // Verification
+   const char* internal_name() const;
+   void oop_verify_on(oop obj, outputStream* st);
+-
+-#ifndef PRODUCT
+-  static void verify_class_klass_nonstatic_oop_maps(klassOop k) PRODUCT_RETURN;
+-#endif
+ };
+ 
+ inline methodOop instanceKlass::method_at_vtable(int index)  {
+diff --git a/src/share/vm/oops/instanceKlassKlass.cpp b/src/share/vm/oops/instanceKlassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
+@@ -426,7 +426,7 @@
+     ik->set_local_interfaces(NULL);
+     ik->set_transitive_interfaces(NULL);
+     ik->init_implementor();
+-    ik->set_fields(NULL);
++    ik->set_fields(NULL, 0);
+     ik->set_constants(NULL);
+     ik->set_class_loader(NULL);
+     ik->set_protection_domain(NULL);
+diff --git a/src/share/vm/prims/jni.cpp b/src/share/vm/prims/jni.cpp
+--- openjdk/hotspot/src/share/vm/prims/jni.cpp
++++ openjdk/hotspot/src/share/vm/prims/jni.cpp
+@@ -498,7 +498,7 @@
+ 
+   // First check if this is a static field
+   if (modifiers & JVM_ACC_STATIC) {
+-    intptr_t offset = instanceKlass::cast(k1())->offset_from_fields( slot );
++    intptr_t offset = instanceKlass::cast(k1())->field_offset( slot );
+     JNIid* id = instanceKlass::cast(k1())->jni_id_for(offset);
+     assert(id != NULL, "corrupt Field object");
+     debug_only(id->set_is_static_field_id();)
+@@ -510,7 +510,7 @@
+   // The slot is the index of the field description in the field-array
+   // The jfieldID is the offset of the field within the object
+   // It may also have hash bits for k, if VerifyJNIFields is turned on.
+-  intptr_t offset = instanceKlass::cast(k1())->offset_from_fields( slot );
++  intptr_t offset = instanceKlass::cast(k1())->field_offset( slot );
+   assert(instanceKlass::cast(k1())->contains_field_offset(offset), "stay within object");
+   ret = jfieldIDWorkaround::to_instance_jfieldID(k1(), offset);
+   return ret;
+diff --git a/src/share/vm/prims/jvm.cpp b/src/share/vm/prims/jvm.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvm.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvm.cpp
+@@ -32,6 +32,7 @@
+ #include "gc_interface/collectedHeap.inline.hpp"
+ #include "memory/oopFactory.hpp"
+ #include "memory/universe.inline.hpp"
++#include "oops/fieldStreams.hpp"
+ #include "oops/instanceKlass.hpp"
+ #include "oops/objArrayKlass.hpp"
+ #include "prims/jvm.h"
+@@ -1562,7 +1563,7 @@
+ 
+   fieldDescriptor fd;
+   KlassHandle kh(THREAD, k);
+-  intptr_t offset = instanceKlass::cast(kh())->offset_from_fields(slot);
++  intptr_t offset = instanceKlass::cast(kh())->field_offset(slot);
+ 
+   if (modifiers & JVM_ACC_STATIC) {
+     // for static fields we only look in the current class
+@@ -1662,9 +1663,6 @@
+   // Ensure class is linked
+   k->link_class(CHECK_NULL);
+ 
+-  typeArrayHandle fields(THREAD, k->fields());
+-  int fields_len = fields->length();
+-
+   // 4496456 We need to filter out java.lang.Throwable.backtrace
+   bool skip_backtrace = false;
+ 
+@@ -1673,12 +1671,11 @@
+ 
+   if (publicOnly) {
+     num_fields = 0;
+-    for (int i = 0, j = 0; i < fields_len; i += instanceKlass::next_offset, j++) {
+-      int mods = fields->ushort_at(i + instanceKlass::access_flags_offset) & JVM_RECOGNIZED_FIELD_MODIFIERS;
+-      if (mods & JVM_ACC_PUBLIC) ++num_fields;
++    for (JavaFieldStream fs(k()); !fs.done(); fs.next()) {
++      if (fs.access_flags().is_public()) ++num_fields;
+     }
+   } else {
+-    num_fields = fields_len / instanceKlass::next_offset;
++    num_fields = k->java_fields_count();
+ 
+     if (k() == SystemDictionary::Throwable_klass()) {
+       num_fields--;
+@@ -1691,16 +1688,15 @@
+ 
+   int out_idx = 0;
+   fieldDescriptor fd;
+-  for (int i = 0; i < fields_len; i += instanceKlass::next_offset) {
++  for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
+     if (skip_backtrace) {
+       // 4496456 skip java.lang.Throwable.backtrace
+-      int offset = k->offset_from_fields(i);
++      int offset = fs.offset();
+       if (offset == java_lang_Throwable::get_backtrace_offset()) continue;
+     }
+ 
+-    int mods = fields->ushort_at(i + instanceKlass::access_flags_offset) & JVM_RECOGNIZED_FIELD_MODIFIERS;
+-    if (!publicOnly || (mods & JVM_ACC_PUBLIC)) {
+-      fd.initialize(k(), i);
++    if (!publicOnly || fs.access_flags().is_public()) {
++      fd.initialize(k(), fs.index());
+       oop field = Reflection::new_field(&fd, UseNewReflection, CHECK_NULL);
+       result->obj_at_put(out_idx, field);
+       ++out_idx;
+@@ -2188,7 +2184,7 @@
+   k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread);
+   if (!Klass::cast(k)->oop_is_instance())
+     return 0;
+-  return instanceKlass::cast(k)->fields()->length() / instanceKlass::next_offset;
++  return instanceKlass::cast(k)->java_fields_count();
+ JVM_END
+ 
+ 
+@@ -2284,8 +2280,7 @@
+   JVMWrapper("JVM_GetFieldIxModifiers");
+   klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls));
+   k = JvmtiThreadState::class_to_verify_considering_redefinition(k, thread);
+-  typeArrayOop fields = instanceKlass::cast(k)->fields();
+-  return fields->ushort_at(field_index * instanceKlass::next_offset + instanceKlass::access_flags_offset) & JVM_RECOGNIZED_FIELD_MODIFIERS;
++  return instanceKlass::cast(k)->field_access_flags(field_index) & JVM_RECOGNIZED_FIELD_MODIFIERS;
+ JVM_END
+ 
+ 
+@@ -2468,7 +2463,7 @@
+ JVM_END
+ 
+ 
+-JVM_QUICK_ENTRY(jint, JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls))
++JVM_ENTRY(jint, JVM_GetCPFieldModifiers(JNIEnv *env, jclass cls, int cp_index, jclass called_cls))
+   JVMWrapper("JVM_GetCPFieldModifiers");
+   klassOop k = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(cls));
+   klassOop k_called = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(called_cls));
+@@ -2480,12 +2475,9 @@
+     case JVM_CONSTANT_Fieldref: {
+       Symbol* name      = cp->uncached_name_ref_at(cp_index);
+       Symbol* signature = cp->uncached_signature_ref_at(cp_index);
+-      typeArrayOop fields = instanceKlass::cast(k_called)->fields();
+-      int fields_count = fields->length();
+-      for (int i = 0; i < fields_count; i += instanceKlass::next_offset) {
+-        if (cp_called->symbol_at(fields->ushort_at(i + instanceKlass::name_index_offset)) == name &&
+-            cp_called->symbol_at(fields->ushort_at(i + instanceKlass::signature_index_offset)) == signature) {
+-          return fields->ushort_at(i + instanceKlass::access_flags_offset) & JVM_RECOGNIZED_FIELD_MODIFIERS;
++      for (JavaFieldStream fs(k_called); !fs.done(); fs.next()) {
++        if (fs.name() == name && fs.signature() == signature) {
++          return fs.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS;
+         }
+       }
+       return -1;
+diff --git a/src/share/vm/prims/jvmtiClassFileReconstituter.cpp b/src/share/vm/prims/jvmtiClassFileReconstituter.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp
+@@ -25,6 +25,7 @@
+ #include "precompiled.hpp"
+ #include "classfile/symbolTable.hpp"
+ #include "interpreter/bytecodeStream.hpp"
++#include "oops/fieldStreams.hpp"
+ #include "prims/jvmtiClassFileReconstituter.hpp"
+ #include "runtime/signature.hpp"
+ #ifdef TARGET_ARCH_x86
+@@ -46,25 +47,22 @@
+ // JVMSpec|     field_info fields[fields_count];
+ void JvmtiClassFileReconstituter::write_field_infos() {
+   HandleMark hm(thread());
+-  typeArrayHandle fields(thread(), ikh()->fields());
+-  int fields_length = fields->length();
+-  int num_fields = fields_length / instanceKlass::next_offset;
+   objArrayHandle fields_anno(thread(), ikh()->fields_annotations());
+ 
+-  write_u2(num_fields);
+-  for (int index = 0; index < fields_length; index += instanceKlass::next_offset) {
+-    AccessFlags access_flags;
+-    int flags = fields->ushort_at(index + instanceKlass::access_flags_offset);
+-    access_flags.set_flags(flags);
+-    int name_index = fields->ushort_at(index + instanceKlass::name_index_offset);
+-    int signature_index = fields->ushort_at(index + instanceKlass::signature_index_offset);
+-    int initial_value_index = fields->ushort_at(index + instanceKlass::initval_index_offset);
++  // Compute the real number of Java fields
++  int java_fields = ikh()->java_fields_count();
++
++  write_u2(java_fields * FieldInfo::field_slots);
++  for (JavaFieldStream fs(ikh()); !fs.done(); fs.next()) {
++    AccessFlags access_flags = fs.access_flags();
++    int name_index = fs.name_index();
++    int signature_index = fs.signature_index();
++    int initial_value_index = fs.initval_index();
+     guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field");
+-    int offset = ikh()->offset_from_fields( index );
+-    int generic_signature_index =
+-                        fields->ushort_at(index + instanceKlass::generic_signature_offset);
++    // int offset = ikh()->field_offset( index );
++    int generic_signature_index = fs.generic_signature_index();
+     typeArrayHandle anno(thread(), fields_anno.not_null() ?
+-                                 (typeArrayOop)(fields_anno->obj_at(index / instanceKlass::next_offset)) :
++                                 (typeArrayOop)(fields_anno->obj_at(fs.index())) :
+                                  (typeArrayOop)NULL);
+ 
+     // JVMSpec|   field_info {
+@@ -75,7 +73,7 @@
+     // JVMSpec|         attribute_info attributes[attributes_count];
+     // JVMSpec|   }
+ 
+-    write_u2(flags & JVM_RECOGNIZED_FIELD_MODIFIERS);
++    write_u2(access_flags.as_int() & JVM_RECOGNIZED_FIELD_MODIFIERS);
+     write_u2(name_index);
+     write_u2(signature_index);
+     int attr_count = 0;
+diff --git a/src/share/vm/prims/jvmtiEnv.cpp b/src/share/vm/prims/jvmtiEnv.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiEnv.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiEnv.cpp
+@@ -2044,7 +2044,6 @@
+   // make sure we haven't set this watch before
+   if (fdesc_ptr->is_field_access_watched()) return JVMTI_ERROR_DUPLICATE;
+   fdesc_ptr->set_is_field_access_watched(true);
+-  update_klass_field_access_flag(fdesc_ptr);
+ 
+   JvmtiEventController::change_field_watch(JVMTI_EVENT_FIELD_ACCESS, true);
+ 
+@@ -2057,7 +2056,6 @@
+   // make sure we have a watch to clear
+   if (!fdesc_ptr->is_field_access_watched()) return JVMTI_ERROR_NOT_FOUND;
+   fdesc_ptr->set_is_field_access_watched(false);
+-  update_klass_field_access_flag(fdesc_ptr);
+ 
+   JvmtiEventController::change_field_watch(JVMTI_EVENT_FIELD_ACCESS, false);
+ 
+@@ -2070,7 +2068,6 @@
+   // make sure we haven't set this watch before
+   if (fdesc_ptr->is_field_modification_watched()) return JVMTI_ERROR_DUPLICATE;
+   fdesc_ptr->set_is_field_modification_watched(true);
+-  update_klass_field_access_flag(fdesc_ptr);
+ 
+   JvmtiEventController::change_field_watch(JVMTI_EVENT_FIELD_MODIFICATION, true);
+ 
+@@ -2083,7 +2080,6 @@
+    // make sure we have a watch to clear
+   if (!fdesc_ptr->is_field_modification_watched()) return JVMTI_ERROR_NOT_FOUND;
+   fdesc_ptr->set_is_field_modification_watched(false);
+-  update_klass_field_access_flag(fdesc_ptr);
+ 
+   JvmtiEventController::change_field_watch(JVMTI_EVENT_FIELD_MODIFICATION, false);
+ 
+diff --git a/src/share/vm/prims/jvmtiEnvBase.cpp b/src/share/vm/prims/jvmtiEnvBase.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
+@@ -565,15 +565,6 @@
+ }
+ 
+ 
+-// update the access_flags for the field in the klass
+-void
+-JvmtiEnvBase::update_klass_field_access_flag(fieldDescriptor *fd) {
+-  instanceKlass* ik = instanceKlass::cast(fd->field_holder());
+-  typeArrayOop fields = ik->fields();
+-  fields->ushort_at_put(fd->index(), (jushort)fd->access_flags().as_short());
+-}
+-
+-
+ // return the vframe on the specified thread and depth, NULL if no such frame
+ vframe*
+ JvmtiEnvBase::vframeFor(JavaThread* java_thread, jint depth) {
+diff --git a/src/share/vm/prims/jvmtiEnvBase.hpp b/src/share/vm/prims/jvmtiEnvBase.hpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp
+@@ -267,8 +267,6 @@
+   // convert to a jni jclass from a non-null klassOop
+   jclass get_jni_class_non_null(klassOop k);
+ 
+-  void update_klass_field_access_flag(fieldDescriptor *fd);
+-
+   jint count_locked_objects(JavaThread *java_thread, Handle hobj);
+   jvmtiError get_locked_objects_in_frame(JavaThread *calling_thread,
+                                    JavaThread* java_thread,
+diff --git a/src/share/vm/prims/jvmtiRedefineClasses.cpp b/src/share/vm/prims/jvmtiRedefineClasses.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
+@@ -30,6 +30,7 @@
+ #include "interpreter/rewriter.hpp"
+ #include "memory/gcLocker.hpp"
+ #include "memory/universe.inline.hpp"
++#include "oops/fieldStreams.hpp"
+ #include "oops/klassVtable.hpp"
+ #include "prims/jvmtiImpl.hpp"
+ #include "prims/jvmtiRedefineClasses.hpp"
+@@ -551,41 +552,35 @@
+ 
+   // Check if the number, names, types and order of fields declared in these classes
+   // are the same.
+-  typeArrayOop k_old_fields = the_class->fields();
+-  typeArrayOop k_new_fields = scratch_class->fields();
+-  int n_fields = k_old_fields->length();
+-  if (n_fields != k_new_fields->length()) {
+-    return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
+-  }
+-
+-  for (i = 0; i < n_fields; i += instanceKlass::next_offset) {
++  JavaFieldStream old_fs(the_class);
++  JavaFieldStream new_fs(scratch_class);
++  for (; !old_fs.done() && !new_fs.done(); old_fs.next(), new_fs.next()) {
+     // access
+-    old_flags = k_old_fields->ushort_at(i + instanceKlass::access_flags_offset);
+-    new_flags = k_new_fields->ushort_at(i + instanceKlass::access_flags_offset);
++    old_flags = old_fs.access_flags().as_short();
++    new_flags = new_fs.access_flags().as_short();
+     if ((old_flags ^ new_flags) & JVM_RECOGNIZED_FIELD_MODIFIERS) {
+       return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
+     }
+     // offset
+-    if (k_old_fields->short_at(i + instanceKlass::low_offset) !=
+-        k_new_fields->short_at(i + instanceKlass::low_offset) ||
+-        k_old_fields->short_at(i + instanceKlass::high_offset) !=
+-        k_new_fields->short_at(i + instanceKlass::high_offset)) {
++    if (old_fs.offset() != new_fs.offset()) {
+       return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
+     }
+     // name and signature
+-    jshort name_index = k_old_fields->short_at(i + instanceKlass::name_index_offset);
+-    jshort sig_index = k_old_fields->short_at(i +instanceKlass::signature_index_offset);
+-    Symbol* name_sym1 = the_class->constants()->symbol_at(name_index);
+-    Symbol* sig_sym1 = the_class->constants()->symbol_at(sig_index);
+-    name_index = k_new_fields->short_at(i + instanceKlass::name_index_offset);
+-    sig_index = k_new_fields->short_at(i + instanceKlass::signature_index_offset);
+-    Symbol* name_sym2 = scratch_class->constants()->symbol_at(name_index);
+-    Symbol* sig_sym2 = scratch_class->constants()->symbol_at(sig_index);
++    Symbol* name_sym1 = the_class->constants()->symbol_at(old_fs.name_index());
++    Symbol* sig_sym1 = the_class->constants()->symbol_at(old_fs.signature_index());
++    Symbol* name_sym2 = scratch_class->constants()->symbol_at(new_fs.name_index());
++    Symbol* sig_sym2 = scratch_class->constants()->symbol_at(new_fs.signature_index());
+     if (name_sym1 != name_sym2 || sig_sym1 != sig_sym2) {
+       return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
+     }
+   }
+ 
++  // If both streams aren't done then we have a differing number of
++  // fields.
++  if (!old_fs.done() || !new_fs.done()) {
++    return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED;
++  }
++
+   // Do a parallel walk through the old and new methods. Detect
+   // cases where they match (exist in both), have been added in
+   // the new methods, or have been deleted (exist only in the
+@@ -2363,38 +2358,34 @@
+   int i;  // for portability
+ 
+   // update each field in klass to use new constant pool indices as needed
+-  typeArrayHandle fields(THREAD, scratch_class->fields());
+-  int n_fields = fields->length();
+-  for (i = 0; i < n_fields; i += instanceKlass::next_offset) {
+-    jshort cur_index = fields->short_at(i + instanceKlass::name_index_offset);
++  for (JavaFieldStream fs(scratch_class); !fs.done(); fs.next()) {
++    jshort cur_index = fs.name_index();
+     jshort new_index = find_new_index(cur_index);
+     if (new_index != 0) {
+       RC_TRACE_WITH_THREAD(0x00080000, THREAD,
+         ("field-name_index change: %d to %d", cur_index, new_index));
+-      fields->short_at_put(i + instanceKlass::name_index_offset, new_index);
++      fs.set_name_index(new_index);
+     }
+-    cur_index = fields->short_at(i + instanceKlass::signature_index_offset);
++    cur_index = fs.signature_index();
+     new_index = find_new_index(cur_index);
+     if (new_index != 0) {
+       RC_TRACE_WITH_THREAD(0x00080000, THREAD,
+         ("field-signature_index change: %d to %d", cur_index, new_index));
+-      fields->short_at_put(i + instanceKlass::signature_index_offset,
+-        new_index);
++      fs.set_signature_index(new_index);
+     }
+-    cur_index = fields->short_at(i + instanceKlass::initval_index_offset);
++    cur_index = fs.initval_index();
+     new_index = find_new_index(cur_index);
+     if (new_index != 0) {
+       RC_TRACE_WITH_THREAD(0x00080000, THREAD,
+         ("field-initval_index change: %d to %d", cur_index, new_index));
+-      fields->short_at_put(i + instanceKlass::initval_index_offset, new_index);
++      fs.set_initval_index(new_index);
+     }
+-    cur_index = fields->short_at(i + instanceKlass::generic_signature_offset);
++    cur_index = fs.generic_signature_index();
+     new_index = find_new_index(cur_index);
+     if (new_index != 0) {
+       RC_TRACE_WITH_THREAD(0x00080000, THREAD,
+         ("field-generic_signature change: %d to %d", cur_index, new_index));
+-      fields->short_at_put(i + instanceKlass::generic_signature_offset,
+-        new_index);
++      fs.set_generic_signature_index(new_index);
+     }
+   } // end for each field
+ 
+diff --git a/src/share/vm/prims/methodHandles.cpp b/src/share/vm/prims/methodHandles.cpp
+--- openjdk/hotspot/src/share/vm/prims/methodHandles.cpp
++++ openjdk/hotspot/src/share/vm/prims/methodHandles.cpp
+@@ -386,7 +386,7 @@
+     int slot  = java_lang_reflect_Field::slot(target_oop);  // fd.index()
+     int mods  = java_lang_reflect_Field::modifiers(target_oop);
+     klassOop k = java_lang_Class::as_klassOop(clazz);
+-    int offset = instanceKlass::cast(k)->offset_from_fields(slot);
++    int offset = instanceKlass::cast(k)->field_offset(slot);
+     init_MemberName(mname_oop, k, accessFlags_from(mods), offset);
+   } else {
+     int decode_flags = 0; klassOop receiver_limit = NULL;
+@@ -646,6 +646,7 @@
+       }
+     }
+   }
++  assert(java_lang_invoke_MethodTypeForm::vmslots(mtform()) == argument_slot_count(mtype()), "must agree");
+ }
+ 
+ // Conversely, a member name which is only initialized from JVM internals
+@@ -1410,8 +1411,6 @@
+     THROW(vmSymbols::java_lang_InternalError());
+   }
+ 
+-  java_dyn_MethodHandle::init_vmslots(mh());
+-
+   if (VerifyMethodHandles) {
+     // The privileged code which invokes this routine should not make
+     // a mistake about types, but it's better to verify.
+@@ -1531,7 +1530,6 @@
+   if (m.is_null())      { THROW(vmSymbols::java_lang_InternalError()); }
+   if (m->is_abstract()) { THROW(vmSymbols::java_lang_AbstractMethodError()); }
+ 
+-  java_dyn_MethodHandle::init_vmslots(mh());
+ 
+   if (VerifyMethodHandles) {
+     verify_BoundMethodHandle_with_receiver(mh, m, CHECK);
+@@ -1639,8 +1637,6 @@
+     THROW(vmSymbols::java_lang_InternalError());
+   }
+ 
+-  java_dyn_MethodHandle::init_vmslots(mh());
+-
+   if (VerifyMethodHandles) {
+     int insert_after = argnum - 1;
+     verify_vmargslot(mh, insert_after, sun_dyn_BoundMethodHandle::vmargslot(mh()), CHECK);
+diff --git a/src/share/vm/prims/unsafe.cpp b/src/share/vm/prims/unsafe.cpp
+--- openjdk/hotspot/src/share/vm/prims/unsafe.cpp
++++ openjdk/hotspot/src/share/vm/prims/unsafe.cpp
+@@ -652,7 +652,7 @@
+     }
+   }
+ 
+-  int offset = instanceKlass::cast(k)->offset_from_fields(slot);
++  int offset = instanceKlass::cast(k)->field_offset(slot);
+   return field_offset_from_byte_offset(offset);
+ }
+ 
+diff --git a/src/share/vm/runtime/fieldDescriptor.cpp b/src/share/vm/runtime/fieldDescriptor.cpp
+--- openjdk/hotspot/src/share/vm/runtime/fieldDescriptor.cpp
++++ openjdk/hotspot/src/share/vm/runtime/fieldDescriptor.cpp
+@@ -42,59 +42,51 @@
+   objArrayOop md = ik->fields_annotations();
+   if (md == NULL)
+     return NULL;
+-  assert((index() % instanceKlass::next_offset) == 0, "");
+-  return typeArrayOop(md->obj_at(index() / instanceKlass::next_offset));
++  return typeArrayOop(md->obj_at(index()));
+ }
+ 
+ constantTag fieldDescriptor::initial_value_tag() const {
+-  return constants()->tag_at(_initial_value_index);
++  return constants()->tag_at(initial_value_index());
+ }
+ 
+ jint fieldDescriptor::int_initial_value() const {
+-  return constants()->int_at(_initial_value_index);
++  return constants()->int_at(initial_value_index());
+ }
+ 
+ jlong fieldDescriptor::long_initial_value() const {
+-  return constants()->long_at(_initial_value_index);
++  return constants()->long_at(initial_value_index());
+ }
+ 
+ jfloat fieldDescriptor::float_initial_value() const {
+-  return constants()->float_at(_initial_value_index);
++  return constants()->float_at(initial_value_index());
+ }
+ 
+ jdouble fieldDescriptor::double_initial_value() const {
+-  return constants()->double_at(_initial_value_index);
++  return constants()->double_at(initial_value_index());
+ }
+ 
+ oop fieldDescriptor::string_initial_value(TRAPS) const {
+-  return constants()->string_at(_initial_value_index, CHECK_0);
++  return constants()->string_at(initial_value_index(), CHECK_0);
+ }
+ 
+ void fieldDescriptor::initialize(klassOop k, int index) {
+   instanceKlass* ik = instanceKlass::cast(k);
+   _cp = ik->constants();
+-  typeArrayOop fields = ik->fields();
++  FieldInfo* f = ik->field(index);
++  assert(!f->is_internal(), "regular Java fields only");
+ 
+-  assert(fields->length() % instanceKlass::next_offset == 0, "Illegal size of field array");
+-  assert(fields->length() >= index + instanceKlass::next_offset, "Illegal size of field array");
+-
+-  _access_flags.set_field_flags(fields->ushort_at(index + instanceKlass::access_flags_offset));
+-  _name_index = fields->ushort_at(index + instanceKlass::name_index_offset);
+-  _signature_index = fields->ushort_at(index + instanceKlass::signature_index_offset);
+-  _initial_value_index = fields->ushort_at(index + instanceKlass::initval_index_offset);
+-  guarantee(_name_index != 0 && _signature_index != 0, "bad constant pool index for fieldDescriptor");
+-  _offset = ik->offset_from_fields( index );
+-  _generic_signature_index = fields->ushort_at(index + instanceKlass::generic_signature_offset);
++  _access_flags = accessFlags_from(f->access_flags());
++  guarantee(f->name_index() != 0 && f->signature_index() != 0, "bad constant pool index for fieldDescriptor");
+   _index = index;
+ }
+ 
+ #ifndef PRODUCT
+ 
+ void fieldDescriptor::print_on(outputStream* st) const {
+-  _access_flags.print_on(st);
+-  constants()->symbol_at(_name_index)->print_value_on(st);
++  access_flags().print_on(st);
++  name()->print_value_on(st);
+   st->print(" ");
+-  constants()->symbol_at(_signature_index)->print_value_on(st);
++  signature()->print_value_on(st);
+   st->print(" @%d ", offset());
+   if (WizardMode && has_initial_value()) {
+     st->print("(initval ");
+diff --git a/src/share/vm/runtime/fieldDescriptor.hpp b/src/share/vm/runtime/fieldDescriptor.hpp
+--- openjdk/hotspot/src/share/vm/runtime/fieldDescriptor.hpp
++++ openjdk/hotspot/src/share/vm/runtime/fieldDescriptor.hpp
+@@ -40,29 +40,40 @@
+ class fieldDescriptor VALUE_OBJ_CLASS_SPEC {
+  private:
+   AccessFlags         _access_flags;
+-  int                 _name_index;
+-  int                 _signature_index;
+-  int                 _initial_value_index;
+-  int                 _offset;
+-  int                 _generic_signature_index;
+-  int                 _index; // index into fields() array
++  int                 _index; // the field index
+   constantPoolHandle  _cp;
+ 
++  // update the access_flags for the field in the klass
++  void update_klass_field_access_flag() {
++    instanceKlass* ik = instanceKlass::cast(field_holder());
++    ik->field(index())->set_access_flags(_access_flags.as_short());
++  }
++
++  FieldInfo* field() const {
++    instanceKlass* ik = instanceKlass::cast(field_holder());
++    return ik->field(_index);
++  }
++
+  public:
+-  Symbol* name() const                 { return _cp->symbol_at(_name_index); }
+-  Symbol* signature() const            { return _cp->symbol_at(_signature_index); }
++  Symbol* name() const {
++    return field()->name(_cp);
++  }
++  Symbol* signature() const {
++    return field()->signature(_cp);
++  }
+   klassOop field_holder() const        { return _cp->pool_holder(); }
+   constantPoolOop constants() const    { return _cp(); }
+   AccessFlags access_flags() const     { return _access_flags; }
+   oop loader() const;
+   // Offset (in words) of field from start of instanceOop / klassOop
+-  int offset() const                   { return _offset; }
+-  Symbol* generic_signature() const    { return (_generic_signature_index > 0 ? _cp->symbol_at(_generic_signature_index) : (Symbol*)NULL); }
++  int offset() const                   { return field()->offset(); }
++  Symbol* generic_signature() const    { return field()->generic_signature(_cp); }
+   int index() const                    { return _index; }
+   typeArrayOop annotations() const;
+ 
+   // Initial field value
+-  bool has_initial_value() const          { return _initial_value_index != 0; }
++  bool has_initial_value() const          { return field()->initval_index() != 0; }
++  int initial_value_index() const         { return field()->initval_index(); }
+   constantTag initial_value_tag() const;  // The tag will return true on one of is_int(), is_long(), is_single(), is_double()
+   jint        int_initial_value() const;
+   jlong       long_initial_value() const;
+@@ -74,25 +85,31 @@
+   BasicType field_type() const            { return FieldType::basic_type(signature()); }
+ 
+   // Access flags
+-  bool is_public() const                  { return _access_flags.is_public(); }
+-  bool is_private() const                 { return _access_flags.is_private(); }
+-  bool is_protected() const               { return _access_flags.is_protected(); }
++  bool is_public() const                  { return access_flags().is_public(); }
++  bool is_private() const                 { return access_flags().is_private(); }
++  bool is_protected() const               { return access_flags().is_protected(); }
+   bool is_package_private() const         { return !is_public() && !is_private() && !is_protected(); }
+ 
+-  bool is_static() const                  { return _access_flags.is_static(); }
+-  bool is_final() const                   { return _access_flags.is_final(); }
+-  bool is_volatile() const                { return _access_flags.is_volatile(); }
+-  bool is_transient() const               { return _access_flags.is_transient(); }
++  bool is_static() const                  { return access_flags().is_static(); }
++  bool is_final() const                   { return access_flags().is_final(); }
++  bool is_volatile() const                { return access_flags().is_volatile(); }
++  bool is_transient() const               { return access_flags().is_transient(); }
+ 
+-  bool is_synthetic() const               { return _access_flags.is_synthetic(); }
++  bool is_synthetic() const               { return access_flags().is_synthetic(); }
+ 
+-  bool is_field_access_watched() const    { return _access_flags.is_field_access_watched(); }
++  bool is_field_access_watched() const    { return access_flags().is_field_access_watched(); }
+   bool is_field_modification_watched() const
+-                                          { return _access_flags.is_field_modification_watched(); }
+-  void set_is_field_access_watched(const bool value)
+-                                          { _access_flags.set_is_field_access_watched(value); }
+-  void set_is_field_modification_watched(const bool value)
+-                                          { _access_flags.set_is_field_modification_watched(value); }
++                                          { return access_flags().is_field_modification_watched(); }
++
++  void set_is_field_access_watched(const bool value) {
++    _access_flags.set_is_field_access_watched(value);
++    update_klass_field_access_flag();
++  }
++
++  void set_is_field_modification_watched(const bool value) {
++    _access_flags.set_is_field_modification_watched(value);
++    update_klass_field_access_flag();
++  }
+ 
+   // Initialization
+   void initialize(klassOop k, int index);
+diff --git a/src/share/vm/runtime/reflectionUtils.hpp b/src/share/vm/runtime/reflectionUtils.hpp
+--- openjdk/hotspot/src/share/vm/runtime/reflectionUtils.hpp
++++ openjdk/hotspot/src/share/vm/runtime/reflectionUtils.hpp
+@@ -107,10 +107,8 @@
+ 
+ class FieldStream : public KlassStream {
+  private:
+-  int length() const                { return fields()->length(); }
+-  constantPoolOop constants() const { return _klass->constants(); }
+- protected:
+-  typeArrayOop fields() const       { return _klass->fields(); }
++  int length() const                { return _klass->java_fields_count(); }
++
+  public:
+   FieldStream(instanceKlassHandle klass, bool local_only, bool classes_only)
+     : KlassStream(klass, local_only, classes_only) {
+@@ -118,26 +116,23 @@
+     next();
+   }
+ 
+-  void next() { _index -= instanceKlass::next_offset; }
++  void next() { _index -= 1; }
+ 
+   // Accessors for current field
+   AccessFlags access_flags() const {
+     AccessFlags flags;
+-    flags.set_flags(fields()->ushort_at(index() + instanceKlass::access_flags_offset));
++    flags.set_flags(_klass->field_access_flags(_index));
+     return flags;
+   }
+   Symbol* name() const {
+-    int name_index = fields()->ushort_at(index() + instanceKlass::name_index_offset);
+-    return constants()->symbol_at(name_index);
++    return _klass->field_name(_index);
+   }
+   Symbol* signature() const {
+-    int signature_index = fields()->ushort_at(index() +
+-                                       instanceKlass::signature_index_offset);
+-    return constants()->symbol_at(signature_index);
++    return _klass->field_signature(_index);
+   }
+   // missing: initval()
+   int offset() const {
+-    return _klass->offset_from_fields( index() );
++    return _klass->field_offset( index() );
+   }
+ };
+ 
+@@ -213,10 +208,10 @@
+   }
+   int field_count();
+   void next() {
+-    _index -= instanceKlass::next_offset;
++    _index -= 1;
+     if (has_filtered_field()) {
+       while (_index >=0 && FilteredFieldsMap::is_filtered_field((klassOop)_klass(), offset())) {
+-        _index -= instanceKlass::next_offset;
++        _index -= 1;
+       }
+     }
+   }
+diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp
+--- openjdk/hotspot/src/share/vm/runtime/thread.cpp
++++ openjdk/hotspot/src/share/vm/runtime/thread.cpp
+@@ -981,7 +981,7 @@
+ // General purpose hook into Java code, run once when the VM is initialized.
+ // The Java library method itself may be changed independently from the VM.
+ static void call_postVMInitHook(TRAPS) {
+-  klassOop k = SystemDictionary::sun_misc_PostVMInitHook_klass();
++  klassOop k = SystemDictionary::PostVMInitHook_klass();
+   instanceKlassHandle klass (THREAD, k);
+   if (klass.not_null()) {
+     JavaValue result(T_VOID);
+diff --git a/src/share/vm/runtime/vmStructs.cpp b/src/share/vm/runtime/vmStructs.cpp
+--- openjdk/hotspot/src/share/vm/runtime/vmStructs.cpp
++++ openjdk/hotspot/src/share/vm/runtime/vmStructs.cpp
+@@ -241,6 +241,7 @@
+   nonstatic_field(instanceKlass,               _nof_implementors,                             int)                                   \
+   nonstatic_field(instanceKlass,               _implementors[0],                              klassOop)                              \
+   nonstatic_field(instanceKlass,               _fields,                                       typeArrayOop)                          \
++  nonstatic_field(instanceKlass,               _java_fields_count,                             int)                                   \
+   nonstatic_field(instanceKlass,               _constants,                                    constantPoolOop)                       \
+   nonstatic_field(instanceKlass,               _class_loader,                                 oop)                                   \
+   nonstatic_field(instanceKlass,               _protection_domain,                            oop)                                   \
+@@ -931,11 +932,11 @@
+   /* java_lang_Class fields        */                                                                                                \
+   /*********************************/                                                                                                \
+                                                                                                                                      \
+-  static_field(java_lang_Class,                klass_offset,                                  int)                                   \
+-  static_field(java_lang_Class,                resolved_constructor_offset,                   int)                                   \
+-  static_field(java_lang_Class,                array_klass_offset,                            int)                                   \
+-  static_field(java_lang_Class,                oop_size_offset,                               int)                                   \
+-  static_field(java_lang_Class,                static_oop_field_count_offset,                 int)                                   \
++  static_field(java_lang_Class,                _klass_offset,                                 int)                                   \
++  static_field(java_lang_Class,                _resolved_constructor_offset,                  int)                                   \
++  static_field(java_lang_Class,                _array_klass_offset,                           int)                                   \
++  static_field(java_lang_Class,                _oop_size_offset,                              int)                                   \
++  static_field(java_lang_Class,                _static_oop_field_count_offset,                int)                                   \
+                                                                                                                                      \
+   /************************/                                                                                                         \
+   /* Miscellaneous fields */                                                                                                         \
+@@ -1627,19 +1628,24 @@
+   declare_constant(constMethodOopDesc::_has_localvariable_table)          \
+                                                                           \
+   /*************************************/                                 \
+-  /* instanceKlass FieldOffset enum    */                                 \
++  /* instanceKlass enum                */                                 \
+   /*************************************/                                 \
+                                                                           \
+-  declare_constant(instanceKlass::access_flags_offset)                    \
+-  declare_constant(instanceKlass::name_index_offset)                      \
+-  declare_constant(instanceKlass::signature_index_offset)                 \
+-  declare_constant(instanceKlass::initval_index_offset)                   \
+-  declare_constant(instanceKlass::low_offset)                             \
+-  declare_constant(instanceKlass::high_offset)                            \
+-  declare_constant(instanceKlass::generic_signature_offset)               \
+-  declare_constant(instanceKlass::next_offset)                            \
+   declare_constant(instanceKlass::implementors_limit)                     \
+                                                                           \
++  /*************************************/                                 \
++  /* FieldInfo FieldOffset enum        */                                 \
++  /*************************************/                                 \
++                                                                          \
++  declare_constant(FieldInfo::access_flags_offset)                        \
++  declare_constant(FieldInfo::name_index_offset)                          \
++  declare_constant(FieldInfo::signature_index_offset)                     \
++  declare_constant(FieldInfo::initval_index_offset)                       \
++  declare_constant(FieldInfo::low_offset)                                 \
++  declare_constant(FieldInfo::high_offset)                                \
++  declare_constant(FieldInfo::generic_signature_offset)                   \
++  declare_constant(FieldInfo::field_slots)                                \
++                                                                          \
+   /************************************************/                      \
+   /* instanceKlass InnerClassAttributeOffset enum */                      \
+   /************************************************/                      \
+diff --git a/src/share/vm/utilities/accessFlags.hpp b/src/share/vm/utilities/accessFlags.hpp
+--- openjdk/hotspot/src/share/vm/utilities/accessFlags.hpp
++++ openjdk/hotspot/src/share/vm/utilities/accessFlags.hpp
+@@ -79,9 +79,14 @@
+   // Note that the class-related ACC_ANNOTATION bit conflicts with these flags.
+   JVM_ACC_FIELD_ACCESS_WATCHED       = 0x00002000,  // field access is watched by JVMTI
+   JVM_ACC_FIELD_MODIFICATION_WATCHED = 0x00008000,  // field modification is watched by JVMTI
++  JVM_ACC_FIELD_INTERNAL             = 0x00000400,  // internal field, same as JVM_ACC_ABSTRACT
++
++  JVM_ACC_FIELD_INTERNAL_FLAGS       = JVM_ACC_FIELD_ACCESS_WATCHED |
++                                       JVM_ACC_FIELD_MODIFICATION_WATCHED |
++                                       JVM_ACC_FIELD_INTERNAL,
+ 
+                                                     // flags accepted by set_field_flags()
+-  JVM_ACC_FIELD_FLAGS                = 0x00008000 | JVM_ACC_WRITTEN_FLAGS
++  JVM_ACC_FIELD_FLAGS                = JVM_RECOGNIZED_FIELD_MODIFIERS | JVM_ACC_FIELD_INTERNAL_FLAGS
+ 
+ };
+ 
+@@ -150,13 +155,17 @@
+   bool is_field_access_watched() const  { return (_flags & JVM_ACC_FIELD_ACCESS_WATCHED) != 0; }
+   bool is_field_modification_watched() const
+                                         { return (_flags & JVM_ACC_FIELD_MODIFICATION_WATCHED) != 0; }
++  bool is_internal() const              { return (_flags & JVM_ACC_FIELD_INTERNAL) != 0; }
+ 
+   // get .class file flags
+   jint get_flags               () const { return (_flags & JVM_ACC_WRITTEN_FLAGS); }
+ 
+   // Initialization
+   void add_promoted_flags(jint flags)   { _flags |= (flags & JVM_ACC_PROMOTED_FLAGS); }
+-  void set_field_flags(jint flags)      { _flags = (flags & JVM_ACC_FIELD_FLAGS); }
++  void set_field_flags(jint flags)      {
++    assert((flags & JVM_ACC_FIELD_FLAGS) == flags, "only recognized flags");
++    _flags = (flags & JVM_ACC_FIELD_FLAGS);
++  }
+   void set_flags(jint flags)            { _flags = (flags & JVM_ACC_WRITTEN_FLAGS); }
+ 
+   void set_queued_for_compilation()    { atomic_set_bits(JVM_ACC_QUEUED); }
+@@ -218,8 +227,8 @@
+                                        }
+ 
+   // Conversion
+-  jshort as_short()                    { return (jshort)_flags; }
+-  jint   as_int()                      { return _flags; }
++  jshort as_short() const              { return (jshort)_flags; }
++  jint   as_int() const                { return _flags; }
+ 
+   inline friend AccessFlags accessFlags_from(jint flags);
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/7171223-strict_aliasing.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,25 @@
+# HG changeset patch
+# User andrew
+# Date 1338391068 -3600
+# Node ID 18416c18dc35344d89a3a997420a65c996e5e906
+# Parent  8634e1665b74843e2af88b51bfa788562a842d7b
+7171223: Building ExtensionSubtables.cpp should use -fno-strict-aliasing
+Summary: GCC 4.4+ have stricter aliasing requirements which produces a new warning from this code
+Reviewed-by: prr, ohair
+
+diff --git a/make/sun/font/Makefile b/make/sun/font/Makefile
+--- openjdk/jdk/make/sun/font/Makefile
++++ openjdk/jdk/make/sun/font/Makefile
+@@ -96,6 +96,12 @@
+ 
+ endif # PLATFORM
+ 
++# Turn off aliasing with GCC for ExtensionSubtables.cpp
++ifeq ($(PLATFORM), linux)
++  CXXFLAGS += $(CXXFLAGS_$(@F))
++  CXXFLAGS_ExtensionSubtables.o = -fno-strict-aliasing
++endif
++
+ #In the non-OpenJDK mode we need to build T2K
+ ifndef OPENJDK
+ t2k:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/openjdk/7195301-no_instanceof_node.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,86 @@
+# HG changeset patch
+# User andrew
+# Date 1371053674 -3600
+# Node ID 2ae6d8da293f30c94c9478a6634c7a480328c5c5
+# Parent  18416c18dc35344d89a3a997420a65c996e5e906
+7195301: XML Signature DOM implementation should not use instanceof to determine type of Node
+Reviewed-by: mullan
+
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java b/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
+@@ -158,7 +158,7 @@
+                 }
+             }
+                         for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
+-                if (!(el instanceof Element)) {
++                if (el.getNodeType() != Node.ELEMENT_NODE) {
+                         continue;
+                 }
+                 String tag=el.getLocalName();
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
+@@ -187,7 +187,7 @@
+         this._excludeNode = excludeNode;
+         try {
+          NameSpaceSymbTable ns=new NameSpaceSymbTable();
+-         if (rootNode instanceof Element) {
++         if (rootNode != null && rootNode.getNodeType() == Node.ELEMENT_NODE) {
+                 //Fills the nssymbtable with the definitions of the parent of the root subnode
+                 getParentNameSpaces((Element)rootNode,ns);
+          }
+@@ -306,7 +306,7 @@
+                                 return;
+                         sibling=parentNode.getNextSibling();
+                         parentNode=parentNode.getParentNode();
+-                        if (!(parentNode instanceof Element)) {
++                        if (parentNode !=null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
+                                 parentNode=null;
+                         }
+                 }
+@@ -509,7 +509,7 @@
+                                 return;
+                         sibling=parentNode.getNextSibling();
+                         parentNode=parentNode.getParentNode();
+-                        if (!(parentNode instanceof Element)) {
++                        if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
+                                 parentNode=null;
+                         }
+                 }
+@@ -541,18 +541,14 @@
+         final static void getParentNameSpaces(Element el,NameSpaceSymbTable ns)  {
+                 List parents=new ArrayList();
+                 Node n1=el.getParentNode();
+-                if (!(n1 instanceof Element)) {
++                if (n1 == null || n1.getNodeType() != Node.ELEMENT_NODE) {
+                         return;
+                 }
+                 //Obtain all the parents of the elemnt
+-                Element parent=(Element) el.getParentNode();
+-                while (parent!=null) {
+-                        parents.add(parent);
+-                        Node n=parent.getParentNode();
+-                        if (!(n instanceof Element )) {
+-                                break;
+-                        }
+-                        parent=(Element)n;
++                Node parent = n1;
++                while (parent!=null && parent.getNodeType() == Node.ELEMENT_NODE) {
++                        parents.add((Element)parent);
++                        parent = parent.getParentNode();
+                 }
+                 //Visit them in reverse order.
+                 ListIterator it=parents.listIterator(parents.size());
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java
+@@ -1523,7 +1523,7 @@
+                 // The de-serialiser returns a fragment whose children we need to
+                 // take on.
+ 
+-                if (sourceParent instanceof Document) {
++                if (sourceParent != null && sourceParent.getNodeType() == Node.DOCUMENT_NODE) {
+ 
+                     // If this is a content decryption, this may have problems
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/6741606-apache_santuario.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,8110 @@
+# HG changeset patch
+# User andrew
+# Date 1371136851 -3600
+# Node ID 7ecadad337414327d0d0ca6a8efcc40b7e8a9d29
+# Parent  a955a845f0d1b8e21e0780986d971b3712db26c7
+6741606: Integrate Apache Santuario
+Reviewed-by: vinnie, hawtin
+
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java b/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/Init.java
+@@ -2,38 +2,43 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-/*
+- * Copyright  1999-2004 The Apache Software Foundation.
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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
+  *
+- *  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
+  *
+- *      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.
+- *
++ * 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.
+  */
+ package com.sun.org.apache.xml.internal.security;
+ 
+ import java.io.InputStream;
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
++import java.util.ArrayList;
++import java.util.List;
++
++import javax.xml.XMLConstants;
+ import javax.xml.parsers.DocumentBuilder;
+ import javax.xml.parsers.DocumentBuilderFactory;
+ 
+ import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
+ import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm;
+ import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
+-import com.sun.org.apache.xml.internal.security.keys.KeyInfo;
+ import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolver;
+ import com.sun.org.apache.xml.internal.security.transforms.Transform;
++import com.sun.org.apache.xml.internal.security.utils.ElementProxy;
+ import com.sun.org.apache.xml.internal.security.utils.I18n;
+-//import com.sun.org.apache.xml.internal.security.utils.PRNG;
+ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver;
+ import org.w3c.dom.Attr;
+@@ -47,367 +52,317 @@
+  * the mapping of Canonicalization and Transform algorithms. Initialization is
+  * done by calling {@link Init#init} which should be done in any static block
+  * of the files of this library. We ensure that this call is only executed once.
+- *
+- * @author $Author: mullan $
+  */
+-public final class Init {
++public class Init {
+ 
+-  /** {@link java.util.logging} logging facility */
+-  static java.util.logging.Logger log =
++    /** The namespace for CONF file **/
++    public static final String CONF_NS = "http://www.xmlsecurity.org/NS/#configuration";
++
++    /** {@link org.apache.commons.logging} logging facility */
++    private static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(Init.class.getName());
+ 
+-   /** Field _initialized */
+-   private static boolean _alreadyInitialized = false;
++    /** Field alreadyInitialized */
++    private static boolean alreadyInitialized = false;
+ 
+-   /** The namespace for CONF file **/
+-   public static final String CONF_NS="http://www.xmlsecurity.org/NS/#configuration";
++    /**
++     * Method isInitialized
++     * @return true if the library is already initialized.
++     */
++    public static synchronized final boolean isInitialized() {
++        return Init.alreadyInitialized;
++    }
+ 
+-   /**
+-    * Method isInitialized
+-    * @return true if the librairy is already initialized.
+-    *
+-    */
+-   public static final boolean isInitialized() {
+-      return Init._alreadyInitialized;
+-   }
++    /**
++     * Method init
++     *
++     */
++    public static synchronized void init() {
++        if (alreadyInitialized) {
++            return;
++        }
+ 
+-   /**
+-    * Method init
+-    *
+-    */
+-   public synchronized static void init() {
++        InputStream is =
++            AccessController.doPrivileged(
++                new PrivilegedAction<InputStream>() {
++                    public InputStream run() {
++                        String cfile =
++                            System.getProperty("com.sun.org.apache.xml.internal.security.resource.config");
++                        if (cfile == null) {
++                            return null;
++                        }
++                        return getClass().getResourceAsStream(cfile);
++                    }
++                });
++        if (is == null) {
++            dynamicInit();
++        } else {
++            fileInit(is);
++        }
+ 
+-      if (_alreadyInitialized) {
+-        return;
+-      }
+-      long XX_configure_i18n_end=0;
+-      long XX_configure_reg_c14n_start=0;
+-      long XX_configure_reg_c14n_end=0;
+-      long XX_configure_reg_jcemapper_end=0;
+-      long XX_configure_reg_keyInfo_start=0;
+-      long XX_configure_reg_keyResolver_end=0;
+-      long XX_configure_reg_prefixes_start=0;
+-      long XX_configure_reg_resourceresolver_start=0;
+-      long XX_configure_reg_sigalgos_end=0;
+-      long XX_configure_reg_transforms_end=0;
+-      long XX_configure_reg_keyInfo_end=0;
+-      long XX_configure_reg_keyResolver_start=0;
+-         _alreadyInitialized = true;
++        alreadyInitialized = true;
++    }
+ 
+-         try {
+-            long XX_init_start = System.currentTimeMillis();
+-            long XX_prng_start = System.currentTimeMillis();
++    /**
++     * Dynamically initialise the library by registering the default algorithms/implementations
++     */
++    private static void dynamicInit() {
++        //
++        // Load the Resource Bundle - the default is the English resource bundle.
++        // To load another resource bundle, call I18n.init(...) before calling this
++        // method.
++        //
++        I18n.init("en", "US");
+ 
+-            //PRNG.init(new java.security.SecureRandom());
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Registering default algorithms");
++        }
++        try {
++            //
++            // Bind the default prefixes
++            //
++            ElementProxy.registerDefaultPrefixes();
+ 
+-            long XX_prng_end = System.currentTimeMillis();
++            //
++            // Set the default Transforms
++            //
++            Transform.registerDefaultAlgorithms();
+ 
++            //
++            // Set the default signature algorithms
++            //
++            SignatureAlgorithm.registerDefaultAlgorithms();
++
++            //
++            // Set the default JCE algorithms
++            //
++            JCEMapper.registerDefaultAlgorithms();
++
++            //
++            // Set the default c14n algorithms
++            //
++            Canonicalizer.registerDefaultAlgorithms();
++
++            //
++            // Register the default resolvers
++            //
++            ResourceResolver.registerDefaultResolvers();
++
++            //
++            // Register the default key resolvers
++            //
++            KeyResolver.registerDefaultResolvers();
++        } catch (Exception ex) {
++            log.log(java.util.logging.Level.SEVERE, ex.getMessage(), ex);
++            ex.printStackTrace();
++        }
++    }
++
++    /**
++     * Initialise the library from a configuration file
++     */
++    private static void fileInit(InputStream is) {
++        try {
+             /* read library configuration file */
+-            long XX_parsing_start = System.currentTimeMillis();
+             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
++            dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+ 
+             dbf.setNamespaceAware(true);
+             dbf.setValidating(false);
+ 
+             DocumentBuilder db = dbf.newDocumentBuilder();
+-            // We don't allow users to override the Apache XML Security
+-            // configuration in the JRE. Users should use the standard security
+-            // provider mechanism instead if implementing their own
+-            // transform or canonicalization algorithms.
+-            // InputStream is = Class.forName("com.sun.org.apache.xml.internal.security.Init").getResourceAsStream("resource/config.xml");
+-            InputStream is = (InputStream) AccessController.doPrivileged(
+-                new PrivilegedAction() {
+-                    public Object run() {
+-//                        String cfile = System.getProperty
+-//                            ("com.sun.org.apache.xml.internal.security.resource.config");
+-                        return getClass().getResourceAsStream
+-//                            (cfile != null ? cfile : "resource/config.xml");
+-                            ("resource/config.xml");
+-                    }
+-                });
+-
+             Document doc = db.parse(is);
+-            long XX_parsing_end = System.currentTimeMillis();
+-            long XX_configure_i18n_start = 0;
+-
+-            {
+-                XX_configure_reg_keyInfo_start = System.currentTimeMillis();
+-               try {
+-                  KeyInfo.init();
+-               } catch (Exception e) {
+-                  e.printStackTrace();
+-
+-                  throw e;
+-               }
+-               XX_configure_reg_keyInfo_end = System.currentTimeMillis();
+-            }
+-
+-                        long XX_configure_reg_transforms_start=0;
+-                        long XX_configure_reg_jcemapper_start=0;
+-                        long XX_configure_reg_sigalgos_start=0;
+-                        long XX_configure_reg_resourceresolver_end=0;
+-                        long XX_configure_reg_prefixes_end=0;
+-            Node config=doc.getFirstChild();
+-            for (;config!=null;config=config.getNextSibling()) {
++            Node config = doc.getFirstChild();
++            for (; config != null; config = config.getNextSibling()) {
+                 if ("Configuration".equals(config.getLocalName())) {
+-                        break;
++                    break;
+                 }
+             }
+-                        for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
+-                if (el.getNodeType() != Node.ELEMENT_NODE) {
+-                        continue;
++            if (config == null) {
++                log.log(java.util.logging.Level.SEVERE, "Error in reading configuration file - Configuration element not found");
++                return;
++            }
++            for (Node el = config.getFirstChild(); el != null; el = el.getNextSibling()) {
++                if (Node.ELEMENT_NODE != el.getNodeType()) {
++                    continue;
+                 }
+-                String tag=el.getLocalName();
+-//
+-// Commented out: not supported in the JDK. We use the default locale.
+-//
+-//            if (tag.equals("ResourceBundles")){
+-//                XX_configure_i18n_start = System.currentTimeMillis();
+-//                Element resource=(Element)el;
+-//               /* configure internationalization */
+-//               Attr langAttr = resource.getAttributeNode("defaultLanguageCode");
+-//               Attr countryAttr = resource.getAttributeNode("defaultCountryCode");
+-//               String languageCode = (langAttr == null)
+-//                                     ? null
+-//                                     : langAttr.getNodeValue();
+-//               String countryCode = (countryAttr == null)
+-//                                    ? null
+-//                                    : countryAttr.getNodeValue();
+-//
+-//               I18n.init(languageCode, countryCode);
+-//               XX_configure_i18n_end = System.currentTimeMillis();
+-//            }
++                String tag = el.getLocalName();
++                if (tag.equals("ResourceBundles")) {
++                    Element resource = (Element)el;
++                    /* configure internationalization */
++                    Attr langAttr = resource.getAttributeNode("defaultLanguageCode");
++                    Attr countryAttr = resource.getAttributeNode("defaultCountryCode");
++                    String languageCode =
++                        (langAttr == null) ? null : langAttr.getNodeValue();
++                    String countryCode =
++                        (countryAttr == null) ? null : countryAttr.getNodeValue();
++                    I18n.init(languageCode, countryCode);
++                }
+ 
+-            if (tag.equals("CanonicalizationMethods")){
+-                XX_configure_reg_c14n_start = System.currentTimeMillis();
+-               Canonicalizer.init();
+-               Element[] list=XMLUtils.selectNodes(el.getFirstChild(),CONF_NS,"CanonicalizationMethod");
++                if (tag.equals("CanonicalizationMethods")) {
++                    Element[] list =
++                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "CanonicalizationMethod");
+ 
+-               for (int i = 0; i < list.length; i++) {
+-                  String URI = list[i].getAttributeNS(null,
+-                                  "URI");
+-                  String JAVACLASS =
+-                     list[i].getAttributeNS(null,
+-                        "JAVACLASS");
+-                  try {
+-                      Class.forName(JAVACLASS);
+-/*                     Method methods[] = c.getMethods();
++                    for (int i = 0; i < list.length; i++) {
++                        String uri = list[i].getAttributeNS(null, "URI");
++                        String javaClass =
++                            list[i].getAttributeNS(null, "JAVACLASS");
++                        try {
++                            Canonicalizer.register(uri, javaClass);
++                            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                                log.log(java.util.logging.Level.FINE, "Canonicalizer.register(" + uri + ", " + javaClass + ")");
++                            }
++                        } catch (ClassNotFoundException e) {
++                            Object exArgs[] = { uri, javaClass };
++                            log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist", exArgs));
++                        }
++                    }
++                }
+ 
+-                     for (int j = 0; j < methods.length; j++) {
+-                        Method currMeth = methods[j];
++                if (tag.equals("TransformAlgorithms")) {
++                    Element[] tranElem =
++                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "TransformAlgorithm");
+ 
+-                        if (currMeth.getDeclaringClass().getName()
+-                                .equals(JAVACLASS)) {
+-                           log.log(java.util.logging.Level.FINE, currMeth.getDe claringClass().toString());
++                    for (int i = 0; i < tranElem.length; i++) {
++                        String uri = tranElem[i].getAttributeNS(null, "URI");
++                        String javaClass =
++                            tranElem[i].getAttributeNS(null, "JAVACLASS");
++                        try {
++                            Transform.register(uri, javaClass);
++                            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                                log.log(java.util.logging.Level.FINE, "Transform.register(" + uri + ", " + javaClass + ")");
++                            }
++                        } catch (ClassNotFoundException e) {
++                            Object exArgs[] = { uri, javaClass };
++
++                            log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist", exArgs));
++                        } catch (NoClassDefFoundError ex) {
++                            log.log(java.util.logging.Level.WARNING, "Not able to found dependencies for algorithm, I'll keep working.");
+                         }
+-                     }*/
+-                      if (log.isLoggable(java.util.logging.Level.FINE))
+-                        log.log(java.util.logging.Level.FINE, "Canonicalizer.register(" + URI + ", "
+-                            + JAVACLASS + ")");
+-                     Canonicalizer.register(URI, JAVACLASS);
+-                  } catch (ClassNotFoundException e) {
+-                     Object exArgs[] = { URI, JAVACLASS };
++                    }
++                }
+ 
+-                     log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist",
+-                                              exArgs));
+-                  }
+-               }
+-               XX_configure_reg_c14n_end = System.currentTimeMillis();
++                if ("JCEAlgorithmMappings".equals(tag)) {
++                    Node algorithmsNode = ((Element)el).getElementsByTagName("Algorithms").item(0);
++                    if (algorithmsNode != null) {
++                        Element[] algorithms =
++                            XMLUtils.selectNodes(algorithmsNode.getFirstChild(), CONF_NS, "Algorithm");
++                        for (int i = 0; i < algorithms.length; i++) {
++                            Element element = algorithms[i];
++                            String id = element.getAttribute("URI");
++                            JCEMapper.register(id, new JCEMapper.Algorithm(element));
++                        }
++                    }
++                }
++
++                if (tag.equals("SignatureAlgorithms")) {
++                    Element[] sigElems =
++                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "SignatureAlgorithm");
++
++                    for (int i = 0; i < sigElems.length; i++) {
++                        String uri = sigElems[i].getAttributeNS(null, "URI");
++                        String javaClass =
++                            sigElems[i].getAttributeNS(null, "JAVACLASS");
++
++                        /** $todo$ handle registering */
++
++                        try {
++                            SignatureAlgorithm.register(uri, javaClass);
++                            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                                log.log(java.util.logging.Level.FINE, "SignatureAlgorithm.register(" + uri + ", "
++                                          + javaClass + ")");
++                            }
++                        } catch (ClassNotFoundException e) {
++                            Object exArgs[] = { uri, javaClass };
++
++                            log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist", exArgs));
++                        }
++                    }
++                }
++
++                if (tag.equals("ResourceResolvers")) {
++                    Element[]resolverElem =
++                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver");
++
++                    for (int i = 0; i < resolverElem.length; i++) {
++                        String javaClass =
++                            resolverElem[i].getAttributeNS(null, "JAVACLASS");
++                        String description =
++                            resolverElem[i].getAttributeNS(null, "DESCRIPTION");
++
++                        if ((description != null) && (description.length() > 0)) {
++                            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                                log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass + ": "
++                                          + description);
++                            }
++                        } else {
++                            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                                log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass
++                                          + ": For unknown purposes");
++                            }
++                        }
++                        try {
++                            ResourceResolver.register(javaClass);
++                        } catch (Throwable e) {
++                            log.log(java.util.logging.Level.WARNING,
++                                 "Cannot register:" + javaClass
++                                 + " perhaps some needed jars are not installed",
++                                 e
++                             );
++                        }
++                    }
++                }
++
++                if (tag.equals("KeyResolver")){
++                    Element[] resolverElem =
++                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "Resolver");
++                    List<String> classNames = new ArrayList<String>(resolverElem.length);
++                    for (int i = 0; i < resolverElem.length; i++) {
++                        String javaClass =
++                            resolverElem[i].getAttributeNS(null, "JAVACLASS");
++                        String description =
++                            resolverElem[i].getAttributeNS(null, "DESCRIPTION");
++
++                        if ((description != null) && (description.length() > 0)) {
++                            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                                log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass + ": "
++                                          + description);
++                            }
++                        } else {
++                            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                                log.log(java.util.logging.Level.FINE, "Register Resolver: " + javaClass
++                                          + ": For unknown purposes");
++                            }
++                        }
++                        classNames.add(javaClass);
++                    }
++                    KeyResolver.registerClassNames(classNames);
++                }
++
++
++                if (tag.equals("PrefixMappings")){
++                    if (log.isLoggable(java.util.logging.Level.FINE)) {
++                        log.log(java.util.logging.Level.FINE, "Now I try to bind prefixes:");
++                    }
++
++                    Element[] nl =
++                        XMLUtils.selectNodes(el.getFirstChild(), CONF_NS, "PrefixMapping");
++
++                    for (int i = 0; i < nl.length; i++) {
++                        String namespace = nl[i].getAttributeNS(null, "namespace");
++                        String prefix = nl[i].getAttributeNS(null, "prefix");
++                        if (log.isLoggable(java.util.logging.Level.FINE)) {
++                            log.log(java.util.logging.Level.FINE, "Now I try to bind " + prefix + " to " + namespace);
++                        }
++                        ElementProxy.setDefaultPrefix(namespace, prefix);
++                    }
++                }
+             }
+-
+-            if (tag.equals("TransformAlgorithms")){
+-               XX_configure_reg_transforms_start = System.currentTimeMillis();
+-               Transform.init();
+-
+-               Element[] tranElem = XMLUtils.selectNodes(el.getFirstChild(),CONF_NS,"TransformAlgorithm");
+-
+-               for (int i = 0; i < tranElem.length; i++) {
+-                  String URI = tranElem[i].getAttributeNS(null,
+-                                  "URI");
+-                  String JAVACLASS =
+-                     tranElem[i].getAttributeNS(null,
+-                        "JAVACLASS");
+-                  try {
+-                     Class.forName(JAVACLASS);
+-                     if (log.isLoggable(java.util.logging.Level.FINE))
+-                        log.log(java.util.logging.Level.FINE, "Transform.register(" + URI + ", " + JAVACLASS + ")");
+-                     Transform.register(URI, JAVACLASS);
+-                  } catch (ClassNotFoundException e) {
+-                     Object exArgs[] = { URI, JAVACLASS };
+-
+-                     log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist",
+-                                              exArgs));
+-
+-                  } catch (NoClassDefFoundError ex) {
+-                                          log.log(java.util.logging.Level.WARNING, "Not able to found dependecies for algorithm, I'm keep working.");
+-                  }
+-               }
+-               XX_configure_reg_transforms_end = System.currentTimeMillis();
+-            }
+-
+-
+-            if ("JCEAlgorithmMappings".equals(tag)){
+-               XX_configure_reg_jcemapper_start = System.currentTimeMillis();
+-               JCEMapper.init((Element)el);
+-               XX_configure_reg_jcemapper_end = System.currentTimeMillis();
+-            }
+-
+-
+-
+-            if (tag.equals("SignatureAlgorithms")){
+-               XX_configure_reg_sigalgos_start = System.currentTimeMillis();
+-               SignatureAlgorithm.providerInit();
+-
+-               Element[] sigElems = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,
+-                  "SignatureAlgorithm");
+-
+-               for (int i = 0; i < sigElems.length; i++) {
+-                  String URI = sigElems[i].getAttributeNS(null,
+-                                  "URI");
+-                  String JAVACLASS =
+-                    sigElems[i].getAttributeNS(null,
+-                        "JAVACLASS");
+-
+-                  /** $todo$ handle registering */
+-
+-                  try {
+-                      Class.forName(JAVACLASS);
+- //                    Method methods[] = c.getMethods();
+-
+-//                     for (int j = 0; j < methods.length; j++) {
+-//                        Method currMeth = methods[j];
+-//
+-//                        if (currMeth.getDeclaringClass().getName()
+-//                                .equals(JAVACLASS)) {
+-//                           log.log(java.util.logging.Level.FINE, currMeth.getDe claringClass().toString());
+-//                        }
+-//                     }
+-                      if (log.isLoggable(java.util.logging.Level.FINE))
+-                        log.log(java.util.logging.Level.FINE, "SignatureAlgorithm.register(" + URI + ", " + JAVACLASS + ")");
+-                     SignatureAlgorithm.register(URI, JAVACLASS);
+-                  } catch (ClassNotFoundException e) {
+-                     Object exArgs[] = { URI, JAVACLASS };
+-
+-                     log.log(java.util.logging.Level.SEVERE, I18n.translate("algorithm.classDoesNotExist",
+-                                              exArgs));
+-
+-                  }
+-               }
+-               XX_configure_reg_sigalgos_end = System.currentTimeMillis();
+-            }
+-
+-
+-
+-            if (tag.equals("ResourceResolvers")){
+-               XX_configure_reg_resourceresolver_start = System.currentTimeMillis();
+-               ResourceResolver.init();
+-
+-               Element[]resolverElem = XMLUtils.selectNodes(el.getFirstChild(),CONF_NS,
+-                  "Resolver");
+-
+-               for (int i = 0; i < resolverElem.length; i++) {
+-                  String JAVACLASS =
+-                      resolverElem[i].getAttributeNS(null,
+-                        "JAVACLASS");
+-                  String Description =
+-                     resolverElem[i].getAttributeNS(null,
+-                        "DESCRIPTION");
+-
+-                  if ((Description != null) && (Description.length() > 0)) {
+-                    if (log.isLoggable(java.util.logging.Level.FINE))
+-                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": " + Description);
+-                  } else {
+-                    if (log.isLoggable(java.util.logging.Level.FINE))
+-                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": For unknown purposes");
+-                  }
+-                                  try {
+-                                          ResourceResolver.register(JAVACLASS);
+-                                  } catch (Throwable e) {
+-                                          log.log(java.util.logging.Level.WARNING, "Cannot register:"+JAVACLASS+" perhaps some needed jars are not installed",e);
+-                                  }
+-                  XX_configure_reg_resourceresolver_end =
+-                    System.currentTimeMillis();
+-               }
+-
+-            }
+-
+-
+-
+-
+-
+-
+-            if (tag.equals("KeyResolver")){
+-               XX_configure_reg_keyResolver_start =System.currentTimeMillis();
+-               KeyResolver.init();
+-
+-               Element[] resolverElem = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,"Resolver");
+-
+-               for (int i = 0; i < resolverElem.length; i++) {
+-                  String JAVACLASS =
+-                     resolverElem[i].getAttributeNS(null,
+-                        "JAVACLASS");
+-                  String Description =
+-                     resolverElem[i].getAttributeNS(null,
+-                        "DESCRIPTION");
+-
+-                  if ((Description != null) && (Description.length() > 0)) {
+-                    if (log.isLoggable(java.util.logging.Level.FINE))
+-                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": " + Description);
+-                  } else {
+-                    if (log.isLoggable(java.util.logging.Level.FINE))
+-                        log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": For unknown purposes");
+-                  }
+-
+-                  KeyResolver.register(JAVACLASS);
+-               }
+-               XX_configure_reg_keyResolver_end = System.currentTimeMillis();
+-            }
+-
+-
+-            if (tag.equals("PrefixMappings")){
+-                XX_configure_reg_prefixes_start = System.currentTimeMillis();
+-                if (log.isLoggable(java.util.logging.Level.FINE))
+-                    log.log(java.util.logging.Level.FINE, "Now I try to bind prefixes:");
+-
+-               Element[] nl = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,"PrefixMapping");
+-
+-               for (int i = 0; i < nl.length; i++) {
+-                  String namespace = nl[i].getAttributeNS(null,
+-                                        "namespace");
+-                  String prefix = nl[i].getAttributeNS(null,
+-                                     "prefix");
+-                  if (log.isLoggable(java.util.logging.Level.FINE))
+-                      log.log(java.util.logging.Level.FINE, "Now I try to bind " + prefix + " to " + namespace);
+-                  com.sun.org.apache.xml.internal.security.utils.ElementProxy
+-                     .setDefaultPrefix(namespace, prefix);
+-               }
+-               XX_configure_reg_prefixes_end = System.currentTimeMillis();
+-            }
+-            }
+-
+-            long XX_init_end = System.currentTimeMillis();
+-
+-            //J-
+-            if (log.isLoggable(java.util.logging.Level.FINE)) {
+-                log.log(java.util.logging.Level.FINE, "XX_init                             " + ((int)(XX_init_end - XX_init_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_prng                           " + ((int)(XX_prng_end - XX_prng_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_parsing                        " + ((int)(XX_parsing_end - XX_parsing_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_configure_i18n                 " + ((int)(XX_configure_i18n_end- XX_configure_i18n_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_c14n             " + ((int)(XX_configure_reg_c14n_end- XX_configure_reg_c14n_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_jcemapper        " + ((int)(XX_configure_reg_jcemapper_end- XX_configure_reg_jcemapper_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_keyInfo          " + ((int)(XX_configure_reg_keyInfo_end- XX_configure_reg_keyInfo_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_keyResolver      " + ((int)(XX_configure_reg_keyResolver_end- XX_configure_reg_keyResolver_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_prefixes         " + ((int)(XX_configure_reg_prefixes_end- XX_configure_reg_prefixes_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_resourceresolver " + ((int)(XX_configure_reg_resourceresolver_end- XX_configure_reg_resourceresolver_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_sigalgos         " + ((int)(XX_configure_reg_sigalgos_end- XX_configure_reg_sigalgos_start)) + " ms");
+-                log.log(java.util.logging.Level.FINE, "  XX_configure_reg_transforms       " + ((int)(XX_configure_reg_transforms_end- XX_configure_reg_transforms_start)) + " ms");
+-            }
+-         } catch (Exception e) {
++        } catch (Exception e) {
+             log.log(java.util.logging.Level.SEVERE, "Bad: ", e);
+             e.printStackTrace();
+-         }
+-
+-   }
+-
++        }
++    }
+ 
+ }
++
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/JCEMapper.java
+@@ -2,167 +2,316 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-/*
+- * Copyright  1999-2004 The Apache Software Foundation.
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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
+  *
+- *  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
+  *
+- *      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.
+- *
++ * 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.
+  */
+ package com.sun.org.apache.xml.internal.security.algorithms;
+ 
++import java.util.Map;
++import java.util.concurrent.ConcurrentHashMap;
+ 
+-
+-import java.util.HashMap;
+-import java.util.Map;
+-
+-
+-import com.sun.org.apache.xml.internal.security.Init;
+-import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
++import com.sun.org.apache.xml.internal.security.encryption.XMLCipher;
++import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
+ import org.w3c.dom.Element;
+ 
+ 
+-
+ /**
+  * This class maps algorithm identifier URIs to JAVA JCE class names.
+- *
+- * @author $Author: mullan $
+  */
+ public class JCEMapper {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
++    /** {@link org.apache.commons.logging} logging facility */
++    private static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(JCEMapper.class.getName());
+ 
++    private static Map<String, Algorithm> algorithmsMap =
++        new ConcurrentHashMap<String, Algorithm>();
+ 
++    private static String providerName = null;
+ 
+-   private static Map uriToJCEName;
++    /**
++     * Method register
++     *
++     * @param id
++     * @param algorithm
++     */
++    public static void register(String id, Algorithm algorithm) {
++        algorithmsMap.put(id, algorithm);
++    }
+ 
+-   private static Map algorithmsMap;
++    /**
++     * This method registers the default algorithms.
++     */
++    public static void registerDefaultAlgorithms() {
++        algorithmsMap.put(
++            MessageDigestAlgorithm.ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5,
++            new Algorithm("", "MD5", "MessageDigest")
++        );
++        algorithmsMap.put(
++            MessageDigestAlgorithm.ALGO_ID_DIGEST_RIPEMD160,
++            new Algorithm("", "RIPEMD160", "MessageDigest")
++        );
++        algorithmsMap.put(
++            MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1,
++            new Algorithm("", "SHA-1", "MessageDigest")
++        );
++        algorithmsMap.put(
++            MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA256,
++            new Algorithm("", "SHA-256", "MessageDigest")
++        );
++        algorithmsMap.put(
++            MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA384,
++            new Algorithm("", "SHA-384", "MessageDigest")
++        );
++        algorithmsMap.put(
++            MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA512,
++            new Algorithm("", "SHA-512", "MessageDigest")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_SIGNATURE_DSA,
++            new Algorithm("", "SHA1withDSA", "Signature")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5,
++            new Algorithm("", "MD5withRSA", "Signature")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160,
++            new Algorithm("", "RIPEMD160withRSA", "Signature")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1,
++            new Algorithm("", "SHA1withRSA", "Signature")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256,
++            new Algorithm("", "SHA256withRSA", "Signature")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384,
++            new Algorithm("", "SHA384withRSA", "Signature")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512,
++            new Algorithm("", "SHA512withRSA", "Signature")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1,
++            new Algorithm("", "SHA1withECDSA", "Signature")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5,
++            new Algorithm("", "HmacMD5", "Mac")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160,
++            new Algorithm("", "HMACRIPEMD160", "Mac")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_SHA1,
++            new Algorithm("", "HmacSHA1", "Mac")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_SHA256,
++            new Algorithm("", "HmacSHA256", "Mac")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_SHA384,
++            new Algorithm("", "HmacSHA384", "Mac")
++        );
++        algorithmsMap.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_SHA512,
++            new Algorithm("", "HmacSHA512", "Mac")
++        );
++        algorithmsMap.put(
++            XMLCipher.TRIPLEDES,
++            new Algorithm("DESede", "DESede/CBC/ISO10126Padding", "BlockEncryption", 192)
++        );
++        algorithmsMap.put(
++            XMLCipher.AES_128,
++            new Algorithm("AES", "AES/CBC/ISO10126Padding", "BlockEncryption", 128)
++        );
++        algorithmsMap.put(
++            XMLCipher.AES_192,
++            new Algorithm("AES", "AES/CBC/ISO10126Padding", "BlockEncryption", 192)
++        );
++        algorithmsMap.put(
++            XMLCipher.AES_256,
++            new Algorithm("AES", "AES/CBC/ISO10126Padding", "BlockEncryption", 256)
++        );
++        algorithmsMap.put(
++            XMLCipher.RSA_v1dot5,
++            new Algorithm("RSA", "RSA/ECB/PKCS1Padding", "KeyTransport")
++        );
++        algorithmsMap.put(
++            XMLCipher.RSA_OAEP,
++            new Algorithm("RSA", "RSA/ECB/OAEPPadding", "KeyTransport")
++        );
++        algorithmsMap.put(
++            XMLCipher.DIFFIE_HELLMAN,
++            new Algorithm("", "", "KeyAgreement")
++        );
++        algorithmsMap.put(
++            XMLCipher.TRIPLEDES_KeyWrap,
++            new Algorithm("DESede", "DESedeWrap", "SymmetricKeyWrap", 192)
++        );
++        algorithmsMap.put(
++            XMLCipher.AES_128_KeyWrap,
++            new Algorithm("AES", "AESWrap", "SymmetricKeyWrap", 128)
++        );
++        algorithmsMap.put(
++            XMLCipher.AES_192_KeyWrap,
++            new Algorithm("AES", "AESWrap", "SymmetricKeyWrap", 192)
++        );
++        algorithmsMap.put(
++            XMLCipher.AES_256_KeyWrap,
++            new Algorithm("AES", "AESWrap", "SymmetricKeyWrap", 256)
++        );
++    }
+ 
+-   private static String providerName = null;
+-   /**
+-    * Method init
+-    *
+-    * @param mappingElement
+-    * @throws Exception
+-    */
+-   public static void init(Element mappingElement) throws Exception {
++    /**
++     * Method translateURItoJCEID
++     *
++     * @param algorithmURI
++     * @return the JCE standard name corresponding to the given URI
++     */
++    public static String translateURItoJCEID(String algorithmURI) {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Request for URI " + algorithmURI);
++        }
+ 
+-      loadAlgorithms((Element)mappingElement.getElementsByTagName("Algorithms").item(0));
+-   }
++        Algorithm algorithm = algorithmsMap.get(algorithmURI);
++        if (algorithm != null) {
++            return algorithm.jceName;
++        }
++        return null;
++    }
+ 
+-   static void loadAlgorithms( Element algorithmsEl) {
+-       Element[] algorithms = XMLUtils.selectNodes(algorithmsEl.getFirstChild(),Init.CONF_NS,"Algorithm");
+-       uriToJCEName = new HashMap( algorithms.length * 2);
+-       algorithmsMap = new HashMap( algorithms.length * 2);
+-       for (int i = 0 ;i < algorithms.length ;i ++) {
+-           Element el = algorithms[i];
+-           String id = el.getAttribute("URI");
+-           String jceName = el.getAttribute("JCEName");
+-           uriToJCEName.put(id, jceName);
+-           algorithmsMap.put(id, new Algorithm(el));
+-       }
++    /**
++     * Method getAlgorithmClassFromURI
++     * @param algorithmURI
++     * @return the class name that implements this algorithm
++     */
++    public static String getAlgorithmClassFromURI(String algorithmURI) {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Request for URI " + algorithmURI);
++        }
+ 
+-   }
++        Algorithm algorithm = algorithmsMap.get(algorithmURI);
++        if (algorithm != null) {
++            return algorithm.algorithmClass;
++        }
++        return null;
++    }
+ 
+-   static Algorithm getAlgorithmMapping(String algoURI) {
+-           return ((Algorithm)algorithmsMap.get(algoURI));
+-   }
++    /**
++     * Returns the keylength in bits for a particular algorithm.
++     *
++     * @param algorithmURI
++     * @return The length of the key used in the algorithm
++     */
++    public static int getKeyLengthFromURI(String algorithmURI) {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Request for URI " + algorithmURI);
++        }
++        Algorithm algorithm = algorithmsMap.get(algorithmURI);
++        if (algorithm != null) {
++            return algorithm.keyLength;
++        }
++        return 0;
++    }
+ 
+-   /**
+-    * Method translateURItoJCEID
+-    *
+-    * @param AlgorithmURI
+-    * @return the JCE standard name corresponding to the given URI
+-    *
+-    */
+-   public static String translateURItoJCEID(String AlgorithmURI) {
+-      if (log.isLoggable(java.util.logging.Level.FINE))
+-          log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
++    /**
++     * Method getJCEKeyAlgorithmFromURI
++     *
++     * @param algorithmURI
++     * @return The KeyAlgorithm for the given URI.
++     */
++    public static String getJCEKeyAlgorithmFromURI(String algorithmURI) {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Request for URI " + algorithmURI);
++        }
++        Algorithm algorithm = algorithmsMap.get(algorithmURI);
++        if (algorithm != null) {
++            return algorithm.requiredKey;
++        }
++        return null;
++    }
+ 
+-      String jceName = (String) uriToJCEName.get(AlgorithmURI);
+-      return jceName;
+-   }
++    /**
++     * Gets the default Provider for obtaining the security algorithms
++     * @return the default providerId.
++     */
++    public static String getProviderId() {
++        return providerName;
++    }
+ 
+-   /**
+-    * Method getAlgorithmClassFromURI
+-    * NOTE(Raul Benito) It seems a buggy function the loop doesn't do
+-    * anything??
+-    * @param AlgorithmURI
+-    * @return the class name that implements this algorithm
+-    *
+-    */
+-   public static String getAlgorithmClassFromURI(String AlgorithmURI) {
+-       if (log.isLoggable(java.util.logging.Level.FINE))
+-           log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
++    /**
++     * Sets the default Provider for obtaining the security algorithms
++     * @param provider the default providerId.
++     */
++    public static void setProviderId(String provider) {
++        providerName = provider;
++    }
+ 
+-       return ((Algorithm) algorithmsMap.get(AlgorithmURI)).algorithmClass;
+-   }
++    /**
++     * Represents the Algorithm xml element
++     */
++    public static class Algorithm {
+ 
+-   /**
+-    * Returns the keylength in bit for a particular algorithm.
+-    *
+-    * @param AlgorithmURI
+-    * @return The length of the key used in the alogrithm
+-    */
+-   public static int getKeyLengthFromURI(String AlgorithmURI) {
+-       return Integer.parseInt(((Algorithm) algorithmsMap.get(AlgorithmURI)).keyLength);
+-   }
++        final String requiredKey;
++        final String jceName;
++        final String algorithmClass;
++        final int keyLength;
+ 
+-   /**
+-    * Method getJCEKeyAlgorithmFromURI
+-    *
+-    * @param AlgorithmURI
+-    * @return The KeyAlgorithm for the given URI.
+-    *
+-    */
+-   public static String getJCEKeyAlgorithmFromURI(String AlgorithmURI) {
+-
+-        return  ((Algorithm) algorithmsMap.get(AlgorithmURI)).requiredKey;
+-
+-   }
+-
+-   /**
+-    * Gets the default Provider for obtaining the security algorithms
+-    * @return the default providerId.
+-    */
+-   public static String getProviderId() {
+-                return providerName;
+-   }
+-
+-   /**
+-    * Sets the default Provider for obtaining the security algorithms
+-    * @param provider the default providerId.
+-    */
+-   public static void setProviderId(String provider) {
+-                providerName=provider;
+-   }
+-
+-   /**
+-    * Represents the Algorithm xml element
+-    */
+-   public static class Algorithm {
+-            String algorithmClass;
+-            String keyLength;
+-            String requiredKey;
+         /**
+          * Gets data from element
+          * @param el
+          */
+         public Algorithm(Element el) {
+-                algorithmClass=el.getAttribute("AlgorithmClass");
+-            keyLength=el.getAttribute("KeyLength");
+-            requiredKey=el.getAttribute("RequiredKey");
++            requiredKey = el.getAttribute("RequiredKey");
++            jceName = el.getAttribute("JCEName");
++            algorithmClass = el.getAttribute("AlgorithmClass");
++            if (el.hasAttribute("KeyLength")) {
++                keyLength = Integer.parseInt(el.getAttribute("KeyLength"));
++            } else {
++                keyLength = 0;
++            }
+         }
+-   }
++
++        public Algorithm(String requiredKey, String jceName) {
++            this(requiredKey, jceName, null, 0);
++        }
++
++        public Algorithm(String requiredKey, String jceName, String algorithmClass) {
++            this(requiredKey, jceName, algorithmClass, 0);
++        }
++
++        public Algorithm(String requiredKey, String jceName, int keyLength) {
++            this(requiredKey, jceName, null, keyLength);
++        }
++
++        public Algorithm(String requiredKey, String jceName, String algorithmClass, int keyLength) {
++            this.requiredKey = requiredKey;
++            this.jceName = jceName;
++            this.algorithmClass = algorithmClass;
++            this.keyLength = keyLength;
++        }
++    }
++
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
+@@ -2,459 +2,446 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-/*
+- * Copyright  1999-2004 The Apache Software Foundation.
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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
+  *
+- *  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
+  *
+- *      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.
+- *
++ * 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.
+  */
+ package com.sun.org.apache.xml.internal.security.algorithms;
+ 
+-
+ import java.security.Key;
+ import java.security.SecureRandom;
+ import java.security.spec.AlgorithmParameterSpec;
+-import java.util.HashMap;
+ import java.util.Map;
++import java.util.concurrent.ConcurrentHashMap;
+ 
+ import com.sun.org.apache.xml.internal.security.algorithms.implementations.IntegrityHmac;
++import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureBaseRSA;
++import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureDSA;
++import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA;
+ import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
++import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
++import com.sun.org.apache.xml.internal.security.utils.ClassLoaderUtils;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
++import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ 
+-
+ /**
+- * Allows selection of digital signature's algorithm, private keys, other security parameters, and algorithm's ID.
++ * Allows selection of digital signature's algorithm, private keys, other
++ * security parameters, and algorithm's ID.
+  *
+  * @author Christian Geuer-Pollmann
+  */
+ public class SignatureAlgorithm extends Algorithm {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
++    /** {@link org.apache.commons.logging} logging facility */
++    private static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(SignatureAlgorithm.class.getName());
+ 
+-   /** Field _alreadyInitialized */
+-   static boolean _alreadyInitialized = false;
++    /** All available algorithm classes are registered here */
++    private static Map<String, Class<? extends SignatureAlgorithmSpi>> algorithmHash =
++        new ConcurrentHashMap<String, Class<? extends SignatureAlgorithmSpi>>();
+ 
+-   /** All available algorithm classes are registered here */
+-   static HashMap _algorithmHash = null;
++    /** Field signatureAlgorithm */
++    private final SignatureAlgorithmSpi signatureAlgorithm;
+ 
+-   static ThreadLocal instancesSigning=new ThreadLocal() {
+-           protected Object initialValue() {
+-                   return new HashMap();
+-           };
+-   };
++    private final String algorithmURI;
+ 
+-   static ThreadLocal instancesVerify=new ThreadLocal() {
+-           protected Object initialValue() {
+-                   return new HashMap();
+-           };
+-   };
++    /**
++     * Constructor SignatureAlgorithm
++     *
++     * @param doc
++     * @param algorithmURI
++     * @throws XMLSecurityException
++     */
++    public SignatureAlgorithm(Document doc, String algorithmURI) throws XMLSecurityException {
++        super(doc, algorithmURI);
++        this.algorithmURI = algorithmURI;
+ 
+-   static ThreadLocal keysSigning=new ThreadLocal() {
+-           protected Object initialValue() {
+-                   return new HashMap();
+-           };
+-   };
+-   static ThreadLocal keysVerify=new ThreadLocal() {
+-           protected Object initialValue() {
+-                   return new HashMap();
+-           };
+-   };
+-//   boolean isForSigning=false;
++        signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
++        signatureAlgorithm.engineGetContextFromElement(this._constructionElement);
++    }
+ 
+-   /** Field _signatureAlgorithm */
+-   protected SignatureAlgorithmSpi _signatureAlgorithm = null;
++    /**
++     * Constructor SignatureAlgorithm
++     *
++     * @param doc
++     * @param algorithmURI
++     * @param hmacOutputLength
++     * @throws XMLSecurityException
++     */
++    public SignatureAlgorithm(
++        Document doc, String algorithmURI, int hmacOutputLength
++    ) throws XMLSecurityException {
++        super(doc, algorithmURI);
++        this.algorithmURI = algorithmURI;
+ 
+-   private String algorithmURI;
++        signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
++        signatureAlgorithm.engineGetContextFromElement(this._constructionElement);
+ 
+-   /**
+-    * Constructor SignatureAlgorithm
+-    *
+-    * @param doc
+-    * @param algorithmURI
+-    * @throws XMLSecurityException
+-    */
+-   public SignatureAlgorithm(Document doc, String algorithmURI)
+-           throws XMLSecurityException {
+-      super(doc, algorithmURI);
+-      this.algorithmURI = algorithmURI;
+-   }
++        signatureAlgorithm.engineSetHMACOutputLength(hmacOutputLength);
++        ((IntegrityHmac)signatureAlgorithm).engineAddContextToElement(_constructionElement);
++    }
+ 
++    /**
++     * Constructor SignatureAlgorithm
++     *
++     * @param element
++     * @param baseURI
++     * @throws XMLSecurityException
++     */
++    public SignatureAlgorithm(Element element, String baseURI) throws XMLSecurityException {
++        this(element, baseURI, false);
++    }
+ 
+-   private void initializeAlgorithm(boolean isForSigning) throws XMLSignatureException {
+-           if (_signatureAlgorithm!=null) {
+-                   return;
+-           }
+-           _signatureAlgorithm=isForSigning ? getInstanceForSigning(algorithmURI) : getInstanceForVerify(algorithmURI);
+-                this._signatureAlgorithm
+-                      .engineGetContextFromElement(this._constructionElement);
+-   }
+-   private static SignatureAlgorithmSpi getInstanceForSigning(String algorithmURI) throws XMLSignatureException {
+-           SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesSigning.get()).get(algorithmURI);
+-           if (result!=null) {
+-                   result.reset();
+-                   return result;
+-           }
+-           result=buildSigner(algorithmURI, result);
+-           ((Map)instancesSigning.get()).put(algorithmURI,result);
+-           return result;
+-   }
+-   private static SignatureAlgorithmSpi getInstanceForVerify(String algorithmURI) throws XMLSignatureException {
+-           SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesVerify.get()).get(algorithmURI);
+-           if (result!=null) {
+-                   result.reset();
+-                   return result;
+-           }
+-           result=buildSigner(algorithmURI, result);
+-           ((Map)instancesVerify.get()).put(algorithmURI,result);
+-           return result;
+-   }
++    /**
++     * Constructor SignatureAlgorithm
++     *
++     * @param element
++     * @param baseURI
++     * @param secureValidation
++     * @throws XMLSecurityException
++     */
++    public SignatureAlgorithm(
++        Element element, String baseURI, boolean secureValidation
++    ) throws XMLSecurityException {
++        super(element, baseURI);
++        algorithmURI = this.getURI();
+ 
+-   private static SignatureAlgorithmSpi buildSigner(String algorithmURI, SignatureAlgorithmSpi result) throws XMLSignatureException {
++        Attr attr = element.getAttributeNodeNS(null, "Id");
++        if (attr != null) {
++            element.setIdAttributeNode(attr, true);
++        }
++
++        if (secureValidation && (XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5.equals(algorithmURI)
++            || XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5.equals(algorithmURI))) {
++            Object exArgs[] = { algorithmURI };
++
++            throw new XMLSecurityException("signature.signatureAlgorithm", exArgs);
++        }
++
++        signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
++        signatureAlgorithm.engineGetContextFromElement(this._constructionElement);
++    }
++
++    /**
++     * Get a SignatureAlgorithmSpi object corresponding to the algorithmURI argument
++     */
++    private static SignatureAlgorithmSpi getSignatureAlgorithmSpi(String algorithmURI)
++        throws XMLSignatureException {
+         try {
+-         Class implementingClass =
+-            SignatureAlgorithm.getImplementingClass(algorithmURI);
+-         if (log.isLoggable(java.util.logging.Level.FINE))
++            Class<? extends SignatureAlgorithmSpi> implementingClass =
++                algorithmHash.get(algorithmURI);
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
+                 log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
+                    + implementingClass + "\"");
+-         result=(SignatureAlgorithmSpi) implementingClass.newInstance();
+-         return   result;
+-      }  catch (IllegalAccessException ex) {
+-         Object exArgs[] = { algorithmURI, ex.getMessage() };
++            }
++            return implementingClass.newInstance();
++        }  catch (IllegalAccessException ex) {
++            Object exArgs[] = { algorithmURI, ex.getMessage() };
++            throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs, ex);
++        } catch (InstantiationException ex) {
++            Object exArgs[] = { algorithmURI, ex.getMessage() };
++            throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs, ex);
++        } catch (NullPointerException ex) {
++            Object exArgs[] = { algorithmURI, ex.getMessage() };
++            throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs, ex);
++        }
++    }
+ 
+-         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
+-                                         ex);
+-      } catch (InstantiationException ex) {
+-         Object exArgs[] = { algorithmURI, ex.getMessage() };
+ 
+-         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
+-                                         ex);
+-      } catch (NullPointerException ex) {
+-         Object exArgs[] = { algorithmURI, ex.getMessage() };
++    /**
++     * Proxy method for {@link java.security.Signature#sign()}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @return the result of the {@link java.security.Signature#sign()} method
++     * @throws XMLSignatureException
++     */
++    public byte[] sign() throws XMLSignatureException {
++        return signatureAlgorithm.engineSign();
++    }
+ 
+-         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
+-                                         ex);
+-      }
++    /**
++     * Proxy method for {@link java.security.Signature#getAlgorithm}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @return the result of the {@link java.security.Signature#getAlgorithm} method
++     */
++    public String getJCEAlgorithmString() {
++        return signatureAlgorithm.engineGetJCEAlgorithmString();
++    }
++
++    /**
++     * Method getJCEProviderName
++     *
++     * @return The Provider of this Signature Algorithm
++     */
++    public String getJCEProviderName() {
++        return signatureAlgorithm.engineGetJCEProviderName();
++    }
++
++    /**
++     * Proxy method for {@link java.security.Signature#update(byte[])}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @param input
++     * @throws XMLSignatureException
++     */
++    public void update(byte[] input) throws XMLSignatureException {
++        signatureAlgorithm.engineUpdate(input);
++    }
++
++    /**
++     * Proxy method for {@link java.security.Signature#update(byte)}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @param input
++     * @throws XMLSignatureException
++     */
++    public void update(byte input) throws XMLSignatureException {
++        signatureAlgorithm.engineUpdate(input);
++    }
++
++    /**
++     * Proxy method for {@link java.security.Signature#update(byte[], int, int)}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @param buf
++     * @param offset
++     * @param len
++     * @throws XMLSignatureException
++     */
++    public void update(byte buf[], int offset, int len) throws XMLSignatureException {
++        signatureAlgorithm.engineUpdate(buf, offset, len);
++    }
++
++    /**
++     * Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey)}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @param signingKey
++     * @throws XMLSignatureException
++     */
++    public void initSign(Key signingKey) throws XMLSignatureException {
++        signatureAlgorithm.engineInitSign(signingKey);
++    }
++
++    /**
++     * Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey,
++     * java.security.SecureRandom)}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @param signingKey
++     * @param secureRandom
++     * @throws XMLSignatureException
++     */
++    public void initSign(Key signingKey, SecureRandom secureRandom) throws XMLSignatureException {
++        signatureAlgorithm.engineInitSign(signingKey, secureRandom);
++    }
++
++    /**
++     * Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey)}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @param signingKey
++     * @param algorithmParameterSpec
++     * @throws XMLSignatureException
++     */
++    public void initSign(
++        Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
++    ) throws XMLSignatureException {
++        signatureAlgorithm.engineInitSign(signingKey, algorithmParameterSpec);
++    }
++
++    /**
++     * Proxy method for {@link java.security.Signature#setParameter(
++     * java.security.spec.AlgorithmParameterSpec)}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @param params
++     * @throws XMLSignatureException
++     */
++    public void setParameter(AlgorithmParameterSpec params) throws XMLSignatureException {
++        signatureAlgorithm.engineSetParameter(params);
++    }
++
++    /**
++     * Proxy method for {@link java.security.Signature#initVerify(java.security.PublicKey)}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @param verificationKey
++     * @throws XMLSignatureException
++     */
++    public void initVerify(Key verificationKey) throws XMLSignatureException {
++        signatureAlgorithm.engineInitVerify(verificationKey);
++    }
++
++    /**
++     * Proxy method for {@link java.security.Signature#verify(byte[])}
++     * which is executed on the internal {@link java.security.Signature} object.
++     *
++     * @param signature
++     * @return true if if the signature is valid.
++     *
++     * @throws XMLSignatureException
++     */
++    public boolean verify(byte[] signature) throws XMLSignatureException {
++        return signatureAlgorithm.engineVerify(signature);
++    }
++
++    /**
++     * Returns the URI representation of Transformation algorithm
++     *
++     * @return the URI representation of Transformation algorithm
++     */
++    public final String getURI() {
++        return _constructionElement.getAttributeNS(null, Constants._ATT_ALGORITHM);
++    }
++
++    /**
++     * Registers implementing class of the Transform algorithm with algorithmURI
++     *
++     * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>.
++     * @param implementingClass <code>implementingClass</code> the implementing class of
++     * {@link SignatureAlgorithmSpi}
++     * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
++     * @throws XMLSignatureException
++     */
++    @SuppressWarnings("unchecked")
++    public static void register(String algorithmURI, String implementingClass)
++       throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
++           XMLSignatureException {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
++        }
++
++        // are we already registered?
++        Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
++        if (registeredClass != null) {
++            Object exArgs[] = { algorithmURI, registeredClass };
++            throw new AlgorithmAlreadyRegisteredException(
++                "algorithm.alreadyRegistered", exArgs
++            );
++        }
++        try {
++            Class<? extends SignatureAlgorithmSpi> clazz =
++                (Class<? extends SignatureAlgorithmSpi>)
++                    ClassLoaderUtils.loadClass(implementingClass, SignatureAlgorithm.class);
++            algorithmHash.put(algorithmURI, clazz);
++        } catch (NullPointerException ex) {
++            Object exArgs[] = { algorithmURI, ex.getMessage() };
++            throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs, ex);
++        }
++    }
++
++    /**
++     * Registers implementing class of the Transform algorithm with algorithmURI
++     *
++     * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>.
++     * @param implementingClass <code>implementingClass</code> the implementing class of
++     * {@link SignatureAlgorithmSpi}
++     * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
++     * @throws XMLSignatureException
++     */
++    public static void register(String algorithmURI, Class<? extends SignatureAlgorithmSpi> implementingClass)
++       throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
++           XMLSignatureException {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
++        }
++
++        // are we already registered?
++        Class<? extends SignatureAlgorithmSpi> registeredClass = algorithmHash.get(algorithmURI);
++        if (registeredClass != null) {
++            Object exArgs[] = { algorithmURI, registeredClass };
++            throw new AlgorithmAlreadyRegisteredException(
++                "algorithm.alreadyRegistered", exArgs
++            );
++        }
++        algorithmHash.put(algorithmURI, implementingClass);
++    }
++
++    /**
++     * This method registers the default algorithms.
++     */
++    public static void registerDefaultAlgorithms() {
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_SHA1, IntegrityHmac.IntegrityHmacSHA1.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5,
++            SignatureBaseRSA.SignatureRSAMD5.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160,
++            SignatureBaseRSA.SignatureRSARIPEMD160.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256, SignatureBaseRSA.SignatureRSASHA256.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384, SignatureBaseRSA.SignatureRSASHA384.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512, SignatureBaseRSA.SignatureRSASHA512.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_RIPEMD160, IntegrityHmac.IntegrityHmacRIPEMD160.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_SHA256, IntegrityHmac.IntegrityHmacSHA256.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_SHA384, IntegrityHmac.IntegrityHmacSHA384.class
++        );
++        algorithmHash.put(
++            XMLSignature.ALGO_ID_MAC_HMAC_SHA512, IntegrityHmac.IntegrityHmacSHA512.class
++        );
++    }
++
++    /**
++     * Method getBaseNamespace
++     *
++     * @return URI of this element
++     */
++    public String getBaseNamespace() {
++        return Constants.SignatureSpecNS;
++    }
++
++    /**
++     * Method getBaseLocalName
++     *
++     * @return Local name
++     */
++    public String getBaseLocalName() {
++        return Constants._TAG_SIGNATUREMETHOD;
++    }
+ }
+-
+-   /**
+-    * Constructor SignatureAlgorithm
+-    *
+-    * @param doc
+-    * @param algorithmURI
+-    * @param HMACOutputLength
+-    * @throws XMLSecurityException
+-    */
+-   public SignatureAlgorithm(
+-           Document doc, String algorithmURI, int HMACOutputLength)
+-              throws XMLSecurityException {
+-
+-      this(doc, algorithmURI);
+-      this.algorithmURI=algorithmURI;
+-      initializeAlgorithm(true);
+-      this._signatureAlgorithm.engineSetHMACOutputLength(HMACOutputLength);
+-      ((IntegrityHmac)this._signatureAlgorithm)
+-         .engineAddContextToElement(this._constructionElement);
+-   }
+-
+-   /**
+-    * Constructor SignatureAlgorithm
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @throws XMLSecurityException
+-    */
+-   public SignatureAlgorithm(Element element, String BaseURI)
+-           throws XMLSecurityException {
+-
+-      super(element, BaseURI);
+-      algorithmURI = this.getURI();
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#sign()}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @return the result of the {@link java.security.Signature#sign()} method
+-    * @throws XMLSignatureException
+-    */
+-   public byte[] sign() throws XMLSignatureException {
+-      return this._signatureAlgorithm.engineSign();
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#getAlgorithm}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @return the result of the {@link java.security.Signature#getAlgorithm} method
+-    */
+-   public String getJCEAlgorithmString() {
+-      try {
+-                return getInstanceForVerify(algorithmURI).engineGetJCEAlgorithmString();
+-        } catch (XMLSignatureException e) {
+-                //Ignore.
+-                return null;
+-        }
+-   }
+-
+-   /**
+-    * Method getJCEProviderName
+-    *
+-    * @return The Provider of this Signature Alogrithm
+-    */
+-   public String getJCEProviderName() {
+-      try {
+-                return getInstanceForVerify(algorithmURI).engineGetJCEProviderName();
+-        } catch (XMLSignatureException e) {
+-                return null;
+-        }
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#update(byte[])}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @param input
+-    * @throws XMLSignatureException
+-    */
+-   public void update(byte[] input) throws XMLSignatureException {
+-      this._signatureAlgorithm.engineUpdate(input);
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#update(byte)}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @param input
+-    * @throws XMLSignatureException
+-    */
+-   public void update(byte input) throws XMLSignatureException {
+-      this._signatureAlgorithm.engineUpdate(input);
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#update(byte[], int, int)}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @param buf
+-    * @param offset
+-    * @param len
+-    * @throws XMLSignatureException
+-    */
+-   public void update(byte buf[], int offset, int len)
+-           throws XMLSignatureException {
+-      this._signatureAlgorithm.engineUpdate(buf, offset, len);
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey)}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @param signingKey
+-    * @throws XMLSignatureException
+-    */
+-   public void initSign(Key signingKey) throws XMLSignatureException {
+-           initializeAlgorithm(true);
+-           Map map=(Map)keysSigning.get();
+-       if (map.get(this.algorithmURI)==signingKey) {
+-           return;
+-       }
+-       map.put(this.algorithmURI,signingKey);
+-           this._signatureAlgorithm.engineInitSign(signingKey);
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey, java.security.SecureRandom)}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @param signingKey
+-    * @param secureRandom
+-    * @throws XMLSignatureException
+-    */
+-   public void initSign(Key signingKey, SecureRandom secureRandom)
+-           throws XMLSignatureException {
+-           initializeAlgorithm(true);
+-      this._signatureAlgorithm.engineInitSign(signingKey, secureRandom);
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey)}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @param signingKey
+-    * @param algorithmParameterSpec
+-    * @throws XMLSignatureException
+-    */
+-   public void initSign(
+-           Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
+-              throws XMLSignatureException {
+-           initializeAlgorithm(true);
+-      this._signatureAlgorithm.engineInitSign(signingKey,
+-                                              algorithmParameterSpec);
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#setParameter(java.security.spec.AlgorithmParameterSpec)}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @param params
+-    * @throws XMLSignatureException
+-    */
+-   public void setParameter(AlgorithmParameterSpec params)
+-           throws XMLSignatureException {
+-      this._signatureAlgorithm.engineSetParameter(params);
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#initVerify(java.security.PublicKey)}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @param verificationKey
+-    * @throws XMLSignatureException
+-    */
+-   public void initVerify(Key verificationKey) throws XMLSignatureException {
+-           initializeAlgorithm(false);
+-           Map map=(Map)keysVerify.get();
+-           if (map.get(this.algorithmURI)==verificationKey) {
+-           return;
+-       }
+-           map.put(this.algorithmURI,verificationKey);
+-           this._signatureAlgorithm.engineInitVerify(verificationKey);
+-   }
+-
+-   /**
+-    * Proxy method for {@link java.security.Signature#verify(byte[])}
+-    * which is executed on the internal {@link java.security.Signature} object.
+-    *
+-    * @param signature
+-    * @return true if if the signature is valid.
+-    *
+-    * @throws XMLSignatureException
+-    */
+-   public boolean verify(byte[] signature) throws XMLSignatureException {
+-      return this._signatureAlgorithm.engineVerify(signature);
+-   }
+-
+-   /**
+-    * Returns the URI representation of Transformation algorithm
+-    *
+-    * @return the URI representation of Transformation algorithm
+-    */
+-   public final String getURI() {
+-      return this._constructionElement.getAttributeNS(null,
+-              Constants._ATT_ALGORITHM);
+-   }
+-
+-   /**
+-    * Initalizes for this {@link com.sun.org.apache.xml.internal.security.transforms.Transform}
+-    *
+-    */
+-   public static void providerInit() {
+-
+-      if (SignatureAlgorithm.log == null) {
+-         SignatureAlgorithm.log =
+-            java.util.logging.Logger
+-               .getLogger(SignatureAlgorithm.class.getName());
+-      }
+-
+-      log.log(java.util.logging.Level.FINE, "Init() called");
+-
+-      if (!SignatureAlgorithm._alreadyInitialized) {
+-         SignatureAlgorithm._algorithmHash = new HashMap(10);
+-         SignatureAlgorithm._alreadyInitialized = true;
+-      }
+-   }
+-
+-   /**
+-    * Registers implementing class of the Transform algorithm with algorithmURI
+-    *
+-    * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>.
+-    * @param implementingClass <code>implementingClass</code> the implementing class of {@link SignatureAlgorithmSpi}
+-    * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
+-    * @throws XMLSignatureException
+-    */
+-   public static void register(String algorithmURI, String implementingClass)
+-           throws AlgorithmAlreadyRegisteredException,XMLSignatureException {
+-
+-      {
+-         if (log.isLoggable(java.util.logging.Level.FINE))
+-                log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
+-
+-         // are we already registered?
+-         Class registeredClassClass =
+-            SignatureAlgorithm.getImplementingClass(algorithmURI);
+-                 if (registeredClassClass!=null) {
+-                         String registeredClass = registeredClassClass.getName();
+-
+-                         if ((registeredClass != null) && (registeredClass.length() != 0)) {
+-                                 Object exArgs[] = { algorithmURI, registeredClass };
+-
+-                                 throw new AlgorithmAlreadyRegisteredException(
+-                                                 "algorithm.alreadyRegistered", exArgs);
+-                         }
+-                 }
+-                 try {
+-                         SignatureAlgorithm._algorithmHash.put(algorithmURI, Class.forName(implementingClass));
+-              } catch (ClassNotFoundException ex) {
+-                 Object exArgs[] = { algorithmURI, ex.getMessage() };
+-
+-                 throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
+-                                                 ex);
+-              } catch (NullPointerException ex) {
+-                 Object exArgs[] = { algorithmURI, ex.getMessage() };
+-
+-                 throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
+-                                                 ex);
+-              }
+-
+-      }
+-   }
+-
+-   /**
+-    * Method getImplementingClass
+-    *
+-    * @param URI
+-    * @return the class that implements the URI
+-    */
+-   private static Class getImplementingClass(String URI) {
+-
+-      if (SignatureAlgorithm._algorithmHash == null) {
+-         return null;
+-      }
+-
+-      return (Class) SignatureAlgorithm._algorithmHash.get(URI);
+-   }
+-
+-   /**
+-    * Method getBaseNamespace
+-    *
+-    * @return URI of this element
+-    */
+-   public String getBaseNamespace() {
+-      return Constants.SignatureSpecNS;
+-   }
+-
+-   /**
+-    * Method getBaseLocalName
+-    *
+-    * @return Local name
+-    */
+-   public String getBaseLocalName() {
+-      return Constants._TAG_SIGNATUREMETHOD;
+-   }
+-}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/Canonicalizer.java
+@@ -2,33 +2,43 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-/*
+- * Copyright  1999-2008 The Apache Software Foundation.
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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
+  *
+- *  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
+  *
+- *      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.
+- *
++ * 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.
+  */
+ package com.sun.org.apache.xml.internal.security.c14n;
+ 
+ import java.io.ByteArrayInputStream;
++import java.io.InputStream;
+ import java.io.OutputStream;
+-import java.util.HashMap;
+ import java.util.Map;
+ import java.util.Set;
++import java.util.concurrent.ConcurrentHashMap;
+ 
++import javax.xml.XMLConstants;
+ import javax.xml.parsers.DocumentBuilder;
+ import javax.xml.parsers.DocumentBuilderFactory;
+ 
++import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_OmitComments;
++import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer11_WithComments;
++import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclOmitComments;
++import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclWithComments;
++import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315OmitComments;
++import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315WithComments;
+ import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Node;
+@@ -45,7 +55,7 @@
+     public static final String ENCODING = "UTF8";
+ 
+     /**
+-     * XPath Expresion for selecting every node and continuous comments joined
++     * XPath Expression for selecting every node and continuous comments joined
+      * in only one node
+      */
+     public static final String XPATH_C14N_WITH_COMMENTS_SINGLE_NODE =
+@@ -82,22 +92,10 @@
+     public static final String ALGO_ID_C14N11_WITH_COMMENTS =
+         ALGO_ID_C14N11_OMIT_COMMENTS + "#WithComments";
+ 
+-    static boolean _alreadyInitialized = false;
+-    static Map _canonicalizerHash = null;
++    private static Map<String, Class<? extends CanonicalizerSpi>> canonicalizerHash =
++        new ConcurrentHashMap<String, Class<? extends CanonicalizerSpi>>();
+ 
+-    protected CanonicalizerSpi canonicalizerSpi = null;
+-
+-    /**
+-     * Method init
+-     *
+-     */
+-    public static void init() {
+-
+-        if (!Canonicalizer._alreadyInitialized) {
+-            Canonicalizer._canonicalizerHash = new HashMap(10);
+-            Canonicalizer._alreadyInitialized = true;
+-        }
+-    }
++    private final CanonicalizerSpi canonicalizerSpi;
+ 
+     /**
+      * Constructor Canonicalizer
+@@ -105,20 +103,18 @@
+      * @param algorithmURI
+      * @throws InvalidCanonicalizerException
+      */
+-    private Canonicalizer(String algorithmURI)
+-           throws InvalidCanonicalizerException {
++    private Canonicalizer(String algorithmURI) throws InvalidCanonicalizerException {
++        try {
++            Class<? extends CanonicalizerSpi> implementingClass =
++                canonicalizerHash.get(algorithmURI);
+ 
+-        try {
+-            Class implementingClass = getImplementingClass(algorithmURI);
+-
+-            this.canonicalizerSpi =
+-                (CanonicalizerSpi) implementingClass.newInstance();
+-            this.canonicalizerSpi.reset=true;
++            canonicalizerSpi = implementingClass.newInstance();
++            canonicalizerSpi.reset = true;
+         } catch (Exception e) {
+             Object exArgs[] = { algorithmURI };
+-
+             throw new InvalidCanonicalizerException(
+-               "signature.Canonicalizer.UnknownCanonicalizer", exArgs);
++                "signature.Canonicalizer.UnknownCanonicalizer", exArgs, e
++            );
+         }
+     }
+ 
+@@ -126,15 +122,12 @@
+      * Method getInstance
+      *
+      * @param algorithmURI
+-     * @return a Conicicalizer instance ready for the job
++     * @return a Canonicalizer instance ready for the job
+      * @throws InvalidCanonicalizerException
+      */
+     public static final Canonicalizer getInstance(String algorithmURI)
+-           throws InvalidCanonicalizerException {
+-
+-        Canonicalizer c14nizer = new Canonicalizer(algorithmURI);
+-
+-        return c14nizer;
++        throws InvalidCanonicalizerException {
++        return new Canonicalizer(algorithmURI);
+     }
+ 
+     /**
+@@ -144,24 +137,71 @@
+      * @param implementingClass
+      * @throws AlgorithmAlreadyRegisteredException
+      */
++    @SuppressWarnings("unchecked")
+     public static void register(String algorithmURI, String implementingClass)
+-           throws AlgorithmAlreadyRegisteredException {
+-
++        throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
+         // check whether URI is already registered
+-        Class registeredClass = getImplementingClass(algorithmURI);
++        Class<? extends CanonicalizerSpi> registeredClass =
++            canonicalizerHash.get(algorithmURI);
+ 
+         if (registeredClass != null)  {
+             Object exArgs[] = { algorithmURI, registeredClass };
+-
+-            throw new AlgorithmAlreadyRegisteredException(
+-                "algorithm.alreadyRegistered", exArgs);
++            throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
+         }
+ 
+-        try {
+-            _canonicalizerHash.put(algorithmURI, Class.forName(implementingClass));
+-        } catch (ClassNotFoundException e) {
+-            throw new RuntimeException("c14n class not found");
++        canonicalizerHash.put(
++            algorithmURI, (Class<? extends CanonicalizerSpi>)Class.forName(implementingClass)
++        );
++    }
++
++    /**
++     * Method register
++     *
++     * @param algorithmURI
++     * @param implementingClass
++     * @throws AlgorithmAlreadyRegisteredException
++     */
++    public static void register(String algorithmURI, Class<CanonicalizerSpi> implementingClass)
++        throws AlgorithmAlreadyRegisteredException, ClassNotFoundException {
++        // check whether URI is already registered
++        Class<? extends CanonicalizerSpi> registeredClass = canonicalizerHash.get(algorithmURI);
++
++        if (registeredClass != null)  {
++            Object exArgs[] = { algorithmURI, registeredClass };
++            throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
+         }
++
++        canonicalizerHash.put(algorithmURI, implementingClass);
++    }
++
++    /**
++     * This method registers the default algorithms.
++     */
++    public static void registerDefaultAlgorithms() {
++        canonicalizerHash.put(
++            Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS,
++            Canonicalizer20010315OmitComments.class
++        );
++        canonicalizerHash.put(
++            Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS,
++            Canonicalizer20010315WithComments.class
++        );
++        canonicalizerHash.put(
++            Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS,
++            Canonicalizer20010315ExclOmitComments.class
++        );
++        canonicalizerHash.put(
++            Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS,
++            Canonicalizer20010315ExclWithComments.class
++        );
++        canonicalizerHash.put(
++            Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS,
++            Canonicalizer11_OmitComments.class
++        );
++        canonicalizerHash.put(
++            Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS,
++            Canonicalizer11_WithComments.class
++        );
+     }
+ 
+     /**
+@@ -170,7 +210,7 @@
+      * @return the URI defined for this c14n instance.
+      */
+     public final String getURI() {
+-        return this.canonicalizerSpi.engineGetURI();
++        return canonicalizerSpi.engineGetURI();
+     }
+ 
+     /**
+@@ -179,7 +219,7 @@
+      * @return true if the c14n respect the comments.
+      */
+     public boolean getIncludeComments() {
+-        return this.canonicalizerSpi.engineGetIncludeComments();
++        return canonicalizerSpi.engineGetIncludeComments();
+     }
+ 
+     /**
+@@ -188,33 +228,32 @@
+      * wrapped with a <CODE>&gt;a&lt;...&gt;/a&lt;</CODE>.
+      *
+      * @param inputBytes
+-     * @return the result of the conicalization.
++     * @return the result of the canonicalization.
+      * @throws CanonicalizationException
+      * @throws java.io.IOException
+      * @throws javax.xml.parsers.ParserConfigurationException
+      * @throws org.xml.sax.SAXException
+      */
+     public byte[] canonicalize(byte[] inputBytes)
+-           throws javax.xml.parsers.ParserConfigurationException,
+-                  java.io.IOException, org.xml.sax.SAXException,
+-                  CanonicalizationException {
+-
+-        ByteArrayInputStream bais = new ByteArrayInputStream(inputBytes);
++        throws javax.xml.parsers.ParserConfigurationException,
++        java.io.IOException, org.xml.sax.SAXException, CanonicalizationException {
++        InputStream bais = new ByteArrayInputStream(inputBytes);
+         InputSource in = new InputSource(bais);
+         DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
++        dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+ 
+         dfactory.setNamespaceAware(true);
+ 
+-        // needs to validate for ID attribute nomalization
++        // needs to validate for ID attribute normalization
+         dfactory.setValidating(true);
+ 
+         DocumentBuilder db = dfactory.newDocumentBuilder();
+ 
+         /*
+          * for some of the test vectors from the specification,
+-         * there has to be a validatin parser for ID attributes, default
++         * there has to be a validating parser for ID attributes, default
+          * attribute values, NMTOKENS, etc.
+-         * Unfortunaltely, the test vectors do use different DTDs or
++         * Unfortunately, the test vectors do use different DTDs or
+          * even no DTD. So Xerces 1.3.1 fires many warnings about using
+          * ErrorHandlers.
+          *
+@@ -230,28 +269,23 @@
+          * declaration are used to help create the canonical form, even
+          * though the document type declaration is not retained in the
+          * canonical form.
+-         *
+          */
+-        db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils
+-            .IgnoreAllErrorHandler());
++        db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils.IgnoreAllErrorHandler());
+ 
+         Document document = db.parse(in);
+-        byte result[] = this.canonicalizeSubtree(document);
+-
+-        return result;
++        return this.canonicalizeSubtree(document);
+     }
+ 
+     /**
+      * Canonicalizes the subtree rooted by <CODE>node</CODE>.
+      *
+-     * @param node The node to canicalize
++     * @param node The node to canonicalize
+      * @return the result of the c14n.
+      *
+      * @throws CanonicalizationException
+      */
+-    public byte[] canonicalizeSubtree(Node node)
+-           throws CanonicalizationException {
+-        return this.canonicalizerSpi.engineCanonicalizeSubTree(node);
++    public byte[] canonicalizeSubtree(Node node) throws CanonicalizationException {
++        return canonicalizerSpi.engineCanonicalizeSubTree(node);
+     }
+ 
+     /**
+@@ -263,9 +297,8 @@
+      * @throws CanonicalizationException
+      */
+     public byte[] canonicalizeSubtree(Node node, String inclusiveNamespaces)
+-           throws CanonicalizationException {
+-        return this.canonicalizerSpi.engineCanonicalizeSubTree(node,
+-              inclusiveNamespaces);
++        throws CanonicalizationException {
++        return canonicalizerSpi.engineCanonicalizeSubTree(node, inclusiveNamespaces);
+     }
+ 
+     /**
+@@ -277,8 +310,8 @@
+      * @throws CanonicalizationException
+      */
+     public byte[] canonicalizeXPathNodeSet(NodeList xpathNodeSet)
+-           throws CanonicalizationException {
+-        return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
++        throws CanonicalizationException {
++        return canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
+     }
+ 
+     /**
+@@ -291,10 +324,10 @@
+      * @throws CanonicalizationException
+      */
+     public byte[] canonicalizeXPathNodeSet(
+-           NodeList xpathNodeSet, String inclusiveNamespaces)
+-              throws CanonicalizationException {
+-        return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
+-              inclusiveNamespaces);
++        NodeList xpathNodeSet, String inclusiveNamespaces
++    ) throws CanonicalizationException {
++        return
++            canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet, inclusiveNamespaces);
+     }
+ 
+     /**
+@@ -304,9 +337,9 @@
+      * @return the result of the c14n.
+      * @throws CanonicalizationException
+      */
+-    public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet)
+-           throws CanonicalizationException {
+-        return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
++    public byte[] canonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
++        throws CanonicalizationException {
++        return canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
+     }
+ 
+     /**
+@@ -317,10 +350,11 @@
+      * @return the result of the c14n.
+      * @throws CanonicalizationException
+      */
+-    public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet,
+-        String inclusiveNamespaces) throws CanonicalizationException {
+-        return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
+-            inclusiveNamespaces);
++    public byte[] canonicalizeXPathNodeSet(
++        Set<Node> xpathNodeSet, String inclusiveNamespaces
++    ) throws CanonicalizationException {
++        return
++            canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet, inclusiveNamespaces);
+     }
+ 
+     /**
+@@ -329,7 +363,7 @@
+      * @param os
+      */
+     public void setWriter(OutputStream os) {
+-        this.canonicalizerSpi.setWriter(os);
++        canonicalizerSpi.setWriter(os);
+     }
+ 
+     /**
+@@ -338,23 +372,14 @@
+      * @return the name of the implementing {@link CanonicalizerSpi} class
+      */
+     public String getImplementingCanonicalizerClass() {
+-        return this.canonicalizerSpi.getClass().getName();
+-    }
+-
+-    /**
+-     * Method getImplementingClass
+-     *
+-     * @param URI
+-     * @return the name of the class that implements the given URI
+-     */
+-    private static Class getImplementingClass(String URI) {
+-        return (Class) _canonicalizerHash.get(URI);
++        return canonicalizerSpi.getClass().getName();
+     }
+ 
+     /**
+      * Set the canonicalizer behaviour to not reset.
+      */
+     public void notReset() {
+-        this.canonicalizerSpi.reset = false;
++        canonicalizerSpi.reset = false;
+     }
++
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizerSpi.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizerSpi.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizerSpi.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/CanonicalizerSpi.java
+@@ -26,8 +26,10 @@
+ import java.io.OutputStream;
+ import java.util.Set;
+ 
++import javax.xml.XMLConstants;
+ import javax.xml.parsers.DocumentBuilder;
+ import javax.xml.parsers.DocumentBuilderFactory;
++import javax.xml.xpath.XPath;
+ 
+ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import org.w3c.dom.Document;
+@@ -66,6 +68,7 @@
+       java.io.ByteArrayInputStream bais = new ByteArrayInputStream(inputBytes);
+       InputSource in = new InputSource(bais);
+       DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
++      dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+ 
+       // needs to validate for ID attribute nomalization
+       dfactory.setNamespaceAware(true);
+@@ -151,7 +154,7 @@
+     * @return the c14n bytes
+     * @throws CanonicalizationException
+     */
+-   public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
++   public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
+       throws CanonicalizationException;
+ 
+    /**
+@@ -162,7 +165,7 @@
+     * @return the c14n bytes
+     * @throws CanonicalizationException
+     */
+-   public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces)
++   public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces)
+       throws CanonicalizationException;
+ 
+    /**
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java b/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/XMLCipher.java
+@@ -41,6 +41,7 @@
+ import javax.crypto.IllegalBlockSizeException;
+ import javax.crypto.NoSuchPaddingException;
+ import javax.crypto.spec.IvParameterSpec;
++import javax.xml.XMLConstants;
+ import javax.xml.parsers.DocumentBuilder;
+ import javax.xml.parsers.DocumentBuilderFactory;
+ import javax.xml.parsers.ParserConfigurationException;
+@@ -1981,22 +1982,23 @@
+             try {
+                 DocumentBuilderFactory dbf =
+                     DocumentBuilderFactory.newInstance();
+-                                dbf.setNamespaceAware(true);
+-                                dbf.setAttribute("http://xml.org/sax/features/namespaces", Boolean.TRUE);
+-                                DocumentBuilder db = dbf.newDocumentBuilder();
+-                                Document d = db.parse(
+-                                    new InputSource(new StringReader(fragment)));
+-
+-                                Element fragElt = (Element) _contextDocument.importNode(
++                dbf.setNamespaceAware(true);
++                dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
++                dbf.setAttribute("http://xml.org/sax/features/namespaces", Boolean.TRUE);
++                DocumentBuilder db = dbf.newDocumentBuilder();
++                Document d = db.parse(
++                    new InputSource(new StringReader(fragment)));
++
++                Element fragElt = (Element) _contextDocument.importNode(
+                                                  d.getDocumentElement(), true);
+-                                result = _contextDocument.createDocumentFragment();
+-                                Node child = fragElt.getFirstChild();
+-                                while (child != null) {
+-                                        fragElt.removeChild(child);
+-                                        result.appendChild(child);
+-                                        child = fragElt.getFirstChild();
+-                                }
+-                                // String outp = serialize(d);
++                result = _contextDocument.createDocumentFragment();
++                Node child = fragElt.getFirstChild();
++                while (child != null) {
++                    fragElt.removeChild(child);
++                    result.appendChild(child);
++                    child = fragElt.getFirstChild();
++                }
++                // String outp = serialize(d);
+ 
+             } catch (SAXException se) {
+                 throw new XMLEncryptionException("empty", se);
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/KeyInfo.java
+@@ -97,12 +97,12 @@
+    /** {@link java.util.logging} logging facility */
+     static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(KeyInfo.class.getName());
+-    List x509Datas=null;
+-    List encryptedKeys=null;
++    List<X509Data> x509Datas=null;
++    List<EncryptedKey> encryptedKeys=null;
+ 
+-    static final List nullList;
++    static final List<StorageResolver> nullList;
+     static {
+-        List list = new ArrayList();
++        List<StorageResolver> list = new ArrayList<StorageResolver>(1);
+         list.add(null);
+         nullList = Collections.unmodifiableList(list);
+     }
+@@ -297,7 +297,7 @@
+     */
+    public void add(X509Data x509data) {
+           if (x509Datas==null)
+-                  x509Datas=new ArrayList();
++                  x509Datas=new ArrayList<X509Data>();
+           x509Datas.add(x509data);
+          this._constructionElement.appendChild(x509data.getElement());
+          XMLUtils.addReturnToElement(this._constructionElement);
+@@ -313,7 +313,7 @@
+         public void add(EncryptedKey encryptedKey)
+                 throws XMLEncryptionException {
+                         if (encryptedKeys==null)
+-                                encryptedKeys=new ArrayList();
++                                encryptedKeys=new ArrayList<EncryptedKey>();
+                         encryptedKeys.add(encryptedKey);
+                         XMLCipher cipher = XMLCipher.getInstance();
+                         this._constructionElement.appendChild(cipher.martial(encryptedKey));
+@@ -541,7 +541,7 @@
+     */
+    public X509Data itemX509Data(int i) throws XMLSecurityException {
+            if (x509Datas!=null) {
+-                   return (X509Data) x509Datas.get(i);
++                   return x509Datas.get(i);
+            }
+       Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
+                                                 Constants._TAG_X509DATA,i);
+@@ -562,7 +562,7 @@
+ 
+         public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException {
+                 if (encryptedKeys!=null) {
+-                        return (EncryptedKey) encryptedKeys.get(i);
++                        return encryptedKeys.get(i);
+                 }
+                 Element e =
+                         XMLUtils.selectXencNode(this._constructionElement.getFirstChild(),
+@@ -719,42 +719,36 @@
+       return null;
+    }
+ 
+-   /**
+-    * Searches the library wide keyresolvers for public keys
+-    *
+-    * @return The publick contained in this Node.
+-    * @throws KeyResolverException
+-    */
+-   PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
+-          int length=KeyResolver.length();
+-          int storageLength=this._storageResolvers.size();
+-          Iterator it= KeyResolver.iterator();
+-      for (int i = 0; i < length; i++) {
+-         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+-         Node currentChild=this._constructionElement.getFirstChild();
+-         String uri= this.getBaseURI();
+-         while (currentChild!=null)      {
+-            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+-                  for (int k = 0; k < storageLength; k++) {
+-                     StorageResolver storage =
+-                        (StorageResolver) this._storageResolvers.get(k);
++    /**
++     * Searches the library wide keyresolvers for public keys
++     *
++     * @return The public key contained in this Node.
++     * @throws KeyResolverException
++     */
++    PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
++        Iterator<KeyResolverSpi> it = KeyResolver.iterator();
++        while (it.hasNext()) {
++            KeyResolverSpi keyResolver = it.next();
++            Node currentChild = this._constructionElement.getFirstChild();
++            String uri = this.getBaseURI();
++            while (currentChild != null) {
++                if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
++                    for (StorageResolver storage : _storageResolvers) {
++                        PublicKey pk =
++                            keyResolver.engineLookupAndResolvePublicKey(
++                                (Element) currentChild, uri, storage
++                            );
+ 
+-                     PublicKey pk =
+-                           keyResolver.engineLookupAndResolvePublicKey((Element) currentChild,
+-                                                       uri,
+-                                                        storage);
+-
+-                     if (pk != null) {
+-                         KeyResolver.hit(it);
+-                         return pk;
+-                     }
+-                  }
++                        if (pk != null) {
++                            return pk;
++                        }
++                    }
++                }
++                currentChild = currentChild.getNextSibling();
+             }
+-            currentChild=currentChild.getNextSibling();
+-         }
+-      }
+-      return null;
+-   }
++        }
++        return null;
++    }
+ 
+    /**
+     * Searches the per-KeyInfo keyresolvers for public keys
+@@ -776,7 +770,7 @@
+             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+                for (int k = 0; k < storageLength; k++) {
+                    StorageResolver storage =
+-                      (StorageResolver) this._storageResolvers.get(k);
++                       this._storageResolvers.get(k);
+                    PublicKey pk = keyResolver
+                            .engineLookupAndResolvePublicKey((Element) currentChild, uri, storage);
+ 
+@@ -829,81 +823,83 @@
+       return null;
+    }
+ 
+-   /**
+-    * This method uses each System-wide {@link KeyResolver} to search the
+-    * child elements. Each combination of {@link KeyResolver} and child element
+-    * is checked against all {@link StorageResolver}s.
+-    *
+-    * @return The certificate contined in this KeyInfo
+-    * @throws KeyResolverException
+-    */
+-   X509Certificate getX509CertificateFromStaticResolvers()
+-           throws KeyResolverException {
+-      if (log.isLoggable(java.util.logging.Level.FINE))
+-        log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromStaticResolvers() with "
+-                + KeyResolver.length() + " resolvers");
+-      String uri=this.getBaseURI();
+-      int length= KeyResolver.length();
+-      int storageLength=this._storageResolvers.size();
+-      Iterator it = KeyResolver.iterator();
+-      for (int i = 0; i <length; i++) {
+-         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+-         X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
+-         if (cert!=null) {
+-                 KeyResolver.hit(it);
+-                 return cert;
+-         }
+-      }
+-      return null;
+-   }
++    /**
++     * This method uses each System-wide {@link KeyResolver} to search the
++     * child elements. Each combination of {@link KeyResolver} and child element
++     * is checked against all {@link StorageResolver}s.
++     *
++     * @return The certificate contained in this KeyInfo
++     * @throws KeyResolverException
++     */
++    X509Certificate getX509CertificateFromStaticResolvers()
++        throws KeyResolverException {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE,
++                "Start getX509CertificateFromStaticResolvers() with " + KeyResolver.length()
++                + " resolvers"
++            );
++        }
++        String uri = this.getBaseURI();
++        Iterator<KeyResolverSpi> it = KeyResolver.iterator();
++        while (it.hasNext()) {
++            KeyResolverSpi keyResolver = it.next();
++            X509Certificate cert = applyCurrentResolver(uri, keyResolver);
++            if (cert != null) {
++                return cert;
++            }
++        }
++        return null;
++    }
+ 
+-   private X509Certificate applyCurrentResolver(String uri, int storageLength, KeyResolverSpi keyResolver) throws KeyResolverException {
+-           Node currentChild=this._constructionElement.getFirstChild();
+-           while (currentChild!=null)      {
+-                   if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+-               for (int k = 0; k < storageLength; k++) {
+-                   StorageResolver storage =
+-                      (StorageResolver) this._storageResolvers.get(k);
++    private X509Certificate applyCurrentResolver(
++        String uri, KeyResolverSpi keyResolver
++    ) throws KeyResolverException {
++        Node currentChild = this._constructionElement.getFirstChild();
++        while (currentChild != null)      {
++            if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
++                for (StorageResolver storage : _storageResolvers) {
++                    X509Certificate cert =
++                        keyResolver.engineLookupResolveX509Certificate(
++                            (Element) currentChild, uri, storage
++                        );
+ 
+-                   X509Certificate cert = keyResolver
+-                        .engineLookupResolveX509Certificate((Element) currentChild, uri,
+-                                        storage);
++                    if (cert != null) {
++                        return cert;
++                    }
++                }
++            }
++            currentChild = currentChild.getNextSibling();
++        }
++        return null;
++    }
+ 
+-                   if (cert != null) {
+-                       return cert;
+-                  }
+-               }
++    /**
++     * Method getX509CertificateFromInternalResolvers
++     *
++     * @return The certificate contined in this KeyInfo
++     * @throws KeyResolverException
++     */
++    X509Certificate getX509CertificateFromInternalResolvers()
++        throws KeyResolverException {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE,
++                "Start getX509CertificateFromInternalResolvers() with "
++                + this.lengthInternalKeyResolver() + " resolvers"
++            );
++        }
++        String uri = this.getBaseURI();
++        for (KeyResolverSpi keyResolver : _internalKeyResolvers) {
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
+             }
+-            currentChild=currentChild.getNextSibling();
+-         }
+-         return null;
+-   }
++            X509Certificate cert = applyCurrentResolver(uri, keyResolver);
++            if (cert != null) {
++                return cert;
++            }
++        }
+ 
+-   /**
+-    * Method getX509CertificateFromInternalResolvers
+-    *
+-    * @return The certificate contined in this KeyInfo
+-    * @throws KeyResolverException
+-    */
+-   X509Certificate getX509CertificateFromInternalResolvers()
+-           throws KeyResolverException {
+-      if (log.isLoggable(java.util.logging.Level.FINE))
+-        log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromInternalResolvers() with "
+-                + this.lengthInternalKeyResolver() + " resolvers");
+-      String uri=this.getBaseURI();
+-      int storageLength=this._storageResolvers.size();
+-      for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
+-         KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
+-         if (log.isLoggable(java.util.logging.Level.FINE))
+-                log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
+-         X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
+-         if (cert!=null) {
+-                 return cert;
+-         }
+-      }
+-
+-      return null;
+-   }
++        return null;
++    }
+ 
+    /**
+     * This method returns a secret (symmetric) key. This is for XML Encryption.
+@@ -944,9 +940,9 @@
+    SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException {
+           final int length=KeyResolver.length();
+           int storageLength=this._storageResolvers.size();
+-          Iterator it = KeyResolver.iterator();
++          Iterator<KeyResolverSpi> it = KeyResolver.iterator();
+       for (int i = 0; i < length; i++) {
+-         KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
++         KeyResolverSpi keyResolver = it.next();
+ 
+          Node currentChild=this._constructionElement.getFirstChild();
+          String uri=this.getBaseURI();
+@@ -954,7 +950,7 @@
+             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+                   for (int k = 0; k < storageLength; k++) {
+                      StorageResolver storage =
+-                        (StorageResolver) this._storageResolvers.get(k);
++                        this._storageResolvers.get(k);
+ 
+                      SecretKey sk =
+                            keyResolver.engineLookupAndResolveSecretKey((Element) currentChild,
+@@ -992,7 +988,7 @@
+             if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+                for (int k = 0; k < storageLength; k++) {
+                      StorageResolver storage =
+-                        (StorageResolver) this._storageResolvers.get(k);
++                        this._storageResolvers.get(k);
+ 
+                      SecretKey sk = keyResolver
+                            .engineLookupAndResolveSecretKey((Element) currentChild, uri, storage);
+@@ -1012,7 +1008,7 @@
+    /**
+     * Stores the individual (per-KeyInfo) {@link KeyResolver}s
+     */
+-   List _internalKeyResolvers = null;
++   List<KeyResolverSpi> _internalKeyResolvers = null;
+ 
+    /**
+     * This method is used to add a custom {@link KeyResolverSpi} to a KeyInfo
+@@ -1022,7 +1018,7 @@
+     */
+    public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) {
+            if (_internalKeyResolvers==null) {
+-                   _internalKeyResolvers=new ArrayList();
++                   _internalKeyResolvers=new ArrayList<KeyResolverSpi>();
+            }
+       this._internalKeyResolvers.add(realKeyResolver);
+    }
+@@ -1044,11 +1040,11 @@
+     * @return the KeyResolverSpi for the index.
+     */
+    KeyResolverSpi itemInternalKeyResolver(int i) {
+-      return (KeyResolverSpi) this._internalKeyResolvers.get(i);
++      return this._internalKeyResolvers.get(i);
+    }
+ 
+    /** Field _storageResolvers */
+-   List _storageResolvers = nullList;
++   private List<StorageResolver> _storageResolvers = nullList;
+ 
+    /**
+     * Method addStorageResolver
+@@ -1057,7 +1053,7 @@
+     */
+    public void addStorageResolver(StorageResolver storageResolver) {
+            if  (_storageResolvers == nullList  ){
+-                   _storageResolvers=new ArrayList();
++                   _storageResolvers=new ArrayList<StorageResolver>();
+            }
+          this._storageResolvers.add(storageResolver);
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolver.java
+@@ -2,356 +2,402 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-/*
+- * Copyright  1999-2004 The Apache Software Foundation.
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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
+  *
+- *  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
+  *
+- *      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.
+- *
++ * 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.
+  */
+ package com.sun.org.apache.xml.internal.security.keys.keyresolver;
+ 
+-
+-
+ import java.security.PublicKey;
+ import java.security.cert.X509Certificate;
+ import java.util.ArrayList;
+ import java.util.Iterator;
+ import java.util.List;
++import java.util.concurrent.CopyOnWriteArrayList;
+ 
+ import javax.crypto.SecretKey;
+ 
++import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.DSAKeyValueResolver;
++import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.RSAKeyValueResolver;
++import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.RetrievalMethodResolver;
++import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.X509CertificateResolver;
++import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.X509IssuerSerialResolver;
++import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.X509SKIResolver;
++import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.X509SubjectNameResolver;
+ import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+ 
+-
+ /**
+  * KeyResolver is factory class for subclass of KeyResolverSpi that
+  * represent child element of KeyInfo.
+- *
+- * @author $Author: mullan $
+- * @version %I%, %G%
+  */
+ public class KeyResolver {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
++    /** {@link org.apache.commons.logging} logging facility */
++    private static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(KeyResolver.class.getName());
+ 
+-   /** Field _alreadyInitialized */
+-   static boolean _alreadyInitialized = false;
++    /** Field resolverVector */
++    private static List<KeyResolver> resolverVector = new CopyOnWriteArrayList<KeyResolver>();
+ 
+-   /** Field _resolverVector */
+-   static List _resolverVector = null;
++    /** Field resolverSpi */
++    private final KeyResolverSpi resolverSpi;
+ 
+-   /** Field _resolverSpi */
+-   protected KeyResolverSpi _resolverSpi = null;
++    /**
++     * Constructor.
++     *
++     * @param keyResolverSpi a KeyResolverSpi instance
++     */
++    private KeyResolver(KeyResolverSpi keyResolverSpi) {
++        resolverSpi = keyResolverSpi;
++    }
+ 
+-   /** Field _storage */
+-   protected StorageResolver _storage = null;
++    /**
++     * Method length
++     *
++     * @return the length of resolvers registered
++     */
++    public static int length() {
++        return resolverVector.size();
++    }
+ 
+-   /**
+-    * Constructor ResourceResolver
+-    *
+-    * @param className
+-    * @throws ClassNotFoundException
+-    * @throws IllegalAccessException
+-    * @throws InstantiationException
+-    */
+-   private KeyResolver(String className)
+-           throws ClassNotFoundException, IllegalAccessException,
+-                  InstantiationException {
+-      this._resolverSpi =
+-         (KeyResolverSpi) Class.forName(className).newInstance();
+-      this._resolverSpi.setGlobalResolver(true);
+-   }
++    /**
++     * Method getX509Certificate
++     *
++     * @param element
++     * @param baseURI
++     * @param storage
++     * @return The certificate represented by the element.
++     *
++     * @throws KeyResolverException
++     */
++    public static final X509Certificate getX509Certificate(
++        Element element, String baseURI, StorageResolver storage
++    ) throws KeyResolverException {
++        for (KeyResolver resolver : resolverVector) {
++            if (resolver == null) {
++                Object exArgs[] = {
++                                   (((element != null)
++                                       && (element.getNodeType() == Node.ELEMENT_NODE))
++                                       ? element.getTagName() : "null")
++                };
+ 
+-   /**
+-    * Method length
+-    *
+-    * @return the length of resolvers registed
+-    */
+-   public static int length() {
+-      return KeyResolver._resolverVector.size();
+-   }
++                throw new KeyResolverException("utils.resolver.noClass", exArgs);
++            }
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass());
++            }
+ 
+-   public static void hit(Iterator hintI) {
+-           ResolverIterator hint = (ResolverIterator) hintI;
+-           int i = hint.i;
+-           if (i!=1 && hint.res ==_resolverVector) {
+-                   List resolverVector=(List)((ArrayList)_resolverVector).clone();
+-                Object ob=resolverVector.remove(i-1);
+-                resolverVector.add(0,ob);
+-                 _resolverVector=resolverVector;
+-         } else {
+-                 //System.out.println("KeyResolver hitting");
+-         }
+-   }
++            X509Certificate cert = resolver.resolveX509Certificate(element, baseURI, storage);
++            if (cert != null) {
++                return cert;
++            }
++        }
+ 
+-   /**
+-    * Method getInstance
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    * @return The certificate represented by the element.
+-    *
+-    * @throws KeyResolverException
+-    */
+-   public static final X509Certificate getX509Certificate(
+-           Element element, String BaseURI, StorageResolver storage)
+-              throws KeyResolverException {
++        Object exArgs[] = {
++                           (((element != null) && (element.getNodeType() == Node.ELEMENT_NODE))
++                           ? element.getTagName() : "null")
++                          };
+ 
+-          // use the old vector to not be hit by updates
+-          List resolverVector = KeyResolver._resolverVector;
+-      for (int i = 0; i < resolverVector.size(); i++) {
+-                  KeyResolver resolver=
+-            (KeyResolver) resolverVector.get(i);
++        throw new KeyResolverException("utils.resolver.noClass", exArgs);
++    }
+ 
+-                  if (resolver==null) {
+-            Object exArgs[] = {
+-               (((element != null)
+-                 && (element.getNodeType() == Node.ELEMENT_NODE))
+-                ? element.getTagName()
+-                : "null") };
++    /**
++     * Method getPublicKey
++     *
++     * @param element
++     * @param baseURI
++     * @param storage
++     * @return the public key contained in the element
++     *
++     * @throws KeyResolverException
++     */
++    public static final PublicKey getPublicKey(
++        Element element, String baseURI, StorageResolver storage
++    ) throws KeyResolverException {
++        for (KeyResolver resolver : resolverVector) {
++            if (resolver == null) {
++                Object exArgs[] = {
++                                   (((element != null)
++                                       && (element.getNodeType() == Node.ELEMENT_NODE))
++                                       ? element.getTagName() : "null")
++                };
+ 
+-            throw new KeyResolverException("utils.resolver.noClass", exArgs);
+-         }
+-         if (log.isLoggable(java.util.logging.Level.FINE))
++                throw new KeyResolverException("utils.resolver.noClass", exArgs);
++            }
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
+                 log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass());
++            }
+ 
+-         X509Certificate cert=resolver.resolveX509Certificate(element, BaseURI, storage);
+-         if (cert!=null) {
+-            return cert;
+-         }
+-      }
++            PublicKey cert = resolver.resolvePublicKey(element, baseURI, storage);
++            if (cert != null) {
++                return cert;
++            }
++        }
+ 
+-      Object exArgs[] = {
+-         (((element != null) && (element.getNodeType() == Node.ELEMENT_NODE))
+-          ? element.getTagName()
+-          : "null") };
++        Object exArgs[] = {
++                           (((element != null) && (element.getNodeType() == Node.ELEMENT_NODE))
++                           ? element.getTagName() : "null")
++                          };
+ 
+-      throw new KeyResolverException("utils.resolver.noClass", exArgs);
+-   }
+-   /**
+-    * Method getInstance
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    * @return the public key contained in the element
+-    *
+-    * @throws KeyResolverException
+-    */
+-   public static final PublicKey getPublicKey(
+-           Element element, String BaseURI, StorageResolver storage)
+-              throws KeyResolverException {
++        throw new KeyResolverException("utils.resolver.noClass", exArgs);
++    }
+ 
+-          List resolverVector = KeyResolver._resolverVector;
+-      for (int i = 0; i < resolverVector.size(); i++) {
+-                  KeyResolver resolver=
+-            (KeyResolver) resolverVector.get(i);
++    /**
++     * This method is used for registering {@link KeyResolverSpi}s which are
++     * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
++     * personalized {@link KeyResolverSpi}s should only be registered directly
++     * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
++     * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
++     * Please note that this method will create a new copy of the underlying array, as the
++     * underlying collection is a CopyOnWriteArrayList.
++     *
++     * @param className
++     * @param globalResolver Whether the KeyResolverSpi is a global resolver or not
++     * @throws InstantiationException
++     * @throws IllegalAccessException
++     * @throws ClassNotFoundException
++     */
++    public static void register(String className, boolean globalResolver)
++        throws ClassNotFoundException, IllegalAccessException, InstantiationException {
++        KeyResolverSpi keyResolverSpi =
++            (KeyResolverSpi) Class.forName(className).newInstance();
++        keyResolverSpi.setGlobalResolver(globalResolver);
++        register(keyResolverSpi, false);
++    }
+ 
+-                  if (resolver==null) {
+-            Object exArgs[] = {
+-               (((element != null)
+-                 && (element.getNodeType() == Node.ELEMENT_NODE))
+-                ? element.getTagName()
+-                : "null") };
++    /**
++     * This method is used for registering {@link KeyResolverSpi}s which are
++     * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
++     * personalized {@link KeyResolverSpi}s should only be registered directly
++     * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
++     * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
++     * Please note that this method will create a new copy of the underlying array, as the
++     * underlying collection is a CopyOnWriteArrayList.
++     *
++     * @param className
++     * @param globalResolver Whether the KeyResolverSpi is a global resolver or not
++     */
++    public static void registerAtStart(String className, boolean globalResolver) {
++        KeyResolverSpi keyResolverSpi = null;
++        Exception ex = null;
++        try {
++            keyResolverSpi = (KeyResolverSpi) Class.forName(className).newInstance();
++        } catch (ClassNotFoundException e) {
++            ex = e;
++        } catch (IllegalAccessException e) {
++            ex = e;
++        } catch (InstantiationException e) {
++            ex = e;
++        }
+ 
+-            throw new KeyResolverException("utils.resolver.noClass", exArgs);
+-         }
+-         if (log.isLoggable(java.util.logging.Level.FINE))
+-                log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass());
++        if (ex != null) {
++            throw (IllegalArgumentException) new
++            IllegalArgumentException("Invalid KeyResolver class name").initCause(ex);
++        }
++        keyResolverSpi.setGlobalResolver(globalResolver);
++        register(keyResolverSpi, true);
++    }
+ 
+-         PublicKey cert=resolver.resolvePublicKey(element, BaseURI, storage);
+-         if (cert!=null) {
+-                 if (i!=0 && resolverVector==_resolverVector) {
+-                         //update resolver.
+-                         resolverVector=(List)((ArrayList)_resolverVector).clone();
+-                                 Object ob=resolverVector.remove(i);
+-                                 resolverVector.add(0,ob);
+-                                 _resolverVector=resolverVector;
+-                 }
+-                 return cert;
+-         }
+-      }
++    /**
++     * This method is used for registering {@link KeyResolverSpi}s which are
++     * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
++     * personalized {@link KeyResolverSpi}s should only be registered directly
++     * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
++     * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
++     * Please note that this method will create a new copy of the underlying array, as the
++     * underlying collection is a CopyOnWriteArrayList.
++     *
++     * @param keyResolverSpi a KeyResolverSpi instance to register
++     * @param start whether to register the KeyResolverSpi at the start of the list or not
++     */
++    public static void register(
++        KeyResolverSpi keyResolverSpi,
++        boolean start
++    ) {
++        KeyResolver resolver = new KeyResolver(keyResolverSpi);
++        if (start) {
++            resolverVector.add(0, resolver);
++        } else {
++            resolverVector.add(resolver);
++        }
++    }
+ 
+-      Object exArgs[] = {
+-         (((element != null) && (element.getNodeType() == Node.ELEMENT_NODE))
+-          ? element.getTagName()
+-          : "null") };
++    /**
++     * This method is used for registering {@link KeyResolverSpi}s which are
++     * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
++     * personalized {@link KeyResolverSpi}s should only be registered directly
++     * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
++     * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
++     * The KeyResolverSpi instances are not registered as a global resolver.
++     *
++     *
++     * @param classNames
++     * @throws InstantiationException
++     * @throws IllegalAccessException
++     * @throws ClassNotFoundException
++     */
++    public static void registerClassNames(List<String> classNames)
++        throws ClassNotFoundException, IllegalAccessException, InstantiationException {
++        List<KeyResolver> keyResolverList = new ArrayList<KeyResolver>(classNames.size());
++        for (String className : classNames) {
++            KeyResolverSpi keyResolverSpi =
++                (KeyResolverSpi) Class.forName(className).newInstance();
++            keyResolverSpi.setGlobalResolver(false);
++            keyResolverList.add(new KeyResolver(keyResolverSpi));
++        }
++        resolverVector.addAll(keyResolverList);
++    }
+ 
+-      throw new KeyResolverException("utils.resolver.noClass", exArgs);
+-   }
++    /**
++     * This method registers the default resolvers.
++     */
++    public static void registerDefaultResolvers() {
+ 
+-   /**
+-    * The init() function is called by com.sun.org.apache.xml.internal.security.Init.init()
+-    */
+-   public static void init() {
++        List<KeyResolver> keyResolverList = new ArrayList<KeyResolver>();
++        keyResolverList.add(new KeyResolver(new RSAKeyValueResolver()));
++        keyResolverList.add(new KeyResolver(new DSAKeyValueResolver()));
++        keyResolverList.add(new KeyResolver(new X509CertificateResolver()));
++        keyResolverList.add(new KeyResolver(new X509SKIResolver()));
++        keyResolverList.add(new KeyResolver(new RetrievalMethodResolver()));
++        keyResolverList.add(new KeyResolver(new X509SubjectNameResolver()));
++        keyResolverList.add(new KeyResolver(new X509IssuerSerialResolver()));
+ 
+-      if (!KeyResolver._alreadyInitialized) {
+-         KeyResolver._resolverVector = new ArrayList(10);
+-         _alreadyInitialized = true;
+-      }
+-   }
++        resolverVector.addAll(keyResolverList);
++    }
+ 
+-   /**
+-    * This method is used for registering {@link KeyResolverSpi}s which are
+-    * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
+-    * personalized {@link KeyResolverSpi}s should only be registered directly
+-    * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using
+-    * {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
+-    *
+-    * @param className
+- * @throws InstantiationException
+- * @throws IllegalAccessException
+- * @throws ClassNotFoundException
+-    */
+-   public static void register(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+-      KeyResolver._resolverVector.add(new KeyResolver(className));
+-   }
++    /**
++     * Method resolvePublicKey
++     *
++     * @param element
++     * @param baseURI
++     * @param storage
++     * @return resolved public key from the registered from the elements
++     *
++     * @throws KeyResolverException
++     */
++    public PublicKey resolvePublicKey(
++        Element element, String baseURI, StorageResolver storage
++    ) throws KeyResolverException {
++        return resolverSpi.engineLookupAndResolvePublicKey(element, baseURI, storage);
++    }
+ 
+-   /**
+-    * This method is used for registering {@link KeyResolverSpi}s which are
+-    * available to <I>all</I> {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} objects. This means that
+-    * personalized {@link KeyResolverSpi}s should only be registered directly
+-    * to the {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo} using {@link com.sun.org.apache.xml.internal.security.keys.KeyInfo#registerInternalKeyResolver}.
+-    *
+-    * @param className
+-    */
+-   public static void registerAtStart(String className) {
+-      KeyResolver._resolverVector.add(0, className);
+-   }
++    /**
++     * Method resolveX509Certificate
++     *
++     * @param element
++     * @param baseURI
++     * @param storage
++     * @return resolved X509certificate key from the registered from the elements
++     *
++     * @throws KeyResolverException
++     */
++    public X509Certificate resolveX509Certificate(
++        Element element, String baseURI, StorageResolver storage
++    ) throws KeyResolverException {
++        return resolverSpi.engineLookupResolveX509Certificate(element, baseURI, storage);
++    }
+ 
+-   /**
+-    * Method resolve
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    * @return resolved public key from the registered from the elements
+-    *
+-    * @throws KeyResolverException
+-    */
+-   public PublicKey resolvePublicKey(
+-           Element element, String BaseURI, StorageResolver storage)
+-              throws KeyResolverException {
+-      return this._resolverSpi.engineLookupAndResolvePublicKey(element, BaseURI, storage);
+-   }
++    /**
++     * @param element
++     * @param baseURI
++     * @param storage
++     * @return resolved SecretKey key from the registered from the elements
++     * @throws KeyResolverException
++     */
++    public SecretKey resolveSecretKey(
++        Element element, String baseURI, StorageResolver storage
++    ) throws KeyResolverException {
++        return resolverSpi.engineLookupAndResolveSecretKey(element, baseURI, storage);
++    }
+ 
+-   /**
+-    * Method resolveX509Certificate
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    * @return resolved X509certificate key from the registered from the elements
+-    *
+-    * @throws KeyResolverException
+-    */
+-   public X509Certificate resolveX509Certificate(
+-           Element element, String BaseURI, StorageResolver storage)
+-              throws KeyResolverException {
+-      return this._resolverSpi.engineLookupResolveX509Certificate(element, BaseURI,
+-              storage);
+-   }
++    /**
++     * Method setProperty
++     *
++     * @param key
++     * @param value
++     */
++    public void setProperty(String key, String value) {
++        resolverSpi.engineSetProperty(key, value);
++    }
+ 
+-   /**
+-    * @param element
+-    * @param BaseURI
+-    * @param storage
+-    * @return resolved SecretKey key from the registered from the elements
+-    * @throws KeyResolverException
+-    */
+-   public SecretKey resolveSecretKey(
+-           Element element, String BaseURI, StorageResolver storage)
+-              throws KeyResolverException {
+-      return this._resolverSpi.engineLookupAndResolveSecretKey(element, BaseURI,
+-              storage);
+-   }
++    /**
++     * Method getProperty
++     *
++     * @param key
++     * @return the property set for this resolver
++     */
++    public String getProperty(String key) {
++        return resolverSpi.engineGetProperty(key);
++    }
+ 
+-   /**
+-    * Method setProperty
+-    *
+-    * @param key
+-    * @param value
+-    */
+-   public void setProperty(String key, String value) {
+-      this._resolverSpi.engineSetProperty(key, value);
+-   }
+ 
+-   /**
+-    * Method getProperty
+-    *
+-    * @param key
+-    * @return the property setted for this resolver
+-    */
+-   public String getProperty(String key) {
+-      return this._resolverSpi.engineGetProperty(key);
+-   }
++    /**
++     * Method understandsProperty
++     *
++     * @param propertyToTest
++     * @return true if the resolver understands property propertyToTest
++     */
++    public boolean understandsProperty(String propertyToTest) {
++        return resolverSpi.understandsProperty(propertyToTest);
++    }
+ 
+ 
+-   /**
+-    * Method understandsProperty
+-    *
+-    * @param propertyToTest
+-    * @return true if the resolver understands property propertyToTest
+-    */
+-   public boolean understandsProperty(String propertyToTest) {
+-      return this._resolverSpi.understandsProperty(propertyToTest);
+-   }
++    /**
++     * Method resolverClassName
++     *
++     * @return the name of the resolver.
++     */
++    public String resolverClassName() {
++        return resolverSpi.getClass().getName();
++    }
+ 
++    /**
++     * Iterate over the KeyResolverSpi instances
++     */
++    static class ResolverIterator implements Iterator<KeyResolverSpi> {
++        List<KeyResolver> res;
++        Iterator<KeyResolver> it;
+ 
+-   /**
+-    * Method resolverClassName
+-    *
+-    * @return the name of the resolver.
+-    */
+-   public String resolverClassName() {
+-      return this._resolverSpi.getClass().getName();
+-   }
++        public ResolverIterator(List<KeyResolver> list) {
++            res = list;
++            it = res.iterator();
++        }
+ 
+-   static class ResolverIterator implements Iterator {
+-           List res;
+-                Iterator it;
+-                int i;
+-           public ResolverIterator(List list) {
+-                res = list;
+-                it = res.iterator();
++        public boolean hasNext() {
++            return it.hasNext();
+         }
+-                public boolean hasNext() {
+-                        // TODO Auto-generated method stub
+-                        return it.hasNext();
+-                }
+ 
+-                public Object next() {
+-                        i++;
+-                        KeyResolver resolver = (KeyResolver) it.next();
+-                      if (resolver==null) {
+-                         throw new RuntimeException("utils.resolver.noClass");
+-                      }
++        public KeyResolverSpi next() {
++            KeyResolver resolver = it.next();
++            if (resolver == null) {
++                throw new RuntimeException("utils.resolver.noClass");
++            }
+ 
+-                      return resolver._resolverSpi;
+-                }
++            return resolver.resolverSpi;
++        }
+ 
+-                public void remove() {
+-                        // TODO Auto-generated method stub
++        public void remove() {
++            throw new UnsupportedOperationException("Can't remove resolvers using the iterator");
++        }
++    };
+ 
+-                }
+-
+-        };
+-        public static Iterator iterator() {
+-                return new ResolverIterator(_resolverVector);
+-   }
++    public static Iterator<KeyResolverSpi> iterator() {
++        return new ResolverIterator(resolverVector);
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
+@@ -34,6 +34,7 @@
+ import java.util.ListIterator;
+ import java.util.Set;
+ 
++import javax.xml.XMLConstants;
+ import javax.xml.parsers.ParserConfigurationException;
+ 
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+@@ -251,6 +252,7 @@
+       try {
+          javax.xml.parsers.DocumentBuilderFactory dbf =javax.xml.parsers.DocumentBuilderFactory.newInstance();
+          dbf.setNamespaceAware(true);
++         dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
+          javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
+          org.w3c.dom.Document doc =
+             db.parse(new java.io.ByteArrayInputStream(bytes));
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties b/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_en.properties
+@@ -1,123 +1,126 @@
+-algorithm.alreadyRegistered = URI {0} already assigned to class {1}
+-algorithm.classDoesNotExist = Cannot register URI {0} to class {1} because this class does not exist in CLASSPATH
+-algorithm.ClassDoesNotExist = Class {0} does not exist
+-algorithm.extendsWrongClass = Cannot register URI {0} to class {1} because it does not extend {2}
+-algorithms.CannotUseAlgorithmParameterSpecOnDSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating DSA signatures.
+-algorithms.CannotUseAlgorithmParameterSpecOnRSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating RSA signatures.
+-algorithms.CannotUseSecureRandomOnMAC = Sorry, but you cannot use a SecureRandom object for creating MACs.
+-algorithms.HMACOutputLengthOnlyForHMAC = A HMACOutputLength can only be specified for HMAC integrity algorithms
+-algorithms.NoSuchAlgorithm = The requested algorithm {0} does not exist. Original Message was: {1}
+-algorithms.NoSuchMap = The algorithm URI "{0}" could not be mapped to a JCE algorithm
+-algorithms.NoSuchProvider = The specified Provider {0} does not exist. Original Message was: {1}
+-algorithms.operationOnlyVerification = A public key can only used for verification of a signature.
+-algorithms.WrongKeyForThisOperation = Sorry, you supplied the wrong key type for this operation! You supplied a {0} but a {1} is needed.
+-attributeValueIllegal = The attribute {0} has value {1} but must be {2}
+-c14n.Canonicalizer.Exception = Exception during Canonicalization:  Original Message was {0}
+-c14n.Canonicalizer.IllegalNode = Illegal node type {0}, node name was {1}
+-c14n.Canonicalizer.NoSuchCanonicalizer = No canonicalizer found with URI {0}
+-c14n.Canonicalizer.ParserConfigurationException = ParserConfigurationException during Canonicalization:  Original Message was {0}
+-c14n.Canonicalizer.RelativeNamespace = Element {0} has a relative namespace: {1}="{2}"
+-c14n.Canonicalizer.SAXException = SAXException during Canonicalization:  Original Message was {0}
+-c14n.Canonicalizer.TraversalNotSupported = This DOM document does not support Traversal {0}
+-c14n.Canonicalizer.UnsupportedEncoding = Unsupported encoding {0}
+-c14n.Canonicalizer.UnsupportedOperation = This canonicalizer does not support this operation
+-c14n.XMLUtils.circumventBug2650forgotten = The tree has not been prepared for canonicalization using XMLUtils#circumventBug2650(Document)
+-certificate.noSki.lowVersion = Certificate cannot contain a SubjectKeyIdentifier because it is only X509v{0}
+-certificate.noSki.notOctetString = Certificates SubjectKeyIdentifier is not a OctetString
+-certificate.noSki.null = Certificate does not contain a SubjectKeyIdentifier
+-defaultNamespaceCannotBeSetHere = Default namespace cannot be set here
+-ElementProxy.nullElement = Cannot create an ElementProxy from a null argument
+-empty = {0}
+-encryption.algorithmCannotBeUsedForEncryptedData = encryption.algorithmCannotBeUsedForEncryptedData {0}
+-encryption.algorithmCannotEatInitParams = encryption.algorithmCannotEatInitParams
+-encryption.algorithmCannotEncryptDecrypt = encryption.algorithmCannotEncryptDecrypt
+-encryption.algorithmCannotWrapUnWrap = encryption.algorithmCannotWrapUnWrap
+-encryption.ExplicitKeySizeMismatch = The xenc:KeySize element requests a key size of {0} bit but the algorithm implements {1} bit
+-encryption.nonceLongerThanDecryptedPlaintext = The given nonce is longer than the available plaintext. I Cannot strip away this.
+-encryption.RSAOAEP.dataHashWrong = data hash wrong
+-encryption.RSAOAEP.dataStartWrong = data wrong start {0}
+-encryption.RSAOAEP.dataTooShort = data too short
+-encryption.RSAPKCS15.blockTruncated = block truncated
+-encryption.RSAPKCS15.noDataInBlock = no data in block
+-encryption.RSAPKCS15.unknownBlockType = unknown block type
+-encryption.nokey = No Key Encryption Key loaded and cannot determine using key resolvers
+-endorsed.jdk1.4.0 = Since it seems that nobody reads our installation notes, we must do it in the exception messages. Hope you read them. You did NOT use the endorsed mechanism from JDK 1.4 properly; look at <http://xml.apache.org/security/Java/installation.html> how to solve this problem.
+-errorMessages.InvalidDigestValueException = INVALID signature -- check reference resolution.
+-errorMessages.InvalidSignatureValueException = INVALID signature -- core validation failed.
+-errorMessages.IOException = Other file I/O and similar exceptions.
+-errorMessages.MissingKeyFailureException = Cannot verify because of missing public key. Provide it via addResource and try again.
+-errorMessages.MissingResourceFailureException = Cannot verify because of unresolved references. Provide it via addResource and try again.
+-errorMessages.NoSuchAlgorithmException = Unknown Algorithm {0}
+-errorMessages.NotYetImplementedException = Functionality not yet there.
+-errorMessages.XMLSignatureException = Verification failed for some other reason.
+-decoding.divisible.four = It should be divisible by four
+-decoding.general = Error while decoding
+-FileKeyStorageImpl.addToDefaultFromRemoteNotImplemented = Method addToDefaultFromRemote() not yet implemented.
+-FileKeyStorageImpl.NoCert.Context = Not found such a X509Certificate including context {0}
+-FileKeyStorageImpl.NoCert.IssNameSerNo = Not found such a X509Certificate with IssuerName {0} and serial number {1}
+-FileKeyStorageImpl.NoCert.SubjName = Not found such a X509Certificate including SubjectName {0}
+-generic.dontHaveConstructionElement = I do not have a construction Element
+-generic.EmptyMessage = {0}
+-generic.NotYetImplemented = {0} Not YET implemented ;-((
+-java.security.InvalidKeyException = Invalid key
+-java.security.NoSuchProviderException = Unknown or unsupported provider
+-java.security.UnknownKeyType = Unknown or unsupported key type {0}
+-KeyInfo.needKeyResolver = More than one keyResovler have to be registered
+-KeyInfo.nokey = Cannot get key from {0}
+-KeyInfo.noKey = Cannot get the public key
+-KeyInfo.wrongNumberOfObject = Need {0} keyObjects
+-KeyInfo.wrongUse = This object was made for getting {0}
+-keyResolver.alreadyRegistered = {1} class has already been registered for {0}
+-KeyResolver.needStorageResolver = Need a StorageResolver to retrieve a Certificate from a {0}
+-KeyResoverSpiImpl.cannotGetCert = Cannot get the Certificate that include or in {1} in implement class {0}
+-KeyResoverSpiImpl.elementGeneration = Cannot make {1} element in implement class {0}
+-KeyResoverSpiImpl.getPoublicKey = Cannot get the public key from implement class {0}
+-KeyResoverSpiImpl.InvalidElement = Cannot set (2) Element in implement class {0}
+-KeyResoverSpiImpl.keyStore = KeyStorage error in implement class {0}
+-KeyResoverSpiImpl.need.Element = {1} type of Element is needed in implement class {0}
+-KeyResoverSpiImpl.wrongCRLElement = Cannot make CRL from {1} in implement class {0}
+-KeyResoverSpiImpl.wrongKeyObject =  Need {1} type of KeyObject for generation Element in implement class{0}
+-KeyResoverSpiImpl.wrongNumberOfObject = Need {1} keyObject in implement class {0}
+-KeyStore.alreadyRegistered = {0} Class has already been registered for {1}
+-KeyStore.register = {1} type class register error  in class {0}
+-KeyStore.registerStore.register = Registeration error for type {0}
+-KeyValue.IllegalArgument = Cannot create a {0} from {1}
+-namespacePrefixAlreadyUsedByOtherURI = Namespace prefix {0} already used by other URI {1}
+-notYetInitialized = The module {0} is not yet initialized
+-prefix.AlreadyAssigned = You want to assign {0} as prefix for namespace {1} but it is already assigned for {2}
+-signature.Canonicalizer.UnknownCanonicalizer = Unknown canonicalizer. No handler installed for URI {0}
+-signature.DSA.invalidFormat = Invalid ASN.1 encoding of the DSA signature
+-signature.Generation.signBeforeGetValue = You have to XMLSignature.sign(java.security.PrivateKey) first
+-signature.signaturePropertyHasNoTarget = The Target attribute of the SignatureProperty must be set
+-signature.Transform.ErrorDuringTransform = A {1} was thrown during the {0} transform
+-signature.Transform.NotYetImplemented = Transform {0} not yet implemented
+-signature.Transform.NullPointerTransform = Null pointer as URI. Programming bug?
+-signature.Transform.UnknownTransform = Unknown transformation. No handler installed for URI {0}
+-signature.Transform.node = Current Node: {0}
+-signature.Transform.nodeAndType = Current Node: {0}, type: {1} 
+-signature.Util.BignumNonPositive = bigInteger.signum() must be positive
+-signature.Util.NonTextNode = Not a text node
+-signature.Util.TooManyChilds = Too many childs of Type {0} in {1}
+-signature.Verification.certificateError = Certificate error
+-signature.Verification.IndexOutOfBounds = Index {0} illegal. We only have {1} References
+-signature.Verification.internalError = Internal error
+-signature.Verification.InvalidDigestOrReference = Invalid digest of reference {0}
+-signature.Verification.keyStore = KeyStore error
+-signature.Verification.MissingID = Cannot resolve element with ID {0}
+-signature.Verification.MissingResources = Cannot resolve external resource {0}
+-signature.Verification.NoSignatureElement = Input document contains no {0} Element in namespace {1}
+-signature.Verification.Reference.NoInput = The Reference for URI {0} has no XMLSignatureInput
+-signature.Verification.SignatureError = Signature error
+-signature.XMLSignatureInput.MissingConstuctor = Cannot construct a XMLSignatureInput from class {0}
+-signature.XMLSignatureInput.SerializeDOM = Input initialized with DOM Element. Use Canonicalization to serialize it
+-signature.XMLSignatureInput.nodesetReference = Unable to convert to nodeset the reference
+-transform.Init.IllegalContextArgument = Invalid context argument of class {0}. Must be String, org.w3c.dom.NodeList or java.io.InputStream.
+-transform.init.NotInitialized =
+-transform.init.wrongURI = Initialized with wrong URI. How could this happen? We implement {0} but {1} was used during initialization
+-utils.Base64.IllegalBitlength = Illegal byte length; Data to be decoded must be a multiple of 4
+-Base64Decoding = Error while decoding
+-utils.resolver.noClass = Could not find a resolver for URI {0} and Base {1}
+-xml.WrongContent = Cannot find {0} in {1}
+-xml.WrongElement = Cannot create a {0} from a {1} element
+-xpath.funcHere.documentsDiffer = The XPath is not in the same document as the context node
+-xpath.funcHere.noXPathContext = Try to evaluate an XPath which uses the here() function but XPath is not inside an ds:XPath Element. XPath was : {0}
++algorithm.alreadyRegistered = URI {0} already assigned to class {1}
++algorithm.classDoesNotExist = Cannot register URI {0} to class {1} because this class does not exist in CLASSPATH
++algorithm.ClassDoesNotExist = Class {0} does not exist
++algorithm.extendsWrongClass = Cannot register URI {0} to class {1} because it does not extend {2}
++algorithms.CannotUseAlgorithmParameterSpecOnDSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating DSA signatures.
++algorithms.CannotUseAlgorithmParameterSpecOnRSA = Sorry, but you cannot use a AlgorithmParameterSpec object for creating RSA signatures.
++algorithms.CannotUseSecureRandomOnMAC = Sorry, but you cannot use a SecureRandom object for creating MACs.
++algorithms.HMACOutputLengthOnlyForHMAC = A HMACOutputLength can only be specified for HMAC integrity algorithms
++algorithms.NoSuchAlgorithm = The requested algorithm {0} does not exist. Original Message was: {1}
++algorithms.NoSuchMap = The algorithm URI "{0}" could not be mapped to a JCE algorithm
++algorithms.NoSuchProvider = The specified Provider {0} does not exist. Original Message was: {1}
++algorithms.operationOnlyVerification = A public key can only used for verification of a signature.
++algorithms.WrongKeyForThisOperation = Sorry, you supplied the wrong key type for this operation! You supplied a {0} but a {1} is needed.
++attributeValueIllegal = The attribute {0} has value {1} but must be {2}
++c14n.Canonicalizer.Exception = Exception during Canonicalization:  Original Message was {0}
++c14n.Canonicalizer.IllegalNode = Illegal node type {0}, node name was {1}
++c14n.Canonicalizer.NoSuchCanonicalizer = No canonicalizer found with URI {0}
++c14n.Canonicalizer.ParserConfigurationException = ParserConfigurationException during Canonicalization:  Original Message was {0}
++c14n.Canonicalizer.RelativeNamespace = Element {0} has a relative namespace: {1}="{2}"
++c14n.Canonicalizer.SAXException = SAXException during Canonicalization:  Original Message was {0}
++c14n.Canonicalizer.TraversalNotSupported = This DOM document does not support Traversal {0}
++c14n.Canonicalizer.UnsupportedEncoding = Unsupported encoding {0}
++c14n.Canonicalizer.UnsupportedOperation = This canonicalizer does not support this operation
++c14n.XMLUtils.circumventBug2650forgotten = The tree has not been prepared for canonicalization using XMLUtils#circumventBug2650(Document)
++certificate.noSki.lowVersion = Certificate cannot contain a SubjectKeyIdentifier because it is only X509v{0}
++certificate.noSki.notOctetString = Certificates SubjectKeyIdentifier is not a OctetString
++certificate.noSki.null = Certificate does not contain a SubjectKeyIdentifier
++defaultNamespaceCannotBeSetHere = Default namespace cannot be set here
++ElementProxy.nullElement = Cannot create an ElementProxy from a null argument
++empty = {0}
++encryption.algorithmCannotBeUsedForEncryptedData = encryption.algorithmCannotBeUsedForEncryptedData {0}
++encryption.algorithmCannotEatInitParams = encryption.algorithmCannotEatInitParams
++encryption.algorithmCannotEncryptDecrypt = encryption.algorithmCannotEncryptDecrypt
++encryption.algorithmCannotWrapUnWrap = encryption.algorithmCannotWrapUnWrap
++encryption.ExplicitKeySizeMismatch = The xenc:KeySize element requests a key size of {0} bit but the algorithm implements {1} bit
++encryption.nonceLongerThanDecryptedPlaintext = The given nonce is longer than the available plaintext. I Cannot strip away this.
++encryption.RSAOAEP.dataHashWrong = data hash wrong
++encryption.RSAOAEP.dataStartWrong = data wrong start {0}
++encryption.RSAOAEP.dataTooShort = data too short
++encryption.RSAPKCS15.blockTruncated = block truncated
++encryption.RSAPKCS15.noDataInBlock = no data in block
++encryption.RSAPKCS15.unknownBlockType = unknown block type
++encryption.nokey = No Key Encryption Key loaded and cannot determine using key resolvers
++endorsed.jdk1.4.0 = Since it seems that nobody reads our installation notes, we must do it in the exception messages. Hope you read them. You did NOT use the endorsed mechanism from JDK 1.4 properly; look at <http://xml.apache.org/security/Java/installation.html> how to solve this problem.
++errorMessages.InvalidDigestValueException = INVALID signature -- check reference resolution.
++errorMessages.InvalidSignatureValueException = INVALID signature -- core validation failed.
++errorMessages.IOException = Other file I/O and similar exceptions.
++errorMessages.MissingKeyFailureException = Cannot verify because of missing public key. Provide it via addResource and try again.
++errorMessages.MissingResourceFailureException = Cannot verify because of unresolved references. Provide it via addResource and try again.
++errorMessages.NoSuchAlgorithmException = Unknown Algorithm {0}
++errorMessages.NotYetImplementedException = Functionality not yet there.
++errorMessages.XMLSignatureException = Verification failed for some other reason.
++decoding.divisible.four = It should be divisible by four
++decoding.general = Error while decoding
++FileKeyStorageImpl.addToDefaultFromRemoteNotImplemented = Method addToDefaultFromRemote() not yet implemented.
++FileKeyStorageImpl.NoCert.Context = Not found such a X509Certificate including context {0}
++FileKeyStorageImpl.NoCert.IssNameSerNo = Not found such a X509Certificate with IssuerName {0} and serial number {1}
++FileKeyStorageImpl.NoCert.SubjName = Not found such a X509Certificate including SubjectName {0}
++generic.dontHaveConstructionElement = I do not have a construction Element
++generic.EmptyMessage = {0}
++generic.NotYetImplemented = {0} Not YET implemented ;-((
++java.security.InvalidKeyException = Invalid key
++java.security.NoSuchProviderException = Unknown or unsupported provider
++java.security.UnknownKeyType = Unknown or unsupported key type {0}
++KeyInfo.needKeyResolver = More than one keyResovler have to be registered
++KeyInfo.nokey = Cannot get key from {0}
++KeyInfo.noKey = Cannot get the public key
++KeyInfo.wrongNumberOfObject = Need {0} keyObjects
++KeyInfo.wrongUse = This object was made for getting {0}
++keyResolver.alreadyRegistered = {1} class has already been registered for {0}
++KeyResolver.needStorageResolver = Need a StorageResolver to retrieve a Certificate from a {0}
++KeyResoverSpiImpl.cannotGetCert = Cannot get the Certificate that include or in {1} in implement class {0}
++KeyResoverSpiImpl.elementGeneration = Cannot make {1} element in implement class {0}
++KeyResoverSpiImpl.getPoublicKey = Cannot get the public key from implement class {0}
++KeyResoverSpiImpl.InvalidElement = Cannot set (2) Element in implement class {0}
++KeyResoverSpiImpl.keyStore = KeyStorage error in implement class {0}
++KeyResoverSpiImpl.need.Element = {1} type of Element is needed in implement class {0}
++KeyResoverSpiImpl.wrongCRLElement = Cannot make CRL from {1} in implement class {0}
++KeyResoverSpiImpl.wrongKeyObject =  Need {1} type of KeyObject for generation Element in implement class{0}
++KeyResoverSpiImpl.wrongNumberOfObject = Need {1} keyObject in implement class {0}
++KeyStore.alreadyRegistered = {0} Class has already been registered for {1}
++KeyStore.register = {1} type class register error  in class {0}
++KeyStore.registerStore.register = Registeration error for type {0}
++KeyValue.IllegalArgument = Cannot create a {0} from {1}
++namespacePrefixAlreadyUsedByOtherURI = Namespace prefix {0} already used by other URI {1}
++notYetInitialized = The module {0} is not yet initialized
++prefix.AlreadyAssigned = You want to assign {0} as prefix for namespace {1} but it is already assigned for {2}
++signature.Canonicalizer.UnknownCanonicalizer = Unknown canonicalizer. No handler installed for URI {0}
++signature.DSA.invalidFormat = Invalid ASN.1 encoding of the DSA signature
++signature.Generation.signBeforeGetValue = You have to XMLSignature.sign(java.security.PrivateKey) first
++signature.Reference.ForbiddenResolver = It is forbidden to access resolver {0} when secure validation is enabled
++signature.signatureAlgorithm = It is forbidden to use algorithm {0} when secure validation is enabled
++signature.signaturePropertyHasNoTarget = The Target attribute of the SignatureProperty must be set
++signature.Transform.ErrorDuringTransform = A {1} was thrown during the {0} transform
++signature.Transform.NotYetImplemented = Transform {0} not yet implemented
++signature.Transform.NullPointerTransform = Null pointer as URI. Programming bug?
++signature.Transform.UnknownTransform = Unknown transformation. No handler installed for URI {0}
++signature.Transform.node = Current Node: {0}
++signature.Transform.nodeAndType = Current Node: {0}, type: {1} 
++signature.Util.BignumNonPositive = bigInteger.signum() must be positive
++signature.Util.NonTextNode = Not a text node
++signature.Util.TooManyChilds = Too many childs of Type {0} in {1}
++signature.Verification.certificateError = Certificate error
++signature.Verification.IndexOutOfBounds = Index {0} illegal. We only have {1} References
++signature.Verification.internalError = Internal error
++signature.Verification.InvalidDigestOrReference = Invalid digest of reference {0}
++signature.Verification.keyStore = KeyStore error
++signature.Verification.MissingID = Cannot resolve element with ID {0}
++signature.Verification.MissingResources = Cannot resolve external resource {0}
++signature.Verification.MultipleIDs = Multiple Elements with the same ID {0} were detected
++signature.Verification.NoSignatureElement = Input document contains no {0} Element in namespace {1}
++signature.Verification.Reference.NoInput = The Reference for URI {0} has no XMLSignatureInput
++signature.Verification.SignatureError = Signature error
++signature.XMLSignatureInput.MissingConstuctor = Cannot construct a XMLSignatureInput from class {0}
++signature.XMLSignatureInput.SerializeDOM = Input initialized with DOM Element. Use Canonicalization to serialize it
++signature.XMLSignatureInput.nodesetReference = Unable to convert to nodeset the reference
++transform.Init.IllegalContextArgument = Invalid context argument of class {0}. Must be String, org.w3c.dom.NodeList or java.io.InputStream.
++transform.init.NotInitialized =
++transform.init.wrongURI = Initialized with wrong URI. How could this happen? We implement {0} but {1} was used during initialization
++utils.Base64.IllegalBitlength = Illegal byte length; Data to be decoded must be a multiple of 4
++Base64Decoding = Error while decoding
++utils.resolver.noClass = Could not find a resolver for URI {0} and Base {1}
++xml.WrongContent = Cannot find {0} in {1}
++xml.WrongElement = Cannot create a {0} from a {1} element
++xpath.funcHere.documentsDiffer = The XPath is not in the same document as the context node
++xpath.funcHere.noXPathContext = Try to evaluate an XPath which uses the here() function but XPath is not inside an ds:XPath Element. XPath was : {0}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/SignedInfo.java
+@@ -25,6 +25,7 @@
+ import java.io.OutputStream;
+ import javax.crypto.SecretKey;
+ import javax.crypto.spec.SecretKeySpec;
++import javax.xml.XMLConstants;
+ import javax.xml.parsers.ParserConfigurationException;
+ 
+ import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm;
+@@ -186,8 +187,10 @@
+                 javax.xml.parsers.DocumentBuilderFactory dbf =
+                     javax.xml.parsers.DocumentBuilderFactory.newInstance();
+                 dbf.setNamespaceAware(true);
++                dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
++                               Boolean.TRUE);
+                 javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
+-                org.w3c.dom.Document newdoc =
++                Document newdoc =
+                     db.parse(new ByteArrayInputStream(this._c14nizedBytes));
+                 Node imported =
+                     this._doc.importNode(newdoc.getDocumentElement(), true);
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignature.java
+@@ -201,14 +201,13 @@
+ 
+       super(doc);
+ 
+-      String xmlnsDsPrefix =
+-         getDefaultPrefixBindings(Constants.SignatureSpecNS);
++      String xmlnsDsPrefix = getDefaultPrefix(Constants.SignatureSpecNS);
+       if (xmlnsDsPrefix == null) {
+          this._constructionElement.setAttributeNS
+             (Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS);
+       } else {
+          this._constructionElement.setAttributeNS
+-            (Constants.NamespaceSpecNS, xmlnsDsPrefix, Constants.SignatureSpecNS);
++            (Constants.NamespaceSpecNS, "xmlns:" + xmlnsDsPrefix, Constants.SignatureSpecNS);
+       }
+       XMLUtils.addReturnToElement(this._constructionElement);
+ 
+@@ -242,14 +241,13 @@
+ 
+       super(doc);
+ 
+-      String xmlnsDsPrefix =
+-         getDefaultPrefixBindings(Constants.SignatureSpecNS);
++      String xmlnsDsPrefix = getDefaultPrefix(Constants.SignatureSpecNS);
+       if (xmlnsDsPrefix == null) {
+          this._constructionElement.setAttributeNS
+             (Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS);
+       } else {
+          this._constructionElement.setAttributeNS
+-            (Constants.NamespaceSpecNS, xmlnsDsPrefix, Constants.SignatureSpecNS);
++            (Constants.NamespaceSpecNS, "xmlns:" + xmlnsDsPrefix, Constants.SignatureSpecNS);
+       }
+       XMLUtils.addReturnToElement(this._constructionElement);
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java b/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/signature/XMLSignatureInput.java
+@@ -31,6 +31,7 @@
+ import java.util.List;
+ import java.util.Set;
+ 
++import javax.xml.XMLConstants;
+ import javax.xml.parsers.DocumentBuilder;
+ import javax.xml.parsers.DocumentBuilderFactory;
+ import javax.xml.parsers.ParserConfigurationException;
+@@ -601,6 +602,8 @@
+         DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
+         dfactory.setValidating(false);
+         dfactory.setNamespaceAware(true);
++        dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
++                            Boolean.TRUE);
+         DocumentBuilder db = dfactory.newDocumentBuilder();
+         // select all nodes, also the comments.
+         try {
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
+@@ -2,29 +2,30 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-/*
+- * Copyright  1999-2004 The Apache Software Foundation.
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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
+  *
+- *  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
+  *
+- *      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.
+- *
++ * 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.
+  */
+ package com.sun.org.apache.xml.internal.security.transforms;
+ 
+ import java.io.IOException;
+ import java.io.OutputStream;
+-import java.security.AccessController;
+-import java.security.PrivilegedAction;
+-import java.util.HashMap;
++import java.util.concurrent.ConcurrentHashMap;
++import java.util.Map;
+ import javax.xml.parsers.ParserConfigurationException;
+ 
+ import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
+@@ -32,6 +33,18 @@
+ import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformBase64Decode;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformC14N;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformC14N11;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformC14N11_WithComments;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformC14NExclusive;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformC14NExclusiveWithComments;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformC14NWithComments;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformEnvelopedSignature;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformXPath;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformXPath2Filter;
++import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformXSLT;
++import com.sun.org.apache.xml.internal.security.utils.ClassLoaderUtils;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.HelperNodeList;
+ import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
+@@ -53,112 +66,31 @@
+  * @author Christian Geuer-Pollmann
+  * @see Transforms
+  * @see TransformSpi
+- *
+  */
+ public final class Transform extends SignatureElementProxy {
+ 
+-    /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
++    /** {@link org.apache.commons.logging} logging facility */
++    private static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(Transform.class.getName());
+ 
+-    /** Field _alreadyInitialized */
+-    private static boolean alreadyInitialized = false;
++    /** All available Transform classes are registered here */
++    private static Map<String, Class<? extends TransformSpi>> transformSpiHash =
++        new ConcurrentHashMap<String, Class<? extends TransformSpi>>();
+ 
+-    /** All available Transform classes are registered here */
+-    private static HashMap transformClassHash = null;
+-
+-    private static HashMap transformSpiHash = new HashMap();
+-
+-    private TransformSpi transformSpi = null;
+-
+-    /**
+-     * Constructs {@link Transform}
+-     *
+-     * @param doc the {@link Document} in which <code>Transform</code> will be
+-     * placed
+-     * @param algorithmURI URI representation of
+-     * <code>Transform algorithm</code> which will be specified as parameter of
+-     * {@link #getInstance(Document, String)}, when generated. </br>
+-     * @param contextNodes the child node list of <code>Transform</code> element
+-     * @throws InvalidTransformException
+-     */
+-    public Transform(Document doc, String algorithmURI, NodeList contextNodes)
+-        throws InvalidTransformException {
+-
+-        super(doc);
+-
+-        this._constructionElement.setAttributeNS
+-            (null, Constants._ATT_ALGORITHM, algorithmURI);
+-
+-        transformSpi = getTransformSpi(algorithmURI);
+-        if (transformSpi == null) {
+-             Object exArgs[] = { algorithmURI };
+-             throw new InvalidTransformException(
+-                "signature.Transform.UnknownTransform", exArgs);
+-        }
+-
+-        if (log.isLoggable(java.util.logging.Level.FINE)) {
+-            log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
+-                   + transformSpi.getClass() + "\"");
+-            log.log(java.util.logging.Level.FINE, "The NodeList is " + contextNodes);
+-        }
+-
+-        // give it to the current document
+-        if (contextNodes != null) {
+-            for (int i = 0; i < contextNodes.getLength(); i++) {
+-               this._constructionElement.appendChild
+-                   (contextNodes.item(i).cloneNode(true));
+-            }
+-        }
+-    }
+-
+-    /**
+-     * This constructor can only be called from the {@link Transforms} object,
+-     * so it's protected.
+-     *
+-     * @param element <code>ds:Transform</code> element
+-     * @param BaseURI the URI of the resource where the XML instance was stored
+-     * @throws InvalidTransformException
+-     * @throws TransformationException
+-     * @throws XMLSecurityException
+-     */
+-    public Transform(Element element, String BaseURI)
+-        throws InvalidTransformException, TransformationException,
+-               XMLSecurityException {
+-
+-        super(element, BaseURI);
+-
+-        // retrieve Algorithm Attribute from ds:Transform
+-        String algorithmURI = element.getAttributeNS(null, Constants._ATT_ALGORITHM);
+-
+-        if (algorithmURI == null || algorithmURI.length() == 0) {
+-            Object exArgs[] = { Constants._ATT_ALGORITHM,
+-                                Constants._TAG_TRANSFORM };
+-            throw new TransformationException("xml.WrongContent", exArgs);
+-        }
+-
+-        transformSpi = getTransformSpi(algorithmURI);
+-        if (transformSpi == null) {
+-            Object exArgs[] = { algorithmURI };
+-            throw new InvalidTransformException(
+-                "signature.Transform.UnknownTransform", exArgs);
+-        }
+-    }
++    private final TransformSpi transformSpi;
+ 
+     /**
+      * Generates a Transform object that implements the specified
+      * <code>Transform algorithm</code> URI.
+      *
++     * @param doc the proxy {@link Document}
+      * @param algorithmURI <code>Transform algorithm</code> URI representation,
+      * such as specified in
+      * <a href=http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg>Transform algorithm </a>
+-     * @param doc the proxy {@link Document}
+-     * @return <code>{@link Transform}</code> object
+      * @throws InvalidTransformException
+      */
+-    public static Transform getInstance(
+-        Document doc, String algorithmURI) throws InvalidTransformException {
+-        return getInstance(doc, algorithmURI, (NodeList) null);
++    public Transform(Document doc, String algorithmURI) throws InvalidTransformException {
++        this(doc, algorithmURI, (NodeList)null);
+     }
+ 
+     /**
+@@ -170,82 +102,160 @@
+      * <a href=http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg>Transform algorithm </a>
+      * @param contextChild the child element of <code>Transform</code> element
+      * @param doc the proxy {@link Document}
+-     * @return <code>{@link Transform}</code> object
+      * @throws InvalidTransformException
+      */
+-    public static Transform getInstance(
+-        Document doc, String algorithmURI, Element contextChild)
++    public Transform(Document doc, String algorithmURI, Element contextChild)
+         throws InvalidTransformException {
++        super(doc);
++        HelperNodeList contextNodes = null;
+ 
+-        HelperNodeList contextNodes = new HelperNodeList();
++        if (contextChild != null) {
++            contextNodes = new HelperNodeList();
+ 
+-        XMLUtils.addReturnToElement(doc, contextNodes);
+-        contextNodes.appendChild(contextChild);
+-        XMLUtils.addReturnToElement(doc, contextNodes);
++            XMLUtils.addReturnToElement(doc, contextNodes);
++            contextNodes.appendChild(contextChild);
++            XMLUtils.addReturnToElement(doc, contextNodes);
++        }
+ 
+-        return getInstance(doc, algorithmURI, contextNodes);
++        transformSpi = initializeTransform(algorithmURI, contextNodes);
+     }
+ 
+     /**
+-     * Generates a Transform object that implements the specified
+-     * <code>Transform algorithm</code> URI.
++     * Constructs {@link Transform}
+      *
+-     * @param algorithmURI <code>Transform algorithm</code> URI form, such as
+-     * specified in <a href=http://www.w3.org/TR/xmldsig-core/#sec-TransformAlg>
+-     * Transform algorithm </a>
++     * @param doc the {@link Document} in which <code>Transform</code> will be
++     * placed
++     * @param algorithmURI URI representation of <code>Transform algorithm</code>
+      * @param contextNodes the child node list of <code>Transform</code> element
+-     * @param doc the proxy {@link Document}
+-     * @return <code>{@link Transform}</code> object
+      * @throws InvalidTransformException
+      */
+-    public static Transform getInstance(
+-        Document doc, String algorithmURI, NodeList contextNodes)
++    public Transform(Document doc, String algorithmURI, NodeList contextNodes)
+         throws InvalidTransformException {
+-        return new Transform(doc, algorithmURI, contextNodes);
++        super(doc);
++        transformSpi = initializeTransform(algorithmURI, contextNodes);
+     }
+ 
+     /**
+-     * Initalizes for this {@link Transform}.
++     * @param element <code>ds:Transform</code> element
++     * @param BaseURI the URI of the resource where the XML instance was stored
++     * @throws InvalidTransformException
++     * @throws TransformationException
++     * @throws XMLSecurityException
+      */
+-    public static void init() {
+-        if (!alreadyInitialized) {
+-            transformClassHash = new HashMap(10);
+-            // make sure builtin algorithms are all registered first
+-            com.sun.org.apache.xml.internal.security.Init.init();
+-            alreadyInitialized = true;
++    public Transform(Element element, String BaseURI)
++        throws InvalidTransformException, TransformationException, XMLSecurityException {
++        super(element, BaseURI);
++
++        // retrieve Algorithm Attribute from ds:Transform
++        String algorithmURI = element.getAttributeNS(null, Constants._ATT_ALGORITHM);
++
++        if (algorithmURI == null || algorithmURI.length() == 0) {
++            Object exArgs[] = { Constants._ATT_ALGORITHM, Constants._TAG_TRANSFORM };
++            throw new TransformationException("xml.WrongContent", exArgs);
++        }
++
++        Class<? extends TransformSpi> transformSpiClass = transformSpiHash.get(algorithmURI);
++        if (transformSpiClass == null) {
++            Object exArgs[] = { algorithmURI };
++            throw new InvalidTransformException("signature.Transform.UnknownTransform", exArgs);
++        }
++        try {
++            transformSpi = transformSpiClass.newInstance();
++        } catch (InstantiationException ex) {
++            Object exArgs[] = { algorithmURI };
++            throw new InvalidTransformException(
++                "signature.Transform.UnknownTransform", exArgs, ex
++            );
++        } catch (IllegalAccessException ex) {
++            Object exArgs[] = { algorithmURI };
++            throw new InvalidTransformException(
++                "signature.Transform.UnknownTransform", exArgs, ex
++            );
+         }
+     }
+ 
+     /**
+      * Registers implementing class of the Transform algorithm with algorithmURI
+      *
+-     * @param algorithmURI algorithmURI URI representation of
+-     * <code>Transform algorithm</code> will be specified as parameter of
+-     * {@link #getInstance(Document, String)}, when generate. </br>
++     * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>
+      * @param implementingClass <code>implementingClass</code> the implementing
+      * class of {@link TransformSpi}
+      * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI
+      * is already registered
+      */
++    @SuppressWarnings("unchecked")
+     public static void register(String algorithmURI, String implementingClass)
++        throws AlgorithmAlreadyRegisteredException, ClassNotFoundException,
++            InvalidTransformException {
++        // are we already registered?
++        Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
++        if (transformSpi != null) {
++            Object exArgs[] = { algorithmURI, transformSpi };
++            throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
++        }
++        Class<? extends TransformSpi> transformSpiClass =
++            (Class<? extends TransformSpi>)
++                ClassLoaderUtils.loadClass(implementingClass, Transform.class);
++        transformSpiHash.put(algorithmURI, transformSpiClass);
++    }
++
++    /**
++     * Registers implementing class of the Transform algorithm with algorithmURI
++     *
++     * @param algorithmURI algorithmURI URI representation of <code>Transform algorithm</code>
++     * @param implementingClass <code>implementingClass</code> the implementing
++     * class of {@link TransformSpi}
++     * @throws AlgorithmAlreadyRegisteredException if specified algorithmURI
++     * is already registered
++     */
++    public static void register(String algorithmURI, Class<? extends TransformSpi> implementingClass)
+         throws AlgorithmAlreadyRegisteredException {
++        // are we already registered?
++        Class<? extends TransformSpi> transformSpi = transformSpiHash.get(algorithmURI);
++        if (transformSpi != null) {
++            Object exArgs[] = { algorithmURI, transformSpi };
++            throw new AlgorithmAlreadyRegisteredException("algorithm.alreadyRegistered", exArgs);
++        }
++        transformSpiHash.put(algorithmURI, implementingClass);
++    }
+ 
+-        // are we already registered?
+-        Class registeredClass = getImplementingClass(algorithmURI);
+-        if ((registeredClass != null) ) {
+-            Object exArgs[] = { algorithmURI, registeredClass };
+-            throw new AlgorithmAlreadyRegisteredException(
+-               "algorithm.alreadyRegistered", exArgs);
+-        }
+-
+-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+-
+-        try {
+-            transformClassHash.put
+-                (algorithmURI, Class.forName(implementingClass, true, cl));
+-        } catch (ClassNotFoundException e) {
+-            throw new RuntimeException(e);
+-        }
++    /**
++     * This method registers the default algorithms.
++     */
++    public static void registerDefaultAlgorithms() {
++        transformSpiHash.put(
++            Transforms.TRANSFORM_BASE64_DECODE, TransformBase64Decode.class
++        );
++        transformSpiHash.put(
++            Transforms.TRANSFORM_C14N_OMIT_COMMENTS, TransformC14N.class
++        );
++        transformSpiHash.put(
++            Transforms.TRANSFORM_C14N_WITH_COMMENTS, TransformC14NWithComments.class
++        );
++        transformSpiHash.put(
++            Transforms.TRANSFORM_C14N11_OMIT_COMMENTS, TransformC14N11.class
++        );
++        transformSpiHash.put(
++            Transforms.TRANSFORM_C14N11_WITH_COMMENTS, TransformC14N11_WithComments.class
++        );
++        transformSpiHash.put(
++            Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS, TransformC14NExclusive.class
++        );
++        transformSpiHash.put(
++            Transforms.TRANSFORM_C14N_EXCL_WITH_COMMENTS, TransformC14NExclusiveWithComments.class
++        );
++        transformSpiHash.put(
++            Transforms.TRANSFORM_XPATH, TransformXPath.class
++        );
++        transformSpiHash.put(
++            Transforms.TRANSFORM_ENVELOPED_SIGNATURE, TransformEnvelopedSignature.class
++        );
++        transformSpiHash.put(
++            Transforms.TRANSFORM_XSLT, TransformXSLT.class
++        );
++        transformSpiHash.put(
++            Transforms.TRANSFORM_XPATH2FILTER, TransformXPath2Filter.class
++        );
+     }
+ 
+     /**
+@@ -254,8 +264,7 @@
+      * @return the URI representation of Transformation algorithm
+      */
+     public String getURI() {
+-        return this._constructionElement.getAttributeNS
+-            (null, Constants._ATT_ALGORITHM);
++        return this._constructionElement.getAttributeNS(null, Constants._ATT_ALGORITHM);
+     }
+ 
+     /**
+@@ -271,30 +280,15 @@
+      * @throws TransformationException
+      */
+     public XMLSignatureInput performTransform(XMLSignatureInput input)
+-         throws IOException, CanonicalizationException,
+-                InvalidCanonicalizerException, TransformationException {
+-
+-        XMLSignatureInput result = null;
+-
+-        try {
+-            result = transformSpi.enginePerformTransform(input, this);
+-        } catch (ParserConfigurationException ex) {
+-            Object exArgs[] = { this.getURI(), "ParserConfigurationException" };
+-            throw new CanonicalizationException(
+-                "signature.Transform.ErrorDuringTransform", exArgs, ex);
+-        } catch (SAXException ex) {
+-            Object exArgs[] = { this.getURI(), "SAXException" };
+-            throw new CanonicalizationException(
+-                "signature.Transform.ErrorDuringTransform", exArgs, ex);
+-        }
+-
+-        return result;
++        throws IOException, CanonicalizationException,
++               InvalidCanonicalizerException, TransformationException {
++        return performTransform(input, null);
+     }
+ 
+     /**
+      * Transforms the input, and generates {@link XMLSignatureInput} as output.
+      *
+-     * @param input input {@link XMLSignatureInput} which can supplied Octet
++     * @param input input {@link XMLSignatureInput} which can supplied Octect
+      * Stream and NodeSet as Input of Transformation
+      * @param os where to output the result of the last transformation
+      * @return the {@link XMLSignatureInput} class as the result of
+@@ -304,10 +298,10 @@
+      * @throws InvalidCanonicalizerException
+      * @throws TransformationException
+      */
+-    public XMLSignatureInput performTransform(XMLSignatureInput input,
+-        OutputStream os) throws IOException, CanonicalizationException,
++    public XMLSignatureInput performTransform(
++        XMLSignatureInput input, OutputStream os
++    ) throws IOException, CanonicalizationException,
+         InvalidCanonicalizerException, TransformationException {
+-
+         XMLSignatureInput result = null;
+ 
+         try {
+@@ -325,43 +319,52 @@
+         return result;
+     }
+ 
+-    /**
+-     * Method getImplementingClass
+-     *
+-     * @param URI
+-     * @return The name of the class implementing the URI.
+-     */
+-    private static Class getImplementingClass(String URI) {
+-        return (Class) transformClassHash.get(URI);
+-    }
+-
+-    private static TransformSpi getTransformSpi(String URI)
+-        throws InvalidTransformException {
+-        try {
+-            Object value = transformSpiHash.get(URI);
+-            if (value != null) {
+-                return (TransformSpi) value;
+-            }
+-            Class cl = (Class) transformClassHash.get(URI);
+-            if (cl != null) {
+-                TransformSpi tr = (TransformSpi) cl.newInstance();
+-                transformSpiHash.put(URI, tr);
+-                return tr;
+-            }
+-        } catch (InstantiationException ex) {
+-            Object exArgs[] = { URI };
+-            throw new InvalidTransformException(
+-                "signature.Transform.UnknownTransform", exArgs, ex);
+-        } catch (IllegalAccessException ex) {
+-            Object exArgs[] = { URI };
+-            throw new InvalidTransformException(
+-                "signature.Transform.UnknownTransform", exArgs, ex);
+-        }
+-        return null;
+-    }
+-
+     /** @inheritDoc */
+     public String getBaseLocalName() {
+         return Constants._TAG_TRANSFORM;
+     }
++
++    /**
++     * Initialize the transform object.
++     */
++    private TransformSpi initializeTransform(String algorithmURI, NodeList contextNodes)
++        throws InvalidTransformException {
++
++        this._constructionElement.setAttributeNS(null, Constants._ATT_ALGORITHM, algorithmURI);
++
++        Class<? extends TransformSpi> transformSpiClass = transformSpiHash.get(algorithmURI);
++        if (transformSpiClass == null) {
++            Object exArgs[] = { algorithmURI };
++            throw new InvalidTransformException("signature.Transform.UnknownTransform", exArgs);
++        }
++        TransformSpi newTransformSpi = null;
++        try {
++            newTransformSpi = transformSpiClass.newInstance();
++        } catch (InstantiationException ex) {
++            Object exArgs[] = { algorithmURI };
++            throw new InvalidTransformException(
++                "signature.Transform.UnknownTransform", exArgs, ex
++            );
++        } catch (IllegalAccessException ex) {
++            Object exArgs[] = { algorithmURI };
++            throw new InvalidTransformException(
++                "signature.Transform.UnknownTransform", exArgs, ex
++            );
++        }
++
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
++                      + newTransformSpi.getClass() + "\"");
++            log.log(java.util.logging.Level.FINE, "The NodeList is " + contextNodes);
++        }
++
++        // give it to the current document
++        if (contextNodes != null) {
++            for (int i = 0; i < contextNodes.getLength(); i++) {
++                this._constructionElement.appendChild(contextNodes.item(i).cloneNode(true));
++            }
++        }
++        return newTransformSpi;
++    }
++
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transforms.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transforms.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transforms.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transforms.java
+@@ -158,8 +158,7 @@
+             if (log.isLoggable(java.util.logging.Level.FINE))
+                 log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transformURI + ")");
+ 
+-            Transform transform =
+-                Transform.getInstance(this._doc, transformURI);
++            Transform transform = new Transform(this._doc, transformURI);
+ 
+             this.addTransform(transform);
+         } catch (InvalidTransformException ex) {
+@@ -184,8 +183,7 @@
+             if (log.isLoggable(java.util.logging.Level.FINE))
+                 log.log(java.util.logging.Level.FINE, "Transforms.addTransform(" + transformURI + ")");
+ 
+-            Transform transform =
+-                Transform.getInstance(this._doc, transformURI, contextElement);
++            Transform transform = new Transform(this._doc, transformURI, contextElement);
+ 
+             this.addTransform(transform);
+         } catch (InvalidTransformException ex) {
+@@ -207,8 +205,7 @@
+            throws TransformationException {
+ 
+         try {
+-            Transform transform =
+-                Transform.getInstance(this._doc, transformURI, contextNodes);
++            Transform transform = new Transform(this._doc, transformURI, contextNodes);
+             this.addTransform(transform);
+         } catch (InvalidTransformException ex) {
+             throw new TransformationException("empty", ex);
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformBase64Decode.java
+@@ -26,6 +26,7 @@
+ import java.io.IOException;
+ import java.io.OutputStream;
+ 
++import javax.xml.XMLConstants;
+ import javax.xml.parsers.DocumentBuilderFactory;
+ import javax.xml.parsers.ParserConfigurationException;
+ 
+@@ -145,11 +146,13 @@
+       }
+ 
+          try {
+-            //Exceptional case there is current not text case testing this(Before it was a
+-                    //a common case).
++            // Exceptional case there is current not text case testing this
++            // (before it was a a common case).
++            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
++            dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
++                           Boolean.TRUE);
+             Document doc =
+-               DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(
+-                  input.getOctetStream());
++                dbf.newDocumentBuilder().parse(input.getOctetStream());
+ 
+             Element rootNode = doc.getDocumentElement();
+             StringBuffer sb = new StringBuffer();
+@@ -157,13 +160,13 @@
+             byte[] decodedBytes = Base64.decode(sb.toString());
+ 
+             return new XMLSignatureInput(decodedBytes);
+-                  } catch (ParserConfigurationException e) {
+-                          throw new TransformationException("c14n.Canonicalizer.Exception",e);
+-                  } catch (SAXException e) {
+-                          throw new TransformationException("SAX exception", e);
+-                  }
++         } catch (ParserConfigurationException e) {
++            throw new TransformationException("c14n.Canonicalizer.Exception",e);
++         } catch (SAXException e) {
++            throw new TransformationException("SAX exception", e);
++         }
+         } catch (Base64DecodingException e) {
+-        throw new TransformationException("Base64Decoding", e);
++            throw new TransformationException("Base64Decoding", e);
+         }
+    }
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/implementations/TransformXSLT.java
+@@ -26,6 +26,7 @@
+ import java.io.OutputStream;
+ import java.lang.reflect.Method;
+ 
++import javax.xml.XMLConstants;
+ import javax.xml.transform.Source;
+ import javax.xml.transform.Transformer;
+ import javax.xml.transform.TransformerConfigurationException;
+@@ -62,14 +63,6 @@
+    static final String defaultXSLTSpecNSprefix = "xslt";
+    static final String XSLTSTYLESHEET          = "stylesheet";
+ 
+-   // check for secure processing feature
+-   private static Class xClass = null;
+-   static {
+-      try {
+-         xClass = Class.forName("javax.xml.XMLConstants");
+-      } catch (Exception e) {}
+-   }
+-
+    static java.util.logging.Logger log =
+       java.util.logging.Logger.getLogger(
+          TransformXSLT.class.getName());
+@@ -101,10 +94,6 @@
+     protected XMLSignatureInput enginePerformTransform(XMLSignatureInput input,OutputStream baos, Transform _transformObject)
+     throws IOException,
+            TransformationException {
+-      if (xClass == null) {
+-         Object exArgs[] = { "SECURE_PROCESSING_FEATURE not supported" };
+-         throw new TransformationException("generic.EmptyMessage", exArgs);
+-      }
+       try {
+          Element transformElement = _transformObject.getElement();
+ 
+@@ -119,11 +108,10 @@
+          }
+ 
+          TransformerFactory tFactory = TransformerFactory.newInstance();
+-         Class c = tFactory.getClass();
+-         Method m = c.getMethod("setFeature", new Class[] {String.class, boolean.class});
++
+          // Process XSLT stylesheets in a secure manner
+-         m.invoke(tFactory, new Object[] {"http://javax.xml.XMLConstants/feature/secure-processing", Boolean.TRUE});
+-
++         tFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
++                             Boolean.TRUE);
+          /*
+           * This transform requires an octet stream as input. If the actual
+           * input is an XPath node-set, then the signature application should
+@@ -193,18 +181,6 @@
+          Object exArgs[] = { ex.getMessage() };
+ 
+          throw new TransformationException("generic.EmptyMessage", exArgs, ex);
+-      } catch (NoSuchMethodException ex) {
+-         Object exArgs[] = { ex.getMessage() };
+-
+-         throw new TransformationException("generic.EmptyMessage", exArgs, ex);
+-      } catch (IllegalAccessException ex) {
+-         Object exArgs[] = { ex.getMessage() };
+-
+-         throw new TransformationException("generic.EmptyMessage", exArgs, ex);
+-      } catch (java.lang.reflect.InvocationTargetException ex) {
+-         Object exArgs[] = { ex.getMessage() };
+-
+-         throw new TransformationException("generic.EmptyMessage", exArgs, ex);
+       }
+    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ElementProxy.java
+@@ -2,28 +2,29 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-/*
+- * Copyright 1999-2008 The Apache Software Foundation.
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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
+  *
+- *  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
+  *
+- *      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.
+- *
++ * 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.
+  */
+ package com.sun.org.apache.xml.internal.security.utils;
+ 
+-
+-
+ import java.math.BigInteger;
+-import java.util.HashMap;
++import java.util.concurrent.ConcurrentHashMap;
++import java.util.Map;
+ 
+ import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException;
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+@@ -34,467 +35,432 @@
+ import org.w3c.dom.NodeList;
+ import org.w3c.dom.Text;
+ 
+-
+ /**
+  * This is the base class to all Objects which have a direct 1:1 mapping to an
+  * Element in a particular namespace.
+- *
+- * @author $Author: mullan $
+  */
+ public abstract class ElementProxy {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
++    protected static final java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(ElementProxy.class.getName());
+ 
+-   /**
+-    * Returns the namespace of the Elements of the sub-class.
+-    *
+-    * @return the namespace of the Elements of the sub-class.
+-    */
+-   public abstract String getBaseNamespace();
++    /** Field constructionElement */
++    protected Element _constructionElement = null;
+ 
+-   /**
+-    * Returns the localname of the Elements of the sub-class.
+-    *
+-    * @return the localname of the Elements of the sub-class.
+-    */
+-   public abstract String getBaseLocalName();
++    /** Field baseURI */
++    protected String _baseURI = null;
+ 
+-   /** Field _constructionElement */
+-   protected Element _constructionElement = null;
++    /** Field doc */
++    protected Document _doc = null;
+ 
+-   /** Field _baseURI */
+-   protected String _baseURI = null;
++    /** Field prefixMappings */
++    private static Map<String, String> prefixMappings = new ConcurrentHashMap<String, String>();
+ 
+-   /** Field _doc */
+-   protected Document _doc = null;
++    /**
++     * Constructor ElementProxy
++     *
++     */
++    public ElementProxy() {
++    }
+ 
+-   /**
+-    * Constructor ElementProxy
+-    *
+-    */
+-   public ElementProxy() {
+-   }
++    /**
++     * Constructor ElementProxy
++     *
++     * @param doc
++     */
++    public ElementProxy(Document doc) {
++        if (doc == null) {
++            throw new RuntimeException("Document is null");
++        }
+ 
+-   /**
+-    * Constructor ElementProxy
+-    *
+-    * @param doc
+-    */
+-   public ElementProxy(Document doc) {
+-      if (doc == null) {
+-         throw new RuntimeException("Document is null");
+-      }
++        this._doc = doc;
++        this._constructionElement =
++            createElementForFamilyLocal(this._doc, this.getBaseNamespace(), this.getBaseLocalName());
++    }
+ 
+-      this._doc = doc;
+-      this._constructionElement = createElementForFamilyLocal(this._doc,
+-                  this.getBaseNamespace(), this.getBaseLocalName());
+-   }
+-   protected Element createElementForFamilyLocal(Document doc, String namespace,
+-           String localName) {
+-                  Element result = null;
+-              if (namespace == null) {
+-                 result = doc.createElementNS(null, localName);
+-              } else {
+-                  String baseName=this.getBaseNamespace();
+-                  String prefix=ElementProxy.getDefaultPrefix(baseName);
+-                 if ((prefix == null) || (prefix.length() == 0)) {
+-                    result = doc.createElementNS(namespace, localName);
++    /**
++     * Constructor ElementProxy
++     *
++     * @param element
++     * @param BaseURI
++     * @throws XMLSecurityException
++     */
++    public ElementProxy(Element element, String BaseURI) throws XMLSecurityException {
++        if (element == null) {
++            throw new XMLSecurityException("ElementProxy.nullElement");
++        }
+ 
+-                    result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns",
+-                                          namespace);
+-                 } else {
+-                         String tagName=null;
+-                         String defaultPrefixNaming=ElementProxy.getDefaultPrefixBindings(baseName);
+-                         StringBuffer sb=new StringBuffer(prefix);
+-                         sb.append(':');
+-                         sb.append(localName);
+-                         tagName=sb.toString();
+-                    result = doc.createElementNS(namespace, tagName );
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "setElement(\"" + element.getTagName() + "\", \"" + BaseURI + "\")");
++        }
+ 
+-                    result.setAttributeNS(Constants.NamespaceSpecNS,  defaultPrefixNaming,
+-                                          namespace);
+-                 }
+-              }
+-              return result;
+-}
++        this._doc = element.getOwnerDocument();
++        this._constructionElement = element;
++        this._baseURI = BaseURI;
+ 
++        this.guaranteeThatElementInCorrectSpace();
++    }
+ 
+-   /**
+-    * This method creates an Element in a given namespace with a given localname.
+-    * It uses the {@link ElementProxy#getDefaultPrefix} method to decide whether
+-    * a particular prefix is bound to that namespace.
+-    * <BR />
+-    * This method was refactored out of the constructor.
+-    *
+-    * @param doc
+-    * @param namespace
+-    * @param localName
+-    * @return The element created.
+-    */
+-   public static Element createElementForFamily(Document doc, String namespace,
+-           String localName) {
+-       //Element nscontext = XMLUtils.createDSctx(doc, "x", namespace);
+-      Element result = null;
+-      String prefix = ElementProxy.getDefaultPrefix(namespace);
++    /**
++     * Returns the namespace of the Elements of the sub-class.
++     *
++     * @return the namespace of the Elements of the sub-class.
++     */
++    public abstract String getBaseNamespace();
+ 
+-      if (namespace == null) {
+-         result = doc.createElementNS(null, localName);
+-      } else {
+-         if ((prefix == null) || (prefix.length() == 0)) {
+-            result = doc.createElementNS(namespace, localName);
++    /**
++     * Returns the localname of the Elements of the sub-class.
++     *
++     * @return the localname of the Elements of the sub-class.
++     */
++    public abstract String getBaseLocalName();
+ 
+-            result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns",
+-                                  namespace);
+-         } else {
+-            result = doc.createElementNS(namespace, prefix + ":" + localName);
+ 
+-            result.setAttributeNS(Constants.NamespaceSpecNS,  ElementProxy.getDefaultPrefixBindings(namespace),
+-                                  namespace);
+-         }
+-      }
++    protected Element createElementForFamilyLocal(
++        Document doc, String namespace, String localName
++    ) {
++        Element result = null;
++        if (namespace == null) {
++            result = doc.createElementNS(null, localName);
++        } else {
++            String baseName = this.getBaseNamespace();
++            String prefix = ElementProxy.getDefaultPrefix(baseName);
++            if ((prefix == null) || (prefix.length() == 0)) {
++                result = doc.createElementNS(namespace, localName);
++                result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", namespace);
++            } else {
++                result = doc.createElementNS(namespace, prefix + ":" + localName);
++                result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix, namespace);
++            }
++        }
++        return result;
++    }
+ 
+-      return result;
+-   }
+ 
+-   /**
+-    * Method setElement
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @throws XMLSecurityException
+-    */
+-   public void setElement(Element element, String BaseURI)
+-           throws XMLSecurityException {
++    /**
++     * This method creates an Element in a given namespace with a given localname.
++     * It uses the {@link ElementProxy#getDefaultPrefix} method to decide whether
++     * a particular prefix is bound to that namespace.
++     * <BR />
++     * This method was refactored out of the constructor.
++     *
++     * @param doc
++     * @param namespace
++     * @param localName
++     * @return The element created.
++     */
++    public static Element createElementForFamily(Document doc, String namespace, String localName) {
++        Element result = null;
++        String prefix = ElementProxy.getDefaultPrefix(namespace);
+ 
+-      if (element == null) {
+-         throw new XMLSecurityException("ElementProxy.nullElement");
+-      }
++        if (namespace == null) {
++            result = doc.createElementNS(null, localName);
++        } else {
++            if ((prefix == null) || (prefix.length() == 0)) {
++                result = doc.createElementNS(namespace, localName);
++                result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", namespace);
++            } else {
++                result = doc.createElementNS(namespace, prefix + ":" + localName);
++                result.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:" + prefix, namespace);
++            }
++        }
+ 
+-      if (log.isLoggable(java.util.logging.Level.FINE)) {
+-        log.log(java.util.logging.Level.FINE, "setElement(" + element.getTagName() + ", \"" + BaseURI + "\"");
+-      }
++        return result;
++    }
+ 
+-      this._doc = element.getOwnerDocument();
+-      this._constructionElement = element;
+-      this._baseURI = BaseURI;
+-   }
++    /**
++     * Method setElement
++     *
++     * @param element
++     * @param BaseURI
++     * @throws XMLSecurityException
++     */
++    public void setElement(Element element, String BaseURI) throws XMLSecurityException {
++        if (element == null) {
++            throw new XMLSecurityException("ElementProxy.nullElement");
++        }
+ 
+-   /**
+-    * Constructor ElementProxy
+-    *
+-    * @param element
+-    * @param BaseURI
+-    * @throws XMLSecurityException
+-    */
+-   public ElementProxy(Element element, String BaseURI)
+-           throws XMLSecurityException {
+-      if (element == null) {
+-         throw new XMLSecurityException("ElementProxy.nullElement");
+-      }
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "setElement(" + element.getTagName() + ", \"" + BaseURI + "\"");
++        }
+ 
+-      if (log.isLoggable(java.util.logging.Level.FINE)) {
+-        log.log(java.util.logging.Level.FINE, "setElement(\"" + element.getTagName() + "\", \"" + BaseURI
+-                + "\")");
+-      }
++        this._doc = element.getOwnerDocument();
++        this._constructionElement = element;
++        this._baseURI = BaseURI;
++    }
+ 
+-      this._doc = element.getOwnerDocument();
+-      this._constructionElement = element;
+-      this._baseURI = BaseURI;
+ 
+-      this.guaranteeThatElementInCorrectSpace();
+-   }
++    /**
++     * Returns the Element which was constructed by the Object.
++     *
++     * @return the Element which was constructed by the Object.
++     */
++    public final Element getElement() {
++        return this._constructionElement;
++    }
+ 
+-   /**
+-    * Returns the Element which was constructed by the Object.
+-    *
+-    * @return the Element which was constructed by the Object.
+-    */
+-   public final Element getElement() {
+-      return this._constructionElement;
+-   }
++    /**
++     * Returns the Element plus a leading and a trailing CarriageReturn Text node.
++     *
++     * @return the Element which was constructed by the Object.
++     */
++    public final NodeList getElementPlusReturns() {
+ 
+-   /**
+-    * Returns the Element plus a leading and a trailing CarriageReturn Text node.
+-    *
+-    * @return the Element which was constructed by the Object.
+-    */
+-   public final NodeList getElementPlusReturns() {
++        HelperNodeList nl = new HelperNodeList();
+ 
+-      HelperNodeList nl = new HelperNodeList();
++        nl.appendChild(this._doc.createTextNode("\n"));
++        nl.appendChild(this.getElement());
++        nl.appendChild(this._doc.createTextNode("\n"));
+ 
+-      nl.appendChild(this._doc.createTextNode("\n"));
+-      nl.appendChild(this.getElement());
+-      nl.appendChild(this._doc.createTextNode("\n"));
++        return nl;
++    }
+ 
+-      return nl;
+-   }
++    /**
++     * Method getDocument
++     *
++     * @return the Document where this element is contained.
++     */
++    public Document getDocument() {
++        return this._doc;
++    }
+ 
+-   /**
+-    * Method getDocument
+-    *
+-    * @return the Document where this element is contained.
+-    */
+-   public Document getDocument() {
+-      return this._doc;
+-   }
++    /**
++     * Method getBaseURI
++     *
++     * @return the base uri of the namespace of this element
++     */
++    public String getBaseURI() {
++        return this._baseURI;
++    }
+ 
+-   /**
+-    * Method getBaseURI
+-    *
+-    * @return the base uri of the namespace of this element
+-    */
+-   public String getBaseURI() {
+-      return this._baseURI;
+-   }
++    /**
++     * Method guaranteeThatElementInCorrectSpace
++     *
++     * @throws XMLSecurityException
++     */
++    void guaranteeThatElementInCorrectSpace() throws XMLSecurityException {
+ 
+-   static ElementChecker checker = new ElementCheckerImpl.InternedNsChecker();
++        String expectedLocalName = this.getBaseLocalName();
++        String expectedNamespaceUri = this.getBaseNamespace();
+ 
+-   /**
+-    * Method guaranteeThatElementInCorrectSpace
+-    *
+-    * @throws XMLSecurityException
+-    */
+-   void guaranteeThatElementInCorrectSpace()
+-           throws XMLSecurityException {
++        String actualLocalName = this._constructionElement.getLocalName();
++        String actualNamespaceUri = this._constructionElement.getNamespaceURI();
+ 
+-          checker.guaranteeThatElementInCorrectSpace(this,this._constructionElement);
++        if(!expectedNamespaceUri.equals(actualNamespaceUri)
++            && !expectedLocalName.equals(actualLocalName)) {
++            Object exArgs[] = { actualNamespaceUri + ":" + actualLocalName,
++                                expectedNamespaceUri + ":" + expectedLocalName};
++            throw new XMLSecurityException("xml.WrongElement", exArgs);
++        }
++    }
+ 
+-   }
++    /**
++     * Method addBigIntegerElement
++     *
++     * @param bi
++     * @param localname
++     */
++    public void addBigIntegerElement(BigInteger bi, String localname) {
++        if (bi != null) {
++            Element e = XMLUtils.createElementInSignatureSpace(this._doc, localname);
+ 
+-   /**
+-    * Method setVal
+-    *
+-    * @param bi
+-    * @param localname
+-    */
+-   public void addBigIntegerElement(BigInteger bi, String localname) {
++            Base64.fillElementWithBigInteger(e, bi);
++            this._constructionElement.appendChild(e);
++            XMLUtils.addReturnToElement(this._constructionElement);
++        }
++    }
+ 
+-      if (bi != null) {
+-         Element e = XMLUtils.createElementInSignatureSpace(this._doc,
+-                        localname);
++    /**
++     * Method addBase64Element
++     *
++     * @param bytes
++     * @param localname
++     */
++    public void addBase64Element(byte[] bytes, String localname) {
++        if (bytes != null) {
++            Element e = Base64.encodeToElement(this._doc, localname, bytes);
+ 
+-         Base64.fillElementWithBigInteger(e, bi);
+-         this._constructionElement.appendChild(e);
+-         XMLUtils.addReturnToElement(this._constructionElement);
+-      }
+-   }
++            this._constructionElement.appendChild(e);
++            if (!XMLUtils.ignoreLineBreaks()) {
++                this._constructionElement.appendChild(this._doc.createTextNode("\n"));
++            }
++        }
++    }
+ 
+-   /**
+-    * Method addBase64Element
+-    *
+-    * @param bytes
+-    * @param localname
+-    */
+-   public void addBase64Element(byte[] bytes, String localname) {
++    /**
++     * Method addTextElement
++     *
++     * @param text
++     * @param localname
++     */
++    public void addTextElement(String text, String localname) {
++        Element e = XMLUtils.createElementInSignatureSpace(this._doc, localname);
++        Text t = this._doc.createTextNode(text);
+ 
+-      if (bytes != null) {
++        e.appendChild(t);
++        this._constructionElement.appendChild(e);
++        XMLUtils.addReturnToElement(this._constructionElement);
++    }
+ 
+-         Element e = Base64.encodeToElement(this._doc, localname, bytes);
++    /**
++     * Method addBase64Text
++     *
++     * @param bytes
++     */
++    public void addBase64Text(byte[] bytes) {
++        if (bytes != null) {
++            Text t = XMLUtils.ignoreLineBreaks()
++                ? this._doc.createTextNode(Base64.encode(bytes))
++                : this._doc.createTextNode("\n" + Base64.encode(bytes) + "\n");
++            this._constructionElement.appendChild(t);
++        }
++    }
+ 
+-         this._constructionElement.appendChild(e);
+-         if (!XMLUtils.ignoreLineBreaks()) {
+-            this._constructionElement.appendChild(this._doc.createTextNode("\n"));
+-         }
+-      }
+-   }
++    /**
++     * Method addText
++     *
++     * @param text
++     */
++    public void addText(String text) {
++        if (text != null) {
++            Text t = this._doc.createTextNode(text);
+ 
+-   /**
+-    * Method addTextElement
+-    *
+-    * @param text
+-    * @param localname
+-    */
+-   public void addTextElement(String text, String localname) {
++            this._constructionElement.appendChild(t);
++        }
++    }
+ 
+-      Element e = XMLUtils.createElementInSignatureSpace(this._doc, localname);
+-      Text t = this._doc.createTextNode(text);
++    /**
++     * Method getVal
++     *
++     * @param localname
++     * @param namespace
++     * @return The biginteger contained in the given element
++     * @throws Base64DecodingException
++     */
++    public BigInteger getBigIntegerFromChildElement(
++        String localname, String namespace
++    ) throws Base64DecodingException {
++        return Base64.decodeBigIntegerFromText(
++            XMLUtils.selectNodeText(
++                this._constructionElement.getFirstChild(), namespace, localname, 0
++            )
++        );
++    }
+ 
+-      e.appendChild(t);
+-      this._constructionElement.appendChild(e);
+-      XMLUtils.addReturnToElement(this._constructionElement);
+-   }
++    /**
++     * Method getBytesFromChildElement
++     * @deprecated
++     * @param localname
++     * @param namespace
++     * @return the bytes
++     * @throws XMLSecurityException
++     */
++    @Deprecated
++    public byte[] getBytesFromChildElement(String localname, String namespace)
++        throws XMLSecurityException {
++        Element e =
++            XMLUtils.selectNode(
++                this._constructionElement.getFirstChild(), namespace, localname, 0
++            );
+ 
+-   /**
+-    * Method addBase64Text
+-    *
+-    * @param bytes
+-    */
+-   public void addBase64Text(byte[] bytes) {
++        return Base64.decode(e);
++    }
+ 
+-      if (bytes != null) {
+-         Text t = XMLUtils.ignoreLineBreaks()
+-             ? this._doc.createTextNode(Base64.encode(bytes))
+-             : this._doc.createTextNode("\n" + Base64.encode(bytes) + "\n");
+-         this._constructionElement.appendChild(t);
+-      }
+-   }
++    /**
++     * Method getTextFromChildElement
++     *
++     * @param localname
++     * @param namespace
++     * @return the Text of the textNode
++     */
++    public String getTextFromChildElement(String localname, String namespace) {
++        return XMLUtils.selectNode(
++                this._constructionElement.getFirstChild(),
++                namespace,
++                localname,
++                0).getTextContent();
++    }
+ 
+-   /**
+-    * Method addText
+-    *
+-    * @param text
+-    */
+-   public void addText(String text) {
++    /**
++     * Method getBytesFromTextChild
++     *
++     * @return The base64 bytes from the text children of this element
++     * @throws XMLSecurityException
++     */
++    public byte[] getBytesFromTextChild() throws XMLSecurityException {
++        return Base64.decode(XMLUtils.getFullTextChildrenFromElement(this._constructionElement));
++    }
+ 
+-      if (text != null) {
+-         Text t = this._doc.createTextNode(text);
++    /**
++     * Method getTextFromTextChild
++     *
++     * @return the Text obtained by concatenating all the text nodes of this
++     *    element
++     */
++    public String getTextFromTextChild() {
++        return XMLUtils.getFullTextChildrenFromElement(this._constructionElement);
++    }
+ 
+-         this._constructionElement.appendChild(t);
+-      }
+-   }
++    /**
++     * Method length
++     *
++     * @param namespace
++     * @param localname
++     * @return the number of elements {namespace}:localname under this element
++     */
++    public int length(String namespace, String localname) {
++        int number = 0;
++        Node sibling = this._constructionElement.getFirstChild();
++        while (sibling != null) {
++            if (localname.equals(sibling.getLocalName())
++                && namespace.equals(sibling.getNamespaceURI())) {
++                number++;
++            }
++            sibling = sibling.getNextSibling();
++        }
++        return number;
++    }
+ 
+-   /**
+-    * Method getVal
+-    *
+-    * @param localname
+-    * @param namespace
+-    * @return The biginter contained in the given element
+- * @throws Base64DecodingException
+-    */
+-   public BigInteger getBigIntegerFromChildElement(
+-           String localname, String namespace) throws Base64DecodingException {
++    /**
++     * Adds an xmlns: definition to the Element. This can be called as follows:
++     *
++     * <PRE>
++     * // set namespace with ds prefix
++     * xpathContainer.setXPathNamespaceContext("ds", "http://www.w3.org/2000/09/xmldsig#");
++     * xpathContainer.setXPathNamespaceContext("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#");
++     * </PRE>
++     *
++     * @param prefix
++     * @param uri
++     * @throws XMLSecurityException
++     */
++    public void setXPathNamespaceContext(String prefix, String uri)
++        throws XMLSecurityException {
++        String ns;
+ 
+-                return Base64.decodeBigIntegerFromText(
+-                                XMLUtils.selectNodeText(this._constructionElement.getFirstChild(),
+-                                                namespace,localname,0));
++        if ((prefix == null) || (prefix.length() == 0)) {
++            throw new XMLSecurityException("defaultNamespaceCannotBeSetHere");
++        } else if (prefix.equals("xmlns")) {
++            throw new XMLSecurityException("defaultNamespaceCannotBeSetHere");
++        } else if (prefix.startsWith("xmlns:")) {
++            ns = prefix;//"xmlns:" + prefix.substring("xmlns:".length());
++        } else {
++            ns = "xmlns:" + prefix;
++        }
+ 
+-   }
++        Attr a = this._constructionElement.getAttributeNodeNS(Constants.NamespaceSpecNS, ns);
+ 
+-   /**
+-    * Method getBytesFromChildElement
+-    * @deprecated
+-    * @param localname
+-    * @param namespace
+-    * @return the bytes
+-    * @throws XMLSecurityException
+-    */
+-   public byte[] getBytesFromChildElement(String localname, String namespace)
+-           throws XMLSecurityException {
++        if (a != null) {
++            if (!a.getNodeValue().equals(uri)) {
++                Object exArgs[] = { ns, this._constructionElement.getAttributeNS(null, ns) };
+ 
+-         Element e =
+-             XMLUtils.selectNode(
+-                 this._constructionElement.getFirstChild(),
+-                 namespace,
+-                 localname,
+-                 0);
++                throw new XMLSecurityException("namespacePrefixAlreadyUsedByOtherURI", exArgs);
++            }
++            return;
++        }
+ 
+-         return Base64.decode(e);
+-   }
+-
+-   /**
+-    * Method getTextFromChildElement
+-    *
+-    * @param localname
+-    * @param namespace
+-    * @return the Text of the textNode
+-    */
+-   public String getTextFromChildElement(String localname, String namespace) {
+-
+-         Text t =
+-             (Text) XMLUtils.selectNode(
+-                        this._constructionElement.getFirstChild(),
+-                        namespace,
+-                        localname,
+-                        0).getFirstChild();
+-
+-         return t.getData();
+-   }
+-
+-   /**
+-    * Method getBytesFromTextChild
+-    *
+-    * @return The base64 bytes from the text children of this element
+-    * @throws XMLSecurityException
+-    */
+-   public byte[] getBytesFromTextChild() throws XMLSecurityException {
+-      return Base64.decode
+-         (XMLUtils.getFullTextChildrenFromElement(this._constructionElement));
+-   }
+-
+-   /**
+-    * Method getTextFromTextChild
+-    *
+-    * @return the Text obtained by concatenating all the text nodes of this
+-    *    element
+-    */
+-   public String getTextFromTextChild() {
+-      return XMLUtils.getFullTextChildrenFromElement(this._constructionElement);
+-   }
+-
+-   /**
+-    * Method length
+-    *
+-    * @param namespace
+-    * @param localname
+-    * @return the number of elements {namespace}:localname under this element
+-    */
+-   public int length(String namespace, String localname) {
+-            int number=0;
+-            Node sibling=this._constructionElement.getFirstChild();
+-            while (sibling!=null) {
+-                if (localname.equals(sibling.getLocalName())
+-                                &&
+-                                        namespace==sibling.getNamespaceURI() ) {
+-                        number++;
+-                }
+-                sibling=sibling.getNextSibling();
+-            }
+-            return number;
+-     }
+-
+-   /**
+-    * Adds an xmlns: definition to the Element. This can be called as follows:
+-    *
+-    * <PRE>
+-    * // set namespace with ds prefix
+-    * xpathContainer.setXPathNamespaceContext("ds", "http://www.w3.org/2000/09/xmldsig#");
+-    * xpathContainer.setXPathNamespaceContext("xmlns:ds", "http://www.w3.org/2000/09/xmldsig#");
+-    * </PRE>
+-    *
+-    * @param prefix
+-    * @param uri
+-    * @throws XMLSecurityException
+-    */
+-   public void setXPathNamespaceContext(String prefix, String uri)
+-           throws XMLSecurityException {
+-
+-      String ns;
+-
+-      if ((prefix == null) || (prefix.length() == 0)) {
+-       throw new XMLSecurityException("defaultNamespaceCannotBeSetHere");
+-      } else if (prefix.equals("xmlns")) {
+-        throw new XMLSecurityException("defaultNamespaceCannotBeSetHere");
+-      } else if (prefix.startsWith("xmlns:")) {
+-         ns = prefix;//"xmlns:" + prefix.substring("xmlns:".length());
+-      } else {
+-         ns = "xmlns:" + prefix;
+-      }
+-
+-
+-
+-      Attr a = this._constructionElement.getAttributeNodeNS(Constants.NamespaceSpecNS, ns);
+-
+-      if (a != null) {
+-       if (!a.getNodeValue().equals(uri)) {
+-         Object exArgs[] = { ns,
+-                             this._constructionElement.getAttributeNS(null,
+-                                                                      ns) };
+-
+-         throw new XMLSecurityException("namespacePrefixAlreadyUsedByOtherURI",
+-                                        exArgs);
+-       }
+-       return;
+-      }
+-
+-      this._constructionElement.setAttributeNS(Constants.NamespaceSpecNS, ns,
+-                                               uri);
+-   }
+-
+-   /** Field _prefixMappings */
+-   static HashMap _prefixMappings = new HashMap();
+-   static HashMap _prefixMappingsBindings = new HashMap();
++        this._constructionElement.setAttributeNS(Constants.NamespaceSpecNS, ns, uri);
++    }
+ 
+     /**
+      * Method setDefaultPrefix
+@@ -505,26 +471,39 @@
+      */
+     public static void setDefaultPrefix(String namespace, String prefix)
+         throws XMLSecurityException {
+-
+-        if (ElementProxy._prefixMappings.containsValue(prefix)) {
+-
+-            Object storedNamespace=ElementProxy._prefixMappings.get(namespace);
+-            if (!storedNamespace.equals(prefix)) {
+-                Object exArgs[] = { prefix, namespace, storedNamespace };
++        if (prefixMappings.containsValue(prefix)) {
++            String storedPrefix = prefixMappings.get(namespace);
++            if (!storedPrefix.equals(prefix)) {
++                Object exArgs[] = { prefix, namespace, storedPrefix };
+ 
+                 throw new XMLSecurityException("prefix.AlreadyAssigned", exArgs);
+             }
+         }
++
+         if (Constants.SignatureSpecNS.equals(namespace)) {
+-            XMLUtils.dsPrefix=prefix;
++            XMLUtils.setDsPrefix(prefix);
+         }
+-        ElementProxy._prefixMappings.put(namespace, prefix.intern());
+-        if (prefix.length() == 0) {
+-            ElementProxy._prefixMappingsBindings.put(namespace, "xmlns");
+-        } else {
+-            ElementProxy._prefixMappingsBindings.put(namespace, ("xmlns:"+prefix).intern());
++        if (EncryptionConstants.EncryptionSpecNS.equals(namespace)) {
++            XMLUtils.setXencPrefix(prefix);
+         }
+-   }
++        prefixMappings.put(namespace, prefix);
++    }
++
++    /**
++     * This method registers the default prefixes.
++     */
++    public static void registerDefaultPrefixes() throws XMLSecurityException {
++        setDefaultPrefix("http://www.w3.org/2000/09/xmldsig#", "ds");
++        setDefaultPrefix("http://www.w3.org/2001/04/xmlenc#", "xenc");
++        setDefaultPrefix("http://www.w3.org/2009/xmlenc11#", "xenc11");
++        setDefaultPrefix("http://www.xmlsecurity.org/experimental#", "experimental");
++        setDefaultPrefix("http://www.w3.org/2002/04/xmldsig-filter2", "dsig-xpath-old");
++        setDefaultPrefix("http://www.w3.org/2002/06/xmldsig-filter2", "dsig-xpath");
++        setDefaultPrefix("http://www.w3.org/2001/10/xml-exc-c14n#", "ec");
++        setDefaultPrefix(
++            "http://www.nue.et-inf.uni-siegen.de/~geuer-pollmann/#xpathFilter", "xx"
++        );
++    }
+ 
+     /**
+      * Method getDefaultPrefix
+@@ -533,10 +512,7 @@
+      * @return the default prefix bind to this element.
+      */
+     public static String getDefaultPrefix(String namespace) {
+-        return (String) ElementProxy._prefixMappings.get(namespace);
++        return prefixMappings.get(namespace);
+     }
+ 
+-    public static String getDefaultPrefixBindings(String namespace) {
+-        return (String) ElementProxy._prefixMappingsBindings.get(namespace);
+-    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/I18n.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/I18n.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/I18n.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/I18n.java
+@@ -2,21 +2,23 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-/*
+- * Copyright  1999-2004 The Apache Software Foundation.
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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
+  *
+- *  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
+  *
+- *      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.
+- *
++ * 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.
+  */
+ package com.sun.org.apache.xml.internal.security.utils;
+ 
+@@ -31,202 +33,136 @@
+  */
+ public class I18n {
+ 
+-   /** Field NOT_INITIALIZED_MSG */
+-   public static final String NOT_INITIALIZED_MSG =
+-      "You must initialize the xml-security library correctly before you use it. "
+-      + "Call the static method \"com.sun.org.apache.xml.internal.security.Init.init();\" to do that "
+-      + "before you use any functionality from that library.";
++    /** Field NOT_INITIALIZED_MSG */
++    public static final String NOT_INITIALIZED_MSG =
++        "You must initialize the xml-security library correctly before you use it. "
++        + "Call the static method \"com.sun.org.apache.xml.internal.security.Init.init();\" to do that "
++        + "before you use any functionality from that library.";
+ 
+-   /** Field defaultLanguageCode */
+-   private static String defaultLanguageCode;    // will be set in static{} block
++    /** Field resourceBundle */
++    private static ResourceBundle resourceBundle;
+ 
+-   /** Field defaultCountryCode */
+-   private static String defaultCountryCode;    // will be set in static{} block
++    /** Field alreadyInitialized */
++    private static boolean alreadyInitialized = false;
+ 
+-   /** Field resourceBundle */
+-   private static ResourceBundle resourceBundle =
+-       ResourceBundle.getBundle
+-         (Constants.exceptionMessagesResourceBundleBase, Locale.US);
++    /**
++     * Constructor I18n
++     *
++     */
++    private I18n() {
++        // we don't allow instantiation
++    }
+ 
+-   /** Field alreadyInitialized */
+-   private static boolean alreadyInitialized = false;
++    /**
++     * Method translate
++     *
++     * translates a message ID into an internationalized String, see alse
++     * <CODE>XMLSecurityException.getExceptionMEssage()</CODE>. The strings are
++     * stored in the <CODE>ResourceBundle</CODE>, which is identified in
++     * <CODE>exceptionMessagesResourceBundleBase</CODE>
++     *
++     * @param message
++     * @param args is an <CODE>Object[]</CODE> array of strings which are inserted into
++     * the String which is retrieved from the <CODE>ResouceBundle</CODE>
++     * @return message translated
++     */
++    public static String translate(String message, Object[] args) {
++        return getExceptionMessage(message, args);
++    }
+ 
+-   /** Field _languageCode */
+-   private static String _languageCode = null;
++    /**
++     * Method translate
++     *
++     * translates a message ID into an internationalized String, see also
++     * <CODE>XMLSecurityException.getExceptionMessage()</CODE>
++     *
++     * @param message
++     * @return message translated
++     */
++    public static String translate(String message) {
++        return getExceptionMessage(message);
++    }
+ 
+-   /** Field _countryCode */
+-   private static String _countryCode = null;
++    /**
++     * Method getExceptionMessage
++     *
++     * @param msgID
++     * @return message translated
++     *
++     */
++    public static String getExceptionMessage(String msgID) {
++        try {
++            return resourceBundle.getString(msgID);
++        } catch (Throwable t) {
++            if (com.sun.org.apache.xml.internal.security.Init.isInitialized()) {
++                return "No message with ID \"" + msgID
++                + "\" found in resource bundle \""
++                + Constants.exceptionMessagesResourceBundleBase + "\"";
++            }
++            return I18n.NOT_INITIALIZED_MSG;
++        }
++    }
+ 
+-   /**
+-    * Constructor I18n
+-    *
+-    */
+-   private I18n() {
++    /**
++     * Method getExceptionMessage
++     *
++     * @param msgID
++     * @param originalException
++     * @return message translated
++     */
++    public static String getExceptionMessage(String msgID, Exception originalException) {
++        try {
++            Object exArgs[] = { originalException.getMessage() };
++            return MessageFormat.format(resourceBundle.getString(msgID), exArgs);
++        } catch (Throwable t) {
++            if (com.sun.org.apache.xml.internal.security.Init.isInitialized()) {
++                return "No message with ID \"" + msgID
++                + "\" found in resource bundle \""
++                + Constants.exceptionMessagesResourceBundleBase
++                + "\". Original Exception was a "
++                + originalException.getClass().getName() + " and message "
++                + originalException.getMessage();
++            }
++            return I18n.NOT_INITIALIZED_MSG;
++        }
++    }
+ 
+-      // we don't allow instantiation
+-   }
++    /**
++     * Method getExceptionMessage
++     *
++     * @param msgID
++     * @param exArgs
++     * @return message translated
++     */
++    public static String getExceptionMessage(String msgID, Object exArgs[]) {
++        try {
++            return MessageFormat.format(resourceBundle.getString(msgID), exArgs);
++        } catch (Throwable t) {
++            if (com.sun.org.apache.xml.internal.security.Init.isInitialized()) {
++                return "No message with ID \"" + msgID
++                + "\" found in resource bundle \""
++                + Constants.exceptionMessagesResourceBundleBase + "\"";
++            }
++            return I18n.NOT_INITIALIZED_MSG;
++        }
++    }
+ 
+-   /**
+-    * Method translate
+-    *
+-    * translates a message ID into an internationalized String, see alse
+-    * <CODE>XMLSecurityException.getExceptionMEssage()</CODE>. The strings are
+-    * stored in the <CODE>ResourceBundle</CODE>, which is identified in
+-    * <CODE>exceptionMessagesResourceBundleBase</CODE>
+-    *
+-    * @param message
+-    * @param args is an <CODE>Object[]</CODE> array of strings which are inserted into the String which is retrieved from the <CODE>ResouceBundle</CODE>
+-    * @return message translated
+-    */
+-   public static String translate(String message, Object[] args) {
+-      return getExceptionMessage(message, args);
+-   }
++    /**
++     * Method init
++     *
++     * @param languageCode
++     * @param countryCode
++     */
++    public synchronized static void init(String languageCode, String countryCode) {
++        if (alreadyInitialized) {
++            return;
++        }
+ 
+-   /**
+-    * Method translate
+-    *
+-    * translates a message ID into an internationalized String, see alse
+-    * <CODE>XMLSecurityException.getExceptionMEssage()</CODE>
+-    *
+-    * @param message
+-    * @return message translated
+-    */
+-   public static String translate(String message) {
+-      return getExceptionMessage(message);
+-   }
+-
+-   /**
+-    * Method getExceptionMessage
+-    *
+-    * @param msgID
+-    * @return message translated
+-    *
+-    */
+-   public static String getExceptionMessage(String msgID) {
+-
+-      try {
+-         String s = resourceBundle.getString(msgID);
+-
+-         return s;
+-      } catch (Throwable t) {
+-         if (com.sun.org.apache.xml.internal.security.Init.isInitialized()) {
+-            return "No message with ID \"" + msgID
+-                   + "\" found in resource bundle \""
+-                   + Constants.exceptionMessagesResourceBundleBase + "\"";
+-         }
+-         return I18n.NOT_INITIALIZED_MSG;
+-      }
+-   }
+-
+-   /**
+-    * Method getExceptionMessage
+-    *
+-    * @param msgID
+-    * @param originalException
+-    * @return message translated
+-    */
+-   public static String getExceptionMessage(String msgID,
+-                                            Exception originalException) {
+-
+-      try {
+-         Object exArgs[] = { originalException.getMessage() };
+-         String s = MessageFormat.format(resourceBundle.getString(msgID),
+-                                         exArgs);
+-
+-         return s;
+-      } catch (Throwable t) {
+-         if (com.sun.org.apache.xml.internal.security.Init.isInitialized()) {
+-            return "No message with ID \"" + msgID
+-                   + "\" found in resource bundle \""
+-                   + Constants.exceptionMessagesResourceBundleBase
+-                   + "\". Original Exception was a "
+-                   + originalException.getClass().getName() + " and message "
+-                   + originalException.getMessage();
+-         }
+-          return I18n.NOT_INITIALIZED_MSG;
+-      }
+-   }
+-
+-   /**
+-    * Method getExceptionMessage
+-    *
+-    * @param msgID
+-    * @param exArgs
+-    * @return message translated
+-    */
+-   public static String getExceptionMessage(String msgID, Object exArgs[]) {
+-
+-      try {
+-         String s = MessageFormat.format(resourceBundle.getString(msgID),
+-                                         exArgs);
+-
+-         return s;
+-      } catch (Throwable t) {
+-         if (com.sun.org.apache.xml.internal.security.Init.isInitialized()) {
+-            return "No message with ID \"" + msgID
+-                   + "\" found in resource bundle \""
+-                   + Constants.exceptionMessagesResourceBundleBase + "\"";
+-         }
+-         return I18n.NOT_INITIALIZED_MSG;
+-      }
+-   }
+-
+-//
+-// Commented out because it modifies shared static
+-// state which could be maliciously called by untrusted code
+-//
+-//   /**
+-//    * Method init
+-//    *
+-//    * @param _defaultLanguageCode
+-//    * @param _defaultCountryCode
+-//    */
+-//   public static void init(String _defaultLanguageCode,
+-//                           String _defaultCountryCode) {
+-//
+-//      I18n.defaultLanguageCode = _defaultLanguageCode;
+-//
+-//      if (I18n.defaultLanguageCode == null) {
+-//         I18n.defaultLanguageCode = Locale.getDefault().getLanguage();
+-//      }
+-//
+-//      I18n.defaultCountryCode = _defaultCountryCode;
+-//
+-//      if (I18n.defaultCountryCode == null) {
+-//         I18n.defaultCountryCode = Locale.getDefault().getCountry();
+-//      }
+-//
+-//      initLocale(I18n.defaultLanguageCode, I18n.defaultCountryCode);
+-//   }
+-
+-//
+-// Commented out because it modifies shared static
+-// state which could be maliciously called by untrusted code
+-//
+-//   /**
+-//    * Method initLocale
+-//    *
+-//    * @param languageCode
+-//    * @param countryCode
+-//    */
+-//   public static void initLocale(String languageCode, String countryCode) {
+-//
+-//      if (alreadyInitialized && languageCode.equals(_languageCode)
+-//              && countryCode.equals(_countryCode)) {
+-//         return;
+-//      }
+-//
+-//      if ((languageCode != null) && (countryCode != null)
+-//              && (languageCode.length() > 0) && (countryCode.length() > 0)) {
+-//         _languageCode = languageCode;
+-//         _countryCode = countryCode;
+-//      } else {
+-//         _countryCode = I18n.defaultCountryCode;
+-//         _languageCode = I18n.defaultLanguageCode;
+-//      }
+-//
+-//      I18n.resourceBundle =
+-//         ResourceBundle.getBundle(Constants.exceptionMessagesResourceBundleBase,
+-//                                  new Locale(_languageCode, _countryCode));
+-//   }
++        I18n.resourceBundle =
++            ResourceBundle.getBundle(
++                Constants.exceptionMessagesResourceBundleBase,
++                new Locale(languageCode, countryCode)
++            );
++        alreadyInitialized = true;
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/XMLUtils.java
+@@ -21,14 +21,15 @@
+ package com.sun.org.apache.xml.internal.security.utils;
+ 
+ 
+-
+ import java.io.IOException;
+ import java.io.OutputStream;
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
++import java.util.ArrayList;
+ import java.util.HashMap;
+ import java.util.HashSet;
+ import java.util.Iterator;
++import java.util.List;
+ import java.util.Map;
+ import java.util.Set;
+ 
+@@ -60,6 +61,12 @@
+          }
+       });
+ 
++    private static volatile String dsPrefix = "ds";
++    private static volatile String xencPrefix = "xenc";
++
++   private static final java.util.logging.Logger log =
++       java.util.logging.Logger.getLogger(XMLUtils.class.getName());
++
+    /**
+     * Constructor XMLUtils
+     *
+@@ -68,6 +75,23 @@
+ 
+       // we don't allow instantiation
+    }
++
++    /**
++     * Set the prefix for the digital signature namespace
++     * @param prefix the new prefix for the digital signature namespace
++     */
++    public static void setDsPrefix(String prefix) {
++        dsPrefix = prefix;
++    }
++
++    /**
++     * Set the prefix for the encryption namespace
++     * @param prefix the new prefix for the encryption namespace
++     */
++    public static void setXencPrefix(String prefix) {
++        xencPrefix = prefix;
++    }
++
+    public static Element getNextElement(Node el) {
+            while ((el!=null) && (el.getNodeType()!=Node.ELEMENT_NODE)) {
+                    el=el.getNextSibling();
+@@ -82,13 +106,15 @@
+     * @param exclude
+     * @param com wheather comments or not
+     */
+-   public static void getSet(Node rootNode,Set result,Node exclude ,boolean com) {
++   public static void getSet(Node rootNode,Set<Node> result,Node exclude ,boolean com) {
+           if ((exclude!=null) && isDescendantOrSelf(exclude,rootNode)){
+                 return;
+       }
+       getSetRec(rootNode,result,exclude,com);
+    }
+-   static final void getSetRec(final Node rootNode,final Set result,
++
++   @SuppressWarnings("fallthrough")
++   static final void getSetRec(final Node rootNode,final Set<Node> result,
+         final Node exclude ,final boolean com) {
+            //Set result = new HashSet();
+        if (rootNode==exclude) {
+@@ -104,7 +130,7 @@
+                                         result.add(nl.item(i));
+                                 }
+                 }
+-                //no return keep working
++                //no return keep working - ignore fallthrough warning
+                 case Node.DOCUMENT_NODE:
+                                 for (Node r=rootNode.getFirstChild();r!=null;r=r.getNextSibling()){
+                                         if (r.getNodeType()==Node.TEXT_NODE) {
+@@ -228,9 +254,8 @@
+       return sb.toString();
+    }
+ 
++   static Map<String, String> namePrefixes=new HashMap<String, String>();
+ 
+-   static  String dsPrefix=null;
+-   static Map namePrefixes=new HashMap();
+    /**
+     * Creates an Element in the XML Signature specification namespace.
+     *
+@@ -248,7 +273,7 @@
+       if ((dsPrefix == null) || (dsPrefix.length() == 0)) {
+          return doc.createElementNS(Constants.SignatureSpecNS, elementName);
+       }
+-      String namePrefix=(String) namePrefixes.get(elementName);
++      String namePrefix= namePrefixes.get(elementName);
+       if (namePrefix==null) {
+           StringBuffer tag=new StringBuffer(dsPrefix);
+           tag.append(':');
+@@ -259,31 +284,38 @@
+       return doc.createElementNS(Constants.SignatureSpecNS, namePrefix);
+    }
+ 
+-   /**
+-    * Returns true if the element is in XML Signature namespace and the local
+-    * name equals the supplied one.
+-    *
+-    * @param element
+-    * @param localName
+-    * @return true if the element is in XML Signature namespace and the local name equals the supplied one
+-    */
+-   public static boolean elementIsInSignatureSpace(Element element,
+-           String localName) {
+-      return ElementProxy.checker.isNamespaceElement(element, localName, Constants.SignatureSpecNS);
+-   }
++    /**
++     * Returns true if the element is in XML Signature namespace and the local
++     * name equals the supplied one.
++     *
++     * @param element
++     * @param localName
++     * @return true if the element is in XML Signature namespace and the local name equals the supplied one
++     */
++    public static boolean elementIsInSignatureSpace(Element element, String localName) {
++        if (element == null) {
++            return false;
++        }
+ 
+-   /**
+-    * Returns true if the element is in XML Encryption namespace and the local
+-    * name equals the supplied one.
+-    *
+-    * @param element
+-    * @param localName
+-    * @return true if the element is in XML Encryption namespace and the local name equals the supplied one
+-    */
+-   public static boolean elementIsInEncryptionSpace(Element element,
+-           String localName) {
+-           return ElementProxy.checker.isNamespaceElement(element, localName, EncryptionConstants.EncryptionSpecNS);
+-   }
++        return Constants.SignatureSpecNS.equals(element.getNamespaceURI())
++            && element.getLocalName().equals(localName);
++    }
++
++    /**
++     * Returns true if the element is in XML Encryption namespace and the local
++     * name equals the supplied one.
++     *
++     * @param element
++     * @param localName
++     * @return true if the element is in XML Encryption namespace and the local name equals the supplied one
++     */
++    public static boolean elementIsInEncryptionSpace(Element element, String localName) {
++        if (element == null) {
++            return false;
++        }
++        return EncryptionConstants.EncryptionSpecNS.equals(element.getNamespaceURI())
++            && element.getLocalName().equals(localName);
++    }
+ 
+    /**
+     * This method returns the owner document of a particular node.
+@@ -318,11 +350,9 @@
+      * @param xpathNodeSet
+      * @return the owner document
+      */
+-    public static Document getOwnerDocument(Set xpathNodeSet) {
++    public static Document getOwnerDocument(Set<Node> xpathNodeSet) {
+        NullPointerException npe = null;
+-       Iterator iterator = xpathNodeSet.iterator();
+-       while(iterator.hasNext()) {
+-           Node node = (Node) iterator.next();
++       for (Node node : xpathNodeSet) {
+            int nodeType =node.getNodeType();
+            if (nodeType == Node.DOCUMENT_NODE) {
+               return (Document) node;
+@@ -397,14 +427,14 @@
+     * @param xpathNodeSet
+     * @return the set with the nodelist
+     */
+-   public static Set convertNodelistToSet(NodeList xpathNodeSet) {
++   public static Set<Node> convertNodelistToSet(NodeList xpathNodeSet) {
+ 
+       if (xpathNodeSet == null) {
+-         return new HashSet();
++         return new HashSet<Node>();
+       }
+ 
+       int length = xpathNodeSet.getLength();
+-      Set set = new HashSet(length);
++      Set<Node> set = new HashSet<Node>(length);
+ 
+       for (int i = 0; i < length; i++) {
+          set.add(xpathNodeSet.item(i));
+@@ -446,6 +476,7 @@
+     * @param node
+     * @see <A HREF="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2650">Namespace axis resolution is not XPath compliant </A>
+     */
++   @SuppressWarnings("fallthrough")
+    private static void circumventBug2650internal(Node node) {
+            Node parent=null;
+            Node sibling=null;
+@@ -503,45 +534,45 @@
+            } while (true);
+    }
+ 
+-   /**
+-    * @param sibling
+-    * @param nodeName
+-    * @param number
+-    * @return nodes with the constrain
+-    */
+-   public static Element selectDsNode(Node sibling, String nodeName, int number) {
+-        while (sibling!=null) {
+-                if (ElementProxy.checker.isNamespaceElement(sibling, nodeName, Constants.SignatureSpecNS )) {
+-                        if (number==0){
+-                                return (Element)sibling;
+-                        }
+-                        number--;
++    /**
++     * @param sibling
++     * @param nodeName
++     * @param number
++     * @return nodes with the constrain
++     */
++    public static Element selectDsNode(Node sibling, String nodeName, int number) {
++        while (sibling != null) {
++            if (Constants.SignatureSpecNS.equals(sibling.getNamespaceURI())
++                && sibling.getLocalName().equals(nodeName)) {
++                if (number == 0){
++                    return (Element)sibling;
+                 }
+-                sibling=sibling.getNextSibling();
++                number--;
++            }
++            sibling = sibling.getNextSibling();
+         }
+         return null;
+-   }
++    }
+ 
+-   /**
+-    * @param sibling
+-    * @param nodeName
+-    * @param number
+-    * @return nodes with the constrain
+-    */
+-
+-   public static Element selectXencNode(Node sibling, String nodeName, int number) {
+-        while (sibling!=null) {
+-                if (ElementProxy.checker.isNamespaceElement(sibling, nodeName, EncryptionConstants.EncryptionSpecNS )) {
+-                        if (number==0){
+-                                return (Element)sibling;
+-                        }
+-                        number--;
++    /**
++     * @param sibling
++     * @param nodeName
++     * @param number
++     * @return nodes with the constrain
++     */
++    public static Element selectXencNode(Node sibling, String nodeName, int number) {
++        while (sibling != null) {
++            if (EncryptionConstants.EncryptionSpecNS.equals(sibling.getNamespaceURI())
++                && sibling.getLocalName().equals(nodeName)) {
++                if (number == 0){
++                    return (Element)sibling;
+                 }
+-                sibling=sibling.getNextSibling();
++                number--;
++            }
++            sibling = sibling.getNextSibling();
+         }
+         return null;
+-   }
+-
++    }
+ 
+    /**
+     * @param sibling
+@@ -580,74 +611,65 @@
+     return (Text)n;
+    }
+ 
+-   /**
+-    * @param sibling
+-    * @param uri
+-    * @param nodeName
+-    * @param number
+-    * @return nodes with the constrain
+-    */
+-   public static Element selectNode(Node sibling, String uri,String nodeName, int number) {
+-        while (sibling!=null) {
+-                if (ElementProxy.checker.isNamespaceElement(sibling, nodeName, uri)) {
+-                        if (number==0){
+-                                return (Element)sibling;
+-                        }
+-                        number--;
++    /**
++     * @param sibling
++     * @param uri
++     * @param nodeName
++     * @param number
++     * @return nodes with the constrain
++     */
++    public static Element selectNode(Node sibling, String uri, String nodeName, int number) {
++        while (sibling != null) {
++            if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri)
++                && sibling.getLocalName().equals(nodeName)) {
++                if (number == 0){
++                    return (Element)sibling;
+                 }
+-                sibling=sibling.getNextSibling();
++                number--;
++            }
++            sibling = sibling.getNextSibling();
+         }
+         return null;
+-   }
++    }
+ 
+-   /**
+-    * @param sibling
+-    * @param nodeName
+-    * @return nodes with the constrain
+-    */
+-   public static Element[] selectDsNodes(Node sibling,String nodeName) {
+-     return selectNodes(sibling,Constants.SignatureSpecNS,nodeName);
+-   }
+-   /**
+-    * @param sibling
+-    * @param uri
+-    * @param nodeName
+-    * @return nodes with the constrain
+-    */
+-    public static Element[] selectNodes(Node sibling,String uri,String nodeName) {
+-        int size=20;
+-        Element[] a= new Element[size];
+-        int curr=0;
+-        //List list=new ArrayList();
+-        while (sibling!=null) {
+-                if (ElementProxy.checker.isNamespaceElement(sibling, nodeName, uri)) {
+-                        a[curr++]=(Element)sibling;
+-                        if (size<=curr) {
+-                                int cursize= size<<2;
+-                                Element []cp=new Element[cursize];
+-                                System.arraycopy(a,0,cp,0,size);
+-                                a=cp;
+-                                size=cursize;
+-                        }
+-                }
+-                sibling=sibling.getNextSibling();
++    /**
++     * @param sibling
++     * @param nodeName
++     * @return nodes with the constrain
++     */
++    public static Element[] selectDsNodes(Node sibling, String nodeName) {
++        return selectNodes(sibling,Constants.SignatureSpecNS, nodeName);
++    }
++
++    /**
++     * @param sibling
++     * @param uri
++     * @param nodeName
++     * @return nodes with the constrain
++     */
++     public static Element[] selectNodes(Node sibling, String uri, String nodeName) {
++        List<Element> list = new ArrayList<Element>();
++        while (sibling != null) {
++            if (sibling.getNamespaceURI() != null && sibling.getNamespaceURI().equals(uri)
++                && sibling.getLocalName().equals(nodeName)) {
++                list.add((Element)sibling);
++            }
++            sibling = sibling.getNextSibling();
+         }
+-        Element []af=new Element[curr];
+-        System.arraycopy(a,0,af,0,curr);
+-        return af;
+-   }
++        return list.toArray(new Element[list.size()]);
++    }
+ 
+    /**
+     * @param signatureElement
+     * @param inputSet
+     * @return nodes with the constrain
+     */
+-    public static Set excludeNodeFromSet(Node signatureElement, Set inputSet) {
+-          Set resultSet = new HashSet();
+-          Iterator iterator = inputSet.iterator();
++    public static Set<Node> excludeNodeFromSet(Node signatureElement, Set<Node> inputSet) {
++          Set<Node> resultSet = new HashSet<Node>();
++          Iterator<Node> iterator = inputSet.iterator();
+ 
+           while (iterator.hasNext()) {
+-            Node inputNode = (Node) iterator.next();
++            Node inputNode = iterator.next();
+ 
+             if (!XMLUtils
+                     .isDescendantOrSelf(signatureElement, inputNode)) {
+@@ -693,4 +715,127 @@
+     public static boolean ignoreLineBreaks() {
+         return ignoreLineBreaks;
+     }
++
++    /**
++     * This method is a tree-search to help prevent against wrapping attacks.
++     * It checks that no two Elements have ID Attributes that match the "value"
++     * argument, if this is the case then "false" is returned. Note that a
++     * return value of "true" does not necessarily mean that a matching Element
++     * has been found, just that no wrapping attack has been detected.
++     */
++    public static boolean protectAgainstWrappingAttack(Node startNode,
++                                                       String value)
++    {
++        Node startParent = startNode.getParentNode();
++        Node processedNode = null;
++        Element foundElement = null;
++
++        String id = value.trim();
++        if (id.charAt(0) == '#') {
++            id = id.substring(1);
++        }
++
++        while (startNode != null) {
++            if (startNode.getNodeType() == Node.ELEMENT_NODE) {
++                Element se = (Element) startNode;
++
++                NamedNodeMap attributes = se.getAttributes();
++                if (attributes != null) {
++                    for (int i = 0; i < attributes.getLength(); i++) {
++                        Attr attr = (Attr)attributes.item(i);
++                        if (attr.isId() && id.equals(attr.getValue())) {
++                            if (foundElement == null) {
++                                // Continue searching to find duplicates
++                                foundElement = attr.getOwnerElement();
++                            } else {
++                                log.log(java.util.logging.Level.FINE, "Multiple elements with the same 'Id' attribute value!");
++                                return false;
++                            }
++                        }
++                    }
++                }
++            }
++
++            processedNode = startNode;
++            startNode = startNode.getFirstChild();
++
++            // no child, this node is done.
++            if (startNode == null) {
++                // close node processing, get sibling
++                startNode = processedNode.getNextSibling();
++            }
++
++            // no more siblings, get parent, all children
++            // of parent are processed.
++            while (startNode == null) {
++                processedNode = processedNode.getParentNode();
++                if (processedNode == startParent) {
++                    return true;
++                }
++                // close parent node processing (processed node now)
++                startNode = processedNode.getNextSibling();
++            }
++        }
++        return true;
++    }
++
++    /**
++     * This method is a tree-search to help prevent against wrapping attacks.
++     * It checks that no other Element than the given "knownElement" argument
++     * has an ID attribute that matches the "value" argument, which is the ID
++     * value of "knownElement". If this is the case then "false" is returned.
++     */
++    public static boolean protectAgainstWrappingAttack(Node startNode,
++                                                       Element knownElement,
++                                                       String value)
++    {
++        Node startParent = startNode.getParentNode();
++        Node processedNode = null;
++
++        String id = value.trim();
++        if (id.charAt(0) == '#') {
++            id = id.substring(1);
++        }
++
++        while (startNode != null) {
++            if (startNode.getNodeType() == Node.ELEMENT_NODE) {
++                Element se = (Element) startNode;
++
++                NamedNodeMap attributes = se.getAttributes();
++                if (attributes != null) {
++                    for (int i = 0; i < attributes.getLength(); i++) {
++                        Attr attr = (Attr)attributes.item(i);
++                        if (attr.isId() && id.equals(attr.getValue())
++                            && se != knownElement)
++                        {
++                            log.log(java.util.logging.Level.FINE, "Multiple elements with the same 'Id' attribute value!");
++                            return false;
++                        }
++                    }
++                }
++            }
++
++            processedNode = startNode;
++            startNode = startNode.getFirstChild();
++
++            // no child, this node is done.
++            if (startNode == null) {
++                // close node processing, get sibling
++                startNode = processedNode.getNextSibling();
++            }
++
++            // no more siblings, get parent, all children
++            // of parent are processed.
++            while (startNode == null) {
++                processedNode = processedNode.getParentNode();
++                if (processedNode == startParent) {
++                    return true;
++                }
++                // close parent node processing (processed node now)
++                startNode = processedNode.getNextSibling();
++            }
++        }
++        return true;
++    }
++
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolver.java
+@@ -2,21 +2,23 @@
+  * reserved comment block
+  * DO NOT REMOVE OR ALTER!
+  */
+-/*
+- * Copyright  1999-2004 The Apache Software Foundation.
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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
+  *
+- *  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
+  *
+- *      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.
+- *
++ * 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.
+  */
+ package com.sun.org.apache.xml.internal.security.utils.resolver;
+ 
+@@ -25,300 +27,318 @@
+ import java.util.Map;
+ 
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
++import com.sun.org.apache.xml.internal.security.utils.resolver.implementations.ResolverDirectHTTP;
++import com.sun.org.apache.xml.internal.security.utils.resolver.implementations.ResolverFragment;
++import com.sun.org.apache.xml.internal.security.utils.resolver.implementations.ResolverLocalFilesystem;
++import com.sun.org.apache.xml.internal.security.utils.resolver.implementations.ResolverXPointer;
+ import org.w3c.dom.Attr;
+ 
+ /**
+  * During reference validation, we have to retrieve resources from somewhere.
+  * This is done by retrieving a Resolver. The resolver needs two arguments: The
+- * URI in which the link to the new resource is defined and the BaseURI of the
+- * file/entity in which the URI occurs (the BaseURI is the same as the SystemId.
+- *
+- * <UL xml:lang="DE" LANG="DE">
+- * <LI> Verschiedene Implementierungen k??nnen sich als Resolver registrieren.
+- * <LI> Standardm????ig werden erste Implementierungen auf dem XML config file registrirt.
+- * <LI> Der Benutzer kann bei Bedarf Implementierungen voranstellen oder anf??gen.
+- * <LI> Implementierungen k??nnen mittels Features customized werden ??
+- *      (z.B. um Proxy-Passworter ??bergeben zu k??nnen).
+- * <LI> Jede Implementierung bekommt das URI Attribut und den Base URI
+- *      ??bergeben und muss antworten, ob sie aufl??sen kann.
+- * <LI> Die erste Implementierung, die die Aufgabe erf??llt, f??hrt die Aufl??sung durch.
+- * </UL>
+- *
+- * @author $Author: mullan $
++ * URI in which the link to the new resource is defined and the baseURI of the
++ * file/entity in which the URI occurs (the baseURI is the same as the SystemId).
+  */
+ public class ResourceResolver {
+ 
+-   /** {@link java.util.logging} logging facility */
+-    static java.util.logging.Logger log =
++    /** {@link org.apache.commons.logging} logging facility */
++    private static java.util.logging.Logger log =
+         java.util.logging.Logger.getLogger(ResourceResolver.class.getName());
+ 
+-   /** Field _alreadyInitialized */
+-   static boolean _alreadyInitialized = false;
++    /** these are the system-wide resolvers */
++    private static List<ResourceResolver> resolverList = new ArrayList<ResourceResolver>();
+ 
+-   /** these are the system-wide resolvers */
+-   static List _resolverVector = null;
++    /** Field resolverSpi */
++    private final ResourceResolverSpi resolverSpi;
+ 
+-   static boolean allThreadSafeInList=true;
++    /**
++     * Constructor ResourceResolver
++     *
++     * @param resourceResolver
++     */
++    public ResourceResolver(ResourceResolverSpi resourceResolver) {
++        this.resolverSpi = resourceResolver;
++    }
+ 
+-   /** Field transformSpi */
+-   protected ResourceResolverSpi _resolverSpi = null;
++    /**
++     * Method getInstance
++     *
++     * @param uri
++     * @param baseURI
++     * @return the instance
++     *
++     * @throws ResourceResolverException
++     */
++    public static final ResourceResolver getInstance(Attr uri, String baseURI)
++        throws ResourceResolverException {
++        return getInstance(uri, baseURI, false);
++    }
+ 
+-   /**
+-    * Constructor ResourceResolver
+-    *
+-    * @param className
+-    * @throws ClassNotFoundException
+-    * @throws IllegalAccessException
+-    * @throws InstantiationException
+-    */
+-   private ResourceResolver(String className)
+-           throws ClassNotFoundException, IllegalAccessException,
+-                  InstantiationException {
+-      this._resolverSpi =
+-         (ResourceResolverSpi) Class.forName(className).newInstance();
+-   }
++    /**
++     * Method getInstance
++     *
++     * @param uri
++     * @param baseURI
++     * @param secureValidation
++     * @return the instance
++     *
++     * @throws ResourceResolverException
++     */
++    public static final ResourceResolver getInstance(
++        Attr uri, String baseURI, boolean secureValidation
++    ) throws ResourceResolverException {
++        synchronized (resolverList) {
++            for (ResourceResolver resolver : resolverList) {
++                ResourceResolver resolverTmp = resolver;
++                if (!resolver.resolverSpi.engineIsThreadSafe()) {
++                    try {
++                        resolverTmp =
++                            new ResourceResolver(resolver.resolverSpi.getClass().newInstance());
++                    } catch (InstantiationException e) {
++                        throw new ResourceResolverException("", e, uri, baseURI);
++                    } catch (IllegalAccessException e) {
++                        throw new ResourceResolverException("", e, uri, baseURI);
++                    }
++                }
+ 
+-   /**
+-    * Constructor ResourceResolver
+-    *
+-    * @param resourceResolver
+-    */
+-   public ResourceResolver(ResourceResolverSpi resourceResolver) {
+-      this._resolverSpi = resourceResolver;
+-   }
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE,
++                        "check resolvability by class " + resolverTmp.getClass().getName()
++                    );
++                }
+ 
++                resolverTmp.resolverSpi.secureValidation = secureValidation;
++                if ((resolverTmp != null) && resolverTmp.canResolve(uri, baseURI)) {
++                    // Check to see whether the Resolver is allowed
++                    if (secureValidation
++                        && (resolverTmp.resolverSpi instanceof ResolverLocalFilesystem
++                            || resolverTmp.resolverSpi instanceof ResolverDirectHTTP)) {
++                        Object exArgs[] = { resolverTmp.resolverSpi.getClass().getName() };
++                        throw new ResourceResolverException(
++                            "signature.Reference.ForbiddenResolver", exArgs, uri, baseURI
++                        );
++                    }
++                    return resolverTmp;
++                }
++            }
++        }
+ 
+-   /**
+-    * Method getInstance
+-    *
+-    * @param uri
+-    * @param BaseURI
+-    * @return the instnace
+-    *
+-    * @throws ResourceResolverException
+-    */
+-   public static final ResourceResolver getInstance(Attr uri, String BaseURI)
+-           throws ResourceResolverException {
+-      int length=ResourceResolver._resolverVector.size();
+-      for (int i = 0; i < length; i++) {
+-                  ResourceResolver resolver =
+-            (ResourceResolver) ResourceResolver._resolverVector.get(i);
+-                  ResourceResolver resolverTmp=null;
+-                  try {
+-                        resolverTmp =  allThreadSafeInList || resolver._resolverSpi.engineIsThreadSafe() ? resolver :
+-                                        new ResourceResolver((ResourceResolverSpi)resolver._resolverSpi.getClass().newInstance());
+-                  } catch (InstantiationException e) {
+-                          throw new ResourceResolverException("",e,uri,BaseURI);
+-                  } catch (IllegalAccessException e) {
+-                          throw new ResourceResolverException("",e,uri,BaseURI);
+-                  }
++        Object exArgs[] = { ((uri != null) ? uri.getNodeValue() : "null"), baseURI };
+ 
+-         if (log.isLoggable(java.util.logging.Level.FINE))
+-                log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver._resolverSpi.getClass().getName());
++        throw new ResourceResolverException("utils.resolver.noClass", exArgs, uri, baseURI);
++    }
+ 
+-         if ((resolver != null) && resolverTmp.canResolve(uri, BaseURI)) {
+-                 if (i!=0) {
+-                 //update resolver.
+-                         //System.out.println("Swaping");
+-                         List resolverVector=(List)((ArrayList)_resolverVector).clone();
+-                         resolverVector.remove(i);
+-                         resolverVector.add(0,resolver);
+-                         _resolverVector=resolverVector;
+-                 } else {
+-                         //System.out.println("hitting");
+-                 }
++    /**
++     * Method getInstance
++     *
++     * @param uri
++     * @param baseURI
++     * @param individualResolvers
++     * @return the instance
++     *
++     * @throws ResourceResolverException
++     */
++    public static ResourceResolver getInstance(
++        Attr uri, String baseURI, List<ResourceResolver> individualResolvers
++    ) throws ResourceResolverException {
++        return getInstance(uri, baseURI, individualResolvers, false);
++    }
+ 
+-            return resolverTmp;
+-         }
+-      }
++    /**
++     * Method getInstance
++     *
++     * @param uri
++     * @param baseURI
++     * @param individualResolvers
++     * @param secureValidation
++     * @return the instance
++     *
++     * @throws ResourceResolverException
++     */
++    public static ResourceResolver getInstance(
++        Attr uri, String baseURI, List<ResourceResolver> individualResolvers, boolean secureValidation
++    ) throws ResourceResolverException {
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE,
++                "I was asked to create a ResourceResolver and got "
++                + (individualResolvers == null ? 0 : individualResolvers.size())
++            );
++        }
+ 
+-      Object exArgs[] = { ((uri != null)
+-                           ? uri.getNodeValue()
+-                           : "null"), BaseURI };
++        // first check the individual Resolvers
++        if (individualResolvers != null) {
++            for (int i = 0; i < individualResolvers.size(); i++) {
++                ResourceResolver resolver = individualResolvers.get(i);
+ 
+-      throw new ResourceResolverException("utils.resolver.noClass", exArgs,
+-                                          uri, BaseURI);
+-   }
+-   /**
+-    * Method getInstance
+-    *
+-    * @param uri
+-    * @param BaseURI
+-    * @param individualResolvers
+-    * @return the instance
+-    *
+-    * @throws ResourceResolverException
+-    */
+-   public static final ResourceResolver getInstance(
+-           Attr uri, String BaseURI, List individualResolvers)
+-              throws ResourceResolverException {
+-      if (log.isLoggable(java.util.logging.Level.FINE)) {
++                if (resolver != null) {
++                    if (log.isLoggable(java.util.logging.Level.FINE)) {
++                        String currentClass = resolver.resolverSpi.getClass().getName();
++                        log.log(java.util.logging.Level.FINE, "check resolvability by class " + currentClass);
++                    }
+ 
+-        log.log(java.util.logging.Level.FINE, "I was asked to create a ResourceResolver and got " + (individualResolvers==null? 0 : individualResolvers.size()) );
+-        log.log(java.util.logging.Level.FINE, " extra resolvers to my existing " + ResourceResolver._resolverVector.size() + " system-wide resolvers");
+-      }
++                    resolver.resolverSpi.secureValidation = secureValidation;
++                    if (resolver.canResolve(uri, baseURI)) {
++                        return resolver;
++                    }
++                }
++            }
++        }
+ 
+-      // first check the individual Resolvers
+-          int size=0;
+-      if ((individualResolvers != null) && ((size=individualResolvers.size()) > 0)) {
+-         for (int i = 0; i < size; i++) {
+-            ResourceResolver resolver =
+-               (ResourceResolver) individualResolvers.get(i);
+-
+-            if (resolver != null) {
+-               String currentClass = resolver._resolverSpi.getClass().getName();
+-               if (log.isLoggable(java.util.logging.Level.FINE))
+-                log.log(java.util.logging.Level.FINE, "check resolvability by class " + currentClass);
+-
+-               if (resolver.canResolve(uri, BaseURI)) {
+-                  return resolver;
+-               }
+-            }
+-         }
+-      }
+-
+-          return getInstance(uri,BaseURI);
+-   }
+-
+-   /**
+-    * The init() function is called by com.sun.org.apache.xml.internal.security.Init.init()
+-    */
+-   public static void init() {
+-
+-      if (!ResourceResolver._alreadyInitialized) {
+-         ResourceResolver._resolverVector = new ArrayList(10);
+-         _alreadyInitialized = true;
+-      }
+-   }
++        return getInstance(uri, baseURI, secureValidation);
++    }
+ 
+     /**
+      * Registers a ResourceResolverSpi class. This method logs a warning if
+      * the class cannot be registered.
+      *
+-     * @param className the name of the ResourceResolverSpi class to be
+-     *    registered
++     * @param className the name of the ResourceResolverSpi class to be registered
+      */
++    @SuppressWarnings("unchecked")
+     public static void register(String className) {
+-        register(className, false);
++        try {
++            Class<ResourceResolverSpi> resourceResolverClass =
++                (Class<ResourceResolverSpi>) Class.forName(className);
++            register(resourceResolverClass, false);
++        } catch (ClassNotFoundException e) {
++            log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className + " disabling it");
++        }
+     }
+ 
+     /**
+      * Registers a ResourceResolverSpi class at the beginning of the provider
+      * list. This method logs a warning if the class cannot be registered.
+      *
+-     * @param className the name of the ResourceResolverSpi class to be
+-     *    registered
++     * @param className the name of the ResourceResolverSpi class to be registered
+      */
++    @SuppressWarnings("unchecked")
+     public static void registerAtStart(String className) {
+-        register(className, true);
+-    }
+-
+-    private static void register(String className, boolean start) {
+         try {
+-            ResourceResolver resolver = new ResourceResolver(className);
+-            if (start) {
+-                ResourceResolver._resolverVector.add(0, resolver);
+-                log.log(java.util.logging.Level.FINE, "registered resolver");
+-            } else {
+-                ResourceResolver._resolverVector.add(resolver);
+-            }
+-            if (!resolver._resolverSpi.engineIsThreadSafe()) {
+-                allThreadSafeInList=false;
+-        }
+-        } catch (Exception e) {
+-            log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className +" disabling it");
+-        } catch (NoClassDefFoundError e) {
+-            log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className +" disabling it");
++            Class<ResourceResolverSpi> resourceResolverClass =
++                (Class<ResourceResolverSpi>) Class.forName(className);
++            register(resourceResolverClass, true);
++        } catch (ClassNotFoundException e) {
++            log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className + " disabling it");
+         }
+     }
+ 
+-   /**
+-    * Method resolve
+-    *
+-    * @param uri
+-    * @param BaseURI
+-    * @return the resource
+-    *
+-    * @throws ResourceResolverException
+-    */
+-   public static XMLSignatureInput resolveStatic(Attr uri, String BaseURI)
+-           throws ResourceResolverException {
++    /**
++     * Registers a ResourceResolverSpi class. This method logs a warning if the class
++     * cannot be registered.
++     * @param className
++     * @param start
++     */
++    public static void register(Class<? extends ResourceResolverSpi> className, boolean start) {
++        try {
++            ResourceResolverSpi resourceResolverSpi = className.newInstance();
++            register(resourceResolverSpi, start);
++        } catch (IllegalAccessException e) {
++            log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className + " disabling it");
++        } catch (InstantiationException e) {
++            log.log(java.util.logging.Level.WARNING, "Error loading resolver " + className + " disabling it");
++        }
++    }
+ 
+-      ResourceResolver myResolver = ResourceResolver.getInstance(uri, BaseURI);
++    /**
++     * Registers a ResourceResolverSpi instance. This method logs a warning if the class
++     * cannot be registered.
++     * @param resourceResolverSpi
++     * @param start
++     */
++    public static void register(ResourceResolverSpi resourceResolverSpi, boolean start) {
++        synchronized(resolverList) {
++            if (start) {
++                resolverList.add(0, new ResourceResolver(resourceResolverSpi));
++            } else {
++                resolverList.add(new ResourceResolver(resourceResolverSpi));
++            }
++        }
++        if (log.isLoggable(java.util.logging.Level.FINE)) {
++            log.log(java.util.logging.Level.FINE, "Registered resolver: " + resourceResolverSpi.toString());
++        }
++    }
+ 
+-      return myResolver.resolve(uri, BaseURI);
+-   }
++    /**
++     * This method registers the default resolvers.
++     */
++    public static void registerDefaultResolvers() {
++        synchronized(resolverList) {
++            resolverList.add(new ResourceResolver(new ResolverFragment()));
++            resolverList.add(new ResourceResolver(new ResolverLocalFilesystem()));
++            resolverList.add(new ResourceResolver(new ResolverXPointer()));
++            resolverList.add(new ResourceResolver(new ResolverDirectHTTP()));
++        }
++    }
+ 
+-   /**
+-    * Method resolve
+-    *
+-    * @param uri
+-    * @param BaseURI
+-    * @return the resource
+-    *
+-    * @throws ResourceResolverException
+-    */
+-   public XMLSignatureInput resolve(Attr uri, String BaseURI)
+-           throws ResourceResolverException {
+-      return this._resolverSpi.engineResolve(uri, BaseURI);
+-   }
++    /**
++     * Method resolve
++     *
++     * @param uri
++     * @param baseURI
++     * @return the resource
++     *
++     * @throws ResourceResolverException
++     */
++    public XMLSignatureInput resolve(Attr uri, String baseURI)
++        throws ResourceResolverException {
++        return resolverSpi.engineResolve(uri, baseURI);
++    }
+ 
+-   /**
+-    * Method setProperty
+-    *
+-    * @param key
+-    * @param value
+-    */
+-   public void setProperty(String key, String value) {
+-      this._resolverSpi.engineSetProperty(key, value);
+-   }
++    /**
++     * Method setProperty
++     *
++     * @param key
++     * @param value
++     */
++    public void setProperty(String key, String value) {
++        resolverSpi.engineSetProperty(key, value);
++    }
+ 
+-   /**
+-    * Method getProperty
+-    *
+-    * @param key
+-    * @return the value of the property
+-    */
+-   public String getProperty(String key) {
+-      return this._resolverSpi.engineGetProperty(key);
+-   }
++    /**
++     * Method getProperty
++     *
++     * @param key
++     * @return the value of the property
++     */
++    public String getProperty(String key) {
++        return resolverSpi.engineGetProperty(key);
++    }
+ 
+-   /**
+-    * Method addProperties
+-    *
+-    * @param properties
+-    */
+-   public void addProperties(Map properties) {
+-      this._resolverSpi.engineAddProperies(properties);
+-   }
++    /**
++     * Method addProperties
++     *
++     * @param properties
++     */
++    public void addProperties(Map<String, String> properties) {
++        resolverSpi.engineAddProperies(properties);
++    }
+ 
+-   /**
+-    * Method getPropertyKeys
+-    *
+-    * @return all property keys.
+-    */
+-   public String[] getPropertyKeys() {
+-      return this._resolverSpi.engineGetPropertyKeys();
+-   }
++    /**
++     * Method getPropertyKeys
++     *
++     * @return all property keys.
++     */
++    public String[] getPropertyKeys() {
++        return resolverSpi.engineGetPropertyKeys();
++    }
+ 
+-   /**
+-    * Method understandsProperty
+-    *
+-    * @param propertyToTest
+-    * @return true if the resolver understands the property
+-    */
+-   public boolean understandsProperty(String propertyToTest) {
+-      return this._resolverSpi.understandsProperty(propertyToTest);
+-   }
++    /**
++     * Method understandsProperty
++     *
++     * @param propertyToTest
++     * @return true if the resolver understands the property
++     */
++    public boolean understandsProperty(String propertyToTest) {
++        return resolverSpi.understandsProperty(propertyToTest);
++    }
+ 
+-   /**
+-    * Method canResolve
+-    *
+-    * @param uri
+-    * @param BaseURI
+-    * @return true if it can resolve the uri
+-    */
+-   private boolean canResolve(Attr uri, String BaseURI) {
+-      return this._resolverSpi.engineCanResolve(uri, BaseURI);
+-   }
++    /**
++     * Method canResolve
++     *
++     * @param uri
++     * @param baseURI
++     * @return true if it can resolve the uri
++     */
++    private boolean canResolve(Attr uri, String baseURI) {
++        return resolverSpi.engineCanResolve(uri, baseURI);
++    }
+ }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/ResourceResolverSpi.java
+@@ -41,7 +41,9 @@
+                     ResourceResolverSpi.class.getName());
+ 
+    /** Field _properties */
+-   protected java.util.Map _properties = null;
++   protected java.util.Map<String,String> _properties = null;
++
++   protected boolean secureValidation;
+ 
+    /**
+     * This is the workhorse method used to resolve resources.
+@@ -63,7 +65,7 @@
+     */
+    public void engineSetProperty(String key, String value) {
+           if (_properties==null) {
+-                  _properties=new HashMap();
++                  _properties=new HashMap<String,String>();
+           }
+       this._properties.put(key, value);
+    }
+@@ -78,17 +80,17 @@
+           if (_properties==null) {
+                         return null;
+           }
+-      return (String) this._properties.get(key);
++      return this._properties.get(key);
+    }
+ 
+    /**
+     *
+     * @param properties
+     */
+-   public void engineAddProperies(Map properties) {
++   public void engineAddProperies(Map<String,String> properties) {
+           if (properties!=null) {
+                   if (_properties==null) {
+-                          _properties=new HashMap();
++                          _properties=new HashMap<String,String>();
+                   }
+                   this._properties.putAll(properties);
+           }
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverFragment.java
+@@ -23,11 +23,12 @@
+ 
+ 
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+-import com.sun.org.apache.xml.internal.security.utils.IdResolver;
++import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverException;
+ import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverSpi;
+ import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
++import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+ 
+ 
+@@ -51,63 +52,68 @@
+    /**
+     * Method engineResolve
+     *
+-    * Wird das gleiche Dokument referenziert?
+-    * Wird ein anderes Dokument referenziert?
+     * @inheritDoc
+     * @param uri
+-    * @param BaseURI
+-    *
++    * @param baseURI
+     */
+-   public XMLSignatureInput engineResolve(Attr uri, String BaseURI)
++   public XMLSignatureInput engineResolve(Attr uri, String baseURI)
+        throws ResourceResolverException
+    {
++        String uriNodeValue = uri.getNodeValue();
++        Document doc = uri.getOwnerElement().getOwnerDocument();
+ 
+-      String uriNodeValue = uri.getNodeValue();
+-      Document doc = uri.getOwnerElement().getOwnerDocument();
++        Node selectedElem = null;
++        if (uriNodeValue.equals("")) {
+ 
++           /*
++            * Identifies the node-set (minus any comment nodes) of the XML
++            * resource containing the signature
++            */
+ 
+-      Node selectedElem = null;
+-      if (uriNodeValue.equals("")) {
++            log.log(java.util.logging.Level.FINE, "ResolverFragment with empty URI (means complete document)");
++            selectedElem = doc;
++        } else {
+ 
+-         /*
+-          * Identifies the node-set (minus any comment nodes) of the XML
+-          * resource containing the signature
+-          */
++            /*
++             * URI="#chapter1"
++             * Identifies a node-set containing the element with ID attribute
++             * value 'chapter1' of the XML resource containing the signature.
++             * XML Signature (and its applications) modify this node-set to
++             * include the element plus all descendents including namespaces and
++             * attributes -- but not comments.
++             */
++            String id = uriNodeValue.substring(1);
+ 
+-         log.log(java.util.logging.Level.FINE, "ResolverFragment with empty URI (means complete document)");
+-         selectedElem = doc;
+-      } else {
++            selectedElem = doc.getElementById(id);
++            if (selectedElem == null) {
++                Object exArgs[] = { id };
++                throw new ResourceResolverException(
++                    "signature.Verification.MissingID", exArgs, uri, baseURI);
++            }
++            if (secureValidation) {
++                Element start = uri.getOwnerDocument().getDocumentElement();
++                if (!XMLUtils.protectAgainstWrappingAttack(start, id)) {
++                    Object exArgs[] = { id };
++                    throw new ResourceResolverException(
++                        "signature.Verification.MultipleIDs", exArgs,
++                        uri, baseURI);
++                }
++            }
++            if (log.isLoggable(java.util.logging.Level.FINE))
++                log.log(java.util.logging.Level.FINE, "Try to catch an Element with ID " + id + " and Element was " + selectedElem);
++        }
+ 
+-         /*
+-          * URI="#chapter1"
+-          * Identifies a node-set containing the element with ID attribute
+-          * value 'chapter1' of the XML resource containing the signature.
+-          * XML Signature (and its applications) modify this node-set to
+-          * include the element plus all descendents including namespaces and
+-          * attributes -- but not comments.
+-          */
+-         String id = uriNodeValue.substring(1);
++        XMLSignatureInput result = new XMLSignatureInput(selectedElem);
++        result.setExcludeComments(true);
+ 
+-         // Element selectedElem = doc.getElementById(id);
+-         selectedElem = IdResolver.getElementById(doc, id);
+-         if (selectedElem==null) {
+-                Object exArgs[] = { id };
+-            throw new ResourceResolverException(
+-               "signature.Verification.MissingID", exArgs, uri, BaseURI);
+-         }
+-         if (log.isLoggable(java.util.logging.Level.FINE))
+-                log.log(java.util.logging.Level.FINE, "Try to catch an Element with ID " + id + " and Element was " + selectedElem);
+-      }
+-
+-      XMLSignatureInput result = new XMLSignatureInput(selectedElem);
+-      result.setExcludeComments(true);
+-
+-      //log.log(java.util.logging.Level.FINE, "We return a nodeset with " + resultSet.size() + " nodes");
+-      result.setMIMEType("text/xml");
+-          result.setSourceURI((BaseURI != null) ? BaseURI.concat(uri.getNodeValue()) :
+-                  uri.getNodeValue());
+-      return result;
+-   }
++        result.setMIMEType("text/xml");
++        if (baseURI != null && baseURI.length() > 0) {
++            result.setSourceURI(baseURI.concat(uri.getNodeValue()));
++        } else {
++            result.setSourceURI(uri.getNodeValue());
++        }
++        return result;
++    }
+ 
+    /**
+     * Method engineCanResolve
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/resolver/implementations/ResolverXPointer.java
+@@ -23,11 +23,12 @@
+ 
+ 
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+-import com.sun.org.apache.xml.internal.security.utils.IdResolver;
++import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverException;
+ import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverSpi;
+ import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
++import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+ 
+ 
+@@ -54,52 +55,55 @@
+                             ResolverXPointer.class.getName());
+ 
+     public boolean engineIsThreadSafe() {
+-           return true;
+-   }
+-   /**
+-    * @inheritDoc
+-    */
+-   public XMLSignatureInput engineResolve(Attr uri, String BaseURI)
++        return true;
++    }
++
++    /**
++     * @inheritDoc
++     */
++    public XMLSignatureInput engineResolve(Attr uri, String baseURI)
+            throws ResourceResolverException {
+ 
+-      Node resultNode = null;
+-      Document doc = uri.getOwnerElement().getOwnerDocument();
++        Node resultNode = null;
++        Document doc = uri.getOwnerElement().getOwnerDocument();
+ 
+-        String uriStr=uri.getNodeValue();
+-         if (isXPointerSlash(uriStr)) {
++        String uriStr = uri.getNodeValue();
++        if (isXPointerSlash(uriStr)) {
+             resultNode = doc;
+ 
+-         } else if (isXPointerId(uriStr)) {
++        } else if (isXPointerId(uriStr)) {
+             String id = getXPointerId(uriStr);
+-            resultNode =IdResolver.getElementById(doc, id);
++            resultNode = doc.getElementById(id);
+ 
+-            // log.log(java.util.logging.Level.FINE, "Use #xpointer(id('" + id + "')) on element " + selectedElem);
++            if (secureValidation) {
++                Element start = uri.getOwnerDocument().getDocumentElement();
++                if (!XMLUtils.protectAgainstWrappingAttack(start, id)) {
++                    Object exArgs[] = { id };
++                    throw new ResourceResolverException(
++                        "signature.Verification.MultipleIDs", exArgs,
++                        uri, baseURI);
++                }
++            }
+ 
+             if (resultNode == null) {
+                Object exArgs[] = { id };
+ 
+                throw new ResourceResolverException(
+-                  "signature.Verification.MissingID", exArgs, uri, BaseURI);
++                  "signature.Verification.MissingID", exArgs, uri, baseURI);
+             }
+-            /*
+-            resultNodes =
+-               cXPathAPI
+-                  .selectNodeList(selectedElem, Canonicalizer
+-                     .XPATH_C14N_WITH_COMMENTS_SINGLE_NODE);*/
+-         }
++        }
+ 
++        XMLSignatureInput result = new XMLSignatureInput(resultNode);
+ 
+-      XMLSignatureInput result = new XMLSignatureInput(resultNode);
++        result.setMIMEType("text/xml");
++        if (baseURI != null && baseURI.length() > 0) {
++            result.setSourceURI(baseURI.concat(uri.getNodeValue()));
++        } else {
++            result.setSourceURI(uri.getNodeValue());
++        }
+ 
+-      result.setMIMEType("text/xml");
+-      if (BaseURI != null && BaseURI.length() > 0) {
+-          result.setSourceURI(BaseURI.concat(uri.getNodeValue()));
+-      } else {
+-          result.setSourceURI(uri.getNodeValue());
+-      }
+-
+-      return result;
+-   }
++        return result;
++    }
+ 
+    /**
+     * @inheritDoc
+diff --git a/src/share/classes/javax/xml/crypto/dsig/dom/DOMValidateContext.java b/src/share/classes/javax/xml/crypto/dsig/dom/DOMValidateContext.java
+--- openjdk/jdk/src/share/classes/javax/xml/crypto/dsig/dom/DOMValidateContext.java
++++ openjdk/jdk/src/share/classes/javax/xml/crypto/dsig/dom/DOMValidateContext.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2005, 2013 Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -74,11 +74,7 @@
+         if (ks == null) {
+             throw new NullPointerException("key selector is null");
+         }
+-        if (node == null) {
+-            throw new NullPointerException("node is null");
+-        }
+-        setKeySelector(ks);
+-        this.node = node;
++        init(node, ks);
+     }
+ 
+     /**
+@@ -97,11 +93,20 @@
+         if (validatingKey == null) {
+             throw new NullPointerException("validatingKey is null");
+         }
++        init(node, KeySelector.singletonKeySelector(validatingKey));
++    }
++
++    private void init(Node node, KeySelector ks) {
+         if (node == null) {
+             throw new NullPointerException("node is null");
+         }
+-        setKeySelector(KeySelector.singletonKeySelector(validatingKey));
++
+         this.node = node;
++        super.setKeySelector(ks);
++        if (System.getSecurityManager() != null) {
++            super.setProperty("org.jcp.xml.dsig.secureValidation",
++                              Boolean.TRUE);
++        }
+     }
+ 
+     /**
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
+@@ -193,7 +193,7 @@
+ 
+         if (apacheTransform == null) {
+             try {
+-                apacheTransform = Transform.getInstance
++                apacheTransform = new Transform
+                     (ownerDoc, getAlgorithm(), transformElem.getChildNodes());
+                 apacheTransform.setElement(transformElem, xc.getBaseURI());
+                 if (log.isLoggable(Level.FINE)) {
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheTransform.java
+@@ -38,6 +38,7 @@
+ 
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+ import com.sun.org.apache.xml.internal.security.transforms.Transform;
++import com.sun.org.apache.xml.internal.security.transforms.Transforms;
+ 
+ import javax.xml.crypto.*;
+ import javax.xml.crypto.dom.DOMCryptoContext;
+@@ -117,7 +118,7 @@
+ 
+         if (apacheTransform == null) {
+             try {
+-                apacheTransform = Transform.getInstance
++                apacheTransform = new Transform
+                     (ownerDoc, getAlgorithm(), transformElem.getChildNodes());
+                 apacheTransform.setElement(transformElem, xc.getBaseURI());
+                 if (log.isLoggable(Level.FINE)) {
+@@ -130,6 +131,15 @@
+             }
+         }
+ 
++        if (Utils.secureValidation(xc)) {
++            String algorithm = getAlgorithm();
++            if (Transforms.TRANSFORM_XSLT.equals(algorithm)) {
++                throw new TransformException(
++                    "Transform " + algorithm +
++                    " is forbidden when secure validation is enabled");
++            }
++        }
++
+         XMLSignatureInput in;
+         if (data instanceof ApacheData) {
+             if (log.isLoggable(Level.FINE)) {
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMKeyInfo.java
+@@ -34,6 +34,7 @@
+ 
+ import java.security.Provider;
+ import java.util.*;
++import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+@@ -87,7 +88,13 @@
+     public DOMKeyInfo(Element kiElem, XMLCryptoContext context,
+         Provider provider) throws MarshalException {
+         // get Id attribute, if specified
+-        id = DOMUtils.getAttributeValue(kiElem, "Id");
++        Attr attr = kiElem.getAttributeNodeNS(null, "Id");
++        if (attr != null) {
++            id = attr.getValue();
++            kiElem.setIdAttributeNode(attr, true);
++        } else {
++            id = null;
++        }
+ 
+         // get all children nodes
+         NodeList nl = kiElem.getChildNodes();
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMManifest.java
+@@ -32,6 +32,7 @@
+ 
+ import java.security.Provider;
+ import java.util.*;
++import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+@@ -85,12 +86,30 @@
+      */
+     public DOMManifest(Element manElem, XMLCryptoContext context,
+         Provider provider) throws MarshalException {
+-        this.id = DOMUtils.getAttributeValue(manElem, "Id");
++        Attr attr = manElem.getAttributeNodeNS(null, "Id");
++        if (attr != null) {
++            this.id = attr.getValue();
++            manElem.setIdAttributeNode(attr, true);
++        } else {
++            this.id = null;
++        }
++
++        boolean secVal = Utils.secureValidation(context);
+         Element refElem = DOMUtils.getFirstChildElement(manElem);
+         List refs = new ArrayList();
++        int refCount = 0;
+         while (refElem != null) {
+             refs.add(new DOMReference(refElem, context, provider));
+             refElem = DOMUtils.getNextSiblingElement(refElem);
++
++            refCount++;
++            if (secVal && (refCount > DOMSignedInfo.MAXIMUM_REFERENCE_COUNT)) {
++                String error = "A maxiumum of " +
++                               DOMSignedInfo.MAXIMUM_REFERENCE_COUNT +
++                               " references per Manifest are allowed with" +
++                               " secure validation";
++                throw new MarshalException(error);
++            }
+         }
+         this.references = Collections.unmodifiableList(refs);
+     }
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMReference.java
+@@ -51,6 +51,7 @@
+ import org.w3c.dom.Node;
+ 
+ import org.jcp.xml.dsig.internal.DigesterOutputStream;
++import com.sun.org.apache.xml.internal.security.algorithms.MessageDigestAlgorithm;
+ import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+ import com.sun.org.apache.xml.internal.security.utils.Base64;
+@@ -65,6 +66,12 @@
+ public final class DOMReference extends DOMStructure
+     implements Reference, DOMURIReference {
+ 
++    /**
++     * The maximum number of transforms per reference, if secure validation
++     * is enabled.
++     */
++    public static final int MAXIMUM_TRANSFORM_COUNT = 5;
++
+    /**
+     * Look up useC14N11 system property. If true, an explicit C14N11 transform
+     * will be added if necessary when generating the signature. See section
+@@ -184,15 +191,27 @@
+      */
+     public DOMReference(Element refElem, XMLCryptoContext context,
+         Provider provider) throws MarshalException {
++        boolean secVal = Utils.secureValidation(context);
++
+         // unmarshal Transforms, if specified
+         Element nextSibling = DOMUtils.getFirstChildElement(refElem);
+         List transforms = new ArrayList(5);
+         if (nextSibling.getLocalName().equals("Transforms")) {
+             Element transformElem = DOMUtils.getFirstChildElement(nextSibling);
++
++            int transformCount = 0;
+             while (transformElem != null) {
+                 transforms.add
+                     (new DOMTransform(transformElem, context, provider));
+                 transformElem = DOMUtils.getNextSiblingElement(transformElem);
++
++                transformCount++;
++                if (secVal && (transformCount > MAXIMUM_TRANSFORM_COUNT)) {
++                    String error = "A maxiumum of " + MAXIMUM_TRANSFORM_COUNT +
++                                   " transforms per Reference are allowed" +
++                                   " with secure validation";
++                    throw new MarshalException(error);
++                }
+             }
+             nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
+         }
+@@ -200,6 +219,14 @@
+         // unmarshal DigestMethod
+         Element dmElem = nextSibling;
+         this.digestMethod = DOMDigestMethod.unmarshal(dmElem);
++        String digestMethodAlgorithm = this.digestMethod.getAlgorithm();
++        if (secVal
++            && MessageDigestAlgorithm.ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5.equals(digestMethodAlgorithm))
++        {
++             throw new MarshalException("It is forbidden to use algorithm " +
++                                        digestMethod +
++                                        " when secure validation is enabled");
++        }
+ 
+         // unmarshal DigestValue
+         try {
+@@ -211,7 +238,14 @@
+ 
+         // unmarshal attributes
+         this.uri = DOMUtils.getAttributeValue(refElem, "URI");
+-        this.id = DOMUtils.getAttributeValue(refElem, "Id");
++
++        Attr attr = refElem.getAttributeNodeNS(null, "Id");
++        if (attr != null) {
++            this.id = attr.getValue();
++            refElem.setIdAttributeNode(attr, true);
++        } else {
++            this.id = null;
++        }
+ 
+         this.type = DOMUtils.getAttributeValue(refElem, "Type");
+         this.here = refElem.getAttributeNodeNS(null, "URI");
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMRetrievalMethod.java
+@@ -38,6 +38,7 @@
+ import java.net.URISyntaxException;
+ import java.security.Provider;
+ import java.util.*;
++import javax.xml.XMLConstants;
+ import javax.xml.crypto.*;
+ import javax.xml.crypto.dsig.*;
+ import javax.xml.crypto.dom.DOMCryptoContext;
+@@ -124,9 +125,13 @@
+         // get here node
+         here = rmElem.getAttributeNodeNS(null, "URI");
+ 
++        boolean secVal = Utils.secureValidation(context);
++
+         // get Transforms, if specified
+         List transforms = new ArrayList();
+         Element transformsElem = DOMUtils.getFirstChildElement(rmElem);
++
++        int transformCount = 0;
+         if (transformsElem != null) {
+             Element transformElem =
+                 DOMUtils.getFirstChildElement(transformsElem);
+@@ -134,6 +139,17 @@
+                 transforms.add
+                     (new DOMTransform(transformElem, context, provider));
+                 transformElem = DOMUtils.getNextSiblingElement(transformElem);
++
++                transformCount++;
++                if (secVal &&
++                    (transformCount > DOMReference.MAXIMUM_TRANSFORM_COUNT))
++                {
++                    String error = "A maxiumum of " +
++                                   DOMReference.MAXIMUM_TRANSFORM_COUNT +
++                                   " transforms per Reference are allowed" +
++                                   " with secure validation";
++                    throw new MarshalException(error);
++                }
+             }
+         }
+         if (transforms.isEmpty()) {
+@@ -224,6 +240,8 @@
+             ApacheData data = (ApacheData) dereference(context);
+             DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+             dbf.setNamespaceAware(true);
++            dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
++                           Boolean.TRUE);
+             DocumentBuilder db = dbf.newDocumentBuilder();
+             Document doc = db.parse(new ByteArrayInputStream
+                 (data.getXMLSignatureInput().getBytes()));
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperties.java
+@@ -31,6 +31,7 @@
+ import javax.xml.crypto.dsig.*;
+ 
+ import java.util.*;
++import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+@@ -86,7 +87,13 @@
+      */
+     public DOMSignatureProperties(Element propsElem) throws MarshalException{
+         // unmarshal attributes
+-        id = DOMUtils.getAttributeValue(propsElem, "Id");
++        Attr attr = propsElem.getAttributeNodeNS(null, "Id");
++        if (attr != null) {
++            id = attr.getValue();
++            propsElem.setIdAttributeNode(attr, true);
++        } else {
++            id = null;
++        }
+ 
+         NodeList nodes = propsElem.getChildNodes();
+         int length = nodes.getLength();
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureProperty.java
+@@ -31,6 +31,7 @@
+ import javax.xml.crypto.dsig.*;
+ 
+ import java.util.*;
++import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+@@ -94,7 +95,13 @@
+         if (target == null) {
+             throw new MarshalException("target cannot be null");
+         }
+-        id = DOMUtils.getAttributeValue(propElem, "Id");
++        Attr attr = propElem.getAttributeNodeNS(null, "Id");
++        if (attr != null) {
++            id = attr.getValue();
++            propElem.setIdAttributeNode(attr, true);
++        } else {
++            id = null;
++        }
+ 
+         NodeList nodes = propElem.getChildNodes();
+         int length = nodes.getLength();
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignedInfo.java
+@@ -45,6 +45,7 @@
+ import org.w3c.dom.Node;
+ 
+ import com.sun.org.apache.xml.internal.security.utils.Base64;
++import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.UnsyncBufferedOutputStream;
+ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ 
+@@ -55,7 +56,22 @@
+  */
+ public final class DOMSignedInfo extends DOMStructure implements SignedInfo {
+ 
++    /**
++     * The maximum number of references per Manifest, if secure validation is
++     * enabled.
++     */
++    public static final int MAXIMUM_REFERENCE_COUNT = 30;
++
+     private static Logger log = Logger.getLogger("org.jcp.xml.dsig.internal.dom");
++
++    /** Signature - NOT Recommended RSAwithMD5 */
++    private static final String ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5 =
++        Constants.MoreAlgorithmsSpecNS + "rsa-md5";
++
++    /** HMAC - NOT Recommended HMAC-MD5 */
++    private static final String ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5 =
++        Constants.MoreAlgorithmsSpecNS + "hmac-md5";
++
+     private List references;
+     private CanonicalizationMethod canonicalizationMethod;
+     private SignatureMethod signatureMethod;
+@@ -143,12 +159,31 @@
+         Element smElem = DOMUtils.getNextSiblingElement(cmElem);
+         signatureMethod = DOMSignatureMethod.unmarshal(smElem);
+ 
++        boolean secVal = Utils.secureValidation(context);
++        String sigMethAlg = signatureMethod.getAlgorithm();
++        if (secVal && ((ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5.equals(sigMethAlg)
++            || ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5.equals(sigMethAlg))))
++        {
++            throw new MarshalException("It is forbidden to use algorithm " +
++                                       signatureMethod +
++                                       " when secure validation is enabled");
++        }
++
+         // unmarshal References
+         ArrayList refList = new ArrayList(5);
+         Element refElem = DOMUtils.getNextSiblingElement(smElem);
++        int refCount = 0;
+         while (refElem != null) {
+             refList.add(new DOMReference(refElem, context, provider));
+             refElem = DOMUtils.getNextSiblingElement(refElem);
++
++            refCount++;
++            if (secVal && (refCount > MAXIMUM_REFERENCE_COUNT)) {
++                String error = "A maxiumum of " + MAXIMUM_REFERENCE_COUNT +
++                               " references per SignedInfo are allowed with" +
++                               " secure validation";
++                throw new MarshalException(error);
++            }
+         }
+         references = Collections.unmodifiableList(refList);
+     }
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMURIDereferencer.java
+@@ -31,7 +31,7 @@
+ import org.w3c.dom.Node;
+ 
+ import com.sun.org.apache.xml.internal.security.Init;
+-import com.sun.org.apache.xml.internal.security.utils.IdResolver;
++import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
+ import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
+ 
+@@ -68,8 +68,11 @@
+         Attr uriAttr = (Attr) domRef.getHere();
+         String uri = uriRef.getURI();
+         DOMCryptoContext dcc = (DOMCryptoContext) context;
++        String baseURI = context.getBaseURI();
+ 
+-        // Check if same-document URI and register ID
++        boolean secVal = Utils.secureValidation(context);
++
++        // Check if same-document URI and already registered on the context
+         if (uri != null && uri.length() != 0 && uri.charAt(0) == '#') {
+             String id = uri.substring(1);
+ 
+@@ -79,19 +82,38 @@
+                 id = id.substring(i1+1, i2);
+             }
+ 
+-            // this is a bit of a hack to check for registered
+-            // IDRefs and manually register them with Apache's IdResolver
+-            // map which includes builtin schema knowledge of DSig/Enc IDs
+-            Node referencedElem = dcc.getElementById(id);
+-            if (referencedElem != null) {
+-                IdResolver.registerElementById((Element) referencedElem, id);
++            Node refElem = dcc.getElementById(id);
++            if (refElem != null) {
++                if (secVal) {
++                    Element start =
++                        refElem.getOwnerDocument().getDocumentElement();
++                    if (!XMLUtils.protectAgainstWrappingAttack(start,
++                                                               (Element)refElem,
++                                                               id)) {
++                        String error = "Multiple Elements with the same ID " +
++                                       id + " were detected";
++                        throw new URIReferenceException(error);
++                    }
++                }
++
++                XMLSignatureInput result = new XMLSignatureInput(refElem);
++                if (!uri.substring(1).startsWith("xpointer(id(")) {
++                    result.setExcludeComments(true);
++                }
++
++                result.setMIMEType("text/xml");
++                if (baseURI != null && baseURI.length() > 0) {
++                    result.setSourceURI(baseURI.concat(uriAttr.getNodeValue()));
++                } else {
++                    result.setSourceURI(uriAttr.getNodeValue());
++                }
++                return new ApacheNodeSetData(result);
+             }
+         }
+ 
+         try {
+-            String baseURI = context.getBaseURI();
+             ResourceResolver apacheResolver =
+-                ResourceResolver.getInstance(uriAttr, baseURI);
++                ResourceResolver.getInstance(uriAttr, baseURI, secVal);
+             XMLSignatureInput in = apacheResolver.resolve(uriAttr, baseURI);
+             if (in.isOctetStream()) {
+                 return new ApacheOctetStreamData(in);
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMUtils.java
+@@ -38,8 +38,6 @@
+ import javax.xml.crypto.dsig.*;
+ import javax.xml.crypto.dsig.spec.*;
+ 
+-import com.sun.org.apache.xml.internal.security.utils.IdResolver;
+-
+ /**
+  * Useful static DOM utility methods.
+  *
+@@ -107,7 +105,7 @@
+     public static void setAttributeID(Element elem, String name, String value) {
+         if (value == null) return;
+         elem.setAttributeNS(null, name, value);
+-        IdResolver.registerElementById(elem, value);
++        elem.setIdAttributeNS(null, name, true);
+     }
+ 
+     /**
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLObject.java
+@@ -32,6 +32,7 @@
+ 
+ import java.security.Provider;
+ import java.util.*;
++import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+@@ -91,7 +92,14 @@
+         Provider provider) throws MarshalException {
+         // unmarshal attributes
+         this.encoding = DOMUtils.getAttributeValue(objElem, "Encoding");
+-        this.id = DOMUtils.getAttributeValue(objElem, "Id");
++
++        Attr attr = objElem.getAttributeNodeNS(null, "Id");
++        if (attr != null) {
++            this.id = attr.getValue();
++            objElem.setIdAttributeNode(attr, true);
++        } else {
++            this.id = null;
++        }
+         this.mimeType = DOMUtils.getAttributeValue(objElem, "MimeType");
+ 
+         NodeList nodes = objElem.getChildNodes();
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMXMLSignature.java
+@@ -50,6 +50,7 @@
+ import java.util.List;
+ import java.util.logging.Level;
+ import java.util.logging.Logger;
++import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.Node;
+@@ -489,7 +490,13 @@
+                 throw new MarshalException(bde);
+             }
+ 
+-            id = DOMUtils.getAttributeValue(sigValueElem, "Id");
++            Attr attr = sigValueElem.getAttributeNodeNS(null, "Id");
++            if (attr != null) {
++                id = attr.getValue();
++                sigValueElem.setIdAttributeNode(attr, true);
++            } else {
++                id = null;
++            }
+             this.sigValueElem = sigValueElem;
+         }
+ 
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/Utils.java
+@@ -30,6 +30,7 @@
+ import java.io.InputStream;
+ import java.io.IOException;
+ import java.util.*;
++import javax.xml.crypto.XMLCryptoContext;
+ import org.w3c.dom.NamedNodeMap;
+ import org.w3c.dom.Node;
+ 
+@@ -104,4 +105,13 @@
+     public static boolean sameDocumentURI(String uri) {
+         return (uri != null && (uri.length() == 0 || uri.charAt(0) == '#'));
+     }
++
++    static boolean secureValidation(XMLCryptoContext xc) {
++        return getBoolean(xc, "org.jcp.xml.dsig.secureValidation");
++    }
++
++    private static boolean getBoolean(XMLCryptoContext xc, String name) {
++        Boolean value = (Boolean)xc.getProperty(name);
++        return (value != null && value.booleanValue());
++    }
+ }
+diff --git a/src/share/lib/security/java.security b/src/share/lib/security/java.security
+--- openjdk/jdk/src/share/lib/security/java.security
++++ openjdk/jdk/src/share/lib/security/java.security
+@@ -148,7 +148,9 @@
+                com.sun.org.apache.xml.internal.res.,\
+                com.sun.org.apache.xml.internal.serializer.utils.,\
+                com.sun.org.apache.xml.internal.utils.,\
+-               com.sun.org.glassfish.
++               com.sun.org.apache.xml.internal.security.,\
++               com.sun.org.glassfish.,\
++               org.jcp.xml.dsig.internal.
+ 
+ #
+ # List of comma-separated packages that start with or equal this string
+@@ -181,7 +183,9 @@
+                    com.sun.org.apache.xml.internal.res.,\
+                    com.sun.org.apache.xml.internal.serializer.utils.,\
+                    com.sun.org.apache.xml.internal.utils.,\
+-                   com.sun.org.glassfish.
++                   com.sun.org.apache.xml.internal.security.,\
++                   com.sun.org.glassfish.,\
++                   org.jcp.xml.dsig.internal.
+ 
+ #
+ # Determines whether this properties file can be appended to
+diff --git a/src/share/lib/security/java.security-solaris b/src/share/lib/security/java.security-solaris
+--- openjdk/jdk/src/share/lib/security/java.security-solaris
++++ openjdk/jdk/src/share/lib/security/java.security-solaris
+@@ -149,7 +149,9 @@
+                com.sun.org.apache.xml.internal.res.,\
+                com.sun.org.apache.xml.internal.serializer.utils.,\
+                com.sun.org.apache.xml.internal.utils.,\
+-               com.sun.org.glassfish.
++               com.sun.org.apache.xml.internal.security.,\
++               com.sun.org.glassfish.,\
++               org.jcp.xml.dsig.internal.
+ 
+ #
+ # List of comma-separated packages that start with or equal this string
+@@ -182,7 +184,9 @@
+                    com.sun.org.apache.xml.internal.res.,\
+                    com.sun.org.apache.xml.internal.serializer.utils.,\
+                    com.sun.org.apache.xml.internal.utils.,\
+-                   com.sun.org.glassfish.
++                   com.sun.org.apache.xml.internal.security.,\
++                   com.sun.org.glassfish.,\
++                   org.jcp.xml.dsig.internal.
+ 
+ #
+ # Determines whether this properties file can be appended to
+diff --git a/src/share/lib/security/java.security-windows b/src/share/lib/security/java.security-windows
+--- openjdk/jdk/src/share/lib/security/java.security-windows
++++ openjdk/jdk/src/share/lib/security/java.security-windows
+@@ -149,7 +149,9 @@
+                com.sun.org.apache.xml.internal.res.,\
+                com.sun.org.apache.xml.internal.serializer.utils.,\
+                com.sun.org.apache.xml.internal.utils.,\
++               com.sun.org.apache.xml.internal.security.,\
+                com.sun.org.glassfish.,\
++               org.jcp.xml.dsig.internal.\
+                com.sun.java.accessibility.
+ 
+ #
+@@ -183,7 +185,9 @@
+                    com.sun.org.apache.xml.internal.res.,\
+                    com.sun.org.apache.xml.internal.serializer.utils.,\
+                    com.sun.org.apache.xml.internal.utils.,\
++                   com.sun.org.apache.xml.internal.security.,\
+                    com.sun.org.glassfish.,\
++                   org.jcp.xml.dsig.internal.\
+                    com.sun.java.accessibility.
+ 
+ #
+diff --git a/test/javax/xml/crypto/dsig/GenerationTests.java b/test/javax/xml/crypto/dsig/GenerationTests.java
+--- openjdk/jdk/test/javax/xml/crypto/dsig/GenerationTests.java
++++ openjdk/jdk/test/javax/xml/crypto/dsig/GenerationTests.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -27,7 +27,7 @@
+  * @summary Basic unit tests for generating XML Signatures with JSR 105
+  * @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java
+  *     X509KeySelector.java GenerationTests.java
+- * @run main GenerationTests
++ * @run main/othervm GenerationTests
+  * @author Sean Mullan
+  */
+ 
+@@ -713,6 +713,7 @@
+ 
+         DOMSignContext dsc = new DOMSignContext(signingKey, doc);
+         dsc.setURIDereferencer(httpUd);
++        dsc.setIdAttributeNS(nc, null, "Id");
+ 
+         sig.sign(dsc);
+ 
+@@ -721,6 +722,7 @@
+         File f = new File(DATA_DIR);
+         dvc.setBaseURI(f.toURI().toString());
+         dvc.setURIDereferencer(httpUd);
++        dvc.setIdAttributeNS(nc, null, "Id");
+ 
+         XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);
+ 
+diff --git a/test/javax/xml/crypto/dsig/SecurityManager/XMLDSigWithSecMgr.java b/test/javax/xml/crypto/dsig/SecurityManager/XMLDSigWithSecMgr.java
+--- openjdk/jdk/test/javax/xml/crypto/dsig/SecurityManager/XMLDSigWithSecMgr.java
++++ openjdk/jdk/test/javax/xml/crypto/dsig/SecurityManager/XMLDSigWithSecMgr.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -26,6 +26,7 @@
+  * @bug 6436919 6460930
+  * @summary check that XML Signatures can be generated and validated with
+  *  SecurityManager enabled and default policy
++ * @run main/othervm XMLDSigWithSecMgr
+  * @author Sean Mullan
+  */
+ import java.io.*;
+@@ -139,6 +140,10 @@
+             // validate a signature with SecurityManager enabled
+             DOMValidateContext dvc = new DOMValidateContext
+                 (kp.getPublic(), envelope.getFirstChild());
++
++            // disable secure validation mode so that http reference will work
++            dvc.setProperty("org.jcp.xml.dsig.secureValidation", Boolean.FALSE);
++
+             sig = fac.unmarshalXMLSignature(dvc);
+             if (!sig.validate(dvc)) {
+                 throw new Exception
+diff --git a/test/javax/xml/crypto/dsig/ValidationTests.java b/test/javax/xml/crypto/dsig/ValidationTests.java
+--- openjdk/jdk/test/javax/xml/crypto/dsig/ValidationTests.java
++++ openjdk/jdk/test/javax/xml/crypto/dsig/ValidationTests.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -27,7 +27,7 @@
+  * @summary Basic unit tests for validating XML Signatures with JSR 105
+  * @compile -XDignore.symbol.file KeySelectors.java SignatureValidator.java
+  *     X509KeySelector.java ValidationTests.java
+- * @run main ValidationTests
++ * @run main/othervm ValidationTests
+  * @author Sean Mullan
+  */
+ import java.io.File;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/7158805-nested_subroutine_rewriting.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,462 @@
+# HG changeset patch
+# User andrew
+# Date 1371562757 18000
+# Node ID 684f0c17ce15a3e012e9b73d618af1462f8c2d64
+# Parent  f5eac6fae49e04b673a8307058ce3b22750da0a9
+7158805: Better rewriting of nested subroutine calls
+Reviewed-by: mschoene, coleenp
+
+diff --git a/src/share/vm/memory/allocation.cpp b/src/share/vm/memory/allocation.cpp
+--- openjdk/hotspot/src/share/vm/memory/allocation.cpp
++++ openjdk/hotspot/src/share/vm/memory/allocation.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -199,7 +199,7 @@
+    ChunkPool(size_t size) : _size(size) { _first = NULL; _num_chunks = _num_used = 0; }
+ 
+   // Allocate a new chunk from the pool (might expand the pool)
+-  void* allocate(size_t bytes) {
++  void* allocate(size_t bytes, AllocFailType alloc_failmode) {
+     assert(bytes == _size, "bad size");
+     void* p = NULL;
+     { ThreadCritical tc;
+@@ -207,9 +207,9 @@
+       p = get_first();
+       if (p == NULL) p = os::malloc(bytes);
+     }
+-    if (p == NULL)
++    if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
+       vm_exit_out_of_memory(bytes, "ChunkPool::allocate");
+-
++    }
+     return p;
+   }
+ 
+@@ -300,7 +300,7 @@
+ //--------------------------------------------------------------------------------------
+ // Chunk implementation
+ 
+-void* Chunk::operator new(size_t requested_size, size_t length) {
++void* Chunk::operator new(size_t requested_size, AllocFailType alloc_failmode, size_t length) {
+   // requested_size is equal to sizeof(Chunk) but in order for the arena
+   // allocations to come out aligned as expected the size must be aligned
+   // to expected arean alignment.
+@@ -308,13 +308,14 @@
+   assert(ARENA_ALIGN(requested_size) == aligned_overhead_size(), "Bad alignment");
+   size_t bytes = ARENA_ALIGN(requested_size) + length;
+   switch (length) {
+-   case Chunk::size:        return ChunkPool::large_pool()->allocate(bytes);
+-   case Chunk::medium_size: return ChunkPool::medium_pool()->allocate(bytes);
+-   case Chunk::init_size:   return ChunkPool::small_pool()->allocate(bytes);
++   case Chunk::size:        return ChunkPool::large_pool()->allocate(bytes, alloc_failmode);
++   case Chunk::medium_size: return ChunkPool::medium_pool()->allocate(bytes, alloc_failmode);
++   case Chunk::init_size:   return ChunkPool::small_pool()->allocate(bytes, alloc_failmode);
+    default: {
+-     void *p =  os::malloc(bytes);
+-     if (p == NULL)
++     void* p = os::malloc(bytes);
++     if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM) {
+        vm_exit_out_of_memory(bytes, "Chunk::new");
++     }
+      return p;
+    }
+   }
+@@ -367,14 +368,14 @@
+ Arena::Arena(size_t init_size) {
+   size_t round_size = (sizeof (char *)) - 1;
+   init_size = (init_size+round_size) & ~round_size;
+-  _first = _chunk = new (init_size) Chunk(init_size);
++  _first = _chunk = new (AllocFailStrategy::EXIT_OOM, init_size) Chunk(init_size);
+   _hwm = _chunk->bottom();      // Save the cached hwm, max
+   _max = _chunk->top();
+   set_size_in_bytes(init_size);
+ }
+ 
+ Arena::Arena() {
+-  _first = _chunk = new (Chunk::init_size) Chunk(Chunk::init_size);
++  _first = _chunk = new (AllocFailStrategy::EXIT_OOM, Chunk::init_size) Chunk(Chunk::init_size);
+   _hwm = _chunk->bottom();      // Save the cached hwm, max
+   _max = _chunk->top();
+   set_size_in_bytes(Chunk::init_size);
+@@ -427,15 +428,15 @@
+ }
+ 
+ // Grow a new Chunk
+-void* Arena::grow( size_t x ) {
++void* Arena::grow(size_t x, AllocFailType alloc_failmode) {
+   // Get minimal required size.  Either real big, or even bigger for giant objs
+   size_t len = MAX2(x, (size_t) Chunk::size);
+ 
+   Chunk *k = _chunk;            // Get filled-up chunk address
+-  _chunk = new (len) Chunk(len);
++  _chunk = new (alloc_failmode, len) Chunk(len);
+ 
+   if (_chunk == NULL) {
+-    signal_out_of_memory(len * Chunk::aligned_overhead_size(), "Arena::grow");
++    return NULL;
+   }
+ 
+   if (k) k->set_next(_chunk);   // Append new chunk to end of linked list
+@@ -451,13 +452,16 @@
+ 
+ 
+ // Reallocate storage in Arena.
+-void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size) {
++void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFailType alloc_failmode) {
+   assert(new_size >= 0, "bad size");
+   if (new_size == 0) return NULL;
+ #ifdef ASSERT
+   if (UseMallocOnly) {
+     // always allocate a new object  (otherwise we'll free this one twice)
+-    char* copy = (char*)Amalloc(new_size);
++    char* copy = (char*)Amalloc(new_size, alloc_failmode);
++    if (copy == NULL) {
++      return NULL;
++    }
+     size_t n = MIN2(old_size, new_size);
+     if (n > 0) memcpy(copy, old_ptr, n);
+     Afree(old_ptr,old_size);    // Mostly done to keep stats accurate
+@@ -483,7 +487,10 @@
+   }
+ 
+   // Oops, got to relocate guts
+-  void *new_ptr = Amalloc(new_size);
++  void *new_ptr = Amalloc(new_size, alloc_failmode);
++  if (new_ptr == NULL) {
++    return NULL;
++  }
+   memcpy( new_ptr, c_old, old_size );
+   Afree(c_old,old_size);        // Mostly done to keep stats accurate
+   return new_ptr;
+diff --git a/src/share/vm/memory/allocation.hpp b/src/share/vm/memory/allocation.hpp
+--- openjdk/hotspot/src/share/vm/memory/allocation.hpp
++++ openjdk/hotspot/src/share/vm/memory/allocation.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -38,6 +38,12 @@
+ #define ARENA_ALIGN_MASK (~((size_t)ARENA_ALIGN_M1))
+ #define ARENA_ALIGN(x) ((((size_t)(x)) + ARENA_ALIGN_M1) & ARENA_ALIGN_MASK)
+ 
++class AllocFailStrategy {
++public:
++  enum AllocFailEnum { EXIT_OOM, RETURN_NULL };
++};
++typedef AllocFailStrategy::AllocFailEnum AllocFailType;
++
+ // All classes in the virtual machine must be subclassed
+ // by one of the following allocation classes:
+ //
+@@ -152,7 +158,7 @@
+   Chunk*       _next;     // Next Chunk in list
+   const size_t _len;      // Size of this Chunk
+  public:
+-  void* operator new(size_t size, size_t length);
++  void* operator new(size_t size, AllocFailType alloc_failmode, size_t length);
+   void  operator delete(void* p);
+   Chunk(size_t length);
+ 
+@@ -200,7 +206,8 @@
+   Chunk *_first;                // First chunk
+   Chunk *_chunk;                // current chunk
+   char *_hwm, *_max;            // High water mark and max in current chunk
+-  void* grow(size_t x);         // Get a new Chunk of at least size x
++  // Get a new Chunk of at least size x
++  void* grow(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
+   NOT_PRODUCT(size_t _size_in_bytes;) // Size of arena (used for memory usage tracing)
+   NOT_PRODUCT(static size_t _bytes_allocated;) // total #bytes allocated since start
+   friend class AllocStats;
+@@ -209,10 +216,15 @@
+ 
+   void signal_out_of_memory(size_t request, const char* whence) const;
+ 
+-  void check_for_overflow(size_t request, const char* whence) const {
++  bool check_for_overflow(size_t request, const char* whence,
++      AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) const {
+     if (UINTPTR_MAX - request < (uintptr_t)_hwm) {
++      if (alloc_failmode == AllocFailStrategy::RETURN_NULL) {
++        return false;
++      }
+       signal_out_of_memory(request, whence);
+     }
++    return true;
+   }
+ 
+  public:
+@@ -224,14 +236,15 @@
+   char* hwm() const             { return _hwm; }
+ 
+   // Fast allocate in the arena.  Common case is: pointer test + increment.
+-  void* Amalloc(size_t x) {
++  void* Amalloc(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
+     assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2");
+     x = ARENA_ALIGN(x);
+     debug_only(if (UseMallocOnly) return malloc(x);)
+-    check_for_overflow(x, "Arena::Amalloc");
++    if (!check_for_overflow(x, "Arena::Amalloc", alloc_failmode))
++      return NULL;
+     NOT_PRODUCT(_bytes_allocated += x);
+     if (_hwm + x > _max) {
+-      return grow(x);
++      return grow(x, alloc_failmode);
+     } else {
+       char *old = _hwm;
+       _hwm += x;
+@@ -239,13 +252,14 @@
+     }
+   }
+   // Further assume size is padded out to words
+-  void *Amalloc_4(size_t x) {
++  void *Amalloc_4(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
+     assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" );
+     debug_only(if (UseMallocOnly) return malloc(x);)
+-    check_for_overflow(x, "Arena::Amalloc_4");
++    if (!check_for_overflow(x, "Arena::Amalloc_4", alloc_failmode))
++      return NULL;
+     NOT_PRODUCT(_bytes_allocated += x);
+     if (_hwm + x > _max) {
+-      return grow(x);
++      return grow(x, alloc_failmode);
+     } else {
+       char *old = _hwm;
+       _hwm += x;
+@@ -255,7 +269,7 @@
+ 
+   // Allocate with 'double' alignment. It is 8 bytes on sparc.
+   // In other cases Amalloc_D() should be the same as Amalloc_4().
+-  void* Amalloc_D(size_t x) {
++  void* Amalloc_D(size_t x, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
+     assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" );
+     debug_only(if (UseMallocOnly) return malloc(x);)
+ #if defined(SPARC) && !defined(_LP64)
+@@ -263,10 +277,11 @@
+     size_t delta = (((size_t)_hwm + DALIGN_M1) & ~DALIGN_M1) - (size_t)_hwm;
+     x += delta;
+ #endif
+-    check_for_overflow(x, "Arena::Amalloc_D");
++    if (!check_for_overflow(x, "Arena::Amalloc_D", alloc_failmode))
++      return NULL;
+     NOT_PRODUCT(_bytes_allocated += x);
+     if (_hwm + x > _max) {
+-      return grow(x); // grow() returns a result aligned >= 8 bytes.
++      return grow(x, alloc_failmode); // grow() returns a result aligned >= 8 bytes.
+     } else {
+       char *old = _hwm;
+       _hwm += x;
+@@ -286,7 +301,8 @@
+     if (((char*)ptr) + size == _hwm) _hwm = (char*)ptr;
+   }
+ 
+-  void *Arealloc( void *old_ptr, size_t old_size, size_t new_size );
++  void *Arealloc( void *old_ptr, size_t old_size, size_t new_size,
++     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
+ 
+   // Move contents of this arena into an empty arena
+   Arena *move_contents(Arena *empty_arena);
+@@ -328,9 +344,12 @@
+ 
+ 
+ //%note allocation_1
+-extern char* resource_allocate_bytes(size_t size);
+-extern char* resource_allocate_bytes(Thread* thread, size_t size);
+-extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size);
++extern char* resource_allocate_bytes(size_t size,
++    AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
++extern char* resource_allocate_bytes(Thread* thread, size_t size,
++    AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
++extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size,
++    AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM);
+ extern void resource_free_bytes( char *old, size_t size );
+ 
+ //----------------------------------------------------------------------
+@@ -376,6 +395,13 @@
+       DEBUG_ONLY(set_allocation_type(res, RESOURCE_AREA);)
+       return res;
+   }
++
++  void* operator new(size_t size, const std::nothrow_t& nothrow_constant) {
++    address res = (address)resource_allocate_bytes(size, AllocFailStrategy::RETURN_NULL);
++    DEBUG_ONLY(if (res != NULL) set_allocation_type(res, RESOURCE_AREA);)
++    return res;
++  }
++
+   void  operator delete(void* p);
+ };
+ 
+@@ -386,6 +412,9 @@
+ #define NEW_RESOURCE_ARRAY(type, size)\
+   (type*) resource_allocate_bytes((size) * sizeof(type))
+ 
++#define NEW_RESOURCE_ARRAY_RETURN_NULL(type, size)\
++  (type*) resource_allocate_bytes((size) * sizeof(type), AllocFailStrategy::RETURN_NULL)
++
+ #define NEW_RESOURCE_ARRAY_IN_THREAD(thread, type, size)\
+   (type*) resource_allocate_bytes(thread, (size) * sizeof(type))
+ 
+diff --git a/src/share/vm/memory/allocation.inline.hpp b/src/share/vm/memory/allocation.inline.hpp
+--- openjdk/hotspot/src/share/vm/memory/allocation.inline.hpp
++++ openjdk/hotspot/src/share/vm/memory/allocation.inline.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -34,25 +34,29 @@
+ 
+ 
+ // allocate using malloc; will fail if no memory available
+-inline char* AllocateHeap(size_t size, const char* name = NULL) {
++inline char* AllocateHeap(size_t size, const char* name = NULL,
++     AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
+   char* p = (char*) os::malloc(size);
+   #ifdef ASSERT
+   if (PrintMallocFree) trace_heap_malloc(size, name, p);
+   #else
+   Unused_Variable(name);
+   #endif
+-  if (p == NULL) vm_exit_out_of_memory(size, name);
++  if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM)
++    vm_exit_out_of_memory(size, "AllocateHeap");
+   return p;
+ }
+ 
+-inline char* ReallocateHeap(char *old, size_t size, const char* name = NULL) {
++inline char* ReallocateHeap(char *old, size_t size, const char* name = NULL,
++    AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
+   char* p = (char*) os::realloc(old,size);
+   #ifdef ASSERT
+   if (PrintMallocFree) trace_heap_malloc(size, name, p);
+   #else
+   Unused_Variable(name);
+   #endif
+-  if (p == NULL) vm_exit_out_of_memory(size, name);
++  if (p == NULL && alloc_failmode == AllocFailStrategy::EXIT_OOM)
++    vm_exit_out_of_memory(size, "ReallocateHeap");
+   return p;
+ }
+ 
+diff --git a/src/share/vm/memory/resourceArea.cpp b/src/share/vm/memory/resourceArea.cpp
+--- openjdk/hotspot/src/share/vm/memory/resourceArea.cpp
++++ openjdk/hotspot/src/share/vm/memory/resourceArea.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -42,15 +42,16 @@
+ // The following routines are declared in allocation.hpp and used everywhere:
+ 
+ // Allocation in thread-local resource area
+-extern char* resource_allocate_bytes(size_t size) {
+-  return Thread::current()->resource_area()->allocate_bytes(size);
++extern char* resource_allocate_bytes(size_t size, AllocFailType alloc_failmode) {
++  return Thread::current()->resource_area()->allocate_bytes(size, alloc_failmode);
+ }
+-extern char* resource_allocate_bytes(Thread* thread, size_t size) {
+-  return thread->resource_area()->allocate_bytes(size);
++extern char* resource_allocate_bytes(Thread* thread, size_t size, AllocFailType alloc_failmode) {
++  return thread->resource_area()->allocate_bytes(size, alloc_failmode);
+ }
+ 
+-extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size){
+-  return (char*)Thread::current()->resource_area()->Arealloc(old, old_size, new_size);
++extern char* resource_reallocate_bytes( char *old, size_t old_size, size_t new_size,
++    AllocFailType alloc_failmode){
++  return (char*)Thread::current()->resource_area()->Arealloc(old, old_size, new_size, alloc_failmode);
+ }
+ 
+ extern void resource_free_bytes( char *old, size_t size ) {
+diff --git a/src/share/vm/memory/resourceArea.hpp b/src/share/vm/memory/resourceArea.hpp
+--- openjdk/hotspot/src/share/vm/memory/resourceArea.hpp
++++ openjdk/hotspot/src/share/vm/memory/resourceArea.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -64,7 +64,7 @@
+     debug_only(_nesting = 0;);
+   }
+ 
+-  char* allocate_bytes(size_t size) {
++  char* allocate_bytes(size_t size, AllocFailType alloc_failmode = AllocFailStrategy::EXIT_OOM) {
+ #ifdef ASSERT
+     if (_nesting < 1 && !_warned++)
+       fatal("memory leak: allocating without ResourceMark");
+@@ -74,7 +74,7 @@
+       return (*save = (char*)os::malloc(size));
+     }
+ #endif
+-    return (char*)Amalloc(size);
++    return (char*)Amalloc(size, alloc_failmode);
+   }
+ 
+   debug_only(int nesting() const { return _nesting; });
+diff --git a/src/share/vm/oops/generateOopMap.cpp b/src/share/vm/oops/generateOopMap.cpp
+--- openjdk/hotspot/src/share/vm/oops/generateOopMap.cpp
++++ openjdk/hotspot/src/share/vm/oops/generateOopMap.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -643,11 +643,20 @@
+ // CellType handling methods
+ //
+ 
++// Allocate memory and throw LinkageError if failure.
++#define ALLOC_RESOURCE_ARRAY(var, type, count) \
++  var = NEW_RESOURCE_ARRAY_RETURN_NULL(type, count);              \
++  if (var == NULL) {                                              \
++    report_error("Cannot reserve enough memory to analyze this method"); \
++    return;                                                       \
++  }
++
+ void GenerateOopMap::init_state() {
+   _state_len     = _max_locals + _max_stack + _max_monitors;
+-  _state         = NEW_RESOURCE_ARRAY(CellTypeState, _state_len);
++  ALLOC_RESOURCE_ARRAY(_state, CellTypeState, _state_len);
+   memset(_state, 0, _state_len * sizeof(CellTypeState));
+-  _state_vec_buf = NEW_RESOURCE_ARRAY(char, MAX3(_max_locals, _max_stack, _max_monitors) + 1/*for null terminator char */);
++  int count = MAX3(_max_locals, _max_stack, _max_monitors) + 1/*for null terminator char */;
++  ALLOC_RESOURCE_ARRAY(_state_vec_buf, char, count)
+ }
+ 
+ void GenerateOopMap::make_context_uninitialized() {
+@@ -905,7 +914,7 @@
+   // But cumbersome since we don't know the stack heights yet.  (Nor the
+   // monitor stack heights...)
+ 
+-  _basic_blocks = NEW_RESOURCE_ARRAY(BasicBlock, _bb_count);
++  ALLOC_RESOURCE_ARRAY(_basic_blocks, BasicBlock, _bb_count);
+ 
+   // Make a pass through the bytecodes.  Count the number of monitorenters.
+   // This can be used an upper bound on the monitor stack depth in programs
+@@ -976,8 +985,8 @@
+     return;
+   }
+ 
+-  CellTypeState *basicBlockState =
+-      NEW_RESOURCE_ARRAY(CellTypeState, bbNo * _state_len);
++  CellTypeState *basicBlockState;
++  ALLOC_RESOURCE_ARRAY(basicBlockState, CellTypeState, bbNo * _state_len);
+   memset(basicBlockState, 0, bbNo * _state_len * sizeof(CellTypeState));
+ 
+   // Make a pass over the basicblocks and assign their state vectors.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/7170730-windows_network_stack.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,1057 @@
+# HG changeset patch
+# User andrew
+# Date 1371235188 -3600
+# Node ID 8664ebe88635d671ed0134e9348d5e6caea81d0d
+# Parent  7ecadad337414327d0d0ca6a8efcc40b7e8a9d29
+7170730: Improve Windows network stack support.
+Summary: Enable exclusive binding of ports on Windows
+Contributed-by: Severin Gehwolf <sgehwolf@redhat.com>
+
+diff --git a/make/java/nio/mapfile-linux b/make/java/nio/mapfile-linux
+--- openjdk/jdk/make/java/nio/mapfile-linux
++++ openjdk/jdk/make/java/nio/mapfile-linux
+@@ -61,7 +61,8 @@
+ 		Java_sun_nio_ch_NativeThread_init;
+ 		Java_sun_nio_ch_NativeThread_signal;
+ 		Java_sun_nio_ch_Net_socket0;
+-		Java_sun_nio_ch_Net_bind;
++		Java_sun_nio_ch_Net_bind0;
++		Java_sun_nio_ch_Net_isExclusiveBindAvailable;
+ 		Java_sun_nio_ch_Net_connect;
+ 		Java_sun_nio_ch_Net_localPort;
+ 		Java_sun_nio_ch_Net_localInetAddress;
+diff --git a/make/java/nio/mapfile-solaris b/make/java/nio/mapfile-solaris
+--- openjdk/jdk/make/java/nio/mapfile-solaris
++++ openjdk/jdk/make/java/nio/mapfile-solaris
+@@ -59,7 +59,8 @@
+ 		Java_sun_nio_ch_NativeThread_init;
+ 		Java_sun_nio_ch_NativeThread_signal;
+ 		Java_sun_nio_ch_Net_socket0;
+-		Java_sun_nio_ch_Net_bind;
++		Java_sun_nio_ch_Net_bind0;
++		Java_sun_nio_ch_Net_isExclusiveBindAvailable;
+ 		Java_sun_nio_ch_Net_connect;
+ 		Java_sun_nio_ch_Net_localPort;
+ 		Java_sun_nio_ch_Net_localInetAddress;
+diff --git a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+@@ -473,6 +473,10 @@
+                             {
+                                 Net.setIntOption(fd, opt, arg);
+                             }
++                            boolean getIsBoundCondition()
++                            {
++                                return localAddress != null;
++                            }
+                         };
+                 options = new SocketOptsImpl.IP(d);
+             }
+diff --git a/src/share/classes/sun/nio/ch/Net.java b/src/share/classes/sun/nio/ch/Net.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/Net.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/Net.java
+@@ -36,8 +36,42 @@
+     private Net() { }
+ 
+ 
++    // set to true if exclusive binding is on for Windows
++    private static final boolean exclusiveBind;
++
++    static {
++        int availLevel = isExclusiveBindAvailable();
++        if (availLevel >= 0) {
++            String exclBindProp =
++                java.security.AccessController.doPrivileged(
++                    new java.security.PrivilegedAction<String>() {
++                        public String run() {
++                            return System.getProperty(
++                                    "sun.net.useExclusiveBind");
++                        }
++                    });
++            if (exclBindProp != null) {
++                exclusiveBind = exclBindProp.length() == 0 ?
++                        true : Boolean.parseBoolean(exclBindProp);
++            } else if (availLevel == 1) {
++                exclusiveBind = true;
++            } else {
++                exclusiveBind = false;
++            }
++        } else {
++            exclusiveBind = false;
++        }
++    }
++
+     // -- Miscellaneous utilities --
+ 
++    /**
++     * Returns true if exclusive binding is on
++     */
++    static boolean useExclusiveBind() {
++        return exclusiveBind;
++    }
++
+     static InetSocketAddress checkAddress(SocketAddress sa) {
+         if (sa == null)
+             throw new IllegalArgumentException();
+@@ -119,10 +153,21 @@
+         return IOUtil.newFD(socket0(stream, true));
+     }
+ 
++    /*
++     * Returns 1 for Windows versions that support exclusive binding by default, 0
++     * for those that do not, and -1 for Solaris/Linux/Mac OS
++     */
++    private static native int isExclusiveBindAvailable();
++
+     // Due to oddities SO_REUSEADDR on windows reuse is ignored
+     private static native int socket0(boolean stream, boolean reuse);
+ 
+-    static native void bind(FileDescriptor fd, InetAddress addr, int port)
++    static void bind(FileDescriptor fd, InetAddress addr, int port)
++        throws IOException {
++        bind0(fd, exclusiveBind, addr, port);
++    }
++
++    private static native void bind0(FileDescriptor fd, boolean useExclBind, InetAddress addr, int port)
+         throws IOException;
+ 
+     static native int connect(FileDescriptor fd,
+diff --git a/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java b/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
+@@ -207,6 +207,10 @@
+                             void setInt(int opt, int arg) throws IOException {
+                                 Net.setIntOption(fd, opt, arg);
+                             }
++                            boolean getIsBoundCondition() {
++                                // always return true
++                                return true;
++                            }
+                         };
+                 options = new SocketOptsImpl.IP.TCP(d);
+             }
+diff --git a/src/share/classes/sun/nio/ch/SocketChannelImpl.java b/src/share/classes/sun/nio/ch/SocketChannelImpl.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java
+@@ -423,6 +423,11 @@
+                             {
+                                 Net.setIntOption(fd, opt, arg);
+                             }
++                            boolean getIsBoundCondition()
++                            {
++                                // always return true
++                                return true;
++                            }
+                         };
+                 options = new SocketOptsImpl.IP.TCP(d);
+             }
+diff --git a/src/share/classes/sun/nio/ch/SocketOptsImpl.java b/src/share/classes/sun/nio/ch/SocketOptsImpl.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/SocketOptsImpl.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/SocketOptsImpl.java
+@@ -35,10 +35,17 @@
+ class SocketOptsImpl
+     implements SocketOpts
+ {
++    // set true when socket is bound and SO_REUSEADDRESS is emulated
++    private boolean reuseAddressEmulated;
++
++    // set true/false when socket is already bound and SO_REUSEADDR is emulated
++    private boolean isReuseAddress;
+ 
+     static abstract class Dispatcher {
+         abstract int getInt(int opt) throws IOException;
+         abstract void setInt(int opt, int arg) throws IOException;
++        // Only used meaningfully by DatagramChannelImpl
++        abstract boolean getIsBoundCondition();
+         // Others that pass addresses, etc., will come later
+     }
+ 
+@@ -167,11 +174,21 @@
+     // SO_REUSEADDR
+ 
+     public boolean reuseAddress() throws IOException {
++        if (reuseAddressEmulated) {
++            return isReuseAddress;
++        }
++        // no special handling
+         return getBoolean(SocketOptions.SO_REUSEADDR);
+     }
+ 
+     public SocketOpts reuseAddress(boolean b) throws IOException {
+-        setBoolean(SocketOptions.SO_REUSEADDR, b);
++        if ( Net.useExclusiveBind() && d.getIsBoundCondition() ) {
++            reuseAddressEmulated = true;
++            this.isReuseAddress = b;
++        } else {
++            // no special handling
++            setBoolean(SocketOptions.SO_REUSEADDR, b);
++        }
+         return this;
+     }
+ 
+diff --git a/src/solaris/native/sun/nio/ch/Net.c b/src/solaris/native/sun/nio/ch/Net.c
+--- openjdk/jdk/src/solaris/native/sun/nio/ch/Net.c
++++ openjdk/jdk/src/solaris/native/sun/nio/ch/Net.c
+@@ -55,6 +55,11 @@
+     /* Here because Windows native code does need to init IDs */
+ }
+ 
++JNIEXPORT jint JNICALL
++Java_sun_nio_ch_Net_isExclusiveBindAvailable(JNIEnv *env, jclass clazz) {
++    return -1;
++}
++
+ JNIEXPORT int JNICALL
+ Java_sun_nio_ch_Net_socket0(JNIEnv *env, jclass cl, jboolean stream,
+                             jboolean reuse)
+@@ -84,8 +89,8 @@
+ }
+ 
+ JNIEXPORT void JNICALL
+-Java_sun_nio_ch_Net_bind(JNIEnv *env, jclass clazz, /* ## Needs rest of PSI gunk */
+-                         jobject fdo, jobject ia, int port)
++Java_sun_nio_ch_Net_bind0(JNIEnv *env, jclass clazz, /* ## Needs rest of PSI gunk */
++                         jobject fdo, jboolean exclBind, jobject ia, int port)
+ {
+     SOCKADDR sa;
+     int sa_len = SOCKADDR_LEN;
+diff --git a/src/windows/classes/java/net/DefaultDatagramSocketImplFactory.java b/src/windows/classes/java/net/DefaultDatagramSocketImplFactory.java
+--- openjdk/jdk/src/windows/classes/java/net/DefaultDatagramSocketImplFactory.java
++++ openjdk/jdk/src/windows/classes/java/net/DefaultDatagramSocketImplFactory.java
+@@ -56,24 +56,45 @@
+     /* If the version supports a dual stack TCP implementation */
+     private static boolean useDualStackImpl = false;
+ 
++    /* sun.net.useExclusiveBind */
++    private static String exclBindProp;
++
++    /* True if exclusive binding is on for Windows */
++    private static boolean exclusiveBind = true;
++
++
+     static {
+         // Determine Windows Version.
+-        java.security.AccessController.doPrivileged( new PrivilegedAction<Object>() {
+-                public Object run() {
+-                    version = 0;
+-                    try {
+-                        version = Float.parseFloat(System.getProperties().getProperty("os.version"));
+-                        preferIPv4Stack = Boolean.parseBoolean(
+-                                          System.getProperties().getProperty("java.net.preferIPv4Stack"));
+-                    } catch (NumberFormatException e ) {
+-                        assert false : e;
++        java.security.AccessController.doPrivileged(
++                new PrivilegedAction<Object>() {
++                    public Object run() {
++                        version = 0;
++                        try {
++                            version = Float.parseFloat(System.getProperties()
++                                    .getProperty("os.version"));
++                            preferIPv4Stack = Boolean.parseBoolean(
++                                              System.getProperties()
++                                              .getProperty(
++                                                   "java.net.preferIPv4Stack"));
++                            exclBindProp = System.getProperty(
++                                    "sun.net.useExclusiveBind");
++                        } catch (NumberFormatException e ) {
++                            assert false : e;
++                        }
++                        return null; // nothing to return
+                     }
+-                    return null; // nothing to return
+-                } });
++                });
+ 
+         // (version >= 6.0) implies Vista or greater.
+         if (version >= 6.0 && !preferIPv4Stack) {
+-            useDualStackImpl = true;
++                useDualStackImpl = true;
++        }
++        if (exclBindProp != null) {
++            // sun.net.useExclusiveBind is true
++            exclusiveBind = exclBindProp.length() == 0 ? true
++                    : Boolean.parseBoolean(exclBindProp);
++        } else if (version < 6.0) {
++            exclusiveBind = false;
+         }
+ 
+         // impl.prefix
+@@ -105,10 +126,12 @@
+                 throw new SocketException("can't instantiate DatagramSocketImpl");
+             }
+         } else {
++            if (isMulticast)
++                exclusiveBind = false;
+             if (useDualStackImpl && !isMulticast)
+-                return new DualStackPlainDatagramSocketImpl();
++                return new DualStackPlainDatagramSocketImpl(exclusiveBind);
+             else
+-                return new TwoStacksPlainDatagramSocketImpl();
++                return new TwoStacksPlainDatagramSocketImpl(exclusiveBind);
+         }
+     }
+ }
+diff --git a/src/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java b/src/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java
+--- openjdk/jdk/src/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java
++++ openjdk/jdk/src/windows/classes/java/net/DualStackPlainDatagramSocketImpl.java
+@@ -46,6 +46,22 @@
+ {
+     static JavaIOFileDescriptorAccess fdAccess = SharedSecrets.getJavaIOFileDescriptorAccess();
+ 
++    // true if this socket is exclusively bound
++    private final boolean exclusiveBind;
++
++    /*
++     * Set to true if SO_REUSEADDR is set after the socket is bound to
++     * indicate SO_REUSEADDR is being emulated
++     */
++    private boolean reuseAddressEmulated;
++
++    // emulates SO_REUSEADDR when exclusiveBind is true and socket is bound
++    private boolean isReuseAddress;
++
++    DualStackPlainDatagramSocketImpl(boolean exclBind) {
++        exclusiveBind = exclBind;
++    }
++
+     protected void datagramSocketCreate() throws SocketException {
+         if (fd == null)
+             throw new SocketException("Socket closed");
+@@ -62,7 +78,7 @@
+         if (laddr == null)
+             throw new NullPointerException("argument address");
+ 
+-        socketBind(nativefd, laddr, lport);
++        socketBind(nativefd, laddr, lport, exclusiveBind);
+         if (lport == 0) {
+             localPort = socketLocalPort(nativefd);
+         } else {
+@@ -142,6 +158,7 @@
+         fdAccess.set(fd, -1);
+     }
+ 
++    @SuppressWarnings("fallthrough")
+     protected void socketSetOption(int opt, Object val) throws SocketException {
+         int nativefd = checkAndReturnNativeFD();
+ 
+@@ -154,6 +171,13 @@
+                 optionValue = ((Integer)val).intValue();
+                 break;
+             case SO_REUSEADDR :
++                if (exclusiveBind && localPort != 0)  {
++                    // socket already bound, emulate SO_REUSEADDR
++                    reuseAddressEmulated = true;
++                    isReuseAddress = (Boolean)val;
++                    return;
++                }
++                //Intentional fallthrough
+             case SO_BROADCAST :
+                 optionValue = ((Boolean)val).booleanValue() ? 1 : 0;
+                 break;
+@@ -171,6 +195,8 @@
+         if (opt == SO_BINDADDR) {
+             return socketLocalAddress(nativefd);
+         }
++        if (opt == SO_REUSEADDR && reuseAddressEmulated)
++            return isReuseAddress;
+ 
+         int value = socketGetIntOption(nativefd, opt);
+         Object returnValue = null;
+@@ -238,8 +264,8 @@
+ 
+     private static native int socketCreate(boolean v6Only);
+ 
+-    private static native void socketBind(int fd, InetAddress localAddress, int localport)
+-        throws SocketException;
++    private static native void socketBind(int fd, InetAddress localAddress,
++            int localport, boolean exclBind) throws SocketException;
+ 
+     private static native void socketConnect(int fd, InetAddress address, int port)
+         throws SocketException;
+diff --git a/src/windows/classes/java/net/DualStackPlainSocketImpl.java b/src/windows/classes/java/net/DualStackPlainSocketImpl.java
+--- openjdk/jdk/src/windows/classes/java/net/DualStackPlainSocketImpl.java
++++ openjdk/jdk/src/windows/classes/java/net/DualStackPlainSocketImpl.java
+@@ -42,10 +42,20 @@
+ {
+     static JavaIOFileDescriptorAccess fdAccess = SharedSecrets.getJavaIOFileDescriptorAccess();
+ 
+-    public DualStackPlainSocketImpl() {}
+ 
+-    public DualStackPlainSocketImpl(FileDescriptor fd) {
++    // true if this socket is exclusively bound
++    private final boolean exclusiveBind;
++
++    // emulates SO_REUSEADDR when exclusiveBind is true
++    private boolean isReuseAddress;
++
++    public DualStackPlainSocketImpl(boolean exclBind) {
++        exclusiveBind = exclBind;
++    }
++
++    public DualStackPlainSocketImpl(FileDescriptor fd, boolean exclBind) {
+         this.fd = fd;
++        exclusiveBind = exclBind;
+     }
+ 
+     void socketCreate(boolean stream) throws IOException {
+@@ -93,7 +103,7 @@
+         if (address == null)
+             throw new NullPointerException("inet address argument is null.");
+ 
+-        bind0(nativefd, address, port);
++        bind0(nativefd, address, port, exclusiveBind);
+         if (port == 0) {
+             localport = localPort0(nativefd);
+         } else {
+@@ -161,6 +171,8 @@
+         shutdown0(nativefd, howto);
+     }
+ 
++    // Intentional fallthrough after SO_REUSEADDR
++    @SuppressWarnings("fallthrough")
+     void socketSetOption(int opt, boolean on, Object value)
+         throws SocketException {
+         int nativefd = checkAndReturnNativeFD();
+@@ -174,8 +186,13 @@
+         switch(opt) {
+             case TCP_NODELAY :
+             case SO_OOBINLINE :
++            case SO_REUSEADDR :
++                if (exclusiveBind) {
++                    // SO_REUSEADDR emulated when using exclusive bind
++                    isReuseAddress = on;
++                    return;
++                }
+             case SO_KEEPALIVE :
+-            case SO_REUSEADDR :
+                 optionValue = on ? 1 : 0;
+                 break;
+             case SO_SNDBUF :
+@@ -206,6 +223,10 @@
+             return 0;  // return value doesn't matter.
+         }
+ 
++        // SO_REUSEADDR emulated when using exclusive bind
++        if (opt == SO_REUSEADDR && exclusiveBind)
++            return isReuseAddress? 1 : -1;
++
+         int value = getIntOption(nativefd, opt);
+ 
+         switch (opt) {
+@@ -245,7 +266,8 @@
+ 
+     static native int socket0(boolean stream, boolean v6Only) throws IOException;
+ 
+-    static native void bind0(int fd, InetAddress localAddress, int localport)
++    static native void bind0(int fd, InetAddress localAddress, int localport,
++                             boolean exclBind)
+         throws IOException;
+ 
+     static native int connect0(int fd, InetAddress remote, int remotePort)
+diff --git a/src/windows/classes/java/net/PlainSocketImpl.java b/src/windows/classes/java/net/PlainSocketImpl.java
+--- openjdk/jdk/src/windows/classes/java/net/PlainSocketImpl.java
++++ openjdk/jdk/src/windows/classes/java/net/PlainSocketImpl.java
+@@ -54,6 +54,12 @@
+     /* If the version supports a dual stack TCP implementation */
+     private static boolean useDualStackImpl = false;
+ 
++    /* sun.net.useExclusiveBind */
++    private static String exclBindProp;
++
++    /* True if exclusive binding is on for Windows */
++    private static boolean exclusiveBind = true;
++
+     static {
+         java.security.AccessController.doPrivileged( new PrivilegedAction<Object>() {
+                 public Object run() {
+@@ -62,6 +68,7 @@
+                         version = Float.parseFloat(System.getProperties().getProperty("os.version"));
+                         preferIPv4Stack = Boolean.parseBoolean(
+                                           System.getProperties().getProperty("java.net.preferIPv4Stack"));
++                        exclBindProp = System.getProperty("sun.net.useExclusiveBind");
+                     } catch (NumberFormatException e ) {
+                         assert false : e;
+                     }
+@@ -70,7 +77,15 @@
+ 
+         // (version >= 6.0) implies Vista or greater.
+         if (version >= 6.0 && !preferIPv4Stack) {
+-            useDualStackImpl = true;
++                useDualStackImpl = true;
++        }
++
++        if (exclBindProp != null) {
++            // sun.net.useExclusiveBind is true
++            exclusiveBind = exclBindProp.length() == 0 ? true
++                    : Boolean.parseBoolean(exclBindProp);
++        } else if (version < 6.0) {
++            exclusiveBind = false;
+         }
+     }
+ 
+@@ -79,9 +94,9 @@
+      */
+     PlainSocketImpl() {
+         if (useDualStackImpl) {
+-            impl = new DualStackPlainSocketImpl();
++            impl = new DualStackPlainSocketImpl(exclusiveBind);
+         } else {
+-            impl = new TwoStacksPlainSocketImpl();
++            impl = new TwoStacksPlainSocketImpl(exclusiveBind);
+         }
+     }
+ 
+@@ -90,9 +105,9 @@
+      */
+     PlainSocketImpl(FileDescriptor fd) {
+         if (useDualStackImpl) {
+-            impl = new DualStackPlainSocketImpl(fd);
++            impl = new DualStackPlainSocketImpl(fd, exclusiveBind);
+         } else {
+-            impl = new TwoStacksPlainSocketImpl(fd);
++            impl = new TwoStacksPlainSocketImpl(fd, exclusiveBind);
+         }
+     }
+ 
+diff --git a/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java b/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java
+--- openjdk/jdk/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java
++++ openjdk/jdk/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java
+@@ -66,6 +66,22 @@
+         init();
+     }
+ 
++    // true if this socket is exclusively bound
++    private final boolean exclusiveBind;
++
++    /*
++     * Set to true if SO_REUSEADDR is set after the socket is bound to
++     * indicate SO_REUSEADDR is being emulated
++     */
++    private boolean reuseAddressEmulated;
++
++    // emulates SO_REUSEADDR when exclusiveBind is true and socket is bound
++    private boolean isReuseAddress;
++
++    TwoStacksPlainDatagramSocketImpl(boolean exclBind) {
++        exclusiveBind = exclBind;
++    }
++
+     protected synchronized void create() throws SocketException {
+         fd1 = new FileDescriptor();
+         super.create();
+@@ -79,6 +95,14 @@
+         }
+     }
+ 
++    @Override
++    protected synchronized void bind0(int lport, InetAddress laddr)
++        throws SocketException
++    {
++        bind0(lport, laddr, exclusiveBind);
++
++    }
++
+     protected synchronized void receive(DatagramPacket p)
+         throws IOException {
+         try {
+@@ -98,8 +122,24 @@
+                 return anyLocalBoundAddr;
+             }
+             return socketGetOption(optID);
+-        } else
++        } else if (optID == SO_REUSEADDR && reuseAddressEmulated) {
++            return isReuseAddress;
++        } else {
+             return super.getOption(optID);
++        }
++    }
++
++    protected void socketSetOption(int opt, Object val)
++        throws SocketException
++    {
++        if (opt == SO_REUSEADDR && exclusiveBind && localPort != 0)  {
++            // socket already bound, emulate
++            reuseAddressEmulated = true;
++            isReuseAddress = (Boolean)val;
++        } else {
++            socketNativeSetOption(opt, val);
++        }
++
+     }
+ 
+     protected boolean isClosed() {
+@@ -117,7 +157,8 @@
+ 
+     /* Native methods */
+ 
+-    protected synchronized native void bind0(int lport, InetAddress laddr)
++    protected synchronized native void bind0(int lport, InetAddress laddr,
++                                             boolean exclBind)
+         throws SocketException;
+ 
+     protected native void send(DatagramPacket p) throws IOException;
+@@ -147,7 +188,7 @@
+ 
+     protected native void datagramSocketClose();
+ 
+-    protected native void socketSetOption(int opt, Object val)
++    protected native void socketNativeSetOption(int opt, Object val)
+         throws SocketException;
+ 
+     protected native Object socketGetOption(int opt) throws SocketException;
+diff --git a/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java b/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java
+--- openjdk/jdk/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java
++++ openjdk/jdk/src/windows/classes/java/net/TwoStacksPlainSocketImpl.java
+@@ -65,14 +65,23 @@
+      */
+     private int lastfd = -1;
+ 
++    // true if this socket is exclusively bound
++    private final boolean exclusiveBind;
++
++    // emulates SO_REUSEADDR when exclusiveBind is true
++    private boolean isReuseAddress;
++
+     static {
+         initProto();
+     }
+ 
+-    public TwoStacksPlainSocketImpl() {}
++    public TwoStacksPlainSocketImpl(boolean exclBind) {
++        exclusiveBind = exclBind;
++    }
+ 
+-    public TwoStacksPlainSocketImpl(FileDescriptor fd) {
++    public TwoStacksPlainSocketImpl(FileDescriptor fd, boolean exclBind) {
+         this.fd = fd;
++        exclusiveBind = exclBind;
+     }
+ 
+     /**
+@@ -110,13 +119,33 @@
+             InetAddressContainer in = new InetAddressContainer();
+             socketGetOption(opt, in);
+             return in.addr;
++        } else if (opt == SO_REUSEADDR && exclusiveBind) {
++            // SO_REUSEADDR emulated when using exclusive bind
++            return isReuseAddress;
+         } else
+             return super.getOption(opt);
+     }
+ 
++    @Override
++    void socketBind(InetAddress address, int port) throws IOException {
++        socketBind(address, port, exclusiveBind);
++    }
++
++    @Override
++    void socketSetOption(int opt, boolean on, Object value)
++        throws SocketException
++    {
++        // SO_REUSEADDR emulated when using exclusive bind
++        if (opt == SO_REUSEADDR && exclusiveBind)
++            isReuseAddress = on;
++        else
++            socketNativeSetOption(opt, on, value);
++    }
++
+     /**
+      * Closes the socket.
+      */
++    @Override
+     protected void close() throws IOException {
+         synchronized(fdLock) {
+             if (fd != null || fd1 != null) {
+@@ -146,6 +175,7 @@
+         }
+     }
+ 
++    @Override
+     void reset() throws IOException {
+         if (fd != null || fd1 != null) {
+             socketClose();
+@@ -158,6 +188,7 @@
+     /*
+      * Return true if already closed or close is pending
+      */
++    @Override
+     public boolean isClosedOrPending() {
+         /*
+          * Lock on fdLock to ensure that we wait if a
+@@ -181,7 +212,7 @@
+     native void socketConnect(InetAddress address, int port, int timeout)
+         throws IOException;
+ 
+-    native void socketBind(InetAddress address, int port)
++    native void socketBind(InetAddress address, int port, boolean exclBind)
+         throws IOException;
+ 
+     native void socketListen(int count) throws IOException;
+@@ -194,7 +225,7 @@
+ 
+     native void socketShutdown(int howto) throws IOException;
+ 
+-    native void socketSetOption(int cmd, boolean on, Object value)
++    native void socketNativeSetOption(int cmd, boolean on, Object value)
+         throws SocketException;
+ 
+     native int socketGetOption(int opt, Object iaContainerObj) throws SocketException;
+diff --git a/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c b/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c
+--- openjdk/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c
++++ openjdk/jdk/src/windows/native/java/net/DualStackPlainDatagramSocketImpl.c
+@@ -112,7 +112,7 @@
+  * Signature: (ILjava/net/InetAddress;I)V
+  */
+ JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketBind
+-  (JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port) {
++  (JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port, jboolean exclBind) {
+     SOCKETADDRESS sa;
+     int rv;
+     int sa_len = sizeof(sa);
+@@ -121,8 +121,7 @@
+                                  &sa_len, JNI_TRUE) != 0) {
+         return;
+     }
+-
+-    rv = bind(fd, (struct sockaddr *)&sa, sa_len);
++    rv = NET_WinBind(fd, (struct sockaddr *)&sa, sa_len, exclBind);
+ 
+     if (rv == SOCKET_ERROR) {
+         if (WSAGetLastError() == WSAEACCES) {
+diff --git a/src/windows/native/java/net/DualStackPlainSocketImpl.c b/src/windows/native/java/net/DualStackPlainSocketImpl.c
+--- openjdk/jdk/src/windows/native/java/net/DualStackPlainSocketImpl.c
++++ openjdk/jdk/src/windows/native/java/net/DualStackPlainSocketImpl.c
+@@ -82,7 +82,9 @@
+  * Signature: (ILjava/net/InetAddress;I)V
+  */
+ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_bind0
+-  (JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port) {
++  (JNIEnv *env, jclass clazz, jint fd, jobject iaObj, jint port,
++   jboolean exclBind)
++{
+     SOCKETADDRESS sa;
+     int rv;
+     int sa_len = sizeof(sa);
+@@ -92,7 +94,7 @@
+       return;
+     }
+ 
+-    rv = NET_Bind(fd, (struct sockaddr *)&sa, sa_len);
++    rv = NET_WinBind(fd, (struct sockaddr *)&sa, sa_len, exclBind);
+ 
+     if (rv == SOCKET_ERROR)
+         NET_ThrowNew(env, WSAGetLastError(), "JVM_Bind");
+diff --git a/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c b/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c
+--- openjdk/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c
++++ openjdk/jdk/src/windows/native/java/net/TwoStacksPlainDatagramSocketImpl.c
+@@ -421,7 +421,8 @@
+ 
+ JNIEXPORT void JNICALL
+ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
+-                                           jint port, jobject addressObj) {
++                                           jint port, jobject addressObj,
++                                           jboolean exclBind) {
+     jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
+     jobject fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
+ 
+@@ -464,7 +465,7 @@
+         v6bind.addr = &lcladdr;
+         v6bind.ipv4_fd = fd;
+         v6bind.ipv6_fd = fd1;
+-        if (NET_BindV6(&v6bind) != -1) {
++        if (NET_BindV6(&v6bind, exclBind) != -1) {
+             /* check if the fds have changed */
+             if (v6bind.ipv4_fd != fd) {
+                 fd = v6bind.ipv4_fd;
+@@ -491,7 +492,7 @@
+             return;
+         }
+     } else {
+-        if (bind(fd, (struct sockaddr *)&lcladdr, lcladdrlen) == -1) {
++        if (NET_WinBind(fd, (struct sockaddr *)&lcladdr, lcladdrlen, exclBind) == -1) {
+             if (WSAGetLastError() == WSAEACCES) {
+                 WSASetLastError(WSAEADDRINUSE);
+             }
+@@ -1780,11 +1781,11 @@
+ 
+ /*
+  * Class:     java_net_TwoStacksPlainDatagramSocketImpl
+- * Method:    socketSetOption
++ * Method:    socketNativeSetOption
+  * Signature: (ILjava/lang/Object;)V
+  */
+ JNIEXPORT void JNICALL
+-Java_java_net_TwoStacksPlainDatagramSocketImpl_socketSetOption(JNIEnv *env,jobject this,
++Java_java_net_TwoStacksPlainDatagramSocketImpl_socketNativeSetOption(JNIEnv *env,jobject this,
+                                                       jint opt,jobject value) {
+ 
+     int fd=-1, fd1=-1;
+diff --git a/src/windows/native/java/net/TwoStacksPlainSocketImpl.c b/src/windows/native/java/net/TwoStacksPlainSocketImpl.c
+--- openjdk/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c
++++ openjdk/jdk/src/windows/native/java/net/TwoStacksPlainSocketImpl.c
+@@ -393,7 +393,8 @@
+  */
+ JNIEXPORT void JNICALL
+ Java_java_net_TwoStacksPlainSocketImpl_socketBind(JNIEnv *env, jobject this,
+-                                         jobject iaObj, jint localport) {
++                                         jobject iaObj, jint localport,
++                                         jboolean exclBind) {
+ 
+     /* fdObj is the FileDescriptor field on this */
+     jobject fdObj, fd1Obj;
+@@ -437,13 +438,12 @@
+                           (struct sockaddr *)&him, &len, JNI_FALSE) != 0) {
+       return;
+     }
+-
+     if (ipv6_supported) {
+         struct ipv6bind v6bind;
+         v6bind.addr = &him;
+         v6bind.ipv4_fd = fd;
+         v6bind.ipv6_fd = fd1;
+-        rv = NET_BindV6(&v6bind);
++        rv = NET_BindV6(&v6bind, exclBind);
+         if (rv != -1) {
+             /* check if the fds have changed */
+             if (v6bind.ipv4_fd != fd) {
+@@ -468,7 +468,7 @@
+             }
+         }
+     } else {
+-        rv = NET_Bind(fd, (struct sockaddr *)&him, len);
++        rv = NET_WinBind(fd, (struct sockaddr *)&him, len, exclBind);
+     }
+ 
+     if (rv == -1) {
+@@ -829,11 +829,12 @@
+  *
+  *
+  * Class:     java_net_TwoStacksPlainSocketImpl
+- * Method:    socketSetOption
++ * Method:    socketNativeSetOption
+  * Signature: (IZLjava/lang/Object;)V
+  */
+ JNIEXPORT void JNICALL
+-Java_java_net_TwoStacksPlainSocketImpl_socketSetOption(JNIEnv *env, jobject this,
++Java_java_net_TwoStacksPlainSocketImpl_socketNativeSetOption(JNIEnv *env,
++                                              jobject this,
+                                               jint cmd, jboolean on,
+                                               jobject value) {
+     int fd, fd1;
+diff --git a/src/windows/native/java/net/net_util_md.c b/src/windows/native/java/net/net_util_md.c
+--- openjdk/jdk/src/windows/native/java/net/net_util_md.c
++++ openjdk/jdk/src/windows/native/java/net/net_util_md.c
+@@ -415,12 +415,24 @@
+                int optlen)
+ {
+     int rv;
++    int parg;
++    int plen = sizeof(parg);
+ 
+     if (level == IPPROTO_IP && optname == IP_TOS) {
+         int *tos = (int *)optval;
+         *tos &= (IPTOS_TOS_MASK | IPTOS_PREC_MASK);
+     }
+ 
++    if (optname == SO_REUSEADDR) {
++        /*
++         * Do not set SO_REUSEADDE if SO_EXCLUSIVEADDUSE is already set
++         */
++        rv = NET_GetSockOpt(s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *)&parg, &plen);
++        if (rv == 0 && parg == 1) {
++            return rv;
++        }
++    }
++
+     rv = setsockopt(s, level, optname, optval, optlen);
+ 
+     if (rv == SOCKET_ERROR) {
+@@ -484,15 +496,32 @@
+ }
+ 
+ /*
++ * Sets SO_ECLUSIVEADDRUSE if SO_REUSEADDR is not already set.
++ */
++void setExclusiveBind(int fd) {
++    int parg;
++    int plen = sizeof(parg);
++    int rv = 0;
++    rv = NET_GetSockOpt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&parg, &plen);
++    if (rv == 0 && parg == 0) {
++        parg = 1;
++        rv = NET_SetSockOpt(fd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char*)&parg, plen);
++    }
++}
++
++/*
+  * Wrapper for bind winsock call - transparent converts an
+  * error related to binding to a port that has exclusive access
+  * into an error indicating the port is in use (facilitates
+  * better error reporting).
++ *
++ * Should be only called by the wrapper method NET_WinBind
+  */
+ JNIEXPORT int JNICALL
+ NET_Bind(int s, struct sockaddr *him, int len)
+ {
+-    int rv = bind(s, him, len);
++    int rv;
++    rv = bind(s, him, len);
+ 
+     if (rv == SOCKET_ERROR) {
+         /*
+@@ -507,6 +536,18 @@
+     return rv;
+ }
+ 
++/*
++ * Wrapper for NET_Bind call. Sets SO_EXCLUSIVEADDRUSE
++ * if required, and then calls NET_BIND
++ */
++JNIEXPORT int JNICALL
++NET_WinBind(int s, struct sockaddr *him, int len, jboolean exclBind)
++{
++    if (exclBind == JNI_TRUE)
++        setExclusiveBind(s);
++    return NET_Bind(s, him, len);
++}
++
+ JNIEXPORT int JNICALL
+ NET_SocketClose(int fd) {
+     struct linger l;
+@@ -653,7 +694,7 @@
+  */
+ 
+ JNIEXPORT int JNICALL
+-NET_BindV6(struct ipv6bind* b) {
++NET_BindV6(struct ipv6bind* b, jboolean exclBind) {
+     int fd=-1, ofd=-1, rv, len;
+     /* need to defer close until new sockets created */
+     int close_fd=-1, close_ofd=-1;
+@@ -666,8 +707,8 @@
+     if (family == AF_INET && (b->addr->him4.sin_addr.s_addr != INADDR_ANY)) {
+         /* bind to v4 only */
+         int ret;
+-        ret = NET_Bind (b->ipv4_fd, (struct sockaddr *)b->addr,
+-                                sizeof (struct sockaddr_in));
++        ret = NET_WinBind (b->ipv4_fd, (struct sockaddr *)b->addr,
++                                sizeof (struct sockaddr_in), exclBind);
+         if (ret == SOCKET_ERROR) {
+             CLOSE_SOCKETS_AND_RETURN;
+         }
+@@ -678,8 +719,8 @@
+     if (family == AF_INET6 && (!IN6_IS_ADDR_ANY(&b->addr->him6.sin6_addr))) {
+         /* bind to v6 only */
+         int ret;
+-        ret = NET_Bind (b->ipv6_fd, (struct sockaddr *)b->addr,
+-                                sizeof (struct SOCKADDR_IN6));
++        ret = NET_WinBind (b->ipv6_fd, (struct sockaddr *)b->addr,
++                                sizeof (struct SOCKADDR_IN6), exclBind);
+         if (ret == SOCKET_ERROR) {
+             CLOSE_SOCKETS_AND_RETURN;
+         }
+@@ -708,7 +749,7 @@
+         oaddr.him4.sin_addr.s_addr = INADDR_ANY;
+     }
+ 
+-    rv = NET_Bind (fd, (struct sockaddr *)b->addr, SOCKETADDRESS_LEN(b->addr));
++    rv = NET_WinBind(fd, (struct sockaddr *)b->addr, SOCKETADDRESS_LEN(b->addr), exclBind);
+     if (rv == SOCKET_ERROR) {
+         CLOSE_SOCKETS_AND_RETURN;
+     }
+@@ -720,8 +761,8 @@
+     }
+     bound_port = GET_PORT (b->addr);
+     SET_PORT (&oaddr, bound_port);
+-    if ((rv=NET_Bind (ofd, (struct sockaddr *) &oaddr,
+-                                SOCKETADDRESS_LEN (&oaddr))) == SOCKET_ERROR) {
++    if ((rv=NET_WinBind (ofd, (struct sockaddr *) &oaddr,
++                         SOCKETADDRESS_LEN (&oaddr), exclBind)) == SOCKET_ERROR) {
+         int retries;
+         int sotype, arglen=sizeof(sotype);
+ 
+@@ -757,7 +798,8 @@
+ 
+             /* bind random port on first socket */
+             SET_PORT (&oaddr, 0);
+-            rv = NET_Bind (ofd, (struct sockaddr *)&oaddr, SOCKETADDRESS_LEN(&oaddr));
++            rv = NET_WinBind (ofd, (struct sockaddr *)&oaddr, SOCKETADDRESS_LEN(&oaddr),
++                              exclBind);
+             if (rv == SOCKET_ERROR) {
+                 CLOSE_SOCKETS_AND_RETURN;
+             }
+@@ -773,7 +815,8 @@
+             }
+             bound_port = GET_PORT (&oaddr);
+             SET_PORT (b->addr, bound_port);
+-            rv = NET_Bind (fd, (struct sockaddr *)b->addr, SOCKETADDRESS_LEN(b->addr));
++            rv = NET_WinBind (fd, (struct sockaddr *)b->addr, SOCKETADDRESS_LEN(b->addr),
++                              exclBind);
+ 
+             if (rv != SOCKET_ERROR) {
+                 if (family == AF_INET) {
+diff --git a/src/windows/native/java/net/net_util_md.h b/src/windows/native/java/net/net_util_md.h
+--- openjdk/jdk/src/windows/native/java/net/net_util_md.h
++++ openjdk/jdk/src/windows/native/java/net/net_util_md.h
+@@ -307,7 +307,7 @@
+  */
+ JNIEXPORT int JNICALL NET_Timeout2(int fd, int fd1, long timeout, int *fdret);
+ 
+-JNIEXPORT int JNICALL NET_BindV6(struct ipv6bind* b);
++JNIEXPORT int JNICALL NET_BindV6(struct ipv6bind* b, jboolean exclBind);
+ 
+ #define NET_WAIT_READ   0x01
+ #define NET_WAIT_WRITE  0x02
+@@ -315,6 +315,9 @@
+ 
+ extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
+ 
++JNIEXPORT int JNICALL NET_WinBind(int s, struct sockaddr *him, int len,
++                                   jboolean exclBind);
++
+ /* XP versions of the native routines */
+ 
+ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0_XP
+diff --git a/src/windows/native/sun/nio/ch/Net.c b/src/windows/native/sun/nio/ch/Net.c
+--- openjdk/jdk/src/windows/native/sun/nio/ch/Net.c
++++ openjdk/jdk/src/windows/native/sun/nio/ch/Net.c
+@@ -72,9 +72,20 @@
+     return (jint)s;
+ }
+ 
++JNIEXPORT jint JNICALL
++Java_sun_nio_ch_Net_isExclusiveBindAvailable(JNIEnv *env, jclass clazz) {
++    OSVERSIONINFO ver;
++    int version;
++    ver.dwOSVersionInfoSize = sizeof(ver);
++    GetVersionEx(&ver);
++    version = ver.dwMajorVersion * 10 + ver.dwMinorVersion;
++    //if os <= xp exclusive binding is off by default
++    return version >= 60 ? 1 : 0;
++}
++
+ JNIEXPORT void JNICALL
+-Java_sun_nio_ch_Net_bind(JNIEnv *env, jclass clazz,
+-                         jobject fdo, jobject iao, jint port)
++Java_sun_nio_ch_Net_bind0(JNIEnv *env, jclass clazz,
++                         jobject fdo, jboolean exclBind, jobject iao, jint port)
+ {
+     SOCKETADDRESS sa;
+     int rv;
+@@ -84,7 +95,7 @@
+       return;
+     }
+ 
+-    rv = NET_Bind(fdval(env, fdo), (struct sockaddr *)&sa, sa_len);
++    rv = NET_WinBind(fdval(env, fdo), (struct sockaddr *)&sa, sa_len, isExclBind);
+     if (rv == SOCKET_ERROR)
+         NET_ThrowNew(env, WSAGetLastError(), "bind");
+ }
+@@ -152,7 +163,6 @@
+     return iao;
+ }
+ 
+-
+ JNIEXPORT jint JNICALL
+ Java_sun_nio_ch_Net_getIntOption0(JNIEnv *env, jclass clazz,
+                                   jobject fdo, jint opt)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8000638-improve_deserialization.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,26 @@
+# HG changeset patch
+# User dmocek
+# Date 1362436455 28800
+# Node ID b1c99cf6c26d9df7ca7d02df1687064656c8ae71
+# Parent  8664ebe88635d671ed0134e9348d5e6caea81d0d
+8000638: Improve deserialization
+Reviewed-by: smarks, hawtin, mchung
+
+diff --git a/src/share/classes/java/io/ObjectStreamClass.java b/src/share/classes/java/io/ObjectStreamClass.java
+--- openjdk/jdk/src/share/classes/java/io/ObjectStreamClass.java
++++ openjdk/jdk/src/share/classes/java/io/ObjectStreamClass.java
+@@ -1135,7 +1135,14 @@
+             end = end.getSuperclass();
+         }
+ 
++        HashSet<String> oscNames = new HashSet<>(3);
++
+         for (ObjectStreamClass d = this; d != null; d = d.superDesc) {
++            if (oscNames.contains(d.name)) {
++                throw new InvalidClassException("Circular reference.");
++            } else {
++                oscNames.add(d.name);
++            }
+ 
+             // search up inheritance hierarchy for class with matching name
+             String searchName = (d.cl != null) ? d.cl.getName() : d.name;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8000642-better_transportation_handling.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,808 @@
+# HG changeset patch
+# User Severin Gehwolf <sgehwolf@redhat.com>
+# Date 1371488468 -7200
+# Node ID bec83758f55670cdb7865e8103f8100dc6f4f0fb
+# Parent  1260b4e54a2373aac77afdcdeb3f7ac8e6319c9e
+8000642: Better handling of objects for transportation
+Summary: Also reviewed by alexander.fomin
+Reviewed-by: alanb, mchung, skoivu
+
+diff --git a/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java b/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/corba/AnyImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,6 +33,8 @@
+ 
+ import java.io.Serializable;
+ import java.math.BigDecimal;
++import java.security.AccessController;
++import java.security.PrivilegedAction;
+ import java.util.List ;
+ import java.util.ArrayList ;
+ 
+@@ -504,7 +506,12 @@
+     public org.omg.CORBA.portable.OutputStream create_output_stream()
+     {
+         //debug.log ("create_output_stream");
+-        return new AnyOutputStream(orb);
++        final ORB finalorb = this.orb;
++        return AccessController.doPrivileged(new PrivilegedAction<AnyOutputStream>() {
++            public AnyOutputStream run() {
++                return new AnyOutputStream(finalorb);
++            }
++        });
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/corba/se/impl/corba/TypeCodeImpl.java b/src/share/classes/com/sun/corba/se/impl/corba/TypeCodeImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/corba/TypeCodeImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/corba/TypeCodeImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -600,7 +600,8 @@
+     }
+ 
+     public static CDROutputStream newOutputStream(ORB orb) {
+-        TypeCodeOutputStream tcos = new TypeCodeOutputStream((ORB)orb);
++        TypeCodeOutputStream tcos =
++            sun.corba.OutputStreamFactory.newTypeCodeOutputStream(orb);
+         //if (debug) System.out.println("Created TypeCodeOutputStream " + tcos +
+         // " with no parent");
+         return tcos;
+diff --git a/src/share/classes/com/sun/corba/se/impl/encoding/IDLJavaSerializationOutputStream.java b/src/share/classes/com/sun/corba/se/impl/encoding/IDLJavaSerializationOutputStream.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/encoding/IDLJavaSerializationOutputStream.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/encoding/IDLJavaSerializationOutputStream.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -66,7 +66,7 @@
+  *
+  * @author Ram Jeyaraman
+  */
+-public class IDLJavaSerializationOutputStream extends CDROutputStreamBase {
++final class IDLJavaSerializationOutputStream extends CDROutputStreamBase {
+ 
+     private ORB orb;
+     private byte encodingVersion;
+diff --git a/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeOutputStream.java b/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeOutputStream.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeOutputStream.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/encoding/TypeCodeOutputStream.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -196,7 +196,8 @@
+     }
+ 
+     public TypeCodeOutputStream createEncapsulation(org.omg.CORBA.ORB _orb) {
+-        TypeCodeOutputStream encap = new TypeCodeOutputStream((ORB)_orb, isLittleEndian());
++        TypeCodeOutputStream encap =
++            sun.corba.OutputStreamFactory.newTypeCodeOutputStream((ORB)_orb, isLittleEndian());
+         encap.setEnclosingOutputStream(this);
+         encap.makeEncapsulation();
+         //if (TypeCodeImpl.debug) System.out.println("Created TypeCodeOutputStream " + encap + " with parent " + this);
+@@ -211,7 +212,8 @@
+ 
+     public static TypeCodeOutputStream wrapOutputStream(OutputStream os) {
+         boolean littleEndian = ((os instanceof CDROutputStream) ? ((CDROutputStream)os).isLittleEndian() : false);
+-        TypeCodeOutputStream tos = new TypeCodeOutputStream((ORB)os.orb(), littleEndian);
++        TypeCodeOutputStream tos =
++            sun.corba.OutputStreamFactory.newTypeCodeOutputStream((ORB)os.orb(), littleEndian);
+         tos.setEnclosingOutputStream(os);
+         //if (TypeCodeImpl.debug) System.out.println("Created TypeCodeOutputStream " + tos + " with parent " + os);
+         return tos;
+diff --git a/src/share/classes/com/sun/corba/se/impl/interceptors/CDREncapsCodec.java b/src/share/classes/com/sun/corba/se/impl/interceptors/CDREncapsCodec.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/interceptors/CDREncapsCodec.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/interceptors/CDREncapsCodec.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -155,7 +155,8 @@
+         // be versioned.  This can be handled once this work is complete.
+ 
+         // Create output stream with default endianness.
+-        EncapsOutputStream cdrOut = new EncapsOutputStream(
++        EncapsOutputStream cdrOut =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream(
+             (com.sun.corba.se.spi.orb.ORB)orb, giopVersion );
+ 
+         // This is an encapsulation, so put out the endian:
+diff --git a/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java b/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java
+@@ -655,7 +655,8 @@
+             // Convert the "core" service context to an
+             // "IOP" ServiceContext by writing it to a
+             // CDROutputStream and reading it back.
+-            EncapsOutputStream out = new EncapsOutputStream(myORB);
++            EncapsOutputStream out =
++                sun.corba.OutputStreamFactory.newEncapsOutputStream(myORB);
+ 
+             context.write( out, GIOPVersion.V1_2 );
+             InputStream inputStream = out.create_input_stream();
+@@ -691,8 +692,8 @@
+     {
+         int id = 0 ;
+         // Convert IOP.service_context to core.ServiceContext:
+-        EncapsOutputStream outputStream = new EncapsOutputStream(
+-            myORB );
++        EncapsOutputStream outputStream =
++           sun.corba.OutputStreamFactory.newEncapsOutputStream(myORB);
+         InputStream inputStream = null;
+         UnknownServiceContext coreServiceContext = null;
+         ServiceContextHelper.write( outputStream, service_context );
+diff --git a/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java b/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java
+@@ -300,11 +300,11 @@
+         resetStream();
+     }
+ 
+-    public final void setOrbStream(org.omg.CORBA_2_3.portable.InputStream os) {
++    final void setOrbStream(org.omg.CORBA_2_3.portable.InputStream os) {
+         orbStream = os;
+     }
+ 
+-    public final org.omg.CORBA_2_3.portable.InputStream getOrbStream() {
++    final org.omg.CORBA_2_3.portable.InputStream getOrbStream() {
+         return orbStream;
+     }
+ 
+@@ -327,11 +327,11 @@
+         return (javax.rmi.CORBA.ValueHandler) vhandler;
+     }
+ 
+-    public final void increaseRecursionDepth(){
++    final void increaseRecursionDepth(){
+         recursionDepth++;
+     }
+ 
+-    public final int decreaseRecursionDepth(){
++    final int decreaseRecursionDepth(){
+         return --recursionDepth;
+     }
+ 
+diff --git a/src/share/classes/com/sun/corba/se/impl/io/IIOPOutputStream.java b/src/share/classes/com/sun/corba/se/impl/io/IIOPOutputStream.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPOutputStream.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPOutputStream.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -124,19 +124,19 @@
+         }
+     }
+ 
+-    public final void setOrbStream(org.omg.CORBA_2_3.portable.OutputStream os) {
++    final void setOrbStream(org.omg.CORBA_2_3.portable.OutputStream os) {
+         orbStream = os;
+     }
+ 
+-    public final org.omg.CORBA_2_3.portable.OutputStream getOrbStream() {
++    final org.omg.CORBA_2_3.portable.OutputStream getOrbStream() {
+         return orbStream;
+     }
+ 
+-    public final void increaseRecursionDepth(){
++    final void increaseRecursionDepth(){
+         recursionDepth++;
+     }
+ 
+-    public final int decreaseRecursionDepth(){
++    final int decreaseRecursionDepth(){
+         return --recursionDepth;
+     }
+ 
+diff --git a/src/share/classes/com/sun/corba/se/impl/io/InputStreamHook.java b/src/share/classes/com/sun/corba/se/impl/io/InputStreamHook.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/io/InputStreamHook.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/io/InputStreamHook.java
+@@ -251,7 +251,7 @@
+     }
+ 
+     protected abstract byte getStreamFormatVersion();
+-    protected abstract org.omg.CORBA_2_3.portable.InputStream getOrbStream();
++    abstract org.omg.CORBA_2_3.portable.InputStream getOrbStream();
+ 
+     // Description of possible actions
+     protected static class ReadObjectState {
+diff --git a/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java b/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/io/OutputStreamHook.java
+@@ -179,7 +179,7 @@
+         putFields.write(this);
+     }
+ 
+-    public abstract org.omg.CORBA_2_3.portable.OutputStream getOrbStream();
++    abstract org.omg.CORBA_2_3.portable.OutputStream getOrbStream();
+ 
+     protected abstract void beginOptionalCustomData();
+ 
+diff --git a/src/share/classes/com/sun/corba/se/impl/ior/EncapsulationUtility.java b/src/share/classes/com/sun/corba/se/impl/ior/EncapsulationUtility.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/EncapsulationUtility.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/EncapsulationUtility.java
+@@ -128,7 +128,8 @@
+     static public void writeEncapsulation( WriteContents obj,
+         OutputStream os )
+     {
+-        EncapsOutputStream out = new EncapsOutputStream( (ORB)os.orb() ) ;
++        EncapsOutputStream out =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream((ORB)os.orb());
+ 
+         out.putEndian() ;
+ 
+diff --git a/src/share/classes/com/sun/corba/se/impl/ior/GenericTaggedProfile.java b/src/share/classes/com/sun/corba/se/impl/ior/GenericTaggedProfile.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/GenericTaggedProfile.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/GenericTaggedProfile.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -95,7 +95,8 @@
+ 
+     public org.omg.IOP.TaggedProfile getIOPProfile()
+     {
+-        EncapsOutputStream os = new EncapsOutputStream( orb ) ;
++        EncapsOutputStream os =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream(orb);
+         write( os ) ;
+         InputStream is = (InputStream)(os.create_input_stream()) ;
+         return org.omg.IOP.TaggedProfileHelper.read( is ) ;
+diff --git a/src/share/classes/com/sun/corba/se/impl/ior/IORImpl.java b/src/share/classes/com/sun/corba/se/impl/ior/IORImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/IORImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/IORImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -213,7 +213,8 @@
+     {
+         StringWriter bs;
+ 
+-        MarshalOutputStream s = new EncapsOutputStream(factory);
++        MarshalOutputStream s =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream(factory);
+         s.putEndian();
+         write( (OutputStream)s );
+         bs = new StringWriter();
+@@ -237,7 +238,8 @@
+     }
+ 
+     public org.omg.IOP.IOR getIOPIOR() {
+-        EncapsOutputStream os = new EncapsOutputStream(factory);
++        EncapsOutputStream os =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream(factory);
+         write(os);
+         InputStream is = (InputStream) (os.create_input_stream());
+         return org.omg.IOP.IORHelper.read(is);
+diff --git a/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyImpl.java b/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/ObjectKeyImpl.java
+@@ -87,7 +87,8 @@
+ 
+     public byte[] getBytes( org.omg.CORBA.ORB orb )
+     {
+-        EncapsOutputStream os = new EncapsOutputStream( (ORB)orb ) ;
++        EncapsOutputStream os =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream((ORB)orb);
+         write( os ) ;
+         return os.toByteArray() ;
+     }
+diff --git a/src/share/classes/com/sun/corba/se/impl/ior/TaggedComponentFactoryFinderImpl.java b/src/share/classes/com/sun/corba/se/impl/ior/TaggedComponentFactoryFinderImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/TaggedComponentFactoryFinderImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/TaggedComponentFactoryFinderImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -61,7 +61,8 @@
+     public TaggedComponent create( org.omg.CORBA.ORB orb,
+         org.omg.IOP.TaggedComponent comp )
+     {
+-        EncapsOutputStream os = new EncapsOutputStream( (ORB)orb ) ;
++        EncapsOutputStream os =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream((ORB)orb);
+         org.omg.IOP.TaggedComponentHelper.write( os, comp ) ;
+         InputStream is = (InputStream)(os.create_input_stream() ) ;
+         // Skip the component ID: we just wrote it out above
+diff --git a/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileImpl.java b/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -247,7 +247,8 @@
+ 
+     public org.omg.IOP.TaggedProfile getIOPProfile()
+     {
+-        EncapsOutputStream os = new EncapsOutputStream( orb ) ;
++        EncapsOutputStream os =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream(orb);
+         os.write_long( getId() ) ;
+         write( os ) ;
+         InputStream is = (InputStream)(os.create_input_stream()) ;
+diff --git a/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileTemplateImpl.java b/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileTemplateImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileTemplateImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/ior/iiop/IIOPProfileTemplateImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -132,8 +132,9 @@
+         // Note that this cannot be accomplished with a codec!
+ 
+         // Use the byte order of the given stream
+-        OutputStream encapsulatedOS = new EncapsOutputStream( (ORB)os.orb(),
+-            ((CDROutputStream)os).isLittleEndian() ) ;
++        OutputStream encapsulatedOS =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream(
++                (ORB)os.orb(), ((CDROutputStream)os).isLittleEndian() ) ;
+ 
+         okeyTemplate.write( id, encapsulatedOS ) ;
+         EncapsulationUtility.writeOutputStream( encapsulatedOS, os ) ;
+diff --git a/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java b/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java
+@@ -564,7 +564,7 @@
+     public synchronized org.omg.CORBA.portable.OutputStream create_output_stream()
+     {
+         checkShutdownState();
+-        return new EncapsOutputStream(this);
++        return sun.corba.OutputStreamFactory.newEncapsOutputStream(this);
+     }
+ 
+     /**
+diff --git a/src/share/classes/com/sun/corba/se/impl/orb/ORBSingleton.java b/src/share/classes/com/sun/corba/se/impl/orb/ORBSingleton.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBSingleton.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBSingleton.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -149,7 +149,7 @@
+     }
+ 
+     public OutputStream create_output_stream() {
+-        return new EncapsOutputStream(this);
++        return sun.corba.OutputStreamFactory.newEncapsOutputStream(this);
+     }
+ 
+     public TypeCode create_struct_tc(String id,
+diff --git a/src/share/classes/com/sun/corba/se/impl/protocol/CorbaMessageMediatorImpl.java b/src/share/classes/com/sun/corba/se/impl/protocol/CorbaMessageMediatorImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaMessageMediatorImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaMessageMediatorImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -1792,8 +1792,7 @@
+ 
+         if (msg.getGIOPVersion().lessThan(GIOPVersion.V1_2)) {
+             // locate msgs 1.0 & 1.1 :=> grow,
+-            // REVISIT - build from factory
+-            outputObject = new CDROutputObject(
++            outputObject = sun.corba.OutputStreamFactory.newCDROutputObject(
+                              (ORB) messageMediator.getBroker(),
+                              this,
+                              GIOPVersion.V1_0,
+@@ -1802,8 +1801,7 @@
+                              ORBConstants.STREAM_FORMAT_VERSION_1);
+         } else {
+             // 1.2 :=> stream
+-            // REVISIT - build from factory
+-            outputObject = new CDROutputObject(
++            outputObject = sun.corba.OutputStreamFactory.newCDROutputObject(
+                              (ORB) messageMediator.getBroker(),
+                              messageMediator,
+                              reply,
+@@ -1957,7 +1955,8 @@
+                           ReplyMessage.NEEDS_ADDRESSING_MODE,
+                           null, null);
+             // REVISIT: via acceptor factory.
+-            CDROutputObject outputObject = new CDROutputObject(
++            CDROutputObject outputObject =
++                sun.corba.OutputStreamFactory.newCDROutputObject(
+                 (ORB)messageMediator.getBroker(),
+                 this,
+                 messageMediator.getGIOPVersion(),
+@@ -2124,7 +2123,7 @@
+         ex.printStackTrace(pw);
+         pw.flush(); // NOTE: you must flush or baos will be empty.
+         EncapsOutputStream encapsOutputStream =
+-            new EncapsOutputStream((ORB)mediator.getBroker());
++            sun.corba.OutputStreamFactory.newEncapsOutputStream((ORB)mediator.getBroker());
+         encapsOutputStream.putEndian();
+         encapsOutputStream.write_wstring(baos.toString());
+         UnknownServiceContext serviceContext =
+@@ -2201,12 +2200,11 @@
+         // REVISIT = do not use null.
+         //
+         if (messageMediator.getConnection() == null) {
+-            // REVISIT - needs factory
+             replyOutputObject =
+-                new CDROutputObject(orb, messageMediator,
+-                                    messageMediator.getReplyHeader(),
+-                                    messageMediator.getStreamFormatVersion(),
+-                                    BufferManagerFactory.GROW);
++                sun.corba.OutputStreamFactory.newCDROutputObject(orb,
++                            messageMediator, messageMediator.getReplyHeader(),
++                            messageMediator.getStreamFormatVersion(),
++                            BufferManagerFactory.GROW);
+         } else {
+             replyOutputObject = messageMediator.getConnection().getAcceptor()
+              .createOutputObject(messageMediator.getBroker(), messageMediator);
+diff --git a/src/share/classes/com/sun/corba/se/impl/transport/CorbaContactInfoBase.java b/src/share/classes/com/sun/corba/se/impl/transport/CorbaContactInfoBase.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaContactInfoBase.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/transport/CorbaContactInfoBase.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -214,7 +214,7 @@
+             messageMediator;
+ 
+         OutputObject outputObject =
+-            new CDROutputObject(orb, messageMediator,
++            sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
+                                 corbaMessageMediator.getRequestHeader(),
+                                 corbaMessageMediator.getStreamFormatVersion());
+ 
+diff --git a/src/share/classes/com/sun/corba/se/impl/transport/SharedCDRContactInfoImpl.java b/src/share/classes/com/sun/corba/se/impl/transport/SharedCDRContactInfoImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/transport/SharedCDRContactInfoImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/transport/SharedCDRContactInfoImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -134,7 +134,7 @@
+             messageMediator;
+         // NOTE: GROW.
+         OutputObject outputObject =
+-            new CDROutputObject(orb, messageMediator,
++            sun.corba.OutputStreamFactory.newCDROutputObject(orb, messageMediator,
+                                 corbaMessageMediator.getRequestHeader(),
+                                 corbaMessageMediator.getStreamFormatVersion(),
+                                 BufferManagerFactory.GROW);
+diff --git a/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java b/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelAcceptorImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -534,9 +534,9 @@
+     {
+         CorbaMessageMediator corbaMessageMediator = (CorbaMessageMediator)
+             messageMediator;
+-        return new CDROutputObject((ORB) broker, corbaMessageMediator,
+-                                   corbaMessageMediator.getReplyHeader(),
+-                                   corbaMessageMediator.getStreamFormatVersion());
++        return sun.corba.OutputStreamFactory.newCDROutputObject((ORB) broker,
++                       corbaMessageMediator, corbaMessageMediator.getReplyHeader(),
++                       corbaMessageMediator.getStreamFormatVersion());
+     }
+ 
+     ////////////////////////////////////////////////////
+diff --git a/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java b/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/transport/SocketOrChannelConnectionImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -1565,8 +1565,8 @@
+     {
+         // REVISIT: See comments in CDROutputObject constructor.
+         CDROutputObject outputObject =
+-            new CDROutputObject((ORB)orb, null, giopVersion, this, msg,
+-                                ORBConstants.STREAM_FORMAT_VERSION_1);
++            sun.corba.OutputStreamFactory.newCDROutputObject((ORB)orb, null, giopVersion,
++                                this, msg, ORBConstants.STREAM_FORMAT_VERSION_1);
+         msg.write(outputObject);
+ 
+         outputObject.writeTo(this);
+diff --git a/src/share/classes/com/sun/corba/se/spi/ior/TaggedComponentBase.java b/src/share/classes/com/sun/corba/se/spi/ior/TaggedComponentBase.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/spi/ior/TaggedComponentBase.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/spi/ior/TaggedComponentBase.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -42,7 +42,8 @@
+     public org.omg.IOP.TaggedComponent getIOPComponent(
+         org.omg.CORBA.ORB orb )
+     {
+-        EncapsOutputStream os = new EncapsOutputStream( (ORB)orb ) ;
++        EncapsOutputStream os =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream((ORB)orb);
+         write( os ) ;
+         InputStream is = (InputStream)(os.create_input_stream() ) ;
+         return org.omg.IOP.TaggedComponentHelper.read( is ) ;
+diff --git a/src/share/classes/com/sun/corba/se/spi/servicecontext/ServiceContext.java b/src/share/classes/com/sun/corba/se/spi/servicecontext/ServiceContext.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/spi/servicecontext/ServiceContext.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/spi/servicecontext/ServiceContext.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -92,7 +92,8 @@
+      */
+     public void write(OutputStream s, GIOPVersion gv) throws SystemException
+     {
+-        EncapsOutputStream os = new EncapsOutputStream( (ORB)(s.orb()), gv ) ;
++        EncapsOutputStream os =
++            sun.corba.OutputStreamFactory.newEncapsOutputStream((ORB)(s.orb()), gv);
+         os.putEndian() ;
+         writeData( os ) ;
+         byte[] data = os.toByteArray() ;
+diff --git a/src/share/classes/org/omg/CORBA_2_3/portable/OutputStream.java b/src/share/classes/org/omg/CORBA_2_3/portable/OutputStream.java
+--- openjdk/corba/src/share/classes/org/omg/CORBA_2_3/portable/OutputStream.java
++++ openjdk/corba/src/share/classes/org/omg/CORBA_2_3/portable/OutputStream.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -31,6 +31,10 @@
+ 
+ package org.omg.CORBA_2_3.portable;
+ 
++import java.io.SerializablePermission;
++import java.security.AccessController;
++import java.security.PrivilegedAction;
++
+ /**
+  * OutputStream provides interface for writing of all of the mapped IDL type
+  * to the stream. It extends org.omg.CORBA.portable.OutputStream, and defines
+@@ -43,6 +47,39 @@
+ 
+ public abstract class OutputStream extends org.omg.CORBA.portable.OutputStream {
+ 
++    private static final String ALLOW_SUBCLASS_PROP = "jdk.corba.allowOutputStreamSubclass";
++    private static final boolean allowSubclass = AccessController.doPrivileged(
++        new PrivilegedAction<Boolean>() {
++            public Boolean run() {
++            String prop = System.getProperty(ALLOW_SUBCLASS_PROP);
++                return prop == null ? false :
++                           (prop.equalsIgnoreCase("false") ? false : true);
++            }
++        });
++
++    private static Void checkPermission() {
++        SecurityManager sm = System.getSecurityManager();
++        if (sm != null) {
++            if (!allowSubclass)
++                sm.checkPermission(new
++                    SerializablePermission("enableSubclassImplementation"));
++        }
++        return null;
++    }
++    private OutputStream(Void ignore) { }
++
++    /**
++     * Create a new instance of this class.
++     *
++     * throw SecurityException if SecurityManager is installed and
++     * enableSubclassImplementation SerializablePermission
++     * is not granted or jdk.corba.allowOutputStreamSubclass system
++     * property is either not set or is set to 'false'
++     */
++    public OutputStream() {
++        this(checkPermission());
++    }
++
+     /**
+      * Marshals a value type to the output stream.
+      * @param value is the acutal value to write
+diff --git a/src/share/classes/sun/corba/OutputStreamFactory.java b/src/share/classes/sun/corba/OutputStreamFactory.java
+new file mode 100644
+--- /dev/null
++++ openjdk/corba/src/share/classes/sun/corba/OutputStreamFactory.java
+@@ -0,0 +1,141 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package sun.corba;
++
++import com.sun.corba.se.impl.corba.AnyImpl;
++import com.sun.corba.se.impl.encoding.BufferManagerWrite;
++import com.sun.corba.se.impl.encoding.CDROutputObject;
++import com.sun.corba.se.impl.encoding.EncapsOutputStream;
++import com.sun.corba.se.impl.encoding.TypeCodeOutputStream;
++import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
++
++import com.sun.corba.se.pept.protocol.MessageMediator;
++
++import com.sun.corba.se.spi.orb.ORB;
++import com.sun.corba.se.spi.transport.CorbaConnection;
++import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
++import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
++
++import java.security.AccessController;
++import java.security.PrivilegedAction;
++
++public final class OutputStreamFactory {
++
++    private OutputStreamFactory() {
++    }
++
++    public static TypeCodeOutputStream newTypeCodeOutputStream(
++            final ORB orb) {
++        return AccessController.doPrivileged(
++            new PrivilegedAction<TypeCodeOutputStream>() {
++                public TypeCodeOutputStream run() {
++                    return new TypeCodeOutputStream(orb);
++                }
++        });
++    }
++
++    public static TypeCodeOutputStream newTypeCodeOutputStream(
++            final ORB orb, final boolean littleEndian) {
++        return AccessController.doPrivileged(
++            new PrivilegedAction<TypeCodeOutputStream>() {
++                public TypeCodeOutputStream run() {
++                    return new TypeCodeOutputStream(orb, littleEndian);
++                }
++        });
++    }
++
++    public static EncapsOutputStream newEncapsOutputStream(
++            final ORB orb) {
++        return AccessController.doPrivileged(
++            new PrivilegedAction<EncapsOutputStream>() {
++                public EncapsOutputStream run() {
++                    return new EncapsOutputStream(
++                        (com.sun.corba.se.spi.orb.ORB)orb);
++                }
++        });
++    }
++
++    public static EncapsOutputStream newEncapsOutputStream(
++            final ORB orb, final GIOPVersion giopVersion) {
++        return AccessController.doPrivileged(
++            new PrivilegedAction<EncapsOutputStream>() {
++                public EncapsOutputStream run() {
++                    return new EncapsOutputStream(
++                        (com.sun.corba.se.spi.orb.ORB)orb, giopVersion);
++                }
++        });
++    }
++
++    public static EncapsOutputStream newEncapsOutputStream(
++            final ORB orb, final boolean isLittleEndian) {
++        return AccessController.doPrivileged(
++            new PrivilegedAction<EncapsOutputStream>() {
++                public EncapsOutputStream run() {
++                    return new EncapsOutputStream(
++                        (com.sun.corba.se.spi.orb.ORB)orb, isLittleEndian);
++                }
++        });
++    }
++
++    public static CDROutputObject newCDROutputObject(
++            final ORB orb, final MessageMediator messageMediator,
++            final Message header, final byte streamFormatVersion) {
++        return AccessController.doPrivileged(
++            new PrivilegedAction<CDROutputObject>() {
++                public CDROutputObject run() {
++                    return new CDROutputObject(orb, messageMediator,
++                        header, streamFormatVersion);
++                }
++        });
++    }
++
++    public static CDROutputObject newCDROutputObject(
++            final ORB orb, final MessageMediator messageMediator,
++            final Message header, final byte streamFormatVersion,
++            final int strategy) {
++        return AccessController.doPrivileged(
++            new PrivilegedAction<CDROutputObject>() {
++                public CDROutputObject run() {
++                    return new CDROutputObject(orb, messageMediator,
++                        header, streamFormatVersion, strategy);
++                }
++        });
++    }
++
++    public static CDROutputObject newCDROutputObject(
++            final ORB orb, final CorbaMessageMediator mediator,
++            final GIOPVersion giopVersion, final CorbaConnection connection,
++            final Message header, final byte streamFormatVersion) {
++        return AccessController.doPrivileged(
++            new PrivilegedAction<CDROutputObject>() {
++                public CDROutputObject run() {
++                    return new CDROutputObject(orb, mediator,
++                        giopVersion, connection, header, streamFormatVersion);
++                }
++        });
++    }
++
++}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001032-restrict_object_access-corba.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,544 @@
+# HG changeset patch
+# User Severin Gehwolf <sgehwolf@redhat.com>
+# Date 1371473490 -7200
+# Node ID 7a0a1f984e7fdd43bd9502b6f77ae890d158ccd1
+# Parent  bec83758f55670cdb7865e8103f8100dc6f4f0fb
+8001032: Restrict object access
+Summary: Restrict object access; fix reviewed also by Alexander Fomin
+Reviewed-by: alanb, ahgross
+
+diff --git a/make/com/sun/corba/minclude/com_sun_corba_se_impl_orbutil.jmk b/make/com/sun/corba/minclude/com_sun_corba_se_impl_orbutil.jmk
+--- openjdk/corba/make/com/sun/corba/minclude/com_sun_corba_se_impl_orbutil.jmk
++++ openjdk/corba/make/com/sun/corba/minclude/com_sun_corba_se_impl_orbutil.jmk
+@@ -1,5 +1,5 @@
+ #
+-# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
++# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ #
+ # This code is free software; you can redistribute it and/or modify it
+@@ -39,7 +39,6 @@
+ 	com/sun/corba/se/impl/orbutil/ObjectStreamClassUtil_1_3.java \
+ 	com/sun/corba/se/impl/orbutil/ORBConstants.java \
+ 	com/sun/corba/se/impl/orbutil/ORBUtility.java \
+-	com/sun/corba/se/impl/orbutil/ORBClassLoader.java \
+ 	com/sun/corba/se/impl/orbutil/RepIdDelegator.java \
+ 	com/sun/corba/se/impl/orbutil/RepositoryIdFactory.java \
+ 	com/sun/corba/se/impl/orbutil/RepositoryIdStrings.java \
+diff --git a/src/share/classes/com/sun/corba/se/impl/activation/ServerManagerImpl.java b/src/share/classes/com/sun/corba/se/impl/activation/ServerManagerImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/activation/ServerManagerImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/activation/ServerManagerImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -81,7 +81,6 @@
+ 
+ import com.sun.corba.se.impl.oa.poa.BadServerIdHandler;
+ import com.sun.corba.se.impl.orbutil.ORBConstants;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader;
+ import com.sun.corba.se.impl.orbutil.ORBUtility;
+ import com.sun.corba.se.impl.util.Utility;
+ 
+diff --git a/src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java b/src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -76,7 +76,6 @@
+ import com.sun.corba.se.impl.logging.ORBUtilSystemException;
+ import com.sun.corba.se.impl.logging.OMGSystemException;
+ import com.sun.corba.se.impl.corba.RequestImpl;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader;
+ import com.sun.corba.se.impl.orbutil.ORBConstants;
+ import com.sun.corba.se.impl.orbutil.ORBUtility;
+ import com.sun.corba.se.impl.orbutil.StackImpl;
+diff --git a/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java b/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -86,13 +86,14 @@
+ import com.sun.corba.se.impl.encoding.EncapsOutputStream;
+ 
+ import com.sun.corba.se.impl.orbutil.ORBUtility;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader;
+ 
+ import com.sun.corba.se.impl.util.RepositoryId;
+ 
+ import com.sun.corba.se.impl.logging.InterceptorsSystemException;
+ import com.sun.corba.se.impl.logging.OMGSystemException;
+ 
++import sun.corba.SharedSecrets;
++
+ /**
+  * Implementation of the RequestInfo interface as specified in
+  * orbos/99-12-02 section 5.4.1.
+@@ -451,7 +452,8 @@
+ 
+             // Find the read method on the helper class:
+             String helperClassName = className + "Helper";
+-            Class helperClass = ORBClassLoader.loadClass( helperClassName );
++            Class<?> helperClass =
++                SharedSecrets.getJavaCorbaAccess().loadClass( helperClassName );
+             Class[] readParams = new Class[1];
+             readParams[0] = org.omg.CORBA.portable.InputStream.class;
+             Method readMethod = helperClass.getMethod( "read", readParams );
+@@ -511,7 +513,8 @@
+                 Class exceptionClass = userException.getClass();
+                 String className = exceptionClass.getName();
+                 String helperClassName = className + "Helper";
+-                Class helperClass = ORBClassLoader.loadClass( helperClassName );
++                Class<?> helperClass =
++                    SharedSecrets.getJavaCorbaAccess().loadClass( helperClassName );
+ 
+                 // Find insert( Any, class ) method
+                 Class[] insertMethodParams = new Class[2];
+diff --git a/src/share/classes/com/sun/corba/se/impl/io/ValueUtility.java b/src/share/classes/com/sun/corba/se/impl/io/ValueUtility.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/io/ValueUtility.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/io/ValueUtility.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -98,6 +98,14 @@
+             public ValueHandlerImpl newValueHandlerImpl() {
+                 return ValueHandlerImpl.getInstance();
+             }
++            public Class<?> loadClass(String className) throws ClassNotFoundException {
++                if (Thread.currentThread().getContextClassLoader() != null) {
++                    return Thread.currentThread().getContextClassLoader().
++                        loadClass(className);
++                } else {
++                    return ClassLoader.getSystemClassLoader().loadClass(className);
++                }
++            }
+         });
+     }
+ 
+diff --git a/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/Util.java b/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/Util.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/Util.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/javax/rmi/CORBA/Util.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -109,12 +109,9 @@
+ import com.sun.corba.se.impl.util.Utility;
+ import com.sun.corba.se.impl.util.IdentityHashtable;
+ import com.sun.corba.se.impl.util.JDKBridge;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader;
+ import com.sun.corba.se.impl.logging.UtilSystemException;
+ import com.sun.corba.se.spi.logging.CORBALogDomains;
+ import sun.corba.SharedSecrets;
+-import sun.corba.JavaCorbaAccess;
+-
+ 
+ /**
+  * Provides utility methods that can be used by stubs and ties to
+@@ -263,7 +260,7 @@
+             return new MarshalException(message,inner);
+         } else if (ex instanceof ACTIVITY_REQUIRED) {
+             try {
+-                Class cl = ORBClassLoader.loadClass(
++                Class<?> cl = SharedSecrets.getJavaCorbaAccess().loadClass(
+                                "javax.activity.ActivityRequiredException");
+                 Class[] params = new Class[2];
+                 params[0] = java.lang.String.class;
+@@ -279,7 +276,7 @@
+             }
+         } else if (ex instanceof ACTIVITY_COMPLETED) {
+             try {
+-                Class cl = ORBClassLoader.loadClass(
++                Class<?> cl = SharedSecrets.getJavaCorbaAccess().loadClass(
+                                "javax.activity.ActivityCompletedException");
+                 Class[] params = new Class[2];
+                 params[0] = java.lang.String.class;
+@@ -295,7 +292,7 @@
+               }
+         } else if (ex instanceof INVALID_ACTIVITY) {
+             try {
+-                Class cl = ORBClassLoader.loadClass(
++                Class<?> cl = SharedSecrets.getJavaCorbaAccess().loadClass(
+                                "javax.activity.InvalidActivityException");
+                 Class[] params = new Class[2];
+                 params[0] = java.lang.String.class;
+diff --git a/src/share/classes/com/sun/corba/se/impl/orb/ORBDataParserImpl.java b/src/share/classes/com/sun/corba/se/impl/orb/ORBDataParserImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBDataParserImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBDataParserImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -48,7 +48,6 @@
+ 
+ import com.sun.corba.se.impl.encoding.CodeSetComponentInfo ;
+ import com.sun.corba.se.impl.legacy.connection.USLPort;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader ;
+ import com.sun.corba.se.impl.orbutil.ORBConstants ;
+ import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
+ 
+diff --git a/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java b/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -149,7 +149,6 @@
+ import com.sun.corba.se.impl.oa.poa.BadServerIdHandler;
+ import com.sun.corba.se.impl.oa.poa.DelegateImpl;
+ import com.sun.corba.se.impl.oa.poa.POAFactory;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader;
+ import com.sun.corba.se.impl.orbutil.ORBConstants;
+ import com.sun.corba.se.impl.orbutil.ORBUtility;
+ import com.sun.corba.se.impl.orbutil.StackImpl;
+diff --git a/src/share/classes/com/sun/corba/se/impl/orb/ParserTable.java b/src/share/classes/com/sun/corba/se/impl/orb/ParserTable.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/orb/ParserTable.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/orb/ParserTable.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -78,7 +78,6 @@
+ import com.sun.corba.se.impl.legacy.connection.USLPort ;
+ import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
+ import com.sun.corba.se.impl.oa.poa.BadServerIdHandler ;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader ;
+ import com.sun.corba.se.impl.orbutil.ORBConstants ;
+ import com.sun.corba.se.impl.protocol.giopmsgheaders.KeyAddr ;
+ import com.sun.corba.se.impl.protocol.giopmsgheaders.ProfileAddr ;
+@@ -86,6 +85,8 @@
+ import com.sun.corba.se.impl.transport.DefaultIORToSocketInfoImpl;
+ import com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl;
+ 
++import sun.corba.SharedSecrets;
++
+ /** Initialize the parser data for the standard ORB parser.  This is used both
+  * to implement ORBDataParserImpl and to provide the basic testing framework
+  * for ORBDataParserImpl.
+@@ -640,8 +641,8 @@
+                 String param = (String)value ;
+ 
+                 try {
+-                    Class legacySocketFactoryClass =
+-                        ORBClassLoader.loadClass(param);
++                    Class<?> legacySocketFactoryClass =
++                        SharedSecrets.getJavaCorbaAccess().loadClass(param);
+                     // For security reasons avoid creating an instance if
+                     // this socket factory class is not one that would fail
+                     // the class cast anyway.
+@@ -670,7 +671,8 @@
+                 String param = (String)value ;
+ 
+                 try {
+-                    Class socketFactoryClass = ORBClassLoader.loadClass(param);
++                    Class<?> socketFactoryClass =
++                        SharedSecrets.getJavaCorbaAccess().loadClass(param);
+                     // For security reasons avoid creating an instance if
+                     // this socket factory class is not one that would fail
+                     // the class cast anyway.
+@@ -699,7 +701,8 @@
+                 String param = (String)value ;
+ 
+                 try {
+-                    Class iorToSocketInfoClass = ORBClassLoader.loadClass(param);
++                    Class<?> iorToSocketInfoClass =
++                        SharedSecrets.getJavaCorbaAccess().loadClass(param);
+                     // For security reasons avoid creating an instance if
+                     // this socket factory class is not one that would fail
+                     // the class cast anyway.
+@@ -728,7 +731,8 @@
+                 String param = (String)value ;
+ 
+                 try {
+-                    Class iiopPrimaryToContactInfoClass = ORBClassLoader.loadClass(param);
++                    Class<?> iiopPrimaryToContactInfoClass =
++                        SharedSecrets.getJavaCorbaAccess().loadClass(param);
+                     // For security reasons avoid creating an instance if
+                     // this socket factory class is not one that would fail
+                     // the class cast anyway.
+@@ -757,8 +761,8 @@
+                 String param = (String)value ;
+ 
+                 try {
+-                    Class contactInfoListFactoryClass =
+-                        ORBClassLoader.loadClass(param);
++                    Class<?> contactInfoListFactoryClass =
++                        SharedSecrets.getJavaCorbaAccess().loadClass(param);
+                     // For security reasons avoid creating an instance if
+                     // this socket factory class is not one that would fail
+                     // the class cast anyway.
+diff --git a/src/share/classes/com/sun/corba/se/impl/orbutil/ORBClassLoader.java b/src/share/classes/com/sun/corba/se/impl/orbutil/ORBClassLoader.java
+deleted file mode 100644
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBClassLoader.java
++++ /dev/null
+@@ -1,47 +0,0 @@
+-/*
+- * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
+- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+- *
+- * This code is free software; you can redistribute it and/or modify it
+- * under the terms of the GNU General Public License version 2 only, as
+- * published by the Free Software Foundation.  Oracle designates this
+- * particular file as subject to the "Classpath" exception as provided
+- * by Oracle in the LICENSE file that accompanied this code.
+- *
+- * This code is distributed in the hope that it will be useful, but WITHOUT
+- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+- * version 2 for more details (a copy is included in the LICENSE file that
+- * accompanied this code).
+- *
+- * You should have received a copy of the GNU General Public License version
+- * 2 along with this work; if not, write to the Free Software Foundation,
+- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+- *
+- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+- * or visit www.oracle.com if you need additional information or have any
+- * questions.
+- */
+-package com.sun.corba.se.impl.orbutil;
+-
+-/**
+- * Based on feedback from bug report 4452016, all class loading
+- * in the ORB is isolated here.  It is acceptable to use
+- * Class.forName only when one is certain that the desired class
+- * should come from the core JDK.
+- */
+-public class ORBClassLoader
+-{
+-    public static Class loadClass(String className)
+-        throws ClassNotFoundException
+-    {
+-        return ORBClassLoader.getClassLoader().loadClass(className);
+-    }
+-
+-    public static ClassLoader getClassLoader() {
+-        if (Thread.currentThread().getContextClassLoader() != null)
+-            return Thread.currentThread().getContextClassLoader();
+-        else
+-            return ClassLoader.getSystemClassLoader();
+-    }
+-}
+diff --git a/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java b/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/orbutil/ORBUtility.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -90,6 +90,8 @@
+ import com.sun.corba.se.impl.logging.OMGSystemException ;
+ import com.sun.corba.se.impl.ior.iiop.JavaSerializationComponent;
+ 
++import sun.corba.SharedSecrets;
++
+ /**
+  *  Handy class full of static functions that don't belong in util.Utility for pure ORB reasons.
+  */
+@@ -262,8 +264,8 @@
+     {
+         try {
+             String name = classNameOf(strm.read_string());
+-            SystemException ex
+-                = (SystemException)ORBClassLoader.loadClass(name).newInstance();
++            SystemException ex = (SystemException)SharedSecrets.
++                getJavaCorbaAccess().loadClass(name).newInstance();
+             ex.minor = strm.read_long();
+             ex.completed = CompletionStatus.from_int(strm.read_long());
+             return ex;
+diff --git a/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/LocateReplyMessage_1_2.java b/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/LocateReplyMessage_1_2.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/LocateReplyMessage_1_2.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/LocateReplyMessage_1_2.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -41,7 +41,6 @@
+ 
+ import com.sun.corba.se.impl.orbutil.ORBUtility;
+ import com.sun.corba.se.impl.orbutil.ORBConstants;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader;
+ 
+ import com.sun.corba.se.spi.logging.CORBALogDomains ;
+ import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
+diff --git a/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/MessageBase.java b/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/MessageBase.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/MessageBase.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/MessageBase.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -60,9 +60,10 @@
+ import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
+ import com.sun.corba.se.impl.orbutil.ORBUtility;
+ import com.sun.corba.se.impl.orbutil.ORBConstants;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader;
+ import com.sun.corba.se.impl.protocol.AddressingDispositionException;
+ 
++import sun.corba.SharedSecrets;
++
+ /**
+  * This class acts as the base class for the various GIOP message types. This
+  * also serves as a factory to create various message types. We currently
+@@ -909,7 +910,8 @@
+         SystemException sysEx = null;
+ 
+         try {
+-            Class clazz = ORBClassLoader.loadClass(exClassName);
++            Class<?> clazz =
++                SharedSecrets.getJavaCorbaAccess().loadClass(exClassName);
+             if (message == null) {
+                 sysEx = (SystemException) clazz.newInstance();
+             } else {
+diff --git a/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/ReplyMessage_1_0.java b/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/ReplyMessage_1_0.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/ReplyMessage_1_0.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/ReplyMessage_1_0.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -37,7 +37,6 @@
+ import com.sun.corba.se.spi.servicecontext.ServiceContexts;
+ import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
+ import com.sun.corba.se.impl.orbutil.ORBUtility;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader;
+ import com.sun.corba.se.spi.ior.IOR;
+ import com.sun.corba.se.impl.encoding.CDRInputStream;
+ 
+diff --git a/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/ReplyMessage_1_1.java b/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/ReplyMessage_1_1.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/ReplyMessage_1_1.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/impl/protocol/giopmsgheaders/ReplyMessage_1_1.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -37,7 +37,6 @@
+ import com.sun.corba.se.spi.servicecontext.ServiceContexts;
+ import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
+ import com.sun.corba.se.impl.orbutil.ORBUtility;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader;
+ import com.sun.corba.se.spi.ior.IOR;
+ import com.sun.corba.se.impl.encoding.CDRInputStream;
+ 
+diff --git a/src/share/classes/com/sun/corba/se/spi/orb/ORB.java b/src/share/classes/com/sun/corba/se/spi/orb/ORB.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/spi/orb/ORB.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/spi/orb/ORB.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -97,8 +97,8 @@
+ 
+ import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ;
+ 
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader ;
+ import sun.awt.AppContext;
++import sun.corba.SharedSecrets;
+ 
+ public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
+     implements Broker, TypeCodeFactory
+@@ -201,7 +201,7 @@
+ 
+                         try {
+                             // First try the configured class name, if any
+-                            Class cls = ORBClassLoader.loadClass( className ) ;
++                            Class<?> cls = SharedSecrets.getJavaCorbaAccess().loadClass( className ) ;
+                             sff = (PresentationManager.StubFactoryFactory)cls.newInstance() ;
+                         } catch (Exception exc) {
+                             // Use the default. Log the error as a warning.
+diff --git a/src/share/classes/com/sun/corba/se/spi/orb/OperationFactory.java b/src/share/classes/com/sun/corba/se/spi/orb/OperationFactory.java
+--- openjdk/corba/src/share/classes/com/sun/corba/se/spi/orb/OperationFactory.java
++++ openjdk/corba/src/share/classes/com/sun/corba/se/spi/orb/OperationFactory.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -35,9 +35,10 @@
+ import com.sun.corba.se.spi.logging.CORBALogDomains ;
+ 
+ import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
+-import com.sun.corba.se.impl.orbutil.ORBClassLoader ;
+ import com.sun.corba.se.impl.orbutil.ObjectUtility ;
+ 
++import sun.corba.SharedSecrets;
++
+ /** This is a static factory class for commonly used operations
+ * for property parsing.  The following operations are supported:
+ * <ul>
+@@ -247,7 +248,8 @@
+             String className = getString( value ) ;
+ 
+             try {
+-                Class result = ORBClassLoader.loadClass( className ) ;
++                Class<?> result =
++                    SharedSecrets.getJavaCorbaAccess().loadClass( className ) ;
+                 return result ;
+             } catch (Exception exc) {
+                 ORBUtilSystemException wrapper = ORBUtilSystemException.get(
+diff --git a/src/share/classes/sun/corba/JavaCorbaAccess.java b/src/share/classes/sun/corba/JavaCorbaAccess.java
+--- openjdk/corba/src/share/classes/sun/corba/JavaCorbaAccess.java
++++ openjdk/corba/src/share/classes/sun/corba/JavaCorbaAccess.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,4 +29,5 @@
+ 
+ public interface JavaCorbaAccess {
+     public ValueHandlerImpl newValueHandlerImpl();
++    public Class<?> loadClass(String className) throws ClassNotFoundException;
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001032-restrict_object_access-jdk.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,21 @@
+# HG changeset patch
+# User andrew
+# Date 1371235319 -3600
+# Node ID 59e36a91e283804e0ff074e43ca67d4002113db9
+# Parent  b1c99cf6c26d9df7ca7d02df1687064656c8ae71
+8001032: Restrict object access
+Summary: Restrict object access; fix reviewed also by Alexander Fomin
+Reviewed-by: alanb, ahgross
+
+diff --git a/test/Makefile b/test/Makefile
+--- openjdk/jdk/test/Makefile
++++ openjdk/jdk/test/Makefile
+@@ -483,7 +483,7 @@
+ JDK_ALL_TARGETS += jdk_misc
+ jdk_misc: demo javax/imageio javax/naming javax/print javax/script \
+           javax/smartcardio javax/xml javax/sound com/sun/java com/sun/jndi \
+-	  com/sun/org sun/misc sun/pisces
++	  com/sun/org com/sun/corba sun/misc sun/pisces
+ 	$(call RunSamevmBatch)
+ 
+ # Stable samevm testruns (minus items from PROBLEM_LIST)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001033-refactor_address_handling.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,119 @@
+# HG changeset patch
+# User andrew
+# Date 1371235593 -3600
+# Node ID ae6fc01dd3d4d1a7f662ace7ce787c071767c28a
+# Parent  59e36a91e283804e0ff074e43ca67d4002113db9
+8001033: Refactor network address handling in virtual machine identifiers
+Reviewed-by: smarks, hawtin, mchung
+
+diff --git a/src/share/classes/java/rmi/dgc/VMID.java b/src/share/classes/java/rmi/dgc/VMID.java
+--- openjdk/jdk/src/share/classes/java/rmi/dgc/VMID.java
++++ openjdk/jdk/src/share/classes/java/rmi/dgc/VMID.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,10 +25,8 @@
+ 
+ package java.rmi.dgc;
+ 
+-import java.io.*;
+-import java.net.*;
+ import java.rmi.server.UID;
+-import java.security.*;
++import java.security.SecureRandom;
+ 
+ /**
+  * A VMID is a identifier that is unique across all Java virtual
+@@ -39,9 +37,8 @@
+  * @author      Peter Jones
+  */
+ public final class VMID implements java.io.Serializable {
+-
+-    /** array of bytes uniquely identifying this host */
+-    private static byte[] localAddr = computeAddressHash();
++    /** Array of bytes uniquely identifying this host */
++    private static final byte[] randomBytes;
+ 
+     /**
+      * @serial array of bytes uniquely identifying host created on
+@@ -56,6 +53,14 @@
+     /** indicate compatibility with JDK 1.1.x version of class */
+     private static final long serialVersionUID = -538642295484486218L;
+ 
++    static {
++        // Generate 8 bytes of random data.
++        SecureRandom secureRandom = new SecureRandom();
++        byte bytes[] = new byte[8];
++        secureRandom.nextBytes(bytes);
++        randomBytes = bytes;
++    }
++
+     /**
+      * Create a new VMID.  Each new VMID returned from this constructor
+      * is unique for all Java virtual machines under the following
+@@ -65,7 +70,7 @@
+      * for the lifetime of this object.  <p>
+      */
+     public VMID() {
+-        addr = localAddr;
++        addr = randomBytes;
+         uid = new UID();
+     }
+ 
+@@ -126,52 +131,4 @@
+         result.append(uid.toString());
+         return result.toString();
+     }
+-
+-    /**
+-     * Compute the hash an IP address.  The hash is the first 8 bytes
+-     * of the SHA digest of the IP address.
+-     */
+-    private static byte[] computeAddressHash() {
+-
+-        /*
+-         * Get the local host's IP address.
+-         */
+-        byte[] addr = (byte[]) java.security.AccessController.doPrivileged(
+-            new PrivilegedAction() {
+-            public Object run() {
+-                try {
+-                    return InetAddress.getLocalHost().getAddress();
+-                } catch (Exception e) {
+-                }
+-                return new byte[] { 0, 0, 0, 0 };
+-            }
+-        });
+-
+-        byte[] addrHash;
+-        final int ADDR_HASH_LENGTH = 8;
+-
+-        try {
+-            /*
+-             * Calculate message digest of IP address using SHA.
+-             */
+-            MessageDigest md = MessageDigest.getInstance("SHA");
+-            ByteArrayOutputStream sink = new ByteArrayOutputStream(64);
+-            DataOutputStream out = new DataOutputStream(
+-                new DigestOutputStream(sink, md));
+-            out.write(addr, 0, addr.length);
+-            out.flush();
+-
+-            byte digest[] = md.digest();
+-            int hashlength = Math.min(ADDR_HASH_LENGTH, digest.length);
+-            addrHash = new byte[hashlength];
+-            System.arraycopy(digest, 0, addrHash, 0, hashlength);
+-
+-        } catch (IOException ignore) {
+-            /* can't happen, but be deterministic anyway. */
+-            addrHash = new byte[0];
+-        } catch (NoSuchAlgorithmException complain) {
+-            throw new InternalError(complain.toString());
+-        }
+-        return addrHash;
+-    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001034-memory_management.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,78 @@
+# HG changeset patch
+# User bae
+# Date 1361951590 -14400
+# Node ID 5b6f070ddeab14b2d7a731c5f4c61eea406638da
+# Parent  ae6fc01dd3d4d1a7f662ace7ce787c071767c28a
+8001034: Memory management improvements
+Reviewed-by: prr, jgodinez
+
+diff --git a/src/solaris/native/sun/awt/awt_GraphicsEnv.c b/src/solaris/native/sun/awt/awt_GraphicsEnv.c
+--- openjdk/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
++++ openjdk/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
+@@ -924,6 +924,8 @@
+ static jint canUseShmExtPixmaps = UNSET_MITSHM;
+ static jboolean xshmAttachFailed = JNI_FALSE;
+ 
++extern int mitShmPermissionMask;
++
+ int J2DXErrHandler(Display *display, XErrorEvent *xerr) {
+     int ret = 0;
+     if (xerr->minor_code == X_ShmAttach) {
+@@ -962,7 +964,8 @@
+      * we need to test that we can actually do XShmAttach.
+      */
+     if (XShmQueryExtension(awt_display)) {
+-        shminfo.shmid = shmget(IPC_PRIVATE, 0x10000, IPC_CREAT|0777);
++        shminfo.shmid = shmget(IPC_PRIVATE, 0x10000,
++                               IPC_CREAT|mitShmPermissionMask);
+         if (shminfo.shmid < 0) {
+             AWT_UNLOCK();
+             J2dRlsTraceLn1(J2D_TRACE_ERROR,
+diff --git a/src/solaris/native/sun/awt/awt_GraphicsEnv.h b/src/solaris/native/sun/awt/awt_GraphicsEnv.h
+--- openjdk/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.h
++++ openjdk/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.h
+@@ -47,6 +47,9 @@
+ #include <X11/extensions/shmproto.h>
+ #endif
+ 
++#define MITSHM_PERM_COMMON (0666)
++#define MITSHM_PERM_OWNER  (0600)
++
+ extern int XShmQueryExtension();
+ 
+ void TryInitMITShm(JNIEnv *env, jint *shmExt, jint *shmPixmaps);
+diff --git a/src/solaris/native/sun/java2d/x11/X11SurfaceData.c b/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
+--- openjdk/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
++++ openjdk/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
+@@ -91,6 +91,7 @@
+ jint useMitShmExt = CANT_USE_MITSHM;
+ jint useMitShmPixmaps = CANT_USE_MITSHM;
+ jint forceSharedPixmaps = JNI_FALSE;
++int mitShmPermissionMask = MITSHM_PERM_OWNER;
+ 
+ /* Cached shared image, one for all surface datas. */
+ static XImage * cachedXImage;
+@@ -154,6 +155,13 @@
+     if (getenv("NO_AWT_MITSHM") == NULL &&
+         getenv("NO_J2D_MITSHM") == NULL) {
+         char * force;
++        char * permission = getenv("J2D_MITSHM_PERMISSION");
++        if (permission != NULL) {
++            if (strcmp(permission, "common") == 0) {
++                mitShmPermissionMask = MITSHM_PERM_COMMON;
++            }
++        }
++
+         TryInitMITShm(env, &useMitShmExt, &useMitShmPixmaps);
+         useMitShmPixmaps = (useMitShmPixmaps == CAN_USE_MITSHM);
+         force = getenv("J2D_PIXMAPS");
+@@ -492,7 +500,8 @@
+         return NULL;
+     }
+     shminfo->shmid =
+-        shmget(IPC_PRIVATE, height * img->bytes_per_line, IPC_CREAT|0777);
++        shmget(IPC_PRIVATE, height * img->bytes_per_line,
++               IPC_CREAT|mitShmPermissionMask);
+     if (shminfo->shmid < 0) {
+         J2dRlsTraceLn1(J2D_TRACE_ERROR,
+                        "X11SD_SetupSharedSegment shmget has failed: %s",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001038-resourcefully_handle_resources.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,236 @@
+# HG changeset patch
+# User bae
+# Date 1364494624 -14400
+# Node ID d514062cbfff28dc38f4b429df12f0d174f960e6
+# Parent  5b6f070ddeab14b2d7a731c5f4c61eea406638da
+8001038: Resourcefully handle resources
+Reviewed-by: mschoene, prr, bae
+Contributed-by: jia-hong.chen@oracle.com
+
+diff --git a/src/share/classes/java/awt/Font.java b/src/share/classes/java/awt/Font.java
+--- openjdk/jdk/src/share/classes/java/awt/Font.java
++++ openjdk/jdk/src/share/classes/java/awt/Font.java
+@@ -850,6 +850,33 @@
+     public static Font createFont(int fontFormat, InputStream fontStream)
+         throws java.awt.FontFormatException, java.io.IOException {
+ 
++        if (hasTempPermission()) {
++            return createFont0(fontFormat, fontStream, null);
++        }
++
++        // Otherwise, be extra conscious of pending temp file creation and
++        // resourcefully handle the temp file resources, among other things.
++        CreatedFontTracker tracker = CreatedFontTracker.getTracker();
++        boolean acquired = false;
++        try {
++            acquired = tracker.acquirePermit();
++            if (!acquired) {
++                throw new IOException("Timed out waiting for resources.");
++            }
++            return createFont0(fontFormat, fontStream, tracker);
++        } catch (InterruptedException e) {
++            throw new IOException("Problem reading font data.");
++        } finally {
++            if (acquired) {
++                tracker.releasePermit();
++            }
++        }
++    }
++
++    private static Font createFont0(int fontFormat, InputStream fontStream,
++                                    CreatedFontTracker tracker)
++        throws java.awt.FontFormatException, java.io.IOException {
++
+         if (fontFormat != Font.TRUETYPE_FONT &&
+             fontFormat != Font.TYPE1_FONT) {
+             throw new IllegalArgumentException ("font format not recognized");
+@@ -864,9 +891,11 @@
+                     }
+                 }
+             );
++            if (tracker != null) {
++                tracker.add(tFile);
++            }
+ 
+             int totalSize = 0;
+-            CreatedFontTracker tracker = null;
+             try {
+                 final OutputStream outStream =
+                     AccessController.doPrivileged(
+@@ -876,8 +905,8 @@
+                             }
+                         }
+                     );
+-                if (!hasTempPermission()) {
+-                    tracker = CreatedFontTracker.getTracker();
++                if (tracker != null) {
++                    tracker.set(tFile, outStream);
+                 }
+                 try {
+                     byte[] buf = new byte[8192]; 
+@@ -892,7 +921,7 @@
+                             }
+                             if (totalSize+tracker.getNumBytes() >
+                                 tracker.MAX_TOTAL_BYTES)
+-                              {
++                            {
+                                 throw new IOException("Total files too big.");
+                             }
+                             totalSize += bytesRead;
+@@ -918,6 +947,9 @@
+                 Font font = new Font(tFile, fontFormat, true, tracker);
+                 return font;
+             } finally {
++                if (tracker != null) {
++                    tracker.remove(tFile);
++                }
+                 if (!copiedFontData) {
+                     if (tracker != null) {
+                         tracker.subBytes(totalSize);
+diff --git a/src/share/classes/sun/font/CreatedFontTracker.java b/src/share/classes/sun/font/CreatedFontTracker.java
+--- openjdk/jdk/src/share/classes/sun/font/CreatedFontTracker.java
++++ openjdk/jdk/src/share/classes/sun/font/CreatedFontTracker.java
+@@ -25,13 +25,22 @@
+ 
+ package sun.font;
+ 
++import java.io.File;
++import java.io.OutputStream;
++import java.util.HashMap;
++import java.util.Map;
++import java.util.concurrent.Semaphore;
++import java.util.concurrent.TimeUnit;
++
++import sun.awt.AppContext;
++
+ public class CreatedFontTracker {
+ 
+     public static final int MAX_FILE_SIZE = 32 * 1024 * 1024;
+     public static final int MAX_TOTAL_BYTES = 10 * MAX_FILE_SIZE;
+ 
+-    static int numBytes;
+     static CreatedFontTracker tracker;
++    int numBytes;
+ 
+     public static synchronized CreatedFontTracker getTracker() {
+         if (tracker == null) {
+@@ -40,6 +49,10 @@
+         return tracker;
+     }
+ 
++    private CreatedFontTracker() {
++        numBytes = 0;
++    }
++
+     public synchronized int getNumBytes() {
+         return numBytes;
+     }
+@@ -51,4 +64,108 @@
+     public synchronized void subBytes(int sz) {
+         numBytes -= sz;
+     }
++
++    /**
++     * Returns an AppContext-specific counting semaphore.
++     */
++    private static synchronized Semaphore getCS() {
++        final AppContext appContext = AppContext.getAppContext();
++        Semaphore cs = (Semaphore) appContext.get(CreatedFontTracker.class);
++        if (cs == null) {
++            // Make a semaphore with 5 permits that obeys the first-in first-out
++            // granting of permits.
++            cs = new Semaphore(5, true);
++            appContext.put(CreatedFontTracker.class, cs);
++        }
++        return cs;
++    }
++
++    public boolean acquirePermit() throws InterruptedException {
++        // This does a timed-out wait.
++        return getCS().tryAcquire(120, TimeUnit.SECONDS);
++    }
++
++    public void releasePermit() {
++        getCS().release();
++    }
++
++    public void add(File file) {
++        TempFileDeletionHook.add(file);
++    }
++
++    public void set(File file, OutputStream os) {
++        TempFileDeletionHook.set(file, os);
++    }
++
++    public void remove(File file) {
++        TempFileDeletionHook.remove(file);
++    }
++
++    /**
++     * Helper class for cleanup of temp files created while processing fonts.
++     * Note that this only applies to createFont() from an InputStream object.
++     */
++    private static class TempFileDeletionHook {
++        private static HashMap<File, OutputStream> files = new HashMap<>();
++
++        private static Thread t = null;
++        static void init() {
++            if (t == null) {
++                // Add a shutdown hook to remove the temp file.
++                java.security.AccessController.doPrivileged(
++                   new java.security.PrivilegedAction() {
++                      public Object run() {
++                          /* The thread must be a member of a thread group
++                           * which will not get GCed before VM exit.
++                           * Make its parent the top-level thread group.
++                           */
++                          ThreadGroup tg =
++                              Thread.currentThread().getThreadGroup();
++                          for (ThreadGroup tgn = tg;
++                               tgn != null;
++                               tg = tgn, tgn = tg.getParent());
++                          t = new Thread(tg, new Runnable() {
++                              public void run() {
++                                  runHooks();
++                              }
++                          });
++                          t.setContextClassLoader(null);
++                          Runtime.getRuntime().addShutdownHook(t);
++                          return null;
++                      }
++                   });
++            }
++        }
++
++        private TempFileDeletionHook() {}
++
++        static synchronized void add(File file) {
++            init();
++            files.put(file, null);
++        }
++
++        static synchronized void set(File file, OutputStream os) {
++            files.put(file, os);
++        }
++
++        static synchronized void remove(File file) {
++            files.remove(file);
++        }
++
++        static synchronized void runHooks() {
++            if (files.isEmpty()) {
++                return;
++            }
++
++            for (Map.Entry<File, OutputStream> entry : files.entrySet()) {
++                // Close the associated output stream, and then delete the file.
++                try {
++                    if (entry.getValue() != null) {
++                        entry.getValue().close();
++                    }
++                } catch (Exception e) {}
++                entry.getKey().delete();
++            }
++        }
++    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001043-clarify_definition_restrictions.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,92 @@
+# HG changeset patch
+# User dfuchs
+# Date 1363366750 -3600
+# Node ID 6bf007b78f5c5f9e9bf4721dd4e4bc956f6f343f
+# Parent  d514062cbfff28dc38f4b429df12f0d174f960e6
+8001043: Clarify definition restrictions
+Reviewed-by: alanb, skoivu, smarks
+
+diff --git a/src/share/classes/sun/rmi/server/LoaderHandler.java b/src/share/classes/sun/rmi/server/LoaderHandler.java
+--- openjdk/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java
++++ openjdk/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java
+@@ -55,6 +55,7 @@
+ import java.util.Map;
+ import java.util.StringTokenizer;
+ import java.util.WeakHashMap;
++import sun.reflect.misc.ReflectUtil;
+ import sun.rmi.runtime.Log;
+ import sun.security.action.GetPropertyAction;
+ 
+@@ -168,7 +169,7 @@
+ 
+         if (defaultLoader != null) {
+             try {
+-                Class c = Class.forName(name, false, defaultLoader);
++                Class c = loadClassForName(name, false, defaultLoader);
+                 if (loaderLog.isLoggable(Log.VERBOSE)) {
+                     loaderLog.log(Log.VERBOSE,
+                         "class \"" + name + "\" found via defaultLoader, " +
+@@ -373,7 +374,7 @@
+         SecurityManager sm = System.getSecurityManager();
+         if (sm == null) {
+             try {
+-                Class c = Class.forName(name, false, parent);
++                Class c = loadClassForName(name, false, parent);
+                 if (loaderLog.isLoggable(Log.VERBOSE)) {
+                     loaderLog.log(Log.VERBOSE,
+                         "class \"" + name + "\" found via " +
+@@ -422,7 +423,7 @@
+                  * resolved without the security-offending codebase anyway;
+                  * if so, return successfully (see bugids 4191926 & 4349670).
+                  */
+-                Class c = Class.forName(name, false, parent);
++                Class c = loadClassForName(name, false, parent);
+                 if (loaderLog.isLoggable(Log.VERBOSE)) {
+                     loaderLog.log(Log.VERBOSE,
+                         "class \"" + name + "\" found via " +
+@@ -448,7 +449,7 @@
+         }
+ 
+         try {
+-            Class c = Class.forName(name, false, loader);
++            Class c = loadClassForName(name, false, loader);
+             if (loaderLog.isLoggable(Log.VERBOSE)) {
+                 loaderLog.log(Log.VERBOSE,
+                     "class \"" + name + "\" " + "found via codebase, " +
+@@ -726,7 +727,7 @@
+ 
+         for (int i = 0; i < interfaces.length; i++) {
+             Class cl =
+-                (classObjs[i] = Class.forName(interfaces[i], false, loader));
++                (classObjs[i] = loadClassForName(interfaces[i], false, loader));
+ 
+             if (!Modifier.isPublic(cl.getModifiers())) {
+                 ClassLoader current = cl.getClassLoader();
+@@ -1194,5 +1195,27 @@
+         public String toString() {
+             return super.toString() + "[\"" + annotation + "\"]";
+         }
++
++        @Override
++        protected Class<?> loadClass(String name, boolean resolve)
++                throws ClassNotFoundException {
++            if (parent == null) {
++                ReflectUtil.checkPackageAccess(name);
++            }
++            return super.loadClass(name, resolve);
++        }
++
+     }
++
++    private static Class<?> loadClassForName(String name,
++                                              boolean initialize,
++                                              ClassLoader loader)
++            throws ClassNotFoundException
++    {
++        if (loader == null) {
++            ReflectUtil.checkPackageAccess(name);
++        }
++        return Class.forName(name, initialize, loader);
++    }
++
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001309-better_handling_of_annotation_interfaces.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,36 @@
+# HG changeset patch
+# User andrew
+# Date 1371236018 -3600
+# Node ID 1226e37bd53ebb2c4fbb9d71dd60ee5e226c9f1b
+# Parent  6bf007b78f5c5f9e9bf4721dd4e4bc956f6f343f
+8001309: Better handling of annotation interfaces
+Reviewed-by: darcy
+
+diff --git a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
+--- openjdk/jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
++++ openjdk/jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -337,12 +337,15 @@
+         try {
+             annotationType = AnnotationType.getInstance(type);
+         } catch(IllegalArgumentException e) {
+-            // Class is no longer an annotation type; all bets are off
+-            return;
++            // Class is no longer an annotation type; time to punch out
++            throw new java.io.InvalidObjectException("Non-annotation type in annotation serial stream");
+         }
+ 
+         Map<String, Class> memberTypes = annotationType.memberTypes();
+ 
++
++        // If there are annotation members without values, that
++        // situation is handled by the invoke method.
+         for (Map.Entry<String, Object> memberValue : memberValues.entrySet()) {
+             String name = memberValue.getKey();
+             Class memberType = memberTypes.get(name);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001318-6_fixup.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,114 @@
+# HG changeset patch
+# User andrew
+# Date 1371826938 18000
+# Node ID ccd06d9c7258aea155d7053d399431bcd1af4405
+# Parent  662fbd43808413b2bd7ae4ae95683da98999023e
+Fix up 8001318
+
+diff --git a/src/share/classes/java/net/ServerSocket.java b/src/share/classes/java/net/ServerSocket.java
+--- openjdk/jdk/src/share/classes/java/net/ServerSocket.java
++++ openjdk/jdk/src/share/classes/java/net/ServerSocket.java
+@@ -363,7 +363,7 @@
+             }
+             return in;
+         } catch (SecurityException e) {
+-            return InetAddress.getLoopbackAddress();
++            return InetAddress.impl.loopbackAddress();
+         } catch (SocketException e) {
+             // nothing
+             // If we're bound, the impl has been created
+@@ -675,7 +675,7 @@
+         if (!NetUtil.doRevealLocalAddress() &&
+                 System.getSecurityManager() != null)
+         {
+-            in = InetAddress.getLoopbackAddress();
++            in = InetAddress.impl.loopbackAddress();
+         } else {
+             in = impl.getInetAddress();
+         }
+diff --git a/src/share/classes/java/net/Socket.java b/src/share/classes/java/net/Socket.java
+--- openjdk/jdk/src/share/classes/java/net/Socket.java
++++ openjdk/jdk/src/share/classes/java/net/Socket.java
+@@ -666,7 +666,7 @@
+                 in = InetAddress.anyLocalAddress();
+             }
+         } catch (SecurityException e) {
+-            in = InetAddress.getLoopbackAddress();
++            in = InetAddress.impl.loopbackAddress();
+         } catch (Exception e) {
+             in = InetAddress.anyLocalAddress(); // "0.0.0.0"
+         }
+diff --git a/src/share/classes/sun/nio/ch/Net.java b/src/share/classes/sun/nio/ch/Net.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/Net.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/Net.java
+@@ -29,7 +29,8 @@
+ import java.lang.reflect.*;
+ import java.net.*;
+ import java.nio.channels.*;
+-
++import java.security.AccessController;
++import java.security.PrivilegedExceptionAction;
+ 
+ class Net {                                             // package-private
+ 
+@@ -233,4 +234,60 @@
+         initIDs();
+     }
+ 
++     /**
++     * Returns the local address after performing a SecurityManager#checkConnect.
++     */
++    static InetSocketAddress getRevealedLocalAddress(InetSocketAddress addr) {
++        SecurityManager sm = System.getSecurityManager();
++        if (addr == null || sm == null)
++            return addr;
++
++        if (!getRevealLocalAddress()) {
++            // Return loopback address only if security check fails
++            try{
++                sm.checkConnect(addr.getAddress().getHostAddress(), -1);
++                //Security check passed
++            } catch (SecurityException e) {
++                //Return loopback address
++                addr = getLoopbackAddress(addr.getPort());
++            }
++        }
++        return addr;
++    }
++
++    static String getRevealedLocalAddressAsString(InetSocketAddress addr) {
++        if (!getRevealLocalAddress() && System.getSecurityManager() != null)
++            addr = getLoopbackAddress(addr.getPort());
++        return addr.toString();
++    }
++
++    private static boolean getRevealLocalAddress() {
++        if (!propRevealLocalAddress) {
++            try {
++                revealLocalAddress = Boolean.parseBoolean(
++                      AccessController.doPrivileged(
++                          new PrivilegedExceptionAction<String>() {
++                              public String run() {
++                                  return System.getProperty(
++                                      "jdk.net.revealLocalAddress");
++                              }
++                          }));
++
++            } catch (Exception e) {
++                // revealLocalAddress is false
++            }
++            propRevealLocalAddress = true;
++        }
++        return revealLocalAddress;
++    }
++
++    private static InetSocketAddress getLoopbackAddress(int port) {
++	try {
++	    return new InetSocketAddress(InetAddress.getByName(null),
++					 port);
++	} catch (UnknownHostException e) { 
++	    throw new InternalError("Shouldn't reach here.");
++	}
++    }
++
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001318-socket_getlocaladdress_consistency.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,470 @@
+# HG changeset patch
+# User andrew
+# Date 1371237878 -3600
+# Node ID f2c674e184e04dcd8e39b6ba6f784c75a3553ef5
+# Parent  1226e37bd53ebb2c4fbb9d71dd60ee5e226c9f1b
+8001318: Socket.getLocalAddress not consistent with InetAddress.getLocalHost
+
+diff --git a/src/share/classes/java/net/NetUtil.java b/src/share/classes/java/net/NetUtil.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/java/net/NetUtil.java
+@@ -0,0 +1,73 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package java.net;
++
++import java.security.AccessController;
++import java.security.PrivilegedExceptionAction;
++
++class NetUtil {
++
++    // Value of jdk.net.revealLocalAddress
++    private static boolean revealLocalAddress;
++
++    // True if jdk.net.revealLocalAddress had been read
++    private static volatile boolean propRevealLocalAddr;
++
++    /*
++     * Returns true if security check on localAddress is disabled
++     */
++    static boolean doRevealLocalAddress() {
++        return propRevealLocalAddr ? revealLocalAddress
++                                     : readRevealLocalAddr();
++
++    }
++
++    private static boolean readRevealLocalAddr() {
++        SecurityManager sm = System.getSecurityManager();
++        if (sm != null) {
++            try {
++                revealLocalAddress = Boolean.parseBoolean(
++                      AccessController.doPrivileged(
++                          new PrivilegedExceptionAction<String>() {
++                              public String run() {
++                                  return System.getProperty(
++                                      "jdk.net.revealLocalAddress");
++                              }
++                          }));
++
++            } catch (Exception e) {
++                //revealLocalAddress is false
++            }
++            propRevealLocalAddr = true;
++        }
++        /*
++         * No security manager, or security check passed or
++         * jdk.net.revealLocalAddress set to true
++         */
++        return revealLocalAddress;
++    }
++
++}
+diff --git a/src/share/classes/java/net/ServerSocket.java b/src/share/classes/java/net/ServerSocket.java
+--- openjdk/jdk/src/share/classes/java/net/ServerSocket.java
++++ openjdk/jdk/src/share/classes/java/net/ServerSocket.java
+@@ -355,7 +355,15 @@
+         if (!isBound())
+             return null;
+         try {
+-            return getImpl().getInetAddress();
++            InetAddress in = getImpl().getInetAddress();
++            if (!NetUtil.doRevealLocalAddress()) {
++                SecurityManager sm = System.getSecurityManager();
++                if (sm != null)
++                    sm.checkConnect(in.getHostAddress(), -1);
++            }
++            return in;
++        } catch (SecurityException e) {
++            return InetAddress.getLoopbackAddress();
+         } catch (SocketException e) {
+             // nothing
+             // If we're bound, the impl has been created
+@@ -660,13 +668,20 @@
+      *
+      * @return  a string representation of this socket.
+      */
+-    public String toString() {
++   public String toString() {
+         if (!isBound())
+             return "ServerSocket[unbound]";
+-        return "ServerSocket[addr=" + impl.getInetAddress() +
+-                ",port=" + impl.getPort() +
++        InetAddress in;
++        if (!NetUtil.doRevealLocalAddress() &&
++                System.getSecurityManager() != null)
++        {
++            in = InetAddress.getLoopbackAddress();
++        } else {
++            in = impl.getInetAddress();
++        }
++        return "ServerSocket[addr=" + in +
+                 ",localport=" + impl.getLocalPort()  + "]";
+-    }
++   }
+ 
+     void setBound() {
+         bound = true;
+diff --git a/src/share/classes/java/net/Socket.java b/src/share/classes/java/net/Socket.java
+--- openjdk/jdk/src/share/classes/java/net/Socket.java
++++ openjdk/jdk/src/share/classes/java/net/Socket.java
+@@ -656,9 +656,17 @@
+         InetAddress in = null;
+         try {
+             in = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
++
++            if (!NetUtil.doRevealLocalAddress()) {
++                SecurityManager sm = System.getSecurityManager();
++                if (sm != null)
++                    sm.checkConnect(in.getHostAddress(), -1);
++            }
+             if (in.isAnyLocalAddress()) {
+                 in = InetAddress.anyLocalAddress();
+             }
++        } catch (SecurityException e) {
++            in = InetAddress.getLoopbackAddress();
+         } catch (Exception e) {
+             in = InetAddress.anyLocalAddress(); // "0.0.0.0"
+         }
+diff --git a/src/share/classes/java/net/SocksSocketImpl.java b/src/share/classes/java/net/SocksSocketImpl.java
+--- openjdk/jdk/src/share/classes/java/net/SocksSocketImpl.java
++++ openjdk/jdk/src/share/classes/java/net/SocksSocketImpl.java
+@@ -28,6 +28,7 @@
+ import java.io.OutputStream;
+ import java.io.BufferedOutputStream;
+ import java.security.AccessController;
++import java.security.PrivilegedAction;
+ import java.security.PrivilegedExceptionAction;
+ import java.util.prefs.Preferences;
+ import sun.net.www.ParseUtil;
+@@ -584,7 +585,13 @@
+         /* Test for AnyLocal */
+         InetAddress naddr = baddr;
+         if (naddr.isAnyLocalAddress()) {
+-            naddr = cmdsock.getLocalAddress();
++            naddr = AccessController.doPrivileged(
++                        new PrivilegedAction<InetAddress>() {
++                            public InetAddress run() {
++                                return cmdsock.getLocalAddress();
++
++                            }
++                        });
+             addr1 = naddr.getAddress();
+         }
+         out.write(PROTO_VERS4);
+diff --git a/src/share/classes/sun/net/NetworkClient.java b/src/share/classes/sun/net/NetworkClient.java
+--- openjdk/jdk/src/share/classes/sun/net/NetworkClient.java
++++ openjdk/jdk/src/share/classes/sun/net/NetworkClient.java
+@@ -198,7 +198,13 @@
+     protected InetAddress getLocalAddress() throws IOException {
+         if (serverSocket == null)
+             throw new IOException("not connected");
+-        return serverSocket.getLocalAddress();
++        return  AccessController.doPrivileged(
++                        new PrivilegedAction<InetAddress>() {
++                            public InetAddress run() {
++                                return serverSocket.getLocalAddress();
++
++                            }
++                        });
+     }
+ 
+     /** Close an open connection to the server. */
+diff --git a/src/share/classes/sun/net/httpserver/ServerImpl.java b/src/share/classes/sun/net/httpserver/ServerImpl.java
+--- openjdk/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java
++++ openjdk/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java
+@@ -30,6 +30,8 @@
+ import java.nio.*;
+ import java.security.*;
+ import java.nio.channels.*;
++import java.security.AccessController;
++import java.security.PrivilegedAction;
+ import java.util.*;
+ import java.util.concurrent.*;
+ import java.util.logging.Logger;
+@@ -222,7 +224,14 @@
+     }
+ 
+     public InetSocketAddress getAddress() {
+-        return (InetSocketAddress)schan.socket().getLocalSocketAddress();
++        return AccessController.doPrivileged(
++                new PrivilegedAction<InetSocketAddress>() {
++                    public InetSocketAddress run() {
++                        return
++                            (InetSocketAddress)schan.socket()
++                                .getLocalSocketAddress();
++                    }
++                });
+     }
+ 
+     Selector getSelector () {
+diff --git a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+@@ -83,8 +83,8 @@
+     private int state = ST_UNINITIALIZED;
+ 
+     // Binding
+-    private SocketAddress localAddress = null;
+-    SocketAddress remoteAddress = null;
++    private InetSocketAddress localAddress = null;
++    InetSocketAddress remoteAddress = null;
+ 
+     // Options
+     private SocketOpts.IP options = null;
+@@ -500,7 +500,7 @@
+                 InetSocketAddress isa = (InetSocketAddress)localAddress;
+                 sm.checkConnect(isa.getAddress().getHostAddress(), -1);
+             }
+-            return localAddress;
++            return Net.getRevealedLocalAddress(localAddress);
+         }
+     }
+ 
+@@ -543,6 +543,7 @@
+         }
+     }
+ 
++    @Override
+     public DatagramChannel connect(SocketAddress sa) throws IOException {
+         int trafficClass = 0;
+         int localPort = 0;
+@@ -565,7 +566,7 @@
+ 
+                     // Connection succeeded; disallow further invocation
+                     state = ST_CONNECTED;
+-                    remoteAddress = sa;
++                    remoteAddress = isa;
+                     sender = isa;
+                     cachedSenderInetAddress = isa.getAddress();
+                     cachedSenderPort = isa.getPort();
+@@ -581,7 +582,7 @@
+                 synchronized (stateLock) {
+                     if (!isConnected() || !isOpen())
+                         return this;
+-                    InetSocketAddress isa = (InetSocketAddress)remoteAddress;
++                    InetSocketAddress isa = remoteAddress;
+                     SecurityManager sm = System.getSecurityManager();
+                     if (sm != null)
+                         sm.checkConnect(isa.getAddress().getHostAddress(),
+diff --git a/src/share/classes/sun/nio/ch/Net.java b/src/share/classes/sun/nio/ch/Net.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/Net.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/Net.java
+@@ -36,6 +36,12 @@
+     private Net() { }
+ 
+ 
++    // Value of jdk.net.revealLocalAddress
++    private static boolean revealLocalAddress;
++
++    // True if jdk.net.revealLocalAddress had been read
++    private static volatile boolean propRevealLocalAddress;
++
+     // set to true if exclusive binding is on for Windows
+     private static final boolean exclusiveBind;
+ 
+diff --git a/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java b/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/ServerSocketAdaptor.java
+@@ -83,7 +83,8 @@
+     public InetAddress getInetAddress() {
+         if (!ssc.isBound())
+             return null;
+-        return Net.asInetSocketAddress(ssc.localAddress()).getAddress();
++        return Net.getRevealedLocalAddress(ssc.localAddress()).getAddress();
++
+     }
+ 
+     public int getLocalPort() {
+diff --git a/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java b/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/ServerSocketChannelImpl.java
+@@ -75,7 +75,7 @@
+     private int state = ST_UNINITIALIZED;
+ 
+     // Binding
+-    private SocketAddress localAddress = null; // null => unbound
++    private InetSocketAddress localAddress; // null => unbound
+ 
+     // Options, created on demand
+     private SocketOpts.IP.TCP options = null;
+@@ -118,9 +118,11 @@
+         }
+     }
+ 
+-    public SocketAddress localAddress() {
++    public InetSocketAddress localAddress() {
+         synchronized (stateLock) {
+-            return localAddress;
++            return localAddress == null? localAddress
++                    : Net.getRevealedLocalAddress(
++                          Net.asInetSocketAddress(localAddress));
+         }
+     }
+ 
+@@ -307,14 +309,15 @@
+         StringBuffer sb = new StringBuffer();
+         sb.append(this.getClass().getName());
+         sb.append('[');
+-        if (!isOpen())
++        if (!isOpen()) {
+             sb.append("closed");
+-        else {
++        } else {
+             synchronized (stateLock) {
+-                if (localAddress() == null) {
++                InetSocketAddress addr = localAddress();
++                if (addr == null) {
+                     sb.append("unbound");
+                 } else {
+-                    sb.append(localAddress().toString());
++                    sb.append(Net.getRevealedLocalAddressAsString(addr));
+                 }
+             }
+         }
+diff --git a/src/share/classes/sun/nio/ch/SocketAdaptor.java b/src/share/classes/sun/nio/ch/SocketAdaptor.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java
+@@ -162,7 +162,7 @@
+     public InetAddress getLocalAddress() {
+         if (!sc.isBound())
+             return new InetSocketAddress(0).getAddress();
+-        return Net.asInetSocketAddress(sc.localAddress()).getAddress();
++        return Net.getRevealedLocalAddress(sc.localAddress()).getAddress();
+     }
+ 
+     public int getPort() {
+diff --git a/src/share/classes/sun/nio/ch/SocketChannelImpl.java b/src/share/classes/sun/nio/ch/SocketChannelImpl.java
+--- openjdk/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java
++++ openjdk/jdk/src/share/classes/sun/nio/ch/SocketChannelImpl.java
+@@ -78,8 +78,8 @@
+     private int state = ST_UNINITIALIZED;
+ 
+     // Binding
+-    private SocketAddress localAddress = null;
+-    private SocketAddress remoteAddress = null;
++    private InetSocketAddress localAddress;
++    private InetSocketAddress remoteAddress;
+ 
+     // Input/Output open
+     private boolean isInputOpen = true;
+@@ -443,7 +443,7 @@
+         }
+     }
+ 
+-    public SocketAddress localAddress() {
++    public InetSocketAddress localAddress() {
+         synchronized (stateLock) {
+             if (state == ST_CONNECTED &&
+                 (localAddress == null ||
+@@ -452,7 +452,7 @@
+                     // Socket was bound with an "anyLocalAddress"
+                     localAddress = Net.localAddress(fd);
+             }
+-            return localAddress;
++            return  Net.getRevealedLocalAddress(localAddress);
+         }
+     }
+ 
+@@ -830,6 +830,7 @@
+         return fdVal;
+     }
+ 
++    @Override
+     public String toString() {
+         StringBuffer sb = new StringBuffer();
+         sb.append(this.getClass().getSuperclass().getName());
+@@ -853,9 +854,10 @@
+                         sb.append(" oshut");
+                     break;
+                 }
+-                if (localAddress() != null) {
++                InetSocketAddress addr = localAddress();
++                if (addr != null) {
+                     sb.append(" local=");
+-                    sb.append(localAddress().toString());
++                    sb.append(Net.getRevealedLocalAddressAsString(addr));
+                 }
+                 if (remoteAddress() != null) {
+                     sb.append(" remote=");
+diff --git a/src/share/classes/sun/rmi/server/Activation.java b/src/share/classes/sun/rmi/server/Activation.java
+--- openjdk/jdk/src/share/classes/sun/rmi/server/Activation.java
++++ openjdk/jdk/src/share/classes/sun/rmi/server/Activation.java
+@@ -2202,7 +2202,12 @@
+         }
+ 
+         public InetAddress getInetAddress() {
+-            return serverSocket.getInetAddress();
++            return AccessController.doPrivileged(
++                new PrivilegedAction<InetAddress>() {
++                    public InetAddress run() {
++                        return serverSocket.getInetAddress();
++                    }
++                });
+         }
+ 
+         public int getLocalPort() {
+@@ -2210,7 +2215,12 @@
+         }
+ 
+         public SocketAddress getLocalSocketAddress() {
+-            return serverSocket.getLocalSocketAddress();
++            return AccessController.doPrivileged(
++                new PrivilegedAction<SocketAddress>() {
++                    public SocketAddress run() {
++                        return serverSocket.getLocalSocketAddress();
++                    }
++                });
+         }
+ 
+         /**
+diff --git a/src/share/classes/sun/rmi/transport/proxy/WrappedSocket.java b/src/share/classes/sun/rmi/transport/proxy/WrappedSocket.java
+--- openjdk/jdk/src/share/classes/sun/rmi/transport/proxy/WrappedSocket.java
++++ openjdk/jdk/src/share/classes/sun/rmi/transport/proxy/WrappedSocket.java
+@@ -28,6 +28,8 @@
+ import java.net.InetAddress;
+ import java.net.Socket;
+ import java.net.SocketException;
++import java.security.AccessController;
++import java.security.PrivilegedAction;
+ 
+ /**
+  * The WrappedSocket class provides a general wrapper for providing an
+@@ -78,7 +80,13 @@
+      * Get the local address to which the socket is bound.
+      */
+     public InetAddress getLocalAddress() {
+-        return socket.getLocalAddress();
++        return  AccessController.doPrivileged(
++                        new PrivilegedAction<InetAddress>() {
++                            public InetAddress run() {
++                                return socket.getLocalAddress();
++
++                            }
++                        });
+     }
+ 
+     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001330-checking_order_improvement.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,380 @@
+# HG changeset patch
+# User andrew
+# Date 1371562887 18000
+# Node ID d521fcfccc58dce20f41178374292f2b8430686c
+# Parent  684f0c17ce15a3e012e9b73d618af1462f8c2d64
+8001330: Improve on checking order
+Reviewed-by: acorn, hawtin
+
+diff --git a/src/share/vm/classfile/javaClasses.cpp b/src/share/vm/classfile/javaClasses.cpp
+--- openjdk/hotspot/src/share/vm/classfile/javaClasses.cpp
++++ openjdk/hotspot/src/share/vm/classfile/javaClasses.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -2559,6 +2559,7 @@
+ int java_security_AccessControlContext::_context_offset = 0;
+ int java_security_AccessControlContext::_privilegedContext_offset = 0;
+ int java_security_AccessControlContext::_isPrivileged_offset = 0;
++int java_security_AccessControlContext::_isAuthorized_offset = -1;
+ 
+ void java_security_AccessControlContext::compute_offsets() {
+   assert(_isPrivileged_offset == 0, "offsets should be initialized only once");
+@@ -2579,9 +2580,20 @@
+     fatal("Invalid layout of java.security.AccessControlContext");
+   }
+   _isPrivileged_offset = fd.offset();
++
++  // The offset may not be present for bootstrapping with older JDK.
++  if (ik->find_local_field(vmSymbols::isAuthorized_name(), vmSymbols::bool_signature(), &fd)) {
++    _isAuthorized_offset = fd.offset();
++  }
+ }
+ 
+ 
++bool java_security_AccessControlContext::is_authorized(Handle context) {
++  assert(context.not_null() && context->klass() == SystemDictionary::AccessControlContext_klass(), "Invalid type");
++  assert(_isAuthorized_offset != -1, "should be set");
++  return context->bool_field(_isAuthorized_offset) != 0;
++}
++
+ oop java_security_AccessControlContext::create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS) {
+   assert(_isPrivileged_offset != 0, "offsets should have been initialized");
+   // Ensure klass is initialized
+@@ -2592,6 +2604,8 @@
+   result->obj_field_put(_context_offset, context());
+   result->obj_field_put(_privilegedContext_offset, privileged_context());
+   result->bool_field_put(_isPrivileged_offset, isPrivileged);
++  // whitelist AccessControlContexts created by the JVM.
++  result->bool_field_put(_isAuthorized_offset, true);
+   return result;
+ }
+ 
+@@ -2656,6 +2670,15 @@
+ }
+ 
+ 
++bool java_lang_System::has_security_manager() {
++  instanceKlass* ik = instanceKlass::cast(SystemDictionary::System_klass());
++  address addr = ik->static_field_addr(static_security_offset);
++  if (UseCompressedOops) {
++    return oopDesc::load_decode_heap_oop((narrowOop *)addr) != NULL;
++  } else {
++    return oopDesc::load_decode_heap_oop((oop*)addr) != NULL;
++  }
++}
+ 
+ int java_lang_String::value_offset;
+ int java_lang_String::offset_offset;
+@@ -2712,6 +2735,7 @@
+ int java_lang_System::static_in_offset;
+ int java_lang_System::static_out_offset;
+ int java_lang_System::static_err_offset;
++int java_lang_System::static_security_offset;
+ int java_lang_StackTraceElement::declaringClass_offset;
+ int java_lang_StackTraceElement::methodName_offset;
+ int java_lang_StackTraceElement::fileName_offset;
+@@ -2866,6 +2890,7 @@
+   java_lang_System::static_in_offset  = java_lang_System::hc_static_in_offset  * x;
+   java_lang_System::static_out_offset = java_lang_System::hc_static_out_offset * x;
+   java_lang_System::static_err_offset = java_lang_System::hc_static_err_offset * x;
++  java_lang_System::static_security_offset = java_lang_System::hc_static_security_offset * x;
+ 
+   // java_lang_StackTraceElement
+   java_lang_StackTraceElement::declaringClass_offset = java_lang_StackTraceElement::hc_declaringClass_offset  * x + header;
+@@ -3067,6 +3092,7 @@
+   CHECK_STATIC_OFFSET("java/lang/System", java_lang_System,  in, "Ljava/io/InputStream;");
+   CHECK_STATIC_OFFSET("java/lang/System", java_lang_System, out, "Ljava/io/PrintStream;");
+   CHECK_STATIC_OFFSET("java/lang/System", java_lang_System, err, "Ljava/io/PrintStream;");
++  CHECK_STATIC_OFFSET("java/lang/System", java_lang_System, security, "Ljava/lang/SecurityManager;");
+ 
+   // java.lang.StackTraceElement
+ 
+diff --git a/src/share/vm/classfile/javaClasses.hpp b/src/share/vm/classfile/javaClasses.hpp
+--- openjdk/hotspot/src/share/vm/classfile/javaClasses.hpp
++++ openjdk/hotspot/src/share/vm/classfile/javaClasses.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -1146,11 +1146,14 @@
+   static int _context_offset;
+   static int _privilegedContext_offset;
+   static int _isPrivileged_offset;
++  static int _isAuthorized_offset;
+ 
+   static void compute_offsets();
+  public:
+   static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS);
+ 
++  static bool is_authorized(Handle context);
++
+   // Debugging/initialization
+   friend class JavaClasses;
+ };
+@@ -1186,13 +1189,15 @@
+   enum {
+    hc_static_in_offset  = 0,
+    hc_static_out_offset = 1,
+-   hc_static_err_offset = 2
++   hc_static_err_offset = 2,
++   hc_static_security_offset = 3
+   };
+ 
+   static int offset_of_static_fields;
+   static int  static_in_offset;
+   static int static_out_offset;
+   static int static_err_offset;
++  static int static_security_offset;
+ 
+   static void compute_offsets();
+ 
+@@ -1201,6 +1206,8 @@
+   static int out_offset_in_bytes();
+   static int err_offset_in_bytes();
+ 
++  static bool has_security_manager();
++
+   // Debugging
+   friend class JavaClasses;
+ };
+diff --git a/src/share/vm/classfile/vmSymbols.hpp b/src/share/vm/classfile/vmSymbols.hpp
+--- openjdk/hotspot/src/share/vm/classfile/vmSymbols.hpp
++++ openjdk/hotspot/src/share/vm/classfile/vmSymbols.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -93,6 +93,7 @@
+   template(java_lang_CharSequence,                    "java/lang/CharSequence")                   \
+   template(java_security_AccessControlContext,        "java/security/AccessControlContext")       \
+   template(java_security_ProtectionDomain,            "java/security/ProtectionDomain")           \
++  template(impliesCreateAccessControlContext_name,    "impliesCreateAccessControlContext")        \
+   template(java_io_OutputStream,                      "java/io/OutputStream")                     \
+   template(java_io_Reader,                            "java/io/Reader")                           \
+   template(java_io_BufferedReader,                    "java/io/BufferedReader")                   \
+@@ -315,6 +316,7 @@
+   template(contextClassLoader_name,                   "contextClassLoader")                       \
+   template(inheritedAccessControlContext_name,        "inheritedAccessControlContext")            \
+   template(isPrivileged_name,                         "isPrivileged")                             \
++  template(isAuthorized_name,                         "isAuthorized")                             \
+   template(wait_name,                                 "wait")                                     \
+   template(checkPackageAccess_name,                   "checkPackageAccess")                       \
+   template(stackSize_name,                            "stackSize")                                \
+diff --git a/src/share/vm/memory/universe.cpp b/src/share/vm/memory/universe.cpp
+--- openjdk/hotspot/src/share/vm/memory/universe.cpp
++++ openjdk/hotspot/src/share/vm/memory/universe.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -143,6 +143,7 @@
+ oop Universe::_the_min_jint_string                   = NULL;
+ LatestMethodOopCache* Universe::_finalizer_register_cache = NULL;
+ LatestMethodOopCache* Universe::_loader_addClass_cache    = NULL;
++LatestMethodOopCache* Universe::_pd_implies_cache         = NULL;
+ ActiveMethodOopsCache* Universe::_reflect_invoke_cache    = NULL;
+ oop Universe::_out_of_memory_error_java_heap          = NULL;
+ oop Universe::_out_of_memory_error_perm_gen           = NULL;
+@@ -265,6 +266,7 @@
+   f->do_oop((oop*)&_the_min_jint_string);
+   _finalizer_register_cache->oops_do(f);
+   _loader_addClass_cache->oops_do(f);
++  _pd_implies_cache->oops_do(f);
+   _reflect_invoke_cache->oops_do(f);
+   f->do_oop((oop*)&_out_of_memory_error_java_heap);
+   f->do_oop((oop*)&_out_of_memory_error_perm_gen);
+@@ -787,6 +789,7 @@
+   // CompactingPermGenGen::initialize_oops() tries to populate them.
+   Universe::_finalizer_register_cache = new LatestMethodOopCache();
+   Universe::_loader_addClass_cache    = new LatestMethodOopCache();
++  Universe::_pd_implies_cache         = new LatestMethodOopCache();
+   Universe::_reflect_invoke_cache     = new ActiveMethodOopsCache();
+ 
+   if (UseSharedSpaces) {
+@@ -1137,6 +1140,23 @@
+   Universe::_loader_addClass_cache->init(
+     SystemDictionary::ClassLoader_klass(), m, CHECK_false);
+ 
++  // Setup method for checking protection domain
++  instanceKlass::cast(SystemDictionary::ProtectionDomain_klass())->link_class(CHECK_false);
++  m = instanceKlass::cast(SystemDictionary::ProtectionDomain_klass())->
++            find_method(vmSymbols::impliesCreateAccessControlContext_name(),
++                        vmSymbols::void_boolean_signature());
++  // Allow NULL which should only happen with bootstrapping.
++  if (m != NULL) {
++    if (m->is_static()) {
++      // NoSuchMethodException doesn't actually work because it tries to run the
++      // <init> function before java_lang_Class is linked. Print error and exit.
++      tty->print_cr("ProtectionDomain.impliesCreateAccessControlContext() has the wrong linkage");
++      return false; // initialization failed
++    }
++    Universe::_pd_implies_cache->init(
++      SystemDictionary::ProtectionDomain_klass(), m, CHECK_false);;
++  }
++
+   // The folowing is initializing converter functions for serialization in
+   // JVM.cpp. If we clean up the StrictMath code above we may want to find
+   // a better solution for this as well.
+@@ -1570,6 +1590,7 @@
+ 
+ 
+ methodOop LatestMethodOopCache::get_methodOop() {
++  if (klass() == NULL) return NULL;
+   instanceKlass* ik = instanceKlass::cast(klass());
+   methodOop m = ik->method_with_idnum(method_idnum());
+   assert(m != NULL, "sanity check");
+diff --git a/src/share/vm/memory/universe.hpp b/src/share/vm/memory/universe.hpp
+--- openjdk/hotspot/src/share/vm/memory/universe.hpp
++++ openjdk/hotspot/src/share/vm/memory/universe.hpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -179,6 +179,7 @@
+   static oop          _the_min_jint_string;          // A cache of "-2147483648" as a Java string
+   static LatestMethodOopCache* _finalizer_register_cache; // static method for registering finalizable objects
+   static LatestMethodOopCache* _loader_addClass_cache;    // method for registering loaded classes in class loader vector
++  static LatestMethodOopCache* _pd_implies_cache;         // method for checking protection domain attributes
+   static ActiveMethodOopsCache* _reflect_invoke_cache;    // method for security checks
+   static oop          _out_of_memory_error_java_heap; // preallocated error object (no backtrace)
+   static oop          _out_of_memory_error_perm_gen;  // preallocated error object (no backtrace)
+@@ -322,6 +323,7 @@
+   static oop          the_min_jint_string()          { return _the_min_jint_string;          }
+   static methodOop    finalizer_register_method()     { return _finalizer_register_cache->get_methodOop(); }
+   static methodOop    loader_addClass_method()        { return _loader_addClass_cache->get_methodOop(); }
++  static methodOop protection_domain_implies_method() { return _pd_implies_cache->get_methodOop(); }
+   static ActiveMethodOopsCache* reflect_invoke_cache() { return _reflect_invoke_cache; }
+   static oop          null_ptr_exception_instance()   { return _null_ptr_exception_instance;   }
+   static oop          arithmetic_exception_instance() { return _arithmetic_exception_instance; }
+diff --git a/src/share/vm/prims/jvm.cpp b/src/share/vm/prims/jvm.cpp
+--- openjdk/hotspot/src/share/vm/prims/jvm.cpp
++++ openjdk/hotspot/src/share/vm/prims/jvm.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -1101,6 +1101,56 @@
+   }
+ JVM_END
+ 
++static bool is_authorized(Handle context, instanceKlassHandle klass, TRAPS) {
++  // If there is a security manager and protection domain, check the access
++  // in the protection domain, otherwise it is authorized.
++  if (java_lang_System::has_security_manager()) {
++
++    // For bootstrapping, if pd implies method isn't in the JDK, allow
++    // this context to revert to older behavior.
++    // In this case the isAuthorized field in AccessControlContext is also not
++    // present.
++    if (Universe::protection_domain_implies_method() == NULL) {
++      return true;
++    }
++
++    // Whitelist certain access control contexts
++    if (java_security_AccessControlContext::is_authorized(context)) {
++      return true;
++    }
++
++    oop prot = klass->protection_domain();
++    if (prot != NULL) {
++      // Call pd.implies(new SecurityPermission("createAccessControlContext"))
++      // in the new wrapper.
++      methodHandle m(THREAD, Universe::protection_domain_implies_method());
++      Handle h_prot(THREAD, prot);
++      JavaValue result(T_BOOLEAN);
++      JavaCallArguments args(h_prot);
++      JavaCalls::call(&result, m, &args, CHECK_false);
++      return (result.get_jboolean() != 0);
++    }
++  }
++  return true;
++}
++
++// Create an AccessControlContext with a protection domain with null codesource
++// and null permissions - which gives no permissions.
++oop create_dummy_access_control_context(TRAPS) {
++  instanceKlassHandle pd_klass (THREAD, SystemDictionary::ProtectionDomain_klass());
++  // new ProtectionDomain(null,null);
++  oop null_protection_domain = pd_klass->allocate_instance(CHECK_NULL);
++  Handle null_pd(THREAD, null_protection_domain);
++
++  // new ProtectionDomain[] {pd};
++  objArrayOop context = oopFactory::new_objArray(pd_klass(), 1, CHECK_NULL);
++  context->obj_at_put(0, null_pd());
++
++  // new AccessControlContext(new ProtectionDomain[] {pd})
++  objArrayHandle h_context(THREAD, context);
++  oop result = java_security_AccessControlContext::create(h_context, false, Handle(), CHECK_NULL);
++  return result;
++}
+ 
+ JVM_ENTRY(jobject, JVM_DoPrivileged(JNIEnv *env, jclass cls, jobject action, jobject context, jboolean wrapException))
+   JVMWrapper("JVM_DoPrivileged");
+@@ -1109,8 +1159,29 @@
+     THROW_MSG_0(vmSymbols::java_lang_NullPointerException(), "Null action");
+   }
+ 
+-  // Stack allocated list of privileged stack elements
+-  PrivilegedElement pi;
++  // Compute the frame initiating the do privileged operation and setup the privileged stack
++  vframeStream vfst(thread);
++  vfst.security_get_caller_frame(1);
++
++  if (vfst.at_end()) {
++    THROW_MSG_0(vmSymbols::java_lang_InternalError(), "no caller?");
++  }
++
++  methodOop method      = vfst.method();
++  instanceKlassHandle klass (THREAD, method->method_holder());
++
++  // Check that action object understands "Object run()"
++  Handle h_context;
++  if (context != NULL) {
++    h_context = Handle(THREAD, JNIHandles::resolve(context));
++    bool authorized = is_authorized(h_context, klass, CHECK_NULL);
++    if (!authorized) {
++      // Create an unprivileged access control object and call it's run function
++      // instead.
++      oop noprivs = create_dummy_access_control_context(CHECK_NULL);
++      h_context = Handle(THREAD, noprivs);
++    }
++  }
+ 
+   // Check that action object understands "Object run()"
+   Handle object (THREAD, JNIHandles::resolve(action));
+@@ -1124,12 +1195,10 @@
+     THROW_MSG_0(vmSymbols::java_lang_InternalError(), "No run method");
+   }
+ 
+-  // Compute the frame initiating the do privileged operation and setup the privileged stack
+-  vframeStream vfst(thread);
+-  vfst.security_get_caller_frame(1);
+-
++  // Stack allocated list of privileged stack elements
++  PrivilegedElement pi;
+   if (!vfst.at_end()) {
+-    pi.initialize(&vfst, JNIHandles::resolve(context), thread->privileged_stack_top(), CHECK_NULL);
++    pi.initialize(&vfst, h_context(), thread->privileged_stack_top(), CHECK_NULL);
+     thread->set_privileged_stack_top(&pi);
+   }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8001330-improve_checking_order.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,97 @@
+# HG changeset patch
+# User andrew
+# Date 1371238187 -3600
+# Node ID 66880d810dc10655031bfbbb1e4ea6ff66061f08
+# Parent  f2c674e184e04dcd8e39b6ba6f784c75a3553ef5
+8001330: Improve on checking order
+Reviewed-by: acorn, hawtin
+
+diff --git a/src/share/classes/java/security/AccessControlContext.java b/src/share/classes/java/security/AccessControlContext.java
+--- openjdk/jdk/src/share/classes/java/security/AccessControlContext.java
++++ openjdk/jdk/src/share/classes/java/security/AccessControlContext.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -79,7 +79,10 @@
+ public final class AccessControlContext {
+ 
+     private ProtectionDomain context[];
++    // isPrivileged and isAuthorized are referenced by the VM - do not remove
++    // or change their names
+     private boolean isPrivileged;
++    private boolean isAuthorized = false;
+ 
+     // Note: This field is directly used by the virtual machine
+     // native codes. Don't touch it.
+@@ -192,6 +195,7 @@
+         SecurityManager sm = System.getSecurityManager();
+         if (sm != null) {
+             sm.checkPermission(SecurityConstants.CREATE_ACC_PERMISSION);
++            this.isAuthorized = true;
+         }
+ 
+         this.context = acc.context;
+@@ -213,6 +217,7 @@
+             this.context = context.clone();
+         }
+         this.combiner = combiner;
++        this.isAuthorized = true;
+     }
+ 
+     /**
+@@ -220,10 +225,11 @@
+      */
+ 
+     AccessControlContext(ProtectionDomain context[],
+-                                 boolean isPrivileged)
++                         boolean isPrivileged)
+     {
+         this.context = context;
+         this.isPrivileged = isPrivileged;
++        this.isAuthorized = true;
+     }
+ 
+     /**
+@@ -504,7 +510,7 @@
+     }
+ 
+     private AccessControlContext goCombiner(ProtectionDomain[] current,
+-                                        AccessControlContext assigned) {
++                                            AccessControlContext assigned) {
+ 
+         // the assigned ACC's combiner is not null --
+         // let the combiner do its thing
+@@ -526,6 +532,7 @@
+         this.context = combinedPds;
+         this.combiner = assigned.combiner;
+         this.isPrivileged = false;
++        this.isAuthorized = assigned.isAuthorized;
+ 
+         return this;
+     }
+diff --git a/src/share/classes/java/security/ProtectionDomain.java b/src/share/classes/java/security/ProtectionDomain.java
+--- openjdk/jdk/src/share/classes/java/security/ProtectionDomain.java
++++ openjdk/jdk/src/share/classes/java/security/ProtectionDomain.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -246,6 +246,11 @@
+         return false;
+     }
+ 
++    // called by the VM -- do not remove
++    boolean impliesCreateAccessControlContext() {
++        return implies(SecurityConstants.CREATE_ACC_PERMISSION);
++    }
++
+     /**
+      * Convert a ProtectionDomain to a String.
+      */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8003703-update_rmi_connection_dialog.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,131 @@
+# HG changeset patch
+# User andrew
+# Date 1371238398 -3600
+# Node ID 672b00f8dd800d0b494cde9eb219bd82179c5ff5
+# Parent  66880d810dc10655031bfbbb1e4ea6ff66061f08
+8003703: Update RMI connection dialog box
+Reviewed-by: skoivu, ahgross, mchung, jbachorik
+
+diff --git a/src/share/classes/sun/tools/jconsole/ProxyClient.java b/src/share/classes/sun/tools/jconsole/ProxyClient.java
+--- openjdk/jdk/src/share/classes/sun/tools/jconsole/ProxyClient.java
++++ openjdk/jdk/src/share/classes/sun/tools/jconsole/ProxyClient.java
+@@ -309,11 +309,11 @@
+         }
+     }
+ 
+-    void connect() {
++    void connect(boolean requireSSL) {
+         setConnectionState(ConnectionState.CONNECTING);
+         Exception exception = null;
+         try {
+-            tryConnect();
++            tryConnect(requireSSL);
+         } catch (IOException ex) {
+             if (JConsole.isDebug()) {
+                 ex.printStackTrace();
+@@ -333,7 +333,7 @@
+         }
+     }
+ 
+-    private void tryConnect() throws IOException {
++    private void tryConnect(boolean requireRemoteSSL) throws IOException {
+         if (jmxUrl == null && "localhost".equals(hostName) && port == 0) {
+             // Monitor self
+             this.jmxc = null;
+@@ -353,6 +353,10 @@
+                     this.jmxUrl = new JMXServiceURL(lvm.connectorAddress());
+                 }
+             }
++            Map<String, Object> env = new HashMap<String, Object>();
++            if (requireRemoteSSL) {
++                env.put("jmx.remote.x.check.stub", "true");
++            }
+             // Need to pass in credentials ?
+             if (userName == null && password == null) {
+                 if (isVmConnector()) {
+@@ -361,12 +365,11 @@
+                         checkSslConfig();
+                     }
+                     this.jmxc = new RMIConnector(stub, null);
+-                    jmxc.connect();
++                    jmxc.connect(env);
+                 } else {
+-                    this.jmxc = JMXConnectorFactory.connect(jmxUrl);
++                    this.jmxc = JMXConnectorFactory.connect(jmxUrl, env);
+                 }
+             } else {
+-                Map<String, String[]> env = new HashMap<String, String[]>();
+                 env.put(JMXConnector.CREDENTIALS,
+                         new String[] {userName, password});
+                 if (isVmConnector()) {
+diff --git a/src/share/classes/sun/tools/jconsole/VMPanel.java b/src/share/classes/sun/tools/jconsole/VMPanel.java
+--- openjdk/jdk/src/share/classes/sun/tools/jconsole/VMPanel.java
++++ openjdk/jdk/src/share/classes/sun/tools/jconsole/VMPanel.java
+@@ -62,6 +62,7 @@
+     private static ArrayList<TabInfo> tabInfos = new ArrayList<TabInfo>();
+ 
+     private boolean wasConnected = false;
++    private boolean shouldUseSSL = true;
+ 
+     // The everConnected flag keeps track of whether the window can be
+     // closed if the user clicks Cancel after a failed connection attempt.
+@@ -295,7 +296,7 @@
+         } else {
+             new Thread("VMPanel.connect") {
+                 public void run() {
+-                    proxyClient.connect();
++                    proxyClient.connect(shouldUseSSL);
+                 }
+             }.start();
+         }
+@@ -472,6 +473,7 @@
+ 
+         final String connectStr   = getText("Connect");
+         final String reconnectStr = getText("Reconnect");
++        final String insecureStr = getText("Insecure");
+         final String cancelStr    = getText("Cancel");
+ 
+         String msgTitle, msgExplanation, buttonStr;
+@@ -481,6 +483,10 @@
+             msgTitle = getText("connectionLost1");
+             msgExplanation = getText("connectionLost2", getConnectionName());
+             buttonStr = reconnectStr;
++        } else if (shouldUseSSL) {
++            msgTitle = getText("connectionFailedSSL1");
++            msgExplanation = getText("connectionFailedSSL2", getConnectionName());
++            buttonStr = insecureStr;
+         } else {
+             msgTitle = getText("connectionFailed1");
+             msgExplanation = getText("connectionFailed2", getConnectionName());
+@@ -503,6 +509,9 @@
+ 
+                     if (value == reconnectStr || value == connectStr) {
+                         connect();
++                    } else if (value == insecureStr) {
++                        shouldUseSSL = false;
++                        connect();
+                     } else if (!everConnected) {
+                         try {
+                             getFrame().setClosed(true);
+diff --git a/src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java b/src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java
+--- openjdk/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java
++++ openjdk/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources.java
+@@ -212,6 +212,7 @@
+         {"Impact","Impact"},
+         {"Info","Info"},
+         {"INFO","INFO"},
++        {"Insecure", "Insecure connection"},
+         {"Invalid plugin path", "Warning: Invalid plugin path: {0}"},
+         {"Invalid URL", "Invalid URL: {0}"},
+         {"Is","Is"},
+@@ -417,6 +418,10 @@
+         {"connectionFailed1","Connection Failed: Retry?"},
+         {"connectionFailed2","The connection to {0} did not succeed.<br>" +
+                              "Would you like to try again?"},
++        {"connectionFailedSSL1","Secure connection failed. Retry insecurely?"},
++        {"connectionFailedSSL2","The connection to {0} could not be made using SSL.<br>" +
++                             "Would you like to try without SSL?<br>" +
++                             "(Username and password will be sent in plain text.)"},
+         {"connectionLost1","Connection Lost: Reconnect?"},
+         {"connectionLost2","The connection to {0} has been lost " +
+                            "because the remote process has been terminated.<br>" +
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8004584-augment_applet_contextualization.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,322 @@
+# HG changeset patch
+# User andrew
+# Date 1371392356 18000
+# Node ID 148e0adac8e895f2cee0d121f0699bb9d4923044
+# Parent  672b00f8dd800d0b494cde9eb219bd82179c5ff5
+8004584: Augment applet contextualization
+Summary: Do not create the main AppContext for applets
+
+diff --git a/src/share/classes/java/util/logging/LogManager.java b/src/share/classes/java/util/logging/LogManager.java
+--- openjdk/jdk/src/share/classes/java/util/logging/LogManager.java
++++ openjdk/jdk/src/share/classes/java/util/logging/LogManager.java
+@@ -342,27 +342,23 @@
+                 // from the execution stack.
+                 Object ecx = javaAwtAccess.getExecutionContext();
+                 if (ecx == null) {
+-                    // fall back to AppContext.getAppContext()
++                    // fall back to thread group seach of AppContext
+                     ecx = javaAwtAccess.getContext();
+                 }
+-                context = (LoggerContext) javaAwtAccess.get(ecx, LoggerContext.class);
+-                if (context == null) {
+-                    if (javaAwtAccess.isMainAppContext()) {
+-                        context = userContext;
+-                    } else {
+-                        context = new LoggerContext();
+-                        // during initialization, rootLogger is null when
+-                        // instantiating itself RootLogger
+-                        if (manager.rootLogger != null)
+-                            context.addLocalLogger(manager.rootLogger);
++                if (ecx != null) {
++                    context = (LoggerContext)javaAwtAccess.get(ecx, LoggerContext.class);
++                    if (context == null) {
++                        if (javaAwtAccess.isMainAppContext()) {
++                            context = userContext;
++                        } else {
++                            context = new LoggerContext();
++                        }
++                        javaAwtAccess.put(ecx, LoggerContext.class, context);
+                     }
+-                    javaAwtAccess.put(ecx, LoggerContext.class, context);
+                 }
+             }
+-        } else {
+-            context = userContext;
+         }
+-        return context;
++        return context != null ? context : userContext;
+     }
+ 
+     private List<LoggerContext> contexts() {
+@@ -489,9 +485,22 @@
+             return logger;
+         }
+ 
++        synchronized void ensureRootLogger(Logger logger) {
++            if (logger == manager.rootLogger)
++                return;
++
++            // during initialization, rootLogger is null when
++            // instantiating itself RootLogger
++            if (findLogger("") == null && manager.rootLogger != null) {
++                addLocalLogger(manager.rootLogger);
++            }
++        }
++
+         // Add a logger to this context.  This method will only set its level
+         // and process parent loggers.  It doesn't set its handlers.
+         synchronized boolean addLocalLogger(Logger logger) {
++            ensureRootLogger(logger);
++
+             final String name = logger.getName();
+             if (name == null) {
+                 throw new NullPointerException();
+diff --git a/src/share/classes/sun/applet/AppletSecurity.java b/src/share/classes/sun/applet/AppletSecurity.java
+--- openjdk/jdk/src/share/classes/sun/applet/AppletSecurity.java
++++ openjdk/jdk/src/share/classes/sun/applet/AppletSecurity.java
+@@ -52,7 +52,6 @@
+  */
+ public
+ class AppletSecurity extends AWTSecurityManager {
+-    private AppContext mainAppContext;
+ 
+     //URLClassLoader.acc
+     private static Field facc = null;
+@@ -77,7 +76,6 @@
+      */
+     public AppletSecurity() {
+         reset();
+-        mainAppContext = AppContext.getAppContext();
+     }
+ 
+     // Cache to store known restricted packages
+@@ -312,7 +310,7 @@
+         AppContext appContext = AppContext.getAppContext();
+         AppletClassLoader appletClassLoader = currentAppletClassLoader();
+ 
+-        if ((appContext == mainAppContext) && (appletClassLoader != null)) {
++        if (AppContext.isMainContext(appContext) && (appletClassLoader != null)) {
+             // If we're about to allow access to the main EventQueue,
+             // and anything untrusted is on the class context stack,
+             // disallow access.
+diff --git a/src/share/classes/sun/awt/AppContext.java b/src/share/classes/sun/awt/AppContext.java
+--- openjdk/jdk/src/share/classes/sun/awt/AppContext.java
++++ openjdk/jdk/src/share/classes/sun/awt/AppContext.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -42,6 +42,7 @@
+ import java.util.HashSet;
+ import java.beans.PropertyChangeSupport;
+ import java.beans.PropertyChangeListener;
++import java.util.concurrent.atomic.AtomicInteger;
+ 
+ /**
+  * The AppContext is a table referenced by ThreadGroup which stores
+@@ -147,8 +148,9 @@
+     }
+ 
+     /* The main "system" AppContext, used by everything not otherwise
+-       contained in another AppContext.
+-     */
++       contained in another AppContext. It is implicitly created for
++       standalone apps only (i.e. not applets)
++    */
+     private static AppContext mainAppContext = null;
+ 
+     /*
+@@ -181,27 +183,6 @@
+     }
+ 
+ 
+-    static {
+-        // On the main Thread, we get the ThreadGroup, make a corresponding
+-        // AppContext, and instantiate the Java EventQueue.  This way, legacy
+-        // code is unaffected by the move to multiple AppContext ability.
+-        AccessController.doPrivileged(new PrivilegedAction() {
+-          public Object run() {
+-            ThreadGroup currentThreadGroup =
+-                                Thread.currentThread().getThreadGroup();
+-            ThreadGroup parentThreadGroup = currentThreadGroup.getParent();
+-            while (parentThreadGroup != null) {
+-                // Find the root ThreadGroup to construct our main AppContext
+-                currentThreadGroup = parentThreadGroup;
+-                parentThreadGroup = currentThreadGroup.getParent();
+-            }
+-            mainAppContext = new AppContext(currentThreadGroup);
+-            numAppContexts = 1;
+-            return mainAppContext;
+-          }
+-        });
+-    }
+-
+     /*
+      * The total number of AppContexts, system-wide.  This number is
+      * incremented at the beginning of the constructor, and decremented
+@@ -209,7 +190,7 @@
+      * number is 1.  If so, it returns the sole AppContext without
+      * checking Thread.currentThread().
+      */
+-    private static int numAppContexts;
++    private static final AtomicInteger numAppContexts = new AtomicInteger(0);
+ 
+     /*
+      * The context ClassLoader that was used to create this AppContext.
+@@ -230,7 +211,7 @@
+      * @since   1.2
+      */
+     AppContext(ThreadGroup threadGroup) {
+-        numAppContexts++;
++        numAppContexts.incrementAndGet();
+ 
+         this.threadGroup = threadGroup;
+         threadGroup2appContext.put(threadGroup, this);
+@@ -245,6 +226,27 @@
+ 
+     private static MostRecentThreadAppContext mostRecentThreadAppContext = null;
+ 
++    private final static void initMainAppContext() {
++        // On the main Thread, we get the ThreadGroup, make a corresponding
++        // AppContext, and instantiate the Java EventQueue.  This way, legacy
++        // code is unaffected by the move to multiple AppContext ability.
++        AccessController.doPrivileged(new PrivilegedAction<Void>() {
++            public Void run() {
++                ThreadGroup currentThreadGroup =
++                        Thread.currentThread().getThreadGroup();
++                ThreadGroup parentThreadGroup = currentThreadGroup.getParent();
++                while (parentThreadGroup != null) {
++                    // Find the root ThreadGroup to construct our main AppContext
++                    currentThreadGroup = parentThreadGroup;
++                    parentThreadGroup = currentThreadGroup.getParent();
++                }
++
++                mainAppContext = SunToolkit.createNewAppContext(currentThreadGroup);
++                return null;
++            }
++        });
++    }
++
+     /**
+      * Returns the appropriate AppContext for the caller,
+      * as determined by its ThreadGroup.  If the main "system" AppContext
+@@ -257,8 +259,10 @@
+      * @since   1.2
+      */
+     public final static AppContext getAppContext() {
+-        if (numAppContexts == 1)   // If there's only one system-wide,
+-            return mainAppContext; // return the main system AppContext.
++        // we are standalone app, return the main app context
++        if (numAppContexts.get() == 1 && mainAppContext != null) {
++            return mainAppContext;
++        }
+ 
+         final Thread currentThread = Thread.currentThread();
+ 
+@@ -284,16 +288,25 @@
+             // when new AppContext objects are created.
+             ThreadGroup currentThreadGroup = currentThread.getThreadGroup();
+             ThreadGroup threadGroup = currentThreadGroup;
++
++                    // Special case: we implicitly create the main app context
++                    // if no contexts have been created yet. This covers standalone apps
++                    // and excludes applets because by the time applet starts
++                    // a number of contexts have already been created by the plugin.
++                    if (numAppContexts.get() == 0) {
++                        // This check is not necessary, its purpose is to help
++                        // Plugin devs to catch all the cases of main AC creation.
++                        if (System.getProperty("javaplugin.version") == null &&
++                                System.getProperty("javawebstart.version") == null) {
++                            initMainAppContext();
++                        }
++                    }
++
+             AppContext context = threadGroup2appContext.get(threadGroup);
+             while (context == null) {
+                 threadGroup = threadGroup.getParent();
+                 if (threadGroup == null) {
+-                    // If we get here, we're running under a ThreadGroup that
+-                    // has no AppContext associated with it.  This should never
+-                    // happen, because createNewContext() should be used by the
+-                    // toolkit to create the ThreadGroup that everything runs
+-                    // under.
+-                    throw new RuntimeException("Invalid ThreadGroup");
++		    return null;
+                 }
+                 context = threadGroup2appContext.get(threadGroup);
+             }
+@@ -303,10 +316,8 @@
+             for (ThreadGroup tg = currentThreadGroup; tg != threadGroup; tg = tg.getParent()) {
+                 threadGroup2appContext.put(tg, context);
+             }
++
+             // Now we're done, so we cache the latest key/value pair.
+-            // (we do this before checking with any AWTSecurityManager, so if
+-            // this Thread equates with the main AppContext in the cache, it
+-            // still will)
+             mostRecentThreadAppContext =
+                 new MostRecentThreadAppContext(currentThread, context);
+ 
+@@ -315,17 +326,17 @@
+          });
+         }
+ 
+-        if (appContext == mainAppContext)  {
+-            // Before we return the main "system" AppContext, check to
+-            // see if there's an AWTSecurityManager installed.  If so,
+-            // allow it to choose the AppContext to return.
+-            AppContext secAppContext = getExecutionAppContext();
+-            if (secAppContext != null) {
+-               appContext = secAppContext; // Return what we're told
+-            }
+-        }
++        return appContext;
++    }
+ 
+-        return appContext;
++    /**
++     * Returns true if the specified AppContext is the main AppContext.
++     *
++     * @param   ctx the context to compare with the main context
++     * @return  true if the specified AppContext is the main AppContext.
++     */
++    public final static boolean isMainContext(AppContext ctx) {
++        return (ctx != null && ctx == mainAppContext);
+     }
+ 
+     private final static AppContext getExecutionAppContext() {
+@@ -500,7 +511,7 @@
+             this.table.clear(); // Clear out the Hashtable to ease garbage collection
+         }
+ 
+-        numAppContexts--;
++        numAppContexts.decrementAndGet();
+ 
+         mostRecentKeyValue = null;
+     }
+@@ -790,7 +801,7 @@
+                 return getAppContext().isDisposed();
+             }
+             public boolean isMainAppContext() {
+-                return (numAppContexts == 1);
++                return (numAppContexts.get() == 1 && mainAppContext != null);
+             }
+             public Object getContext() {
+                 return getAppContext();
+diff --git a/src/share/classes/sun/awt/SunToolkit.java b/src/share/classes/sun/awt/SunToolkit.java
+--- openjdk/jdk/src/share/classes/sun/awt/SunToolkit.java
++++ openjdk/jdk/src/share/classes/sun/awt/SunToolkit.java
+@@ -293,6 +293,10 @@
+      */
+     public static AppContext createNewAppContext() {
+         ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
++        return createNewAppContext(threadGroup);
++    }
++
++    static final AppContext createNewAppContext(ThreadGroup threadGroup) {
+         EventQueue eventQueue;
+         String eqName = System.getProperty("AWT.EventQueueClass",
+                                            "java.awt.EventQueue");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8005007-better_glyph_processing.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,118 @@
+# HG changeset patch
+# User prr
+# Date 1364745958 25200
+# Node ID ff15c4e83482223b179baee18be068908c7e2dce
+# Parent  148e0adac8e895f2cee0d121f0699bb9d4923044
+8005007: Better glyph processing
+Reviewed-by: srl, mschoene, bae
+
+diff --git a/src/share/classes/sun/font/ExtendedTextSourceLabel.java b/src/share/classes/sun/font/ExtendedTextSourceLabel.java
+--- openjdk/jdk/src/share/classes/sun/font/ExtendedTextSourceLabel.java
++++ openjdk/jdk/src/share/classes/sun/font/ExtendedTextSourceLabel.java
+@@ -366,6 +366,9 @@
+     validate(index);
+     float[] charinfo = getCharinfo();
+     index = l2v(index) * numvals;
++    if ((index+vish) >= charinfo.length) {
++        return new Rectangle2D.Float();
++    }
+     return new Rectangle2D.Float(
+                                  charinfo[index + visx],
+                                  charinfo[index + visy],
+@@ -455,6 +458,10 @@
+     int length = source.getLength();
+     --start;
+     while (width >= 0 && ++start < length) {
++      int cidx = l2v(start) * numvals + advx;
++      if (cidx >= charinfo.length) {
++          break; // layout bailed for some reason
++      }
+       float adv = charinfo[l2v(start) * numvals + advx];
+       width -= adv;
+     }
+@@ -468,7 +475,11 @@
+     float[] charinfo = getCharinfo();
+     --start;
+     while (++start < limit) {
+-      a += charinfo[l2v(start) * numvals + advx];
++      int cidx = l2v(start) * numvals + advx;
++      if (cidx >= charinfo.length) {
++          break; // layout bailed for some reason
++      }
++      a += charinfo[cidx];
+     }
+ 
+     return a;
+diff --git a/src/share/native/sun/font/layout/LEGlyphStorage.cpp b/src/share/native/sun/font/layout/LEGlyphStorage.cpp
+--- openjdk/jdk/src/share/native/sun/font/layout/LEGlyphStorage.cpp
++++ openjdk/jdk/src/share/native/sun/font/layout/LEGlyphStorage.cpp
+@@ -584,7 +584,7 @@
+ {
+     le_int32 growAmount = fInsertionList->getGrowAmount();
+ 
+-    if (growAmount == 0) {
++    if (growAmount <= 0) {
+         return fGlyphCount;
+     }
+ 
+@@ -613,7 +613,9 @@
+         fAuxData = (le_uint32 *)newAuxData;
+     }
+ 
+-    fSrcIndex  = fGlyphCount - 1;
++    if (fGlyphCount > 0) {
++       fSrcIndex  = fGlyphCount - 1;
++    }
+     fDestIndex = newGlyphCount - 1;
+ 
+ #if 0
+@@ -653,6 +655,10 @@
+     }
+ #endif
+ 
++    if (atPosition < 0 || fSrcIndex < 0 || fDestIndex < 0) {
++        return FALSE;
++    }
++
+     if (fAuxData != NULL) {
+         le_int32 src = fSrcIndex, dest = fDestIndex;
+ 
+@@ -665,7 +671,7 @@
+         }
+     }
+ 
+-    while (fSrcIndex > atPosition) {
++    while (fSrcIndex > atPosition && fSrcIndex >= 0 && fDestIndex >= 0) {
+         fGlyphs[fDestIndex]      = fGlyphs[fSrcIndex];
+         fCharIndices[fDestIndex] = fCharIndices[fSrcIndex];
+ 
+@@ -673,7 +679,7 @@
+         fSrcIndex  -= 1;
+     }
+ 
+-    for (le_int32 i = count - 1; i >= 0; i -= 1) {
++    for (le_int32 i = count - 1; i >= 0 && fDestIndex >= 0; i -= 1) {
+         fGlyphs[fDestIndex]      = newGlyphs[i];
+         fCharIndices[fDestIndex] = fCharIndices[atPosition];
+ 
+@@ -682,7 +688,7 @@
+ 
+     // the source glyph we're pointing at
+     // just got replaced by the insertion
+-    fSrcIndex -= 1;
++        fSrcIndex -= 1;
+ 
+     return FALSE;
+ }
+diff --git a/src/share/native/sun/font/layout/LookupProcessor.cpp b/src/share/native/sun/font/layout/LookupProcessor.cpp
+--- openjdk/jdk/src/share/native/sun/font/layout/LookupProcessor.cpp
++++ openjdk/jdk/src/share/native/sun/font/layout/LookupProcessor.cpp
+@@ -61,7 +61,7 @@
+ 
+         delta = applySubtable(lookupSubtable, lookupType, glyphIterator, fontInstance, success);
+ 
+-        if (delta > 0 && LE_FAILURE(success)) {
++        if (delta > 0 || LE_FAILURE(success)) {
+             return 1;
+         }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8006328-6_fixup.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,31 @@
+# HG changeset patch
+# User andrew
+# Date 1371827929 18000
+# Node ID 9892a997b49abd5ae9a5e1ec8fef1f93631f87ae
+# Parent  059ac6834c32c540ad86b99c0e5339554398def2
+Fix up 8006328
+
+diff --git a/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java b/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
+@@ -531,7 +531,7 @@
+      * Also, it has some optimizations regarding sending to the Receivers,
+      * for known Receivers, and managing itself in the TransmitterList.
+      */
+-    class BasicTransmitter implements MidiDeviceTransmitter {
++    class BasicTransmitter implements Transmitter {
+ 
+         private Receiver receiver = null;
+         TransmitterList tlist = null;
+diff --git a/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java b/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
+@@ -470,7 +470,7 @@
+ 
+     private final Encoding[] formats = {Encoding.PCM_SIGNED,
+                                         Encoding.PCM_UNSIGNED,
+-                                        Encoding.PCM_FLOAT};
++                                        AudioFloatConverter.PCM_FLOAT};
+ 
+     public AudioInputStream getAudioInputStream(Encoding targetEncoding,
+             AudioInputStream sourceStream) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8006328-sound_class_robustness.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,6937 @@
+# HG changeset patch
+# User andrew
+# Date 1371394319 18000
+# Node ID 5c9fbf7443a24076a6545cb043102cb2527f62ca
+# Parent  ff15c4e83482223b179baee18be068908c7e2dce
+8006328: Improve robustness of sound classes
+8009057: Improve MIDI event handling
+Reviewed-by: amenkov, art, skoivu
+
+diff --git a/src/share/classes/com/sun/media/sound/AbstractDataLine.java b/src/share/classes/com/sun/media/sound/AbstractDataLine.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractDataLine.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractDataLine.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,15 +25,12 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.util.Vector;
+-
+ import javax.sound.sampled.AudioFormat;
+ import javax.sound.sampled.AudioSystem;
+ import javax.sound.sampled.Control;
+ import javax.sound.sampled.DataLine;
+ import javax.sound.sampled.LineEvent;
+ import javax.sound.sampled.LineUnavailableException;
+-import javax.sound.sampled.Mixer;
+ 
+ 
+ /**
+@@ -46,13 +43,13 @@
+     // DEFAULTS
+ 
+     // default format
+-    protected /*final*/ AudioFormat defaultFormat;
++    private final AudioFormat defaultFormat;
+ 
+     // default buffer size in bytes
+-    protected /*final*/ int defaultBufferSize;
++    private final int defaultBufferSize;
+ 
+     // the lock for synchronization
+-    protected Object lock = new Object();
++    protected final Object lock = new Object();
+ 
+     // STATE
+ 
+@@ -103,7 +100,7 @@
+ 
+     // DATA LINE METHODS
+ 
+-    public void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
++    public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
+         //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
+         synchronized (mixer) {
+             if (Printer.trace) Printer.trace("> AbstractDataLine.open(format, bufferSize) (class: "+getClass().getName());
+@@ -152,7 +149,7 @@
+     }
+ 
+ 
+-    public void open(AudioFormat format) throws LineUnavailableException {
++    public final void open(AudioFormat format) throws LineUnavailableException {
+         open(format, AudioSystem.NOT_SPECIFIED);
+     }
+ 
+@@ -181,7 +178,7 @@
+     }
+ 
+ 
+-    public void start() {
++    public final void start() {
+         //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
+         synchronized(mixer) {
+             if (Printer.trace) Printer.trace("> "+getClass().getName()+".start() - AbstractDataLine");
+@@ -205,7 +202,7 @@
+     }
+ 
+ 
+-    public void stop() {
++    public final void stop() {
+ 
+         //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
+         synchronized(mixer) {
+@@ -249,16 +246,16 @@
+     // in MixerSourceLine and MixerClip, and I want to touch as little
+     // code as possible to change isStarted() back to isRunning().
+ 
+-    public boolean isRunning() {
++    public final boolean isRunning() {
+         return started;
+     }
+ 
+-    public boolean isActive() {
++    public final boolean isActive() {
+         return active;
+     }
+ 
+ 
+-    public long getMicrosecondPosition() {
++    public final long getMicrosecondPosition() {
+ 
+         long microseconds = getLongFramePosition();
+         if (microseconds != AudioSystem.NOT_SPECIFIED) {
+@@ -268,26 +265,26 @@
+     }
+ 
+ 
+-    public AudioFormat getFormat() {
++    public final AudioFormat getFormat() {
+         return format;
+     }
+ 
+ 
+-    public int getBufferSize() {
++    public final int getBufferSize() {
+         return bufferSize;
+     }
+ 
+     /**
+      * This implementation does NOT change the buffer size
+      */
+-    public int setBufferSize(int newSize) {
++    public final int setBufferSize(int newSize) {
+         return getBufferSize();
+     }
+ 
+     /**
+      * This implementation returns AudioSystem.NOT_SPECIFIED.
+      */
+-    public float getLevel() {
++    public final float getLevel() {
+         return (float)AudioSystem.NOT_SPECIFIED;
+     }
+ 
+@@ -304,7 +301,7 @@
+     // it to isStartedRunning().  This is part of backing out the
+     // change denied in RFE 4297981.
+ 
+-    protected boolean isStartedRunning() {
++    final boolean isStartedRunning() {
+         return running;
+     }
+ 
+@@ -312,7 +309,7 @@
+      * This method sets the active state and generates
+      * events if it changes.
+      */
+-    protected void setActive(boolean active) {
++    final void setActive(boolean active) {
+ 
+         if (Printer.trace) Printer.trace("> AbstractDataLine: setActive(" + active + ")");
+ 
+@@ -351,7 +348,7 @@
+      * This method sets the started state and generates
+      * events if it changes.
+      */
+-    protected void setStarted(boolean started) {
++    final void setStarted(boolean started) {
+ 
+         if (Printer.trace) Printer.trace("> AbstractDataLine: setStarted(" + started + ")");
+ 
+@@ -388,7 +385,7 @@
+      * This method generates a STOP event and sets the started state to false.
+      * It is here for historic reasons when an EOM event existed.
+      */
+-    protected void setEOM() {
++    final void setEOM() {
+ 
+         if (Printer.trace) Printer.trace("> AbstractDataLine: setEOM()");
+         //$$fb 2002-04-21: sometimes, 2 STOP events are generated.
+@@ -408,7 +405,7 @@
+      * line is open, this should return quietly because the values
+      * requested will match the current ones.
+      */
+-    public void open() throws LineUnavailableException {
++    public final void open() throws LineUnavailableException {
+ 
+         if (Printer.trace) Printer.trace("> "+getClass().getName()+".open() - AbstractDataLine");
+ 
+@@ -422,7 +419,7 @@
+      * This should also stop the line.  The closed line should not be running or active.
+      * After we close the line, we reset the format and buffer size to the defaults.
+      */
+-    public void close() {
++    public final void close() {
+         //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
+         synchronized (mixer) {
+             if (Printer.trace) Printer.trace("> "+getClass().getName()+".close() - in AbstractDataLine.");
+diff --git a/src/share/classes/com/sun/media/sound/AbstractLine.java b/src/share/classes/com/sun/media/sound/AbstractLine.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,11 +25,12 @@
+ 
+ package com.sun.media.sound;
+ 
++import java.util.Map;
+ import java.util.Vector;
++import java.util.WeakHashMap;
+ 
+ import javax.sound.sampled.AudioSystem;
+ import javax.sound.sampled.Control;
+-import javax.sound.sampled.Mixer;
+ import javax.sound.sampled.Line;
+ import javax.sound.sampled.LineEvent;
+ import javax.sound.sampled.LineListener;
+@@ -43,28 +44,17 @@
+  */
+ abstract class AbstractLine implements Line {
+ 
+-    protected Line.Info info;
++    protected final Line.Info info;
+     protected Control[] controls;
+-    protected AbstractMixer mixer;
++    AbstractMixer mixer;
+     private boolean open     = false;
+-    private Vector listeners = new Vector();
++    private final Vector listeners = new Vector();
+ 
+     /**
+-     * Global event thread
++     * Contains event dispatcher per thread group.
+      */
+-    private static final EventDispatcher eventDispatcher;
+-
+-    static {
+-        // create and start the global event thread
+-
+-        // $$kk: 12.21.98:
+-        // 1) probably don't want a single global event queue
+-        // 2) need a way to stop this thread when the engine is done
+-
+-        eventDispatcher = new EventDispatcher();
+-        eventDispatcher.start();
+-    }
+-
++    private static final Map<ThreadGroup, EventDispatcher> dispatchers =
++            new WeakHashMap<>();
+ 
+     /**
+      * Constructs a new AbstractLine.
+@@ -85,18 +75,17 @@
+ 
+     // LINE METHODS
+ 
+-    public Line.Info getLineInfo() {
++    public final Line.Info getLineInfo() {
+         return info;
+     }
+ 
+ 
+-    public boolean isOpen() {
++    public final boolean isOpen() {
+         return open;
+     }
+ 
+ 
+-    public void addLineListener(LineListener listener) {
+-
++    public final void addLineListener(LineListener listener) {
+         synchronized(listeners) {
+             if ( ! (listeners.contains(listener)) ) {
+                 listeners.addElement(listener);
+@@ -109,7 +98,7 @@
+      * Removes an audio listener.
+      * @param listener listener to remove
+      */
+-    public void removeLineListener(LineListener listener) {
++    public final void removeLineListener(LineListener listener) {
+         listeners.removeElement(listener);
+     }
+ 
+@@ -120,8 +109,7 @@
+      * array of length 0.
+      * @return control set
+      */
+-    public Control[] getControls() {
+-
++    public final Control[] getControls() {
+         Control[] returnedArray = new Control[controls.length];
+ 
+         for (int i = 0; i < controls.length; i++) {
+@@ -132,8 +120,7 @@
+     }
+ 
+ 
+-    public boolean isControlSupported(Control.Type controlType) {
+-
++    public final boolean isControlSupported(Control.Type controlType) {
+         // protect against a NullPointerException
+         if (controlType == null) {
+             return false;
+@@ -149,8 +136,7 @@
+     }
+ 
+ 
+-    public Control getControl(Control.Type controlType) {
+-
++    public final Control getControl(Control.Type controlType) {
+         // protect against a NullPointerException
+         if (controlType != null) {
+ 
+@@ -172,7 +158,7 @@
+      * This method sets the open state and generates
+      * events if it changes.
+      */
+-    protected void setOpen(boolean open) {
++    final void setOpen(boolean open) {
+ 
+         if (Printer.trace) Printer.trace("> "+getClass().getName()+" (AbstractLine): setOpen(" + open + ")  this.open: " + this.open);
+ 
+@@ -200,8 +186,8 @@
+     /**
+      * Send line events.
+      */
+-    protected void sendEvents(LineEvent event) {
+-        eventDispatcher.sendAudioEvents(event, listeners);
++    final void sendEvents(LineEvent event) {
++        getEventDispatcher().sendAudioEvents(event, listeners);
+     }
+ 
+ 
+@@ -227,12 +213,23 @@
+     // $$kk: 06.03.99: returns the mixer used in construction.
+     // this is a hold-over from when there was a public method like
+     // this on line and should be fixed!!
+-    protected AbstractMixer getMixer() {
++    final AbstractMixer getMixer() {
+         return mixer;
+     }
+ 
+-    protected EventDispatcher getEventDispatcher() {
+-        return eventDispatcher;
++    final EventDispatcher getEventDispatcher() {
++        // create and start the global event thread
++        //TODO  need a way to stop this thread when the engine is done
++        final ThreadGroup tg = Thread.currentThread().getThreadGroup();
++        synchronized (dispatchers) {
++            EventDispatcher eventDispatcher = dispatchers.get(tg);
++            if (eventDispatcher == null) {
++                eventDispatcher = new EventDispatcher();
++                dispatchers.put(tg, eventDispatcher);
++                eventDispatcher.start();
++            }
++            return eventDispatcher;
++        }
+     }
+ 
+     // ABSTRACT METHODS
+diff --git a/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java b/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -60,12 +60,12 @@
+ 
+     // DEVICE ATTRIBUTES
+ 
+-    private MidiDevice.Info info;
++    private final MidiDevice.Info info;
+ 
+ 
+     // DEVICE STATE
+ 
+-    protected /*private*/ boolean open          = false;
++    private boolean open          = false;
+     private int openRefCount;
+ 
+     /** List of Receivers and Transmitters that opened the device implicitely.
+@@ -102,7 +102,7 @@
+ 
+     // MIDI DEVICE METHODS
+ 
+-    public MidiDevice.Info getDeviceInfo() {
++    public final MidiDevice.Info getDeviceInfo() {
+         return info;
+     }
+ 
+@@ -111,7 +111,7 @@
+      * opened the the device implicitly from closing it. The only way to close the device after
+      * this call is a call to close().
+      */
+-    public void open() throws MidiUnavailableException {
++    public final void open() throws MidiUnavailableException {
+         if (Printer.trace) Printer.trace("> AbstractMidiDevice: open()");
+         synchronized(this) {
+             openRefCount = -1;
+@@ -159,7 +159,7 @@
+     }
+ 
+ 
+-    public void close() {
++    public final void close() {
+         if (Printer.trace) Printer.trace("> AbstractMidiDevice: close()");
+         synchronized (this) {
+             doClose();
+@@ -181,7 +181,7 @@
+      * @param object The object that might have been opening the device implicitely (for now,
+      * this may be a Transmitter or receiver).
+      */
+-    public void closeInternal(Object object) {
++    public final void closeInternal(Object object) {
+         if (Printer.trace) Printer.trace("> AbstractMidiDevice: closeInternal()");
+         synchronized(this) {
+             if (getOpenKeepingObjects().remove(object)) {
+@@ -197,7 +197,7 @@
+     }
+ 
+ 
+-    public void doClose() {
++    public final void doClose() {
+         if (Printer.trace) Printer.trace("> AbstractMidiDevice: doClose()");
+         synchronized(this) {
+             if (isOpen()) {
+@@ -209,7 +209,7 @@
+     }
+ 
+ 
+-    public boolean isOpen() {
++    public final boolean isOpen() {
+         return open;
+     }
+ 
+@@ -329,7 +329,7 @@
+ 
+     // HELPER METHODS
+ 
+-    long getId() {
++    final long getId() {
+         return id;
+     }
+ 
+@@ -339,7 +339,8 @@
+     /** Retrieve a Receiver and open the device implicitly.
+         This method is called by MidiSystem.getReceiver().
+      */
+-    public Receiver getReceiverReferenceCounting() throws MidiUnavailableException {
++    public final Receiver getReceiverReferenceCounting()
++            throws MidiUnavailableException {
+         /* Keep this order of commands! If getReceiver() throws an exception,
+            openInternal() should not be called!
+         */
+@@ -355,7 +356,8 @@
+     /** Retrieve a Transmitter and open the device implicitly.
+         This method is called by MidiSystem.getTransmitter().
+      */
+-    public Transmitter getTransmitterReferenceCounting() throws MidiUnavailableException {
++    public final Transmitter getTransmitterReferenceCounting()
++            throws MidiUnavailableException {
+         /* Keep this order of commands! If getTransmitter() throws an exception,
+            openInternal() should not be called!
+         */
+@@ -422,7 +424,7 @@
+ 
+     /** Return the internal list of Transmitters, possibly creating it first.
+      */
+-    protected TransmitterList getTransmitterList() {
++    final TransmitterList getTransmitterList() {
+         synchronized (traRecLock) {
+             if (transmitterList == null) {
+                 transmitterList = new TransmitterList();
+@@ -462,7 +464,7 @@
+     /**
+      * close this device if discarded by the garbage collector
+      */
+-    protected void finalize() {
++    protected final void finalize() {
+         close();
+     }
+ 
+@@ -529,7 +531,7 @@
+      * Also, it has some optimizations regarding sending to the Receivers,
+      * for known Receivers, and managing itself in the TransmitterList.
+      */
+-    protected class BasicTransmitter implements Transmitter {
++    class BasicTransmitter implements MidiDeviceTransmitter {
+ 
+         private Receiver receiver = null;
+         TransmitterList tlist = null;
+@@ -541,7 +543,7 @@
+             this.tlist = tlist;
+         }
+ 
+-        public void setReceiver(Receiver receiver) {
++        public final void setReceiver(Receiver receiver) {
+             if (tlist != null && this.receiver != receiver) {
+                 if (Printer.debug) Printer.debug("Transmitter "+toString()+": set receiver "+receiver);
+                 tlist.receiverChanged(this, this.receiver, receiver);
+@@ -549,7 +551,7 @@
+             }
+         }
+ 
+-        public Receiver getReceiver() {
++        public final Receiver getReceiver() {
+             return receiver;
+         }
+ 
+@@ -559,7 +561,7 @@
+          * Therefore, subclasses that override this method must call
+          * 'super.close()'.
+          */
+-        public void close() {
++        public final void close() {
+             AbstractMidiDevice.this.closeInternal(this);
+             if (tlist != null) {
+                 tlist.receiverChanged(this, this.receiver, null);
+@@ -575,9 +577,9 @@
+     /**
+      * a class to manage a list of transmitters
+      */
+-    class TransmitterList {
++    final class TransmitterList {
+ 
+-        private ArrayList<Transmitter> transmitters = new ArrayList<Transmitter>();
++        private final ArrayList<Transmitter> transmitters = new ArrayList<Transmitter>();
+         private MidiOutDevice.MidiOutReceiver midiOutReceiver;
+ 
+         // how many transmitters must be present for optimized
+diff --git a/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java b/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,7 +36,7 @@
+  */
+ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider {
+ 
+-    private static boolean enabled;
++    private static final boolean enabled;
+ 
+     /**
+      * Create objects representing all MIDI output devices on the system.
+@@ -52,7 +52,7 @@
+     }
+ 
+ 
+-    synchronized void readDeviceInfos() {
++    final synchronized void readDeviceInfos() {
+         Info[] infos = getInfoCache();
+         MidiDevice[] devices = getDeviceCache();
+         if (!enabled) {
+@@ -118,7 +118,7 @@
+     }
+ 
+ 
+-    public MidiDevice.Info[] getDeviceInfo() {
++    public final MidiDevice.Info[] getDeviceInfo() {
+         readDeviceInfos();
+         Info[] infos = getInfoCache();
+         MidiDevice.Info[] localArray = new MidiDevice.Info[infos.length];
+@@ -127,7 +127,7 @@
+     }
+ 
+ 
+-    public MidiDevice getDevice(MidiDevice.Info info) {
++    public final MidiDevice getDevice(MidiDevice.Info info) {
+         if (info instanceof Info) {
+             readDeviceInfos();
+             MidiDevice[] devices = getDeviceCache();
+@@ -164,7 +164,7 @@
+             this.index = index;
+         }
+ 
+-        boolean equalStrings(Info info) {
++        final boolean equalStrings(Info info) {
+             return      (info != null
+                          && getName().equals(info.getName())
+                          && getVendor().equals(info.getVendor())
+@@ -172,11 +172,11 @@
+                          && getVersion().equals(info.getVersion()));
+         }
+ 
+-        int getIndex() {
++        final int getIndex() {
+             return index;
+         }
+ 
+-        void setIndex(int index) {
++        final void setIndex(int index) {
+             this.index = index;
+         }
+ 
+diff --git a/src/share/classes/com/sun/media/sound/AbstractMixer.java b/src/share/classes/com/sun/media/sound/AbstractMixer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -27,14 +27,9 @@
+ 
+ import java.util.Vector;
+ 
+-import javax.sound.sampled.AudioFormat;
+-import javax.sound.sampled.AudioSystem;
+ import javax.sound.sampled.Control;
+-import javax.sound.sampled.DataLine;
+ import javax.sound.sampled.Mixer;
+ import javax.sound.sampled.Line;
+-import javax.sound.sampled.LineEvent;
+-import javax.sound.sampled.LineListener;
+ import javax.sound.sampled.LineUnavailableException;
+ 
+ /**
+@@ -95,13 +90,13 @@
+     /**
+      * Source lines (ports) currently open
+      */
+-    protected Vector sourceLines = new Vector();
++    private final Vector sourceLines = new Vector();
+ 
+ 
+     /**
+      * Target lines currently open.
+      */
+-    protected Vector targetLines = new Vector();
++    private final Vector targetLines = new Vector();
+ 
+ 
+     /**
+@@ -133,19 +128,19 @@
+     // MIXER METHODS
+ 
+ 
+-    public Mixer.Info getMixerInfo() {
++    public final Mixer.Info getMixerInfo() {
+         return mixerInfo;
+     }
+ 
+ 
+-    public Line.Info[] getSourceLineInfo() {
++    public final Line.Info[] getSourceLineInfo() {
+         Line.Info[] localArray = new Line.Info[sourceLineInfo.length];
+         System.arraycopy(sourceLineInfo, 0, localArray, 0, sourceLineInfo.length);
+         return localArray;
+     }
+ 
+ 
+-    public Line.Info[] getTargetLineInfo() {
++    public final Line.Info[] getTargetLineInfo() {
+ 
+         Line.Info[] localArray = new Line.Info[targetLineInfo.length];
+         System.arraycopy(targetLineInfo, 0, localArray, 0, targetLineInfo.length);
+@@ -153,7 +148,7 @@
+     }
+ 
+ 
+-    public Line.Info[] getSourceLineInfo(Line.Info info) {
++    public final Line.Info[] getSourceLineInfo(Line.Info info) {
+ 
+         int i;
+         Vector vec = new Vector();
+@@ -174,7 +169,7 @@
+     }
+ 
+ 
+-    public Line.Info[] getTargetLineInfo(Line.Info info) {
++    public final Line.Info[] getTargetLineInfo(Line.Info info) {
+ 
+         int i;
+         Vector vec = new Vector();
+@@ -195,7 +190,7 @@
+     }
+ 
+ 
+-    public boolean isLineSupported(Line.Info info) {
++    public final boolean isLineSupported(Line.Info info) {
+ 
+         int i;
+ 
+@@ -227,7 +222,7 @@
+     protected abstract void implClose();
+ 
+ 
+-    public Line[] getSourceLines() {
++    public final Line[] getSourceLines() {
+ 
+         Line[] localLines;
+ 
+@@ -244,7 +239,7 @@
+     }
+ 
+ 
+-    public Line[] getTargetLines() {
++    public final Line[] getTargetLines() {
+ 
+         Line[] localLines;
+ 
+@@ -264,7 +259,7 @@
+     /**
+      * Default implementation always throws an exception.
+      */
+-    public void synchronize(Line[] lines, boolean maintainSync) {
++    public final void synchronize(Line[] lines, boolean maintainSync) {
+         throw new IllegalArgumentException("Synchronization not supported by this mixer.");
+     }
+ 
+@@ -272,7 +267,7 @@
+     /**
+      * Default implementation always throws an exception.
+      */
+-    public void unsynchronize(Line[] lines) {
++    public final void unsynchronize(Line[] lines) {
+         throw new IllegalArgumentException("Synchronization not supported by this mixer.");
+     }
+ 
+@@ -280,7 +275,8 @@
+     /**
+      * Default implementation always returns false.
+      */
+-    public boolean isSynchronizationSupported(Line[] lines, boolean maintainSync) {
++    public final boolean isSynchronizationSupported(Line[] lines,
++                                                    boolean maintainSync) {
+         return false;
+     }
+ 
+@@ -290,14 +286,14 @@
+     /**
+      * This implementation tries to open the mixer with its current format and buffer size settings.
+      */
+-    public synchronized void open() throws LineUnavailableException {
++    public final synchronized void open() throws LineUnavailableException {
+         open(true);
+     }
+ 
+     /**
+      * This implementation tries to open the mixer with its current format and buffer size settings.
+      */
+-    protected synchronized void open(boolean manual) throws LineUnavailableException {
++    final synchronized void open(boolean manual) throws LineUnavailableException {
+         if (Printer.trace) Printer.trace(">> AbstractMixer: open()");
+         if (!isOpen()) {
+             implOpen();
+@@ -322,7 +318,7 @@
+      * The mixer may be opened at a format different than the line's
+      * format if it is a DataLine.
+      */
+-    protected synchronized void open(Line line) throws LineUnavailableException {
++    final synchronized void open(Line line) throws LineUnavailableException {
+ 
+         if (Printer.trace) Printer.trace(">> AbstractMixer: open(line = " + line + ")");
+ 
+@@ -367,7 +363,7 @@
+      * open target lines, if it exists in either.
+      * If the list is now empty, closes the mixer.
+      */
+-    protected synchronized void close(Line line) {
++    final synchronized void close(Line line) {
+ 
+         if (Printer.trace) Printer.trace(">> AbstractMixer: close(" + line + ")");
+ 
+@@ -396,7 +392,7 @@
+     /**
+      * Close all lines and then close this mixer.
+      */
+-    public synchronized void close() {
++    public final synchronized void close() {
+         if (Printer.trace) Printer.trace(">> AbstractMixer: close()");
+         if (isOpen()) {
+             // close all source lines
+@@ -423,7 +419,7 @@
+     /**
+      * Starts the mixer.
+      */
+-    protected synchronized void start(Line line) {
++    final synchronized void start(Line line) {
+ 
+         if (Printer.trace) Printer.trace(">> AbstractMixer: start(" + line + ")");
+ 
+@@ -447,7 +443,7 @@
+     /**
+      * Stops the mixer if this was the last running line.
+      */
+-    protected synchronized void stop(Line line) {
++    final synchronized void stop(Line line) {
+ 
+         if (Printer.trace) Printer.trace(">> AbstractMixer: stop(" + line + ")");
+ 
+@@ -501,7 +497,7 @@
+      * Right now this just checks whether it's supported, but should
+      * check whether it actually belongs to this mixer....
+      */
+-    boolean isSourceLine(Line.Info info) {
++    final boolean isSourceLine(Line.Info info) {
+ 
+         for (int i = 0; i < sourceLineInfo.length; i++) {
+             if (info.matches(sourceLineInfo[i])) {
+@@ -518,7 +514,7 @@
+      * Right now this just checks whether it's supported, but should
+      * check whether it actually belongs to this mixer....
+      */
+-    boolean isTargetLine(Line.Info info) {
++    final boolean isTargetLine(Line.Info info) {
+ 
+         for (int i = 0; i < targetLineInfo.length; i++) {
+             if (info.matches(targetLineInfo[i])) {
+@@ -535,7 +531,7 @@
+      * matches the one specified, or null if no matching Line.Info
+      * object is found.
+      */
+-    Line.Info getLineInfo(Line.Info info) {
++    final Line.Info getLineInfo(Line.Info info) {
+         if (info == null) {
+             return null;
+         }
+diff --git a/src/share/classes/com/sun/media/sound/AiffFileFormat.java b/src/share/classes/com/sun/media/sound/AiffFileFormat.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AiffFileFormat.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AiffFileFormat.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -35,7 +35,7 @@
+  * @author Jan Borgersen
+  */
+ 
+-class AiffFileFormat extends AudioFileFormat {
++final class AiffFileFormat extends AudioFileFormat {
+ 
+     static final int AIFF_MAGIC         = 1179603533;
+ 
+@@ -62,13 +62,13 @@
+     //$$fb 2001-07-13: added management of header size in this class
+ 
+     /** header size in bytes */
+-    private int headerSize=AIFF_HEADERSIZE;
++    private final int headerSize=AIFF_HEADERSIZE;
+ 
+     /** comm chunk size in bytes, inclusive magic and length field */
+-    private int commChunkSize=26;
++    private final int commChunkSize=26;
+ 
+     /** FVER chunk size in bytes, inclusive magic and length field */
+-    private int fverChunkSize=0;
++    private final int fverChunkSize=0;
+ 
+     AiffFileFormat( AudioFileFormat aff ) {
+         this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() );
+diff --git a/src/share/classes/com/sun/media/sound/AiffFileReader.java b/src/share/classes/com/sun/media/sound/AiffFileReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AiffFileReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AiffFileReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,28 +25,17 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.util.Vector;
++import java.io.DataInputStream;
++import java.io.DataOutputStream;
+ import java.io.File;
++import java.io.FileInputStream;
++import java.io.IOException;
+ import java.io.InputStream;
+-import java.io.OutputStream;
+-import java.io.IOException;
+-import java.io.EOFException;
+ import java.net.URL;
+-import java.net.MalformedURLException;
+-
+-import java.io.BufferedInputStream;
+-import java.io.BufferedOutputStream;
+-import java.io.DataInputStream;
+-import java.io.FileInputStream;
+-import java.io.DataOutputStream;
+-import java.io.FileOutputStream;
+-import java.io.ByteArrayInputStream;
+-import java.io.ByteArrayOutputStream;
+-import java.io.SequenceInputStream;
+ 
+ import javax.sound.sampled.AudioFileFormat;
++import javax.sound.sampled.AudioFormat;
+ import javax.sound.sampled.AudioInputStream;
+-import javax.sound.sampled.AudioFormat;
+ import javax.sound.sampled.AudioSystem;
+ import javax.sound.sampled.UnsupportedAudioFileException;
+ 
+@@ -58,19 +47,10 @@
+  * @author Jan Borgersen
+  * @author Florian Bomers
+  */
+-public class AiffFileReader extends SunFileReader  {
++public final class AiffFileReader extends SunFileReader {
+ 
+     private static final int MAX_READ_LENGTH = 8;
+ 
+-
+-    /**
+-     * AIFF parser type
+-     */
+-    public static final AudioFileFormat.Type types[] = {
+-        AudioFileFormat.Type.AIFF
+-    };
+-
+-
+     /**
+      * Constructs a new AiffParser object.
+      */
+diff --git a/src/share/classes/com/sun/media/sound/AiffFileWriter.java b/src/share/classes/com/sun/media/sound/AiffFileWriter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -52,21 +52,13 @@
+  *
+  * @author Jan Borgersen
+  */
+-public class AiffFileWriter extends SunFileWriter {
+-
+-    /**
+-     * AIFF type
+-     */
+-    private static final AudioFileFormat.Type aiffTypes[] = {
+-        AudioFileFormat.Type.AIFF
+-    };
+-
++public final class AiffFileWriter extends SunFileWriter {
+ 
+     /**
+      * Constructs a new AiffFileWriter object.
+      */
+     public AiffFileWriter() {
+-        super(aiffTypes);
++        super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AIFF});
+     }
+ 
+ 
+diff --git a/src/share/classes/com/sun/media/sound/AlawCodec.java b/src/share/classes/com/sun/media/sound/AlawCodec.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,14 +25,12 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.io.InputStream;
+ import java.io.IOException;
+-
+ import java.util.Vector;
+ 
+ import javax.sound.sampled.AudioFormat;
++import javax.sound.sampled.AudioInputStream;
+ import javax.sound.sampled.AudioSystem;
+-import javax.sound.sampled.AudioInputStream;
+ 
+ 
+ /**
+@@ -40,12 +38,12 @@
+  *
+  * @author Kara Kytle
+  */
+-public class AlawCodec extends SunCodec {
++public final class AlawCodec extends SunCodec {
+ 
+     /* Tables used for A-law decoding */
+ 
+-    final static byte ALAW_TABH[] = new byte[256];
+-    final static byte ALAW_TABL[] = new byte[256];
++    private static final byte[] ALAW_TABH = new byte[256];
++    private static final byte[] ALAW_TABL = new byte[256];
+ 
+     private static final AudioFormat.Encoding[] alawEncodings = { AudioFormat.Encoding.ALAW, AudioFormat.Encoding.PCM_SIGNED };
+ 
+@@ -262,7 +260,7 @@
+     }
+ 
+ 
+-    class AlawCodecStream extends AudioInputStream {
++    final class AlawCodecStream extends AudioInputStream {
+ 
+         /**
+          * True to encode to a-law, false to decode to linear
+diff --git a/src/share/classes/com/sun/media/sound/AuFileFormat.java b/src/share/classes/com/sun/media/sound/AuFileFormat.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AuFileFormat.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AuFileFormat.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,7 +36,7 @@
+  * @author Jan Borgersen
+  */
+ 
+-class AuFileFormat extends AudioFileFormat {
++final class AuFileFormat extends AudioFileFormat {
+ 
+     // magic numbers
+     static final int AU_SUN_MAGIC =     0x2e736e64;
+@@ -60,7 +60,7 @@
+ 
+     static final int AU_HEADERSIZE       = 24;
+ 
+-    int auType;
++    private int auType;
+ 
+     AuFileFormat( AudioFileFormat aff ) {
+ 
+diff --git a/src/share/classes/com/sun/media/sound/AuFileReader.java b/src/share/classes/com/sun/media/sound/AuFileReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AuFileReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AuFileReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,28 +25,17 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.util.Vector;
++import java.io.BufferedInputStream;
++import java.io.DataInputStream;
+ import java.io.File;
++import java.io.FileInputStream;
++import java.io.IOException;
+ import java.io.InputStream;
+-import java.io.OutputStream;
+-import java.io.IOException;
+-import java.io.EOFException;
+ import java.net.URL;
+-import java.net.MalformedURLException;
+-
+-import java.io.BufferedInputStream;
+-import java.io.BufferedOutputStream;
+-import java.io.DataInputStream;
+-import java.io.FileInputStream;
+-import java.io.DataOutputStream;
+-import java.io.FileOutputStream;
+-import java.io.ByteArrayInputStream;
+-import java.io.ByteArrayOutputStream;
+-import java.io.SequenceInputStream;
+ 
+ import javax.sound.sampled.AudioFileFormat;
++import javax.sound.sampled.AudioFormat;
+ import javax.sound.sampled.AudioInputStream;
+-import javax.sound.sampled.AudioFormat;
+ import javax.sound.sampled.AudioSystem;
+ import javax.sound.sampled.UnsupportedAudioFileException;
+ 
+@@ -58,16 +47,7 @@
+  * @author Jan Borgersen
+  * @author Florian Bomers
+  */
+-public class AuFileReader extends SunFileReader {
+-
+-    /**
+-     * AU reader type
+-     */
+-
+-    public static final AudioFileFormat.Type types[] = {
+-        AudioFileFormat.Type.AU
+-    };
+-
++public final class AuFileReader extends SunFileReader {
+ 
+     /**
+      * Constructs a new AuFileReader object.
+diff --git a/src/share/classes/com/sun/media/sound/AuFileWriter.java b/src/share/classes/com/sun/media/sound/AuFileWriter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -51,28 +51,18 @@
+  *
+  * @author Jan Borgersen
+  */
+-public class AuFileWriter extends SunFileWriter {
++public final class AuFileWriter extends SunFileWriter {
+ 
+     //$$fb value for length field if length is not known
+     public final static int UNKNOWN_SIZE=-1;
+ 
+     /**
+-     * AU type
+-     */
+-    private static final AudioFileFormat.Type auTypes[] = {
+-        AudioFileFormat.Type.AU
+-    };
+-
+-
+-    /**
+      * Constructs a new AuFileWriter object.
+      */
+     public AuFileWriter() {
+-        super(auTypes);
++        super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AU});
+     }
+ 
+-
+-
+     public AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) {
+ 
+         AudioFileFormat.Type[] filetypes = new AudioFileFormat.Type[types.length];
+diff --git a/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java b/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -43,7 +43,7 @@
+  * 
+  * @author Karl Helgason
+  */
+-public class AudioFileSoundbankReader extends SoundbankReader {
++public final class AudioFileSoundbankReader extends SoundbankReader {
+ 
+     public Soundbank getSoundbank(URL url) 
+             throws InvalidMidiDataException, IOException {
+diff --git a/src/share/classes/com/sun/media/sound/AudioFloatConverter.java b/src/share/classes/com/sun/media/sound/AudioFloatConverter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -53,7 +53,7 @@
+ 
+     private static class AudioFloatLSBFilter extends AudioFloatConverter {
+ 
+-        private AudioFloatConverter converter;
++        private final AudioFloatConverter converter;
+ 
+         final private int offset;
+ 
+@@ -63,8 +63,7 @@
+ 
+         private byte[] mask_buffer;
+ 
+-        public AudioFloatLSBFilter(AudioFloatConverter converter,
+-                AudioFormat format) {
++        AudioFloatLSBFilter(AudioFloatConverter converter, AudioFormat format) {
+             int bits = format.getSampleSizeInBits();
+             boolean bigEndian = format.isBigEndian();
+             this.converter = converter;
+@@ -742,7 +741,7 @@
+ 
+         final int xbytes;
+ 
+-        public AudioFloatConversion32xSL(int xbytes) {
++        AudioFloatConversion32xSL(int xbytes) {
+             this.xbytes = xbytes;
+         }
+ 
+@@ -783,7 +782,7 @@
+ 
+         final int xbytes;
+ 
+-        public AudioFloatConversion32xSB(int xbytes) {
++        AudioFloatConversion32xSB(int xbytes) {
+             this.xbytes = xbytes;
+         }
+ 
+@@ -825,7 +824,7 @@
+ 
+         final int xbytes;
+ 
+-        public AudioFloatConversion32xUL(int xbytes) {
++        AudioFloatConversion32xUL(int xbytes) {
+             this.xbytes = xbytes;
+         }
+ 
+@@ -868,7 +867,7 @@
+ 
+         final int xbytes;
+ 
+-        public AudioFloatConversion32xUB(int xbytes) {
++        AudioFloatConversion32xUB(int xbytes) {
+             this.xbytes = xbytes;
+         }
+ 
+@@ -1010,49 +1009,51 @@
+ 
+     private AudioFormat format;
+ 
+-    public AudioFormat getFormat() {
++    public final AudioFormat getFormat() {
+         return format;
+     }
+ 
+     public abstract float[] toFloatArray(byte[] in_buff, int in_offset,
+             float[] out_buff, int out_offset, int out_len);
+ 
+-    public float[] toFloatArray(byte[] in_buff, float[] out_buff,
++    public final float[] toFloatArray(byte[] in_buff, float[] out_buff,
+             int out_offset, int out_len) {
+         return toFloatArray(in_buff, 0, out_buff, out_offset, out_len);
+     }
+ 
+-    public float[] toFloatArray(byte[] in_buff, int in_offset,
++    public final float[] toFloatArray(byte[] in_buff, int in_offset,
+             float[] out_buff, int out_len) {
+         return toFloatArray(in_buff, in_offset, out_buff, 0, out_len);
+     }
+ 
+-    public float[] toFloatArray(byte[] in_buff, float[] out_buff, int out_len) {
++    public final float[] toFloatArray(byte[] in_buff, float[] out_buff,
++                                      int out_len) {
+         return toFloatArray(in_buff, 0, out_buff, 0, out_len);
+     }
+ 
+-    public float[] toFloatArray(byte[] in_buff, float[] out_buff) {
++    public final float[] toFloatArray(byte[] in_buff, float[] out_buff) {
+         return toFloatArray(in_buff, 0, out_buff, 0, out_buff.length);
+     }
+ 
+     public abstract byte[] toByteArray(float[] in_buff, int in_offset,
+             int in_len, byte[] out_buff, int out_offset);
+ 
+-    public byte[] toByteArray(float[] in_buff, int in_len, byte[] out_buff,
+-            int out_offset) {
++    public final byte[] toByteArray(float[] in_buff, int in_len,
++                                    byte[] out_buff, int out_offset) {
+         return toByteArray(in_buff, 0, in_len, out_buff, out_offset);
+     }
+ 
+-    public byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
+-            byte[] out_buff) {
++    public final byte[] toByteArray(float[] in_buff, int in_offset, int in_len,
++                                    byte[] out_buff) {
+         return toByteArray(in_buff, in_offset, in_len, out_buff, 0);
+     }
+ 
+-    public byte[] toByteArray(float[] in_buff, int in_len, byte[] out_buff) {
++    public final byte[] toByteArray(float[] in_buff, int in_len,
++                                    byte[] out_buff) {
+         return toByteArray(in_buff, 0, in_len, out_buff, 0);
+     }
+ 
+-    public byte[] toByteArray(float[] in_buff, byte[] out_buff) {
++    public final byte[] toByteArray(float[] in_buff, byte[] out_buff) {
+         return toByteArray(in_buff, 0, in_buff.length, out_buff, 0);
+     }
+ }
+diff --git a/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java b/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -42,19 +42,19 @@
+  * 
+  * @author Karl Helgason
+  */
+-public class AudioFloatFormatConverter extends FormatConversionProvider {
++public final class AudioFloatFormatConverter extends FormatConversionProvider {
+ 
+     private static class AudioFloatFormatConverterInputStream extends
+             InputStream {
+-        private AudioFloatConverter converter;
++        private final AudioFloatConverter converter;
+ 
+-        private AudioFloatInputStream stream;
++        private final AudioFloatInputStream stream;
+ 
+         private float[] readfloatbuffer;
+ 
+-        private int fsize = 0;
++        private final int fsize;
+ 
+-        public AudioFloatFormatConverterInputStream(AudioFormat targetFormat,
++        AudioFloatFormatConverterInputStream(AudioFormat targetFormat,
+                 AudioFloatInputStream stream) {
+             this.stream = stream;
+             converter = AudioFloatConverter.getConverter(targetFormat);
+@@ -116,17 +116,17 @@
+     private static class AudioFloatInputStreamChannelMixer extends
+             AudioFloatInputStream {
+ 
+-        private int targetChannels;
++        private final int targetChannels;
+ 
+-        private int sourceChannels;
++        private final int sourceChannels;
+ 
+-        private AudioFloatInputStream ais;
++        private final AudioFloatInputStream ais;
+ 
+-        private AudioFormat targetFormat;
++        private final AudioFormat targetFormat;
+ 
+         private float[] conversion_buffer;
+ 
+-        public AudioFloatInputStreamChannelMixer(AudioFloatInputStream ais,
++        AudioFloatInputStreamChannelMixer(AudioFloatInputStream ais,
+                 int targetChannels) {
+             this.sourceChannels = ais.getFormat().getChannels();
+             this.targetChannels = targetChannels;
+@@ -226,37 +226,37 @@
+     private static class AudioFloatInputStreamResampler extends
+             AudioFloatInputStream {
+ 
+-        private AudioFloatInputStream ais;
++        private final AudioFloatInputStream ais;
+ 
+-        private AudioFormat targetFormat;
++        private final AudioFormat targetFormat;
+ 
+         private float[] skipbuffer;
+ 
+         private SoftAbstractResampler resampler;
+ 
+-        private float[] pitch = new float[1];
++        private final float[] pitch = new float[1];
+ 
+-        private float[] ibuffer2;
++        private final float[] ibuffer2;
+ 
+-        private float[][] ibuffer;
++        private final float[][] ibuffer;
+ 
+         private float ibuffer_index = 0;
+ 
+         private int ibuffer_len = 0;
+ 
+-        private int nrofchannels = 0;
++        private final int nrofchannels;
+ 
+         private float[][] cbuffer;
+ 
+-        private int buffer_len = 512;
++        private final int buffer_len = 512;
+ 
+-        private int pad;
++        private final int pad;
+ 
+-        private int pad2;
++        private final int pad2;
+ 
+-        private float[] ix = new float[1];
++        private final float[] ix = new float[1];
+ 
+-        private int[] ox = new int[1];
++        private final int[] ox = new int[1];
+ 
+         private float[][] mark_ibuffer = null;
+ 
+@@ -264,7 +264,7 @@
+ 
+         private int mark_ibuffer_len = 0;
+ 
+-        public AudioFloatInputStreamResampler(AudioFloatInputStream ais,
++        AudioFloatInputStreamResampler(AudioFloatInputStream ais,
+                 AudioFormat format) {
+             this.ais = ais;
+             AudioFormat sourceFormat = ais.getFormat();
+@@ -468,8 +468,9 @@
+ 
+     }
+ 
+-    private Encoding[] formats = { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED,
+-            AudioFloatConverter.PCM_FLOAT };
++    private final Encoding[] formats = {Encoding.PCM_SIGNED,
++                                        Encoding.PCM_UNSIGNED,
++                                        Encoding.PCM_FLOAT};
+ 
+     public AudioInputStream getAudioInputStream(Encoding targetEncoding,
+             AudioInputStream sourceStream) {
+diff --git a/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java b/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -48,14 +48,14 @@
+ 
+         private int pos = 0;
+         private int markpos = 0;
+-        private AudioFloatConverter converter;
+-        private AudioFormat format;
+-        private byte[] buffer;
+-        private int buffer_offset;
+-        private int buffer_len;
+-        private int framesize_pc;
++        private final AudioFloatConverter converter;
++        private final AudioFormat format;
++        private final byte[] buffer;
++        private final int buffer_offset;
++        private final int buffer_len;
++        private final int framesize_pc;
+ 
+-        public BytaArrayAudioFloatInputStream(AudioFloatConverter converter,
++        BytaArrayAudioFloatInputStream(AudioFloatConverter converter,
+                 byte[] buffer, int offset, int len) {
+             this.converter = converter;
+             this.format = converter.getFormat();
+@@ -125,12 +125,12 @@
+     private static class DirectAudioFloatInputStream
+             extends AudioFloatInputStream {
+ 
+-        private AudioInputStream stream;
++        private final AudioInputStream stream;
+         private AudioFloatConverter converter;
+-        private int framesize_pc; // framesize / channels
++        private final int framesize_pc; // framesize / channels
+         private byte[] buffer;
+ 
+-        public DirectAudioFloatInputStream(AudioInputStream stream) {
++        DirectAudioFloatInputStream(AudioInputStream stream) {
+             converter = AudioFloatConverter.getConverter(stream.getFormat());
+             if (converter == null) {
+                 AudioFormat format = stream.getFormat();
+@@ -255,11 +255,11 @@
+ 
+     public abstract int read(float[] b, int off, int len) throws IOException;
+ 
+-    public int read(float[] b) throws IOException {
++    public final int read(float[] b) throws IOException {
+         return read(b, 0, b.length);
+     }
+ 
+-    public float read() throws IOException {
++    public final float read() throws IOException {
+         float[] b = new float[1];
+         int ret = read(b, 0, 1);
+         if (ret == -1 || ret == 0)
+diff --git a/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java b/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,7 +29,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class AudioSynthesizerPropertyInfo {
++public final class AudioSynthesizerPropertyInfo {
+ 
+     /**
+      * Constructs a <code>AudioSynthesizerPropertyInfo</code> object with a given
+diff --git a/src/share/classes/com/sun/media/sound/DLSInfo.java b/src/share/classes/com/sun/media/sound/DLSInfo.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DLSInfo.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DLSInfo.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -30,7 +30,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class DLSInfo {
++public final class DLSInfo {
+ 
+     /**
+      * (INAM) Title or subject.
+diff --git a/src/share/classes/com/sun/media/sound/DLSInstrument.java b/src/share/classes/com/sun/media/sound/DLSInstrument.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DLSInstrument.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DLSInstrument.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -39,15 +39,15 @@
+  *
+  * @author Karl Helgason
+  */
+-public class DLSInstrument extends ModelInstrument {
++public final class DLSInstrument extends ModelInstrument {
+ 
+-    protected int preset = 0;
+-    protected int bank = 0;
+-    protected boolean druminstrument = false;
+-    protected byte[] guid = null;
+-    protected DLSInfo info = new DLSInfo();
+-    protected List<DLSRegion> regions = new ArrayList<DLSRegion>();
+-    protected List<DLSModulator> modulators = new ArrayList<DLSModulator>();
++    int preset = 0;
++    int bank = 0;
++    boolean druminstrument = false;
++    byte[] guid = null;
++    DLSInfo info = new DLSInfo();
++    List<DLSRegion> regions = new ArrayList<DLSRegion>();
++    List<DLSModulator> modulators = new ArrayList<DLSModulator>();
+ 
+     public DLSInstrument() {
+         super(null, null, null, null);
+diff --git a/src/share/classes/com/sun/media/sound/DLSModulator.java b/src/share/classes/com/sun/media/sound/DLSModulator.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DLSModulator.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DLSModulator.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,7 +33,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class DLSModulator {
++public final class DLSModulator {
+ 
+     // DLS1 Destinations
+     public static final int CONN_DST_NONE = 0x000; // 0
+@@ -102,12 +102,12 @@
+     public static final int DST_FORMAT_CENT = 1;
+     public static final int DST_FORMAT_TIMECENT = 2;
+     public static final int DST_FORMAT_PERCENT = 3;
+-    protected int source;
+-    protected int control;
+-    protected int destination;
+-    protected int transform;
+-    protected int scale;
+-    protected int version = 1;
++    int source;
++    int control;
++    int destination;
++    int transform;
++    int scale;
++    int version = 1;
+ 
+     public int getControl() {
+         return control;
+diff --git a/src/share/classes/com/sun/media/sound/DLSRegion.java b/src/share/classes/com/sun/media/sound/DLSRegion.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DLSRegion.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DLSRegion.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,21 +36,21 @@
+  *
+  * @author Karl Helgason
+  */
+-public class DLSRegion {
++public final class DLSRegion {
+ 
+     public final static int OPTION_SELFNONEXCLUSIVE = 0x0001;
+-    protected List<DLSModulator> modulators = new ArrayList<DLSModulator>();
+-    protected int keyfrom;
+-    protected int keyto;
+-    protected int velfrom;
+-    protected int velto;
+-    protected int options;
+-    protected int exclusiveClass;
+-    protected int fusoptions;
+-    protected int phasegroup;
+-    protected long channel;
+-    protected DLSSample sample = null;
+-    protected DLSSampleOptions sampleoptions;
++    List<DLSModulator> modulators = new ArrayList<DLSModulator>();
++    int keyfrom;
++    int keyto;
++    int velfrom;
++    int velto;
++    int options;
++    int exclusiveClass;
++    int fusoptions;
++    int phasegroup;
++    long channel;
++    DLSSample sample = null;
++    DLSSampleOptions sampleoptions;
+ 
+     public List<DLSModulator> getModulators() {
+         return modulators;
+diff --git a/src/share/classes/com/sun/media/sound/DLSSample.java b/src/share/classes/com/sun/media/sound/DLSSample.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSample.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSample.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -39,13 +39,13 @@
+  *
+  * @author Karl Helgason
+  */
+-public class DLSSample extends SoundbankResource {
++public final class DLSSample extends SoundbankResource {
+ 
+-    protected byte[] guid = null;
+-    protected DLSInfo info = new DLSInfo();
+-    protected DLSSampleOptions sampleoptions;
+-    protected ModelByteBuffer data;
+-    protected AudioFormat format;
++    byte[] guid = null;
++    DLSInfo info = new DLSInfo();
++    DLSSampleOptions sampleoptions;
++    ModelByteBuffer data;
++    AudioFormat format;
+ 
+     public DLSSample(Soundbank soundBank) {
+         super(soundBank, null, AudioInputStream.class);
+diff --git a/src/share/classes/com/sun/media/sound/DLSSampleLoop.java b/src/share/classes/com/sun/media/sound/DLSSampleLoop.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSampleLoop.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSampleLoop.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,13 +29,13 @@
+  *
+  * @author Karl Helgason
+  */
+-public class DLSSampleLoop {
++public final class DLSSampleLoop {
+ 
+     public final static int LOOP_TYPE_FORWARD = 0;
+     public final static int LOOP_TYPE_RELEASE = 1;
+-    protected long type;
+-    protected long start;
+-    protected long length;
++    long type;
++    long start;
++    long length;
+ 
+     public long getLength() {
+         return length;
+diff --git a/src/share/classes/com/sun/media/sound/DLSSampleOptions.java b/src/share/classes/com/sun/media/sound/DLSSampleOptions.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSampleOptions.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSampleOptions.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -34,13 +34,13 @@
+  *
+  * @author Karl Helgason
+  */
+-public class DLSSampleOptions {
++public final class DLSSampleOptions {
+ 
+-    protected int unitynote;
+-    protected short finetune;
+-    protected int attenuation;
+-    protected long options;
+-    protected List<DLSSampleLoop> loops = new ArrayList<DLSSampleLoop>();
++    int unitynote;
++    short finetune;
++    int attenuation;
++    long options;
++    List<DLSSampleLoop> loops = new ArrayList<DLSSampleLoop>();
+ 
+     public int getAttenuation() {
+         return attenuation;
+diff --git a/src/share/classes/com/sun/media/sound/DLSSoundbank.java b/src/share/classes/com/sun/media/sound/DLSSoundbank.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -51,7 +51,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class DLSSoundbank implements Soundbank {
++public final class DLSSoundbank implements Soundbank {
+ 
+     static private class DLSID {
+         long i1;
+@@ -69,7 +69,7 @@
+         private DLSID() {
+         }
+ 
+-        public DLSID(long i1, int s1, int s2, int x1, int x2, int x3, int x4,
++        DLSID(long i1, int s1, int s2, int x1, int x2, int x3, int x4,
+                 int x5, int x6, int x7, int x8) {
+             this.i1 = i1;
+             this.s1 = s1;
+@@ -174,10 +174,10 @@
+     private long major = -1;
+     private long minor = -1;
+ 
+-    private DLSInfo info = new DLSInfo();
++    private final DLSInfo info = new DLSInfo();
+ 
+-    private List<DLSInstrument> instruments = new ArrayList<DLSInstrument>();
+-    private List<DLSSample> samples = new ArrayList<DLSSample>();
++    private final List<DLSInstrument> instruments = new ArrayList<DLSInstrument>();
++    private final List<DLSSample> samples = new ArrayList<DLSSample>();
+ 
+     private boolean largeFormat = false;
+     private File sampleFile;
+diff --git a/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java b/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -39,7 +39,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class DLSSoundbankReader extends SoundbankReader {
++public final class DLSSoundbankReader extends SoundbankReader {
+ 
+     public Soundbank getSoundbank(URL url)
+             throws InvalidMidiDataException, IOException {
+diff --git a/src/share/classes/com/sun/media/sound/DataPusher.java b/src/share/classes/com/sun/media/sound/DataPusher.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DataPusher.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DataPusher.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -37,13 +37,13 @@
+  * @author Florian Bomers
+  */
+ 
+-public class DataPusher implements Runnable {
++public final class DataPusher implements Runnable {
+ 
+     private static final int AUTO_CLOSE_TIME = 5000;
+     private static final boolean DEBUG = false;
+ 
+-    private SourceDataLine source = null;
+-    private AudioFormat format = null;
++    private final SourceDataLine source;
++    private final AudioFormat format;
+ 
+     // stream as source data
+     private AudioInputStream ais = null;
+diff --git a/src/share/classes/com/sun/media/sound/DirectAudioDevice.java b/src/share/classes/com/sun/media/sound/DirectAudioDevice.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -42,7 +42,7 @@
+  *
+  * @author Florian Bomers
+  */
+-class DirectAudioDevice extends AbstractMixer {
++final class DirectAudioDevice extends AbstractMixer {
+ 
+     // CONSTANTS
+     private static final int CLIP_BUFFER_TIME = 1000; // in milliseconds
+@@ -335,8 +335,8 @@
+      * but isFormatSupported() also returns true
+      * for formats with wrong endianness.
+      */
+-    private static class DirectDLI extends DataLine.Info {
+-        AudioFormat[] hardwareFormats;
++    private static final class DirectDLI extends DataLine.Info {
++        final AudioFormat[] hardwareFormats;
+ 
+         private DirectDLI(Class clazz, AudioFormat[] formatArray,
+                           AudioFormat[] hardwareFormatArray,
+@@ -370,12 +370,12 @@
+      * Private inner class as base class for direct lines
+      */
+     private static class DirectDL extends AbstractDataLine implements EventDispatcher.LineMonitor {
+-        protected int mixerIndex;
+-        protected int deviceID;
++        protected final int mixerIndex;
++        protected final int deviceID;
+         protected long id;
+         protected int waitTime;
+         protected volatile boolean flushing = false;
+-        protected boolean isSource;         // true for SourceDataLine, false for TargetDataLine
++        protected final boolean isSource;         // true for SourceDataLine, false for TargetDataLine
+         protected volatile long bytePosition;
+         protected volatile boolean doIO = false;     // true in between start() and stop() calls
+         protected volatile boolean stoppedWritten = false; // true if a write occured in stopped state
+@@ -387,10 +387,10 @@
+         protected int softwareConversionSize = 0;
+         protected AudioFormat hardwareFormat;
+ 
+-        private Gain gainControl = new Gain();
+-        private Mute muteControl = new Mute();
+-        private Balance balanceControl = new Balance();
+-        private Pan panControl = new Pan();
++        private final Gain gainControl = new Gain();
++        private final Mute muteControl = new Mute();
++        private final Balance balanceControl = new Balance();
++        private final Pan panControl = new Pan();
+         private float leftGain, rightGain;
+         protected volatile boolean noService = false; // do not run the nService method
+ 
+@@ -865,7 +865,7 @@
+ 
+         /////////////////// CONTROLS /////////////////////////////
+ 
+-        protected class Gain extends FloatControl {
++        protected final class Gain extends FloatControl {
+ 
+             private float linearGain = 1.0f;
+ 
+@@ -898,7 +898,7 @@
+         } // class Gain
+ 
+ 
+-        private class Mute extends BooleanControl {
++        private final class Mute extends BooleanControl {
+ 
+             private Mute() {
+                 super(BooleanControl.Type.MUTE, false, "True", "False");
+@@ -910,7 +910,7 @@
+             }
+         }  // class Mute
+ 
+-        private class Balance extends FloatControl {
++        private final class Balance extends FloatControl {
+ 
+             private Balance() {
+                 super(FloatControl.Type.BALANCE, -1.0f, 1.0f, (1.0f / 128.0f), -1, 0.0f,
+@@ -929,7 +929,7 @@
+ 
+         } // class Balance
+ 
+-        private class Pan extends FloatControl {
++        private final class Pan extends FloatControl {
+ 
+             private Pan() {
+                 super(FloatControl.Type.PAN, -1.0f, 1.0f, (1.0f / 128.0f), -1, 0.0f,
+@@ -954,7 +954,8 @@
+     /**
+      * Private inner class representing a SourceDataLine
+      */
+-    private static class DirectSDL extends DirectDL implements SourceDataLine {
++    private static final class DirectSDL extends DirectDL
++            implements SourceDataLine {
+ 
+         // CONSTRUCTOR
+         private DirectSDL(DataLine.Info info,
+@@ -970,7 +971,8 @@
+     /**
+      * Private inner class representing a TargetDataLine
+      */
+-    private static class DirectTDL extends DirectDL implements TargetDataLine {
++    private static final class DirectTDL extends DirectDL
++            implements TargetDataLine {
+ 
+         // CONSTRUCTOR
+         private DirectTDL(DataLine.Info info,
+@@ -1049,7 +1051,9 @@
+      * Private inner class representing a Clip
+      * This clip is realized in software only
+      */
+-    private static class DirectClip extends DirectDL implements Clip,  Runnable, AutoClosingClip {
++    private static final class DirectClip extends DirectDL
++            implements Clip, Runnable, AutoClosingClip {
++
+         private Thread thread;
+         private byte[] audioData = null;
+         private int frameSize;         // size of one frame in bytes
+@@ -1082,7 +1086,7 @@
+ 
+             byte[] newData = new byte[bufferSize];
+             System.arraycopy(data, offset, newData, 0, bufferSize);
+-            open(format, data, bufferSize / format.getFrameSize());
++            open(format, newData, bufferSize / format.getFrameSize());
+         }
+ 
+         // this method does not copy the data array
+@@ -1478,7 +1482,7 @@
+      * which allows retrieval of the internal array
+      */
+     private static class DirectBAOS extends ByteArrayOutputStream {
+-        public DirectBAOS() {
++        DirectBAOS() {
+             super();
+         }
+ 
+diff --git a/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java b/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,8 +25,6 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.util.Vector;
+-
+ import javax.sound.sampled.Mixer;
+ import javax.sound.sampled.spi.MixerProvider;
+ 
+@@ -36,7 +34,7 @@
+  *
+  * @author Florian Bomers
+  */
+-public class DirectAudioDeviceProvider extends MixerProvider {
++public final class DirectAudioDeviceProvider extends MixerProvider {
+ 
+     // STATIC VARIABLES
+ 
+@@ -66,16 +64,17 @@
+      * Required public no-arg constructor.
+      */
+     public DirectAudioDeviceProvider() {
+-        //if (Printer.trace) Printer.trace("DirectAudioDeviceProvider: constructor");
+-        if (Platform.isDirectAudioEnabled()) {
+-            init();
+-        } else {
+-            infos = new DirectAudioDeviceInfo[0];
+-            devices = new DirectAudioDevice[0];
++        synchronized (DirectAudioDeviceProvider.class) {
++            if (Platform.isDirectAudioEnabled()) {
++                init();
++            } else {
++                infos = new DirectAudioDeviceInfo[0];
++                devices = new DirectAudioDevice[0];
++            }
+         }
+     }
+ 
+-    private synchronized static void init() {
++    private static void init() {
+         // get the number of input devices
+         int numDevices = nGetNumDevices();
+ 
+@@ -94,36 +93,39 @@
+     }
+ 
+     public Mixer.Info[] getMixerInfo() {
+-        Mixer.Info[] localArray = new Mixer.Info[infos.length];
+-        System.arraycopy(infos, 0, localArray, 0, infos.length);
+-        return localArray;
++        synchronized (DirectAudioDeviceProvider.class) {
++            Mixer.Info[] localArray = new Mixer.Info[infos.length];
++            System.arraycopy(infos, 0, localArray, 0, infos.length);
++            return localArray;
++        }
+     }
+ 
+ 
+     public Mixer getMixer(Mixer.Info info) {
+-        // if the default device is asked, we provide the mixer
+-        // with SourceDataLine's
+-        if (info == null) {
++        synchronized (DirectAudioDeviceProvider.class) {
++            // if the default device is asked, we provide the mixer
++            // with SourceDataLine's
++            if (info == null) {
++                for (int i = 0; i < infos.length; i++) {
++                    Mixer mixer = getDevice(infos[i]);
++                    if (mixer.getSourceLineInfo().length > 0) {
++                        return mixer;
++                    }
++                }
++            }
++            // otherwise get the first mixer that matches
++            // the requested info object
+             for (int i = 0; i < infos.length; i++) {
+-                Mixer mixer = getDevice(infos[i]);
+-                if (mixer.getSourceLineInfo().length > 0) {
+-                    return mixer;
++                if (infos[i].equals(info)) {
++                    return getDevice(infos[i]);
+                 }
+             }
+         }
+-        // otherwise get the first mixer that matches
+-        // the requested info object
+-        for (int i = 0; i < infos.length; i++) {
+-            if (infos[i].equals(info)) {
+-                return getDevice(infos[i]);
+-            }
+-        }
+-
+         throw new IllegalArgumentException("Mixer " + info.toString() + " not supported by this provider.");
+     }
+ 
+ 
+-    private Mixer getDevice(DirectAudioDeviceInfo info) {
++    private static Mixer getDevice(DirectAudioDeviceInfo info) {
+         int index = info.getIndex();
+         if (devices[index] == null) {
+             devices[index] = new DirectAudioDevice(info);
+@@ -139,12 +141,12 @@
+      * making native references to a particular device.
+      * This constructor is called from native.
+      */
+-    static class DirectAudioDeviceInfo extends Mixer.Info {
+-        private int index;
+-        private int maxSimulLines;
++    static final class DirectAudioDeviceInfo extends Mixer.Info {
++        private final int index;
++        private final int maxSimulLines;
+ 
+         // For ALSA, the deviceID contains the encoded card index, device index, and sub-device-index
+-        private int deviceID;
++        private final int deviceID;
+ 
+         private DirectAudioDeviceInfo(int index, int deviceID, int maxSimulLines,
+                                       String name, String vendor,
+diff --git a/src/share/classes/com/sun/media/sound/EmergencySoundbank.java b/src/share/classes/com/sun/media/sound/EmergencySoundbank.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/EmergencySoundbank.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/EmergencySoundbank.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -35,7 +35,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class EmergencySoundbank {
++public final class EmergencySoundbank {
+ 
+     private final static String[] general_midi_instruments = {
+         "Acoustic Grand Piano",
+diff --git a/src/share/classes/com/sun/media/sound/EventDispatcher.java b/src/share/classes/com/sun/media/sound/EventDispatcher.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,20 +25,16 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.util.EventObject;
+ import java.util.ArrayList;
+ import java.util.List;
+ 
+-import javax.sound.sampled.Clip;
+-import javax.sound.sampled.Line;
++import javax.sound.midi.ControllerEventListener;
++import javax.sound.midi.MetaEventListener;
++import javax.sound.midi.MetaMessage;
++import javax.sound.midi.ShortMessage;
+ import javax.sound.sampled.LineEvent;
+ import javax.sound.sampled.LineListener;
+ 
+-import javax.sound.midi.MetaMessage;
+-import javax.sound.midi.ShortMessage;
+-import javax.sound.midi.MetaEventListener;
+-import javax.sound.midi.ControllerEventListener;
+-
+ 
+ 
+ /**
+@@ -49,7 +45,7 @@
+  * @author Kara Kytle
+  * @author Florian Bomers
+  */
+-class EventDispatcher implements Runnable {
++final class EventDispatcher implements Runnable {
+ 
+     /**
+      * time of inactivity until the auto closing clips
+@@ -61,7 +57,7 @@
+     /**
+      * List of events
+      */
+-    private ArrayList eventQueue = new ArrayList();
++    private final ArrayList eventQueue = new ArrayList();
+ 
+ 
+     /**
+@@ -73,12 +69,12 @@
+     /*
+      * support for auto-closing Clips
+      */
+-    private ArrayList<ClipInfo> autoClosingClips = new ArrayList<ClipInfo>();
++    private final ArrayList<ClipInfo> autoClosingClips = new ArrayList<ClipInfo>();
+ 
+     /*
+      * support for monitoring data lines
+      */
+-    private ArrayList<LineMonitor> lineMonitors = new ArrayList<LineMonitor>();
++    private final ArrayList<LineMonitor> lineMonitors = new ArrayList<LineMonitor>();
+ 
+     /**
+      * Approximate interval between calls to LineMonitor.checkLine
+@@ -105,7 +101,7 @@
+      * Invoked when there is at least one event in the queue.
+      * Implement this as a callback to process one event.
+      */
+-    protected void processEvent(EventInfo eventInfo) {
++    void processEvent(EventInfo eventInfo) {
+         int count = eventInfo.getListenerCount();
+ 
+         // process an LineEvent
+@@ -166,7 +162,7 @@
+      * exclusive access over the code where an event is removed from the
+      *queue.
+      */
+-    protected void dispatchEvents() {
++    void dispatchEvents() {
+ 
+         EventInfo eventInfo = null;
+ 
+@@ -388,8 +384,8 @@
+      */
+     private class EventInfo {
+ 
+-        private Object event;
+-        private Object[] listeners;
++        private final Object event;
++        private final Object[] listeners;
+ 
+         /**
+          * Create a new instance of this event Info class
+@@ -421,8 +417,8 @@
+      */
+     private class ClipInfo {
+ 
+-        private AutoClosingClip clip;
+-        private long expiration;
++        private final AutoClosingClip clip;
++        private final long expiration;
+ 
+         /**
+          * Create a new instance of this clip Info class
+diff --git a/src/share/classes/com/sun/media/sound/FFT.java b/src/share/classes/com/sun/media/sound/FFT.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/FFT.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/FFT.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -31,11 +31,11 @@
+  */
+ public final class FFT {
+ 
+-    private double[] w;
+-    private int fftFrameSize;
+-    private int sign;
+-    private int[] bitm_array;
+-    private int fftFrameSize2;
++    private final double[] w;
++    private final int fftFrameSize;
++    private final int sign;
++    private final int[] bitm_array;
++    private final int fftFrameSize2;
+ 
+     // Sign = -1 is FFT, 1 is IFFT (inverse FFT)
+     // Data = Interlaced double array to be transformed.
+diff --git a/src/share/classes/com/sun/media/sound/FastShortMessage.java b/src/share/classes/com/sun/media/sound/FastShortMessage.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/FastShortMessage.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/FastShortMessage.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -35,13 +35,13 @@
+ final class FastShortMessage extends ShortMessage {
+     private int packedMsg;
+ 
+-    public FastShortMessage(int packedMsg) throws InvalidMidiDataException {
++    FastShortMessage(int packedMsg) throws InvalidMidiDataException {
+         this.packedMsg = packedMsg;
+         getDataLength(packedMsg & 0xFF); // to check for validity
+     }
+ 
+     /** Creates a FastShortMessage from this ShortMessage */
+-    public FastShortMessage(ShortMessage msg) {
++    FastShortMessage(ShortMessage msg) {
+         this.packedMsg = msg.getStatus()
+             | (msg.getData1() << 8)
+             | (msg.getData2() << 16);
+diff --git a/src/share/classes/com/sun/media/sound/JARSoundbankReader.java b/src/share/classes/com/sun/media/sound/JARSoundbankReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,14 +36,16 @@
+ import javax.sound.midi.Soundbank;
+ import javax.sound.midi.spi.SoundbankReader;
+ 
++import sun.reflect.misc.ReflectUtil;
++
+ /**
+- * JarSoundbankReader is used to read sounbank object from jar files.
++ * JarSoundbankReader is used to read soundbank object from jar files.
+  *
+  * @author Karl Helgason
+  */
+-public class JARSoundbankReader extends SoundbankReader {
++public final class JARSoundbankReader extends SoundbankReader {
+ 
+-    public boolean isZIP(URL url) {
++    private static boolean isZIP(URL url) {
+         boolean ok = false;
+         try {
+             InputStream stream = url.openStream();
+@@ -81,14 +83,14 @@
+             while (line != null) {
+                 if (!line.startsWith("#")) {
+                     try {
+-                        Class c = Class.forName(line.trim(), true, ucl);
+-                        Object o = c.newInstance();
+-                        if (o instanceof Soundbank) {
++                        Class<?> c = Class.forName(line.trim(), false, ucl);
++                        if (Soundbank.class.isAssignableFrom(c)) {
++                            Object o = ReflectUtil.newInstance(c);
+                             soundbanks.add((Soundbank) o);
+                         }
+-                    } catch (ClassNotFoundException  e) {
+-                    } catch (InstantiationException  e) {
+-                    } catch (IllegalAccessException  e) {
++                    } catch (ClassNotFoundException ignored) {
++                    } catch (InstantiationException ignored) {
++                    } catch (IllegalAccessException ignored) {
+                     }
+                 }
+                 line = r.readLine();
+diff --git a/src/share/classes/com/sun/media/sound/JDK13Services.java b/src/share/classes/com/sun/media/sound/JDK13Services.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -31,16 +31,6 @@
+ import java.util.Map;
+ import java.util.Properties;
+ 
+-import javax.sound.sampled.spi.AudioFileReader;
+-import javax.sound.sampled.spi.AudioFileWriter;
+-import javax.sound.sampled.spi.FormatConversionProvider;
+-import javax.sound.sampled.spi.MixerProvider;
+-
+-import javax.sound.midi.spi.MidiFileReader;
+-import javax.sound.midi.spi.MidiFileWriter;
+-import javax.sound.midi.spi.SoundbankReader;
+-import javax.sound.midi.spi.MidiDeviceProvider;
+-
+ import javax.sound.midi.Receiver;
+ import javax.sound.midi.Sequencer;
+ import javax.sound.midi.Synthesizer;
+@@ -62,7 +52,7 @@
+  *
+  * @author Matthias Pfisterer
+  */
+-public class JDK13Services {
++public final class JDK13Services {
+ 
+     /** The default for the length of the period to hold the cache.
+         This value is given in milliseconds. It is equivalent to
+@@ -80,7 +70,7 @@
+         Class objects of the provider type (MixerProvider, MidiDeviceProvider
+         ...) are used as keys. The values are instances of ProviderCache.
+     */
+-    private static Map providersCacheMap = new HashMap();
++    private static final Map providersCacheMap = new HashMap();
+ 
+ 
+     /** The length of the period to hold the cache.
+diff --git a/src/share/classes/com/sun/media/sound/JSSecurityManager.java b/src/share/classes/com/sun/media/sound/JSSecurityManager.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -49,7 +49,7 @@
+  *
+  * @author Matthias Pfisterer
+  */
+-class JSSecurityManager {
++final class JSSecurityManager {
+ 
+     /** Prevent instantiation.
+      */
+@@ -75,30 +75,6 @@
+         }
+     }
+ 
+-
+-    static void loadLibrary(final String libName) {
+-        try {
+-            if (hasSecurityManager()) {
+-                if(Printer.debug) Printer.debug("using security manager to load library");
+-                PrivilegedAction action = new PrivilegedAction() {
+-                        public Object run() {
+-                            System.loadLibrary(libName);
+-                            return null;
+-                        }
+-                    };
+-                AccessController.doPrivileged(action);
+-            } else {
+-                if(Printer.debug) Printer.debug("not using security manager to load library");
+-                System.loadLibrary(libName);
+-            }
+-            if (Printer.debug) Printer.debug("loaded library " + libName);
+-        } catch (UnsatisfiedLinkError e2) {
+-            if (Printer.err)Printer.err("UnsatisfiedLinkError loading native library " + libName);
+-            throw(e2);
+-        }
+-    }
+-
+-
+     static String getProperty(final String propertyName) {
+         String propertyValue;
+         if (hasSecurityManager()) {
+@@ -191,83 +167,13 @@
+         if(Printer.trace)Printer.trace("<< JSSecurityManager: loadPropertiesImpl() completed");
+     }
+ 
+-
+-    private static ThreadGroup getTopmostThreadGroup() {
+-        ThreadGroup topmostThreadGroup;
+-        if(hasSecurityManager()) {
+-            try {
+-                // invoke the privileged action using 1.2 security
+-                PrivilegedAction action = new PrivilegedAction() {
+-                        public Object run() {
+-                            try {
+-                                return getTopmostThreadGroupImpl();
+-                            } catch (Throwable t) {
+-                                return null;
+-                            }
+-                        }
+-                    };
+-                topmostThreadGroup = (ThreadGroup) AccessController.doPrivileged(action);
+-                if(Printer.debug)Printer.debug("Got topmost thread group with JDK 1.2 security");
+-            } catch (Exception e) {
+-                if(Printer.debug)Printer.debug("Exception getting topmost thread group with JDK 1.2 security");
+-                // try without using JDK 1.2 security
+-                topmostThreadGroup = getTopmostThreadGroupImpl();
+-            }
+-        } else {
+-            // not JDK 1.2 security, assume we already have permission
+-            topmostThreadGroup = getTopmostThreadGroupImpl();
+-        }
+-        return topmostThreadGroup;
+-    }
+-
+-
+-    private static ThreadGroup getTopmostThreadGroupImpl() {
+-        if(Printer.trace)Printer.trace(">> JSSecurityManager: getTopmostThreadGroupImpl()");
+-        ThreadGroup g = Thread.currentThread().getThreadGroup();
+-        while ((g.getParent() != null) && (g.getParent().getParent() != null)) {
+-            g = g.getParent();
+-        }
+-        if(Printer.trace)Printer.trace("<< JSSecurityManager: getTopmostThreadGroupImpl() completed");
+-        return g;
+-    }
+-
+-
+-    /** Create a Thread in the topmost ThreadGroup.
++    /** Create a Thread in the current ThreadGroup.
+      */
+     static Thread createThread(final Runnable runnable,
+                                final String threadName,
+                                final boolean isDaemon, final int priority,
+                                final boolean doStart) {
+-        Thread thread = null;
+-        if(hasSecurityManager()) {
+-            PrivilegedAction action = new PrivilegedAction() {
+-                    public Object run() {
+-                        try {
+-                            return createThreadImpl(runnable, threadName,
+-                                                    isDaemon, priority,
+-                                                    doStart);
+-                        } catch (Throwable t) {
+-                            return null;
+-                        }
+-                    }
+-                };
+-            thread = (Thread) AccessController.doPrivileged(action);
+-            if(Printer.debug) Printer.debug("created thread with JDK 1.2 security");
+-        } else {
+-            if(Printer.debug)Printer.debug("not using JDK 1.2 security");
+-            thread = createThreadImpl(runnable, threadName, isDaemon, priority,
+-                                      doStart);
+-        }
+-        return thread;
+-    }
+-
+-
+-    private static Thread createThreadImpl(Runnable runnable,
+-                                           String threadName,
+-                                           boolean isDaemon, int priority,
+-                                           boolean doStart) {
+-        ThreadGroup threadGroup = getTopmostThreadGroupImpl();
+-        Thread thread = new Thread(threadGroup, runnable);
++        Thread thread = new Thread(runnable);
+         if (threadName != null) {
+             thread.setName(threadName);
+         }
+@@ -281,7 +187,6 @@
+         return thread;
+     }
+ 
+-
+     static List getProviders(final Class providerClass) {
+         List p = new ArrayList();
+         // Service.providers(Class) just creates "lazy" iterator instance,
+diff --git a/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java b/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -28,25 +28,19 @@
+ import java.io.IOException;
+ import java.io.InputStream;
+ import java.io.BufferedInputStream;
+-import java.io.ByteArrayInputStream;
+ import java.io.ByteArrayOutputStream;
+ import java.applet.AudioClip;
+-import java.lang.InterruptedException;
+ 
+ import javax.sound.sampled.AudioSystem;
+-import javax.sound.sampled.Mixer;
+ import javax.sound.sampled.Clip;
+-import javax.sound.sampled.Control;
+ import javax.sound.sampled.AudioInputStream;
+ import javax.sound.sampled.AudioFormat;
+ import javax.sound.sampled.DataLine;
+ import javax.sound.sampled.SourceDataLine;
+ import javax.sound.sampled.LineEvent;
+ import javax.sound.sampled.LineListener;
+-import javax.sound.sampled.LineUnavailableException;
+ import javax.sound.sampled.UnsupportedAudioFileException;
+ 
+-
+ import javax.sound.midi.MidiSystem;
+ import javax.sound.midi.MidiFileFormat;
+ import javax.sound.midi.MetaMessage;
+@@ -63,7 +57,7 @@
+  * @author Florian Bomers
+  */
+ 
+-public class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener {
++public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener {
+ 
+     private static final boolean DEBUG = false;
+     private static final int BUFFER_SIZE = 16384; // number of bytes written each time to the source data line
+@@ -476,7 +470,7 @@
+      * which allows retrieval of the internal array
+      */
+     private static class DirectBAOS extends ByteArrayOutputStream {
+-        public DirectBAOS() {
++        DirectBAOS() {
+             super();
+         }
+ 
+diff --git a/src/share/classes/com/sun/media/sound/MidiInDevice.java b/src/share/classes/com/sun/media/sound/MidiInDevice.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/MidiInDevice.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/MidiInDevice.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,9 +25,6 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.util.ArrayList;
+-import java.util.List;
+-
+ import javax.sound.midi.*;
+ 
+ 
+@@ -39,7 +36,7 @@
+  * @author Kara Kytle
+  * @author Florian Bomers
+  */
+-class MidiInDevice extends AbstractMidiDevice implements Runnable {
++final class MidiInDevice extends AbstractMidiDevice implements Runnable {
+ 
+     private Thread midiInThread = null;
+ 
+@@ -127,7 +124,7 @@
+       * An own class to distinguish the class name from
+       * the transmitter of other devices
+       */
+-    private class MidiInTransmitter extends BasicTransmitter {
++    private final class MidiInTransmitter extends BasicTransmitter {
+         private MidiInTransmitter() {
+             super();
+         }
+diff --git a/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java b/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -26,7 +26,6 @@
+ package com.sun.media.sound;
+ 
+ import javax.sound.midi.MidiDevice;
+-import javax.sound.midi.spi.MidiDeviceProvider;
+ 
+ 
+ /**
+@@ -35,15 +34,15 @@
+  * @author Kara Kytle
+  * @author Florian Bomers
+  */
+-public class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
++public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
+ 
+     /** Cache of info objects for all MIDI output devices on the system. */
+-    static Info[] infos = null;
++    private static Info[] infos = null;
+ 
+     /** Cache of open MIDI input devices on the system. */
+-    static MidiDevice[] devices = null;
++    private static MidiDevice[] devices = null;
+ 
+-    private static boolean enabled;
++    private static final boolean enabled;
+ 
+     // STATIC
+ 
+@@ -106,8 +105,8 @@
+      * previous instance may still exist and be open / in use / etc.,
+      * the new instance will not reflect that state...
+      */
+-    static class MidiInDeviceInfo extends AbstractMidiDeviceProvider.Info {
+-        private Class providerClass;
++    static final class MidiInDeviceInfo extends AbstractMidiDeviceProvider.Info {
++        private final Class providerClass;
+ 
+         private MidiInDeviceInfo(int index, Class providerClass) {
+             super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index);
+diff --git a/src/share/classes/com/sun/media/sound/MidiOutDevice.java b/src/share/classes/com/sun/media/sound/MidiOutDevice.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/MidiOutDevice.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/MidiOutDevice.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,7 +36,7 @@
+  * @author Kara Kytle
+  * @author Florian Bomers
+  */
+-class MidiOutDevice extends AbstractMidiDevice {
++final class MidiOutDevice extends AbstractMidiDevice {
+ 
+     // CONSTRUCTOR
+ 
+@@ -101,7 +101,7 @@
+ 
+     // INNER CLASSES
+ 
+-    class MidiOutReceiver extends AbstractReceiver {
++    final class MidiOutReceiver extends AbstractReceiver {
+ 
+         void implSend(final MidiMessage message, final long timeStamp) {
+             final int length = message.getLength();
+diff --git a/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java b/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -26,7 +26,6 @@
+ package com.sun.media.sound;
+ 
+ import javax.sound.midi.MidiDevice;
+-import javax.sound.midi.spi.MidiDeviceProvider;
+ 
+ 
+ /**
+@@ -35,15 +34,15 @@
+  * @author Kara Kytle
+  * @author Florian Bomers
+  */
+-public class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
++public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
+ 
+     /** Cache of info objects for all MIDI output devices on the system. */
+-    static Info[] infos = null;
++    private static Info[] infos = null;
+ 
+     /** Cache of open MIDI output devices on the system. */
+-    static MidiDevice[] devices = null;
++    private static MidiDevice[] devices = null;
+ 
+-    private static boolean enabled;
++    private final static boolean enabled;
+ 
+     // STATIC
+ 
+@@ -104,8 +103,8 @@
+      * previous instance may still exist and be open / in use / etc.,
+      * the new instance will not reflect that state...
+      */
+-    static class MidiOutDeviceInfo extends AbstractMidiDeviceProvider.Info {
+-        private Class providerClass;
++    static final class MidiOutDeviceInfo extends AbstractMidiDeviceProvider.Info {
++        private final Class providerClass;
+ 
+         private MidiOutDeviceInfo(int index, Class providerClass) {
+             super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index);
+diff --git a/src/share/classes/com/sun/media/sound/MidiUtils.java b/src/share/classes/com/sun/media/sound/MidiUtils.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,12 +36,17 @@
+  *
+  * @author Florian Bomers
+  */
+-public class MidiUtils {
++public final class MidiUtils {
+ 
+     public final static int DEFAULT_TEMPO_MPQ = 500000; // 120bpm
+     public final static int META_END_OF_TRACK_TYPE = 0x2F;
+     public final static int META_TEMPO_TYPE = 0x51;
+ 
++    /**
++     * Suppresses default constructor, ensuring non-instantiability.
++     */
++    private MidiUtils() {
++    }
+ 
+     /** return true if the passed message is Meta End Of Track */
+     public static boolean isMetaEndOfTrack(MidiMessage midiMsg) {
+@@ -262,7 +267,7 @@
+     }
+ 
+ 
+-    public static class TempoCache {
++    public static final class TempoCache {
+         long[] ticks;
+         int[] tempos; // in MPQ
+         // index in ticks/tempos at the snapshot
+diff --git a/src/share/classes/com/sun/media/sound/ModelByteBuffer.java b/src/share/classes/com/sun/media/sound/ModelByteBuffer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -38,7 +38,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelByteBuffer {
++public final class ModelByteBuffer {
+ 
+     private ModelByteBuffer root = this;
+     private File file;
+@@ -49,12 +49,12 @@
+ 
+     private class RandomFileInputStream extends InputStream {
+ 
+-        private RandomAccessFile raf;
++        private final RandomAccessFile raf;
+         private long left;
+         private long mark = 0;
+         private long markleft = 0;
+ 
+-        public RandomFileInputStream() throws IOException {
++        RandomFileInputStream() throws IOException {
+             raf = new RandomAccessFile(root.file, "r");
+             raf.seek(root.fileoffset + arrayOffset());
+             left = capacity();
+diff --git a/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java b/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,18 +36,18 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelByteBufferWavetable implements ModelWavetable {
++public final class ModelByteBufferWavetable implements ModelWavetable {
+ 
+     private class Buffer8PlusInputStream extends InputStream {
+ 
+-        private boolean bigendian;
+-        private int framesize_pc;
++        private final boolean bigendian;
++        private final int framesize_pc;
+         int pos = 0;
+         int pos2 = 0;
+         int markpos = 0;
+         int markpos2 = 0;
+ 
+-        public Buffer8PlusInputStream() {
++        Buffer8PlusInputStream() {
+             framesize_pc = format.getFrameSize() / format.getChannels();
+             bigendian = format.isBigEndian();
+         }
+@@ -127,7 +127,7 @@
+ 
+     private float loopStart = -1;
+     private float loopLength = -1;
+-    private ModelByteBuffer buffer;
++    private final ModelByteBuffer buffer;
+     private ModelByteBuffer buffer8 = null;
+     private AudioFormat format = null;
+     private float pitchcorrection = 0;
+diff --git a/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java b/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -32,7 +32,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelConnectionBlock {
++public final class ModelConnectionBlock {
+ 
+     //
+     //   source1 * source2 * scale -> destination
+diff --git a/src/share/classes/com/sun/media/sound/ModelDestination.java b/src/share/classes/com/sun/media/sound/ModelDestination.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelDestination.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelDestination.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -30,7 +30,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelDestination {
++public final class ModelDestination {
+ 
+     public static final ModelIdentifier DESTINATION_NONE = null;
+     public static final ModelIdentifier DESTINATION_KEYNUMBER
+diff --git a/src/share/classes/com/sun/media/sound/ModelIdentifier.java b/src/share/classes/com/sun/media/sound/ModelIdentifier.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelIdentifier.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelIdentifier.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -30,7 +30,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelIdentifier {
++public final class ModelIdentifier {
+ 
+     /*
+      *  Object    Variable
+diff --git a/src/share/classes/com/sun/media/sound/ModelInstrument.java b/src/share/classes/com/sun/media/sound/ModelInstrument.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -69,7 +69,7 @@
+     }
+ 
+     // Get General MIDI 2 Alias patch for this instrument.
+-    public Patch getPatchAlias() {
++    public final Patch getPatchAlias() {
+         Patch patch = getPatch();
+         int program = patch.getProgram();
+         int bank = patch.getBank();
+@@ -87,7 +87,7 @@
+     // Return name of all the keys.
+     // This information is generated from ModelPerformer.getName()
+     // returned from getPerformers().
+-    public String[] getKeys() {
++    public final String[] getKeys() {
+         String[] keys = new String[128];
+         for (ModelPerformer performer : getPerformers()) {
+             for (int k = performer.getKeyFrom(); k <= performer.getKeyTo(); k++) {
+@@ -104,7 +104,7 @@
+ 
+     // Return what channels this instrument will probably response
+     // on General MIDI synthesizer.
+-    public boolean[] getChannels() {
++    public final boolean[] getChannels() {
+         boolean percussion = false;
+         if (getPatch() instanceof ModelPatch)
+             percussion = ((ModelPatch)getPatch()).isPercussion();
+diff --git a/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java b/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -34,7 +34,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelInstrumentComparator implements Comparator<Instrument> {
++public final class ModelInstrumentComparator implements Comparator<Instrument> {
+ 
+     public int compare(Instrument arg0, Instrument arg1) {
+         Patch p0 = arg0.getPatch();
+diff --git a/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java b/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,9 +33,9 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelMappedInstrument extends ModelInstrument {
++public final class ModelMappedInstrument extends ModelInstrument {
+ 
+-    private ModelInstrument ins;
++    private final ModelInstrument ins;
+ 
+     public ModelMappedInstrument(ModelInstrument ins, Patch patch) {
+         super(ins.getSoundbank(), patch, ins.getName(), ins.getDataClass());
+diff --git a/src/share/classes/com/sun/media/sound/ModelPatch.java b/src/share/classes/com/sun/media/sound/ModelPatch.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelPatch.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelPatch.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,7 +33,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelPatch extends Patch {
++public final class ModelPatch extends Patch {
+ 
+     private boolean percussion = false;
+ 
+diff --git a/src/share/classes/com/sun/media/sound/ModelPerformer.java b/src/share/classes/com/sun/media/sound/ModelPerformer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelPerformer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelPerformer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,9 +33,9 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelPerformer {
++public final class ModelPerformer {
+ 
+-    private List<ModelOscillator> oscillators = new ArrayList<ModelOscillator>();
++    private final List<ModelOscillator> oscillators = new ArrayList<ModelOscillator>();
+     private List<ModelConnectionBlock> connectionBlocks
+             = new ArrayList<ModelConnectionBlock>();
+     private int keyFrom = 0;
+diff --git a/src/share/classes/com/sun/media/sound/ModelSource.java b/src/share/classes/com/sun/media/sound/ModelSource.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelSource.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelSource.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -30,7 +30,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelSource {
++public final class ModelSource {
+ 
+     public static final ModelIdentifier SOURCE_NONE = null;
+     public static final ModelIdentifier SOURCE_NOTEON_KEYNUMBER =
+diff --git a/src/share/classes/com/sun/media/sound/ModelStandardDirector.java b/src/share/classes/com/sun/media/sound/ModelStandardDirector.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelStandardDirector.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelStandardDirector.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -30,7 +30,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelStandardDirector implements ModelDirector {
++public final class ModelStandardDirector implements ModelDirector {
+ 
+     ModelPerformer[] performers;
+     ModelDirectedPlayer player;
+diff --git a/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java b/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -30,7 +30,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelStandardIndexedDirector implements ModelDirector {
++public final class ModelStandardIndexedDirector implements ModelDirector {
+ 
+     ModelPerformer[] performers;
+     ModelDirectedPlayer player;
+diff --git a/src/share/classes/com/sun/media/sound/ModelStandardTransform.java b/src/share/classes/com/sun/media/sound/ModelStandardTransform.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/ModelStandardTransform.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/ModelStandardTransform.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,7 +36,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class ModelStandardTransform implements ModelTransform {
++public final class ModelStandardTransform implements ModelTransform {
+ 
+     public static final boolean DIRECTION_MIN2MAX = false;
+     public static final boolean DIRECTION_MAX2MIN = true;
+diff --git a/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java b/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,14 +25,12 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.io.InputStream;
+ import java.io.IOException;
+-
+ import java.util.Vector;
+ 
+ import javax.sound.sampled.AudioFormat;
++import javax.sound.sampled.AudioInputStream;
+ import javax.sound.sampled.AudioSystem;
+-import javax.sound.sampled.AudioInputStream;
+ 
+ 
+ /**
+@@ -40,7 +38,7 @@
+  *
+  * @author Jan Borgersen
+  */
+-public class PCMtoPCMCodec extends SunCodec {
++public final class PCMtoPCMCodec extends SunCodec {
+ 
+ 
+     private static final AudioFormat.Encoding[] inputEncodings = {
+@@ -356,7 +354,7 @@
+         private final int PCM_UNSIGNED_BE2SIGNED_LE             = 7;
+         private final int PCM_SIGNED_BE2UNSIGNED_LE             = 8;
+ 
+-        private int sampleSizeInBytes = 0;
++        private final int sampleSizeInBytes;
+         private int conversionType = 0;
+ 
+ 
+diff --git a/src/share/classes/com/sun/media/sound/Platform.java b/src/share/classes/com/sun/media/sound/Platform.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/Platform.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/Platform.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,6 +25,8 @@
+ 
+ package com.sun.media.sound;
+ 
++import java.security.AccessController;
++import java.security.PrivilegedAction;
+ import java.util.StringTokenizer;
+ 
+ 
+@@ -35,7 +37,7 @@
+  * @author Kara Kytle
+  * @author Florian Bomers
+  */
+-class Platform {
++final class Platform {
+ 
+ 
+     // STATIC FINAL CHARACTERISTICS
+@@ -157,7 +159,13 @@
+ 
+         try {
+             // load the main library
+-            JSSecurityManager.loadLibrary(libNameMain);
++            AccessController.doPrivileged(new PrivilegedAction<Void>() {
++                @Override
++                public Void run() {
++                    System.loadLibrary(libNameMain);
++                    return null;
++                }
++            });
+             // just for the heck of it...
+             loadedLibs |= LIB_MAIN;
+         } catch (SecurityException e) {
+@@ -171,9 +179,16 @@
+         // the string is the libraries, separated by white space
+         StringTokenizer st = new StringTokenizer(extraLibs);
+         while (st.hasMoreTokens()) {
+-            String lib = st.nextToken();
++            final String lib = st.nextToken();
+             try {
+-                JSSecurityManager.loadLibrary(lib);
++                AccessController.doPrivileged(new PrivilegedAction<Void>() {
++                    @Override
++                    public Void run() {
++                        System.loadLibrary(lib);
++                        return null;
++                    }
++                });
++
+                 if (lib.equals(libNameALSA)) {
+                     loadedLibs |= LIB_ALSA;
+                     if (Printer.debug) Printer.debug("Loaded ALSA lib successfully.");
+diff --git a/src/share/classes/com/sun/media/sound/PortMixer.java b/src/share/classes/com/sun/media/sound/PortMixer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/PortMixer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/PortMixer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -41,7 +41,7 @@
+  *
+  * @author Florian Bomers
+  */
+-class PortMixer extends AbstractMixer {
++final class PortMixer extends AbstractMixer {
+ 
+     // CONSTANTS
+     private static final int SRC_UNKNOWN      = 0x01;
+@@ -228,8 +228,10 @@
+     /**
+      * Private inner class representing a Port for the PortMixer.
+      */
+-    private static class PortMixerPort extends AbstractLine implements Port {
+-        private int portIndex;
++    private static final class PortMixerPort extends AbstractLine
++            implements Port {
++
++        private final int portIndex;
+         private long id;
+ 
+         // CONSTRUCTOR
+@@ -342,9 +344,9 @@
+     /**
+      * Private inner class representing a BooleanControl for PortMixerPort
+      */
+-    private static class BoolCtrl extends BooleanControl {
++    private static final class BoolCtrl extends BooleanControl {
+         // the handle to the native control function
+-        private long controlID;
++        private final long controlID;
+         private boolean closed = false;
+ 
+         private static BooleanControl.Type createType(String name) {
+@@ -386,7 +388,7 @@
+         /**
+          * inner class for custom types
+          */
+-        private static class BCT extends BooleanControl.Type {
++        private static final class BCT extends BooleanControl.Type {
+             private BCT(String name) {
+                 super(name);
+             }
+@@ -396,7 +398,7 @@
+     /**
+      * Private inner class representing a CompoundControl for PortMixerPort
+      */
+-    private static class CompCtrl extends CompoundControl {
++    private static final class CompCtrl extends CompoundControl {
+         private CompCtrl(String name, Control[] controls) {
+             super(new CCT(name), controls);
+         }
+@@ -404,7 +406,7 @@
+         /**
+          * inner class for custom compound control types
+          */
+-        private static class CCT extends CompoundControl.Type {
++        private static final class CCT extends CompoundControl.Type {
+             private CCT(String name) {
+                 super(name);
+             }
+@@ -414,9 +416,9 @@
+     /**
+      * Private inner class representing a BooleanControl for PortMixerPort
+      */
+-    private static class FloatCtrl extends FloatControl {
++    private static final class FloatCtrl extends FloatControl {
+         // the handle to the native control function
+-        private long controlID;
++        private final long controlID;
+         private boolean closed = false;
+ 
+         // predefined float control types. See also Ports.h
+@@ -462,7 +464,7 @@
+         /**
+          * inner class for custom types
+          */
+-        private static class FCT extends FloatControl.Type {
++        private static final class FCT extends FloatControl.Type {
+             private FCT(String name) {
+                 super(name);
+             }
+@@ -472,7 +474,7 @@
+     /**
+      * Private inner class representing a port info
+      */
+-    private static class PortInfo extends Port.Info {
++    private static final class PortInfo extends Port.Info {
+         private PortInfo(String name, boolean isSource) {
+             super(Port.class, name, isSource);
+         }
+diff --git a/src/share/classes/com/sun/media/sound/PortMixerProvider.java b/src/share/classes/com/sun/media/sound/PortMixerProvider.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/PortMixerProvider.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/PortMixerProvider.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,8 +25,6 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.util.Vector;
+-
+ import javax.sound.sampled.Mixer;
+ import javax.sound.sampled.spi.MixerProvider;
+ 
+@@ -36,7 +34,7 @@
+  *
+  * @author Florian Bomers
+  */
+-public class PortMixerProvider extends MixerProvider {
++public final class PortMixerProvider extends MixerProvider {
+ 
+     // STATIC VARIABLES
+ 
+@@ -66,16 +64,17 @@
+      * Required public no-arg constructor.
+      */
+     public PortMixerProvider() {
+-        //if (Printer.trace) Printer.trace("PortMixerProvider: constructor");
+-        if (Platform.isPortsEnabled()) {
+-            init();
+-        } else {
+-            infos = new PortMixerInfo[0];
+-            devices = new PortMixer[0];
++        synchronized (PortMixerProvider.class) {
++            if (Platform.isPortsEnabled()) {
++                init();
++            } else {
++                infos = new PortMixerInfo[0];
++                devices = new PortMixer[0];
++            }
+         }
+     }
+ 
+-    private static synchronized void init() {
++    private static void init() {
+         // get the number of input devices
+         int numDevices = nGetNumDevices();
+ 
+@@ -95,23 +94,28 @@
+     }
+ 
+     public Mixer.Info[] getMixerInfo() {
+-        Mixer.Info[] localArray = new Mixer.Info[infos.length];
+-        System.arraycopy(infos, 0, localArray, 0, infos.length);
+-        return localArray;
++        synchronized (PortMixerProvider.class) {
++            Mixer.Info[] localArray = new Mixer.Info[infos.length];
++            System.arraycopy(infos, 0, localArray, 0, infos.length);
++            return localArray;
++        }
+     }
+ 
+ 
+     public Mixer getMixer(Mixer.Info info) {
+-        for (int i = 0; i < infos.length; i++) {
+-            if (infos[i].equals(info)) {
+-                return getDevice(infos[i]);
++        synchronized (PortMixerProvider.class) {
++            for (int i = 0; i < infos.length; i++) {
++                if (infos[i].equals(info)) {
++                    return getDevice(infos[i]);
++                }
+             }
+         }
+-        throw new IllegalArgumentException("Mixer " + info.toString() + " not supported by this provider.");
++        throw new IllegalArgumentException("Mixer " + info.toString()
++                                           + " not supported by this provider.");
+     }
+ 
+ 
+-    private Mixer getDevice(PortMixerInfo info) {
++    private static Mixer getDevice(PortMixerInfo info) {
+         int index = info.getIndex();
+         if (devices[index] == null) {
+             devices[index] = new PortMixer(info);
+@@ -127,8 +131,8 @@
+      * making native references to a particular device.
+      * This constructor is called from native.
+      */
+-    static class PortMixerInfo extends Mixer.Info {
+-        private int index;
++    static final class PortMixerInfo extends Mixer.Info {
++        private final int index;
+ 
+         private PortMixerInfo(int index, String name, String vendor, String description, String version) {
+             super("Port " + name, vendor, description, version);
+diff --git a/src/share/classes/com/sun/media/sound/Printer.java b/src/share/classes/com/sun/media/sound/Printer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/Printer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/Printer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -32,7 +32,7 @@
+  * @author David Rivas
+  * @author Kara Kytle
+  */
+-class Printer {
++final class Printer {
+ 
+     static final boolean err = false;
+     static final boolean debug = false;
+@@ -68,6 +68,12 @@
+       release = on;
+       }*/
+ 
++    /**
++     * Suppresses default constructor, ensuring non-instantiability.
++     */
++    private Printer() {
++    }
++
+     public static void err(String str) {
+ 
+         if (err)
+diff --git a/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java b/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,7 +29,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class RIFFInvalidDataException extends InvalidDataException {
++public final class RIFFInvalidDataException extends InvalidDataException {
+ 
+     private static final long serialVersionUID = 1L;
+ 
+diff --git a/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java b/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -30,7 +30,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class RIFFInvalidFormatException extends InvalidFormatException {
++public final class RIFFInvalidFormatException extends InvalidFormatException {
+ 
+     private static final long serialVersionUID = 1L;
+ 
+diff --git a/src/share/classes/com/sun/media/sound/RIFFReader.java b/src/share/classes/com/sun/media/sound/RIFFReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,11 +33,11 @@
+  *
+  * @author Karl Helgason
+  */
+-public class RIFFReader extends InputStream {
++public final class RIFFReader extends InputStream {
+ 
+-    private RIFFReader root;
++    private final RIFFReader root;
+     private long filepointer = 0;
+-    private String fourcc;
++    private final String fourcc;
+     private String riff_type = null;
+     private long ckSize = 0;
+     private InputStream stream;
+diff --git a/src/share/classes/com/sun/media/sound/RIFFWriter.java b/src/share/classes/com/sun/media/sound/RIFFWriter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFWriter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/RIFFWriter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -35,7 +35,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class RIFFWriter extends OutputStream {
++public final class RIFFWriter extends OutputStream {
+ 
+     private interface RandomAccessWriter {
+ 
+@@ -60,11 +60,11 @@
+ 
+         RandomAccessFile raf;
+ 
+-        public RandomAccessFileWriter(File file) throws FileNotFoundException {
++        RandomAccessFileWriter(File file) throws FileNotFoundException {
+             this.raf = new RandomAccessFile(file, "rw");
+         }
+ 
+-        public RandomAccessFileWriter(String name) throws FileNotFoundException {
++        RandomAccessFileWriter(String name) throws FileNotFoundException {
+             this.raf = new RandomAccessFile(name, "rw");
+         }
+ 
+@@ -107,9 +107,9 @@
+         int length = 0;
+         int pos = 0;
+         byte[] s;
+-        OutputStream stream;
++        final OutputStream stream;
+ 
+-        public RandomAccessByteWriter(OutputStream stream) {
++        RandomAccessByteWriter(OutputStream stream) {
+             this.stream = stream;
+         }
+ 
+@@ -163,8 +163,8 @@
+     }
+     private int chunktype = 0; // 0=RIFF, 1=LIST; 2=CHUNK
+     private RandomAccessWriter raf;
+-    private long chunksizepointer;
+-    private long startpointer;
++    private final long chunksizepointer;
++    private final long startpointer;
+     private RIFFWriter childchunk = null;
+     private boolean open = true;
+     private boolean writeoverride = false;
+diff --git a/src/share/classes/com/sun/media/sound/RealTimeSequencer.java b/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,14 +25,13 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.io.ByteArrayOutputStream;
+-import java.io.ByteArrayInputStream;
+-import java.io.DataOutputStream;
+ import java.io.IOException;
+ import java.io.InputStream;
+ 
+ import java.util.ArrayList;
+ import java.util.List;
++import java.util.Map;
++import java.util.WeakHashMap;
+ 
+ import javax.sound.midi.*;
+ 
+@@ -46,7 +45,8 @@
+ /* TODO:
+  * - rename PlayThread to PlayEngine (because isn't a thread)
+  */
+-class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoConnectSequencer {
++final class RealTimeSequencer extends AbstractMidiDevice
++        implements Sequencer, AutoConnectSequencer {
+ 
+     // STATIC VARIABLES
+ 
+@@ -58,7 +58,8 @@
+      * Event Dispatcher thread. Should be using a shared event
+      * dispatcher instance with a factory in EventDispatcher
+      */
+-    private static final EventDispatcher eventDispatcher;
++    private static final Map<ThreadGroup, EventDispatcher> dispatchers =
++            new WeakHashMap<>();
+ 
+     /**
+      * All RealTimeSequencers share this info object.
+@@ -66,11 +67,11 @@
+     static final RealTimeSequencerInfo info = new RealTimeSequencerInfo();
+ 
+ 
+-    private static Sequencer.SyncMode[] masterSyncModes = { Sequencer.SyncMode.INTERNAL_CLOCK };
+-    private static Sequencer.SyncMode[] slaveSyncModes  = { Sequencer.SyncMode.NO_SYNC };
++    private static final Sequencer.SyncMode[] masterSyncModes = { Sequencer.SyncMode.INTERNAL_CLOCK };
++    private static final Sequencer.SyncMode[] slaveSyncModes  = { Sequencer.SyncMode.NO_SYNC };
+ 
+-    private static Sequencer.SyncMode masterSyncMode    = Sequencer.SyncMode.INTERNAL_CLOCK;
+-    private static Sequencer.SyncMode slaveSyncMode     = Sequencer.SyncMode.NO_SYNC;
++    private static final Sequencer.SyncMode masterSyncMode    = Sequencer.SyncMode.INTERNAL_CLOCK;
++    private static final Sequencer.SyncMode slaveSyncMode     = Sequencer.SyncMode.NO_SYNC;
+ 
+ 
+     /**
+@@ -100,7 +101,7 @@
+     private boolean[] trackSolo = null;
+ 
+     /** tempo cache for getMicrosecondPosition */
+-    private MidiUtils.TempoCache tempoCache = new MidiUtils.TempoCache();
++    private final MidiUtils.TempoCache tempoCache = new MidiUtils.TempoCache();
+ 
+     /**
+      * True if the sequence is running.
+@@ -121,7 +122,7 @@
+     /**
+      * List of tracks to which we're recording
+      */
+-    private List recordingTracks = new ArrayList();
++    private final List recordingTracks = new ArrayList();
+ 
+ 
+     private long loopStart = 0;
+@@ -132,13 +133,13 @@
+     /**
+      * Meta event listeners
+      */
+-    private ArrayList metaEventListeners = new ArrayList();
++    private final ArrayList metaEventListeners = new ArrayList();
+ 
+ 
+     /**
+      * Control change listeners
+      */
+-    private ArrayList controllerEventListeners = new ArrayList();
++    private final ArrayList controllerEventListeners = new ArrayList();
+ 
+ 
+     /** automatic connection support */
+@@ -151,16 +152,9 @@
+     Receiver autoConnectedReceiver = null;
+ 
+ 
+-    static {
+-        // create and start the global event thread
+-        eventDispatcher = new EventDispatcher();
+-        eventDispatcher.start();
+-    }
+-
+-
+     /* ****************************** CONSTRUCTOR ****************************** */
+ 
+-    protected RealTimeSequencer() throws MidiUnavailableException {
++    RealTimeSequencer() throws MidiUnavailableException {
+         super(info);
+ 
+         if (Printer.trace) Printer.trace(">> RealTimeSequencer CONSTRUCTOR");
+@@ -574,7 +568,7 @@
+         return returnedModes;
+     }
+ 
+-    protected int getTrackCount() {
++    int getTrackCount() {
+         Sequence seq = getSequence();
+         if (seq != null) {
+             // $$fb wish there was a nicer way to get the number of tracks...
+@@ -865,7 +859,7 @@
+         if (Printer.trace) Printer.trace("<< RealTimeSequencer: implClose() completed");
+     }
+ 
+-    protected void implStart() {
++    void implStart() {
+         if (Printer.trace) Printer.trace(">> RealTimeSequencer: implStart()");
+ 
+         if (playThread == null) {
+@@ -882,7 +876,7 @@
+     }
+ 
+ 
+-    protected void implStop() {
++    void implStop() {
+         if (Printer.trace) Printer.trace(">> RealTimeSequencer: implStop()");
+ 
+         if (playThread == null) {
+@@ -898,22 +892,36 @@
+         if (Printer.trace) Printer.trace("<< RealTimeSequencer: implStop() completed");
+     }
+ 
++    private static EventDispatcher getEventDispatcher() {
++        // create and start the global event thread
++        //TODO  need a way to stop this thread when the engine is done
++        final ThreadGroup tg = Thread.currentThread().getThreadGroup();
++        synchronized (dispatchers) {
++            EventDispatcher eventDispatcher = dispatchers.get(tg);
++            if (eventDispatcher == null) {
++                eventDispatcher = new EventDispatcher();
++                dispatchers.put(tg, eventDispatcher);
++                eventDispatcher.start();
++            }
++            return eventDispatcher;
++        }
++    }
+ 
+     /**
+      * Send midi player events.
+      * must not be synchronized on "this"
+      */
+-    protected void sendMetaEvents(MidiMessage message) {
++    void sendMetaEvents(MidiMessage message) {
+         if (metaEventListeners.size() == 0) return;
+ 
+         //if (Printer.debug) Printer.debug("sending a meta event");
+-        eventDispatcher.sendAudioEvents(message, metaEventListeners);
++        getEventDispatcher().sendAudioEvents(message, metaEventListeners);
+     }
+ 
+     /**
+      * Send midi player events.
+      */
+-    protected void sendControllerEvents(MidiMessage message) {
++    void sendControllerEvents(MidiMessage message) {
+         int size = controllerEventListeners.size();
+         if (size == 0) return;
+ 
+@@ -935,7 +943,7 @@
+                 }
+             }
+         }
+-        eventDispatcher.sendAudioEvents(message, sendToListeners);
++        getEventDispatcher().sendAudioEvents(message, sendToListeners);
+     }
+ 
+ 
+@@ -1017,7 +1025,7 @@
+     }
+ 
+ 
+-    class SequencerReceiver extends AbstractReceiver {
++    final class SequencerReceiver extends AbstractReceiver {
+ 
+         void implSend(MidiMessage message, long timeStamp) {
+             if (recording) {
+@@ -1085,7 +1093,7 @@
+         //       easier to deal with than turning all the
+         //       ints into objects to use a Vector
+         int []  controllers;
+-        ControllerEventListener listener;
++        final ControllerEventListener listener;
+ 
+         private ControllerListElement(ControllerEventListener listener, int[] controllers) {
+ 
+@@ -1190,7 +1198,7 @@
+ 
+     static class RecordingTrack {
+ 
+-        private Track track;
++        private final Track track;
+         private int channel;
+ 
+         RecordingTrack(Track track, int channel) {
+@@ -1230,15 +1238,15 @@
+     }
+ 
+ 
+-    class PlayThread implements Runnable {
++    final class PlayThread implements Runnable {
+         private Thread thread;
+-        private Object lock = new Object();
++        private final Object lock = new Object();
+ 
+         /** true if playback is interrupted (in close) */
+         boolean interrupted = false;
+         boolean isPumping = false;
+ 
+-        private DataPump dataPump = new DataPump();
++        private final DataPump dataPump = new DataPump();
+ 
+ 
+         PlayThread() {
+diff --git a/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java b/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -34,7 +34,7 @@
+  *
+  * @author Florian Bomers
+  */
+-public class RealTimeSequencerProvider extends MidiDeviceProvider {
++public final class RealTimeSequencerProvider extends MidiDeviceProvider {
+ 
+ 
+     public MidiDevice.Info[] getDeviceInfo() {
+diff --git a/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java b/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,5 +29,5 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SF2GlobalRegion extends SF2Region {
++public final class SF2GlobalRegion extends SF2Region {
+ }
+diff --git a/src/share/classes/com/sun/media/sound/SF2Instrument.java b/src/share/classes/com/sun/media/sound/SF2Instrument.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Instrument.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Instrument.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,16 +36,16 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SF2Instrument extends ModelInstrument {
++public final class SF2Instrument extends ModelInstrument {
+ 
+-    protected String name = "";
+-    protected int preset = 0;
+-    protected int bank = 0;
+-    protected long library = 0;
+-    protected long genre = 0;
+-    protected long morphology = 0;
+-    protected SF2GlobalRegion globalregion = null;
+-    protected List<SF2InstrumentRegion> regions
++    String name = "";
++    int preset = 0;
++    int bank = 0;
++    long library = 0;
++    long genre = 0;
++    long morphology = 0;
++    SF2GlobalRegion globalregion = null;
++    List<SF2InstrumentRegion> regions
+             = new ArrayList<SF2InstrumentRegion>();
+ 
+     public SF2Instrument() {
+@@ -730,7 +730,7 @@
+         return msrc;
+     }
+ 
+-    protected static ModelDestination convertDestination(int dst,
++    static ModelDestination convertDestination(int dst,
+             double[] amountcorrection, ModelSource[] extrasrc) {
+         ModelIdentifier id = null;
+         switch (dst) {
+diff --git a/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java b/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,9 +29,9 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SF2InstrumentRegion extends SF2Region {
++public final class SF2InstrumentRegion extends SF2Region {
+ 
+-    protected SF2Layer layer;
++    SF2Layer layer;
+ 
+     public SF2Layer getLayer() {
+         return layer;
+diff --git a/src/share/classes/com/sun/media/sound/SF2Layer.java b/src/share/classes/com/sun/media/sound/SF2Layer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Layer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Layer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -34,11 +34,11 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SF2Layer extends SoundbankResource {
++public final class SF2Layer extends SoundbankResource {
+ 
+-    protected String name = "";
+-    protected SF2GlobalRegion globalregion = null;
+-    protected List<SF2LayerRegion> regions = new ArrayList<SF2LayerRegion>();
++    String name = "";
++    SF2GlobalRegion globalregion = null;
++    List<SF2LayerRegion> regions = new ArrayList<SF2LayerRegion>();
+ 
+     public SF2Layer(SF2Soundbank soundBank) {
+         super(soundBank, null, null);
+diff --git a/src/share/classes/com/sun/media/sound/SF2LayerRegion.java b/src/share/classes/com/sun/media/sound/SF2LayerRegion.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SF2LayerRegion.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SF2LayerRegion.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,9 +29,9 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SF2LayerRegion extends SF2Region {
++public final class SF2LayerRegion extends SF2Region {
+ 
+-    protected SF2Sample sample;
++    SF2Sample sample;
+ 
+     public SF2Sample getSample() {
+         return sample;
+diff --git a/src/share/classes/com/sun/media/sound/SF2Modulator.java b/src/share/classes/com/sun/media/sound/SF2Modulator.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Modulator.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Modulator.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,7 +29,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SF2Modulator {
++public final class SF2Modulator {
+ 
+     public final static int SOURCE_NONE = 0;
+     public final static int SOURCE_NOTE_ON_VELOCITY = 2;
+@@ -49,11 +49,11 @@
+     public final static int SOURCE_TYPE_SWITCH = 1024 * 3;
+     public final static int TRANSFORM_LINEAR = 0;
+     public final static int TRANSFORM_ABSOLUTE = 2;
+-    protected int sourceOperator;
+-    protected int destinationOperator;
+-    protected short amount;
+-    protected int amountSourceOperator;
+-    protected int transportOperator;
++    int sourceOperator;
++    int destinationOperator;
++    short amount;
++    int amountSourceOperator;
++    int transportOperator;
+ 
+     public short getAmount() {
+         return amount;
+diff --git a/src/share/classes/com/sun/media/sound/SF2Sample.java b/src/share/classes/com/sun/media/sound/SF2Sample.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Sample.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Sample.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,18 +36,18 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SF2Sample extends SoundbankResource {
++public final class SF2Sample extends SoundbankResource {
+ 
+-    protected String name = "";
+-    protected long startLoop = 0;
+-    protected long endLoop = 0;
+-    protected long sampleRate = 44100;
+-    protected int originalPitch = 60;
+-    protected byte pitchCorrection = 0;
+-    protected int sampleLink = 0;
+-    protected int sampleType = 0;
+-    protected ModelByteBuffer data;
+-    protected ModelByteBuffer data24;
++    String name = "";
++    long startLoop = 0;
++    long endLoop = 0;
++    long sampleRate = 44100;
++    int originalPitch = 60;
++    byte pitchCorrection = 0;
++    int sampleLink = 0;
++    int sampleType = 0;
++    ModelByteBuffer data;
++    ModelByteBuffer data24;
+ 
+     public SF2Sample(Soundbank soundBank) {
+         super(soundBank, null, AudioInputStream.class);
+diff --git a/src/share/classes/com/sun/media/sound/SF2Soundbank.java b/src/share/classes/com/sun/media/sound/SF2Soundbank.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Soundbank.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SF2Soundbank.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -50,40 +50,40 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SF2Soundbank implements Soundbank {
++public final class SF2Soundbank implements Soundbank {
+ 
+     // version of the Sound Font RIFF file
+-    protected int major = 2;
+-    protected int minor = 1;
++    int major = 2;
++    int minor = 1;
+     // target Sound Engine
+-    protected String targetEngine = "EMU8000";
++    String targetEngine = "EMU8000";
+     // Sound Font Bank Name
+-    protected String name = "untitled";
++    String name = "untitled";
+     // Sound ROM Name
+-    protected String romName = null;
++    String romName = null;
+     // Sound ROM Version
+-    protected int romVersionMajor = -1;
+-    protected int romVersionMinor = -1;
++    int romVersionMajor = -1;
++    int romVersionMinor = -1;
+     // Date of Creation of the Bank
+-    protected String creationDate = null;
++    String creationDate = null;
+     // Sound Designers and Engineers for the Bank
+-    protected String engineers = null;
++    String engineers = null;
+     // Product for which the Bank was intended
+-    protected String product = null;
++    String product = null;
+     // Copyright message
+-    protected String copyright = null;
++    String copyright = null;
+     // Comments
+-    protected String comments = null;
++    String comments = null;
+     // The SoundFont tools used to create and alter the bank
+-    protected String tools = null;
++    String tools = null;
+     // The Sample Data loaded from the SoundFont
+     private ModelByteBuffer sampleData = null;
+     private ModelByteBuffer sampleData24 = null;
+     private File sampleFile = null;
+     private boolean largeFormat = false;
+-    private List<SF2Instrument> instruments = new ArrayList<SF2Instrument>();
+-    private List<SF2Layer> layers = new ArrayList<SF2Layer>();
+-    private List<SF2Sample> samples = new ArrayList<SF2Sample>();
++    private final List<SF2Instrument> instruments = new ArrayList<SF2Instrument>();
++    private final List<SF2Layer> layers = new ArrayList<SF2Layer>();
++    private final List<SF2Sample> samples = new ArrayList<SF2Sample>();
+ 
+     public SF2Soundbank() {
+     }
+diff --git a/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java b/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -38,7 +38,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SF2SoundbankReader extends SoundbankReader {
++public final class SF2SoundbankReader extends SoundbankReader {
+ 
+     public Soundbank getSoundbank(URL url)
+             throws InvalidMidiDataException, IOException {
+diff --git a/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java b/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -67,7 +67,7 @@
+         float samplerateconv = 1;
+         float pitchcorrection = 0;
+ 
+-        public ModelAbstractResamplerStream() {
++        ModelAbstractResamplerStream() {
+             pad = getPadding();
+             pad2 = getPadding() * 2;
+             ibuffer = new float[2][sector_size + pad2];
+@@ -384,7 +384,7 @@
+             float in_end, float[] pitch, float pitchstep, float[] out,
+             int[] out_offset, int out_end);
+ 
+-    public SoftResamplerStreamer openStreamer() {
++    public final SoftResamplerStreamer openStreamer() {
+         return new ModelAbstractResamplerStream();
+     }
+ }
+diff --git a/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java b/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,7 +33,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftAudioBuffer {
++public final class SoftAudioBuffer {
+ 
+     private int size;
+     private float[] buffer;
+diff --git a/src/share/classes/com/sun/media/sound/SoftAudioPusher.java b/src/share/classes/com/sun/media/sound/SoftAudioPusher.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -34,13 +34,13 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftAudioPusher implements Runnable {
++public final class SoftAudioPusher implements Runnable {
+ 
+     private volatile boolean active = false;
+     private SourceDataLine sourceDataLine = null;
+     private Thread audiothread;
+-    private AudioInputStream ais;
+-    private byte[] buffer;
++    private final AudioInputStream ais;
++    private final byte[] buffer;
+ 
+     public SoftAudioPusher(SourceDataLine sourceDataLine, AudioInputStream ais,
+             int workbuffersizer) {
+diff --git a/src/share/classes/com/sun/media/sound/SoftChannel.java b/src/share/classes/com/sun/media/sound/SoftChannel.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -39,7 +39,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
++public final class SoftChannel implements MidiChannel, ModelDirectedPlayer {
+ 
+     private static boolean[] dontResetControls = new boolean[128];
+     static {
+@@ -90,15 +90,15 @@
+     private static final int RPN_NULL_VALUE = (127 << 7) + 127;
+     private int rpn_control = RPN_NULL_VALUE;
+     private int nrpn_control = RPN_NULL_VALUE;
+-    protected double portamento_time = 1; // keyschanges per control buffer time
+-    protected int[] portamento_lastnote = new int[128];
+-    protected int portamento_lastnote_ix = 0;
++    double portamento_time = 1; // keyschanges per control buffer time
++    int[] portamento_lastnote = new int[128];
++    int portamento_lastnote_ix = 0;
+     private boolean portamento = false;
+     private boolean mono = false;
+     private boolean mute = false;
+     private boolean solo = false;
+     private boolean solomute = false;
+-    private Object control_mutex;
++    private final Object control_mutex;
+     private int channel;
+     private SoftVoice[] voices;
+     private int bank;
+@@ -111,21 +111,21 @@
+     private int pitchbend;
+     private double[] co_midi_pitch = new double[1];
+     private double[] co_midi_channel_pressure = new double[1];
+-    protected SoftTuning tuning = new SoftTuning();
+-    protected int tuning_bank = 0;
+-    protected int tuning_program = 0;
+-    protected SoftInstrument current_instrument = null;
+-    protected ModelChannelMixer current_mixer = null;
+-    protected ModelDirector current_director = null;
++    SoftTuning tuning = new SoftTuning();
++    int tuning_bank = 0;
++    int tuning_program = 0;
++    SoftInstrument current_instrument = null;
++    ModelChannelMixer current_mixer = null;
++    ModelDirector current_director = null;
+ 
+     // Controller Destination Settings
+-    protected int cds_control_number = -1;
+-    protected ModelConnectionBlock[] cds_control_connections = null;
+-    protected ModelConnectionBlock[] cds_channelpressure_connections = null;
+-    protected ModelConnectionBlock[] cds_polypressure_connections = null;
+-    protected boolean sustain = false;
+-    protected boolean[][] keybasedcontroller_active = null;
+-    protected double[][] keybasedcontroller_value = null;
++    int cds_control_number = -1;
++    ModelConnectionBlock[] cds_control_connections = null;
++    ModelConnectionBlock[] cds_channelpressure_connections = null;
++    ModelConnectionBlock[] cds_polypressure_connections = null;
++    boolean sustain = false;
++    boolean[][] keybasedcontroller_active = null;
++    double[][] keybasedcontroller_value = null;
+ 
+     private class MidiControlObject implements SoftControl {
+         double[] pitch = co_midi_pitch;
+@@ -336,7 +336,7 @@
+ 
+     }
+ 
+-    protected void initVoice(SoftVoice voice, SoftPerformer p, int voiceID,
++    void initVoice(SoftVoice voice, SoftPerformer p, int voiceID,
+             int noteNumber, int velocity, int delay, ModelConnectionBlock[] connectionBlocks,
+             ModelChannelMixer channelmixer, boolean releaseTriggered) {
+         if (voice.active) {
+@@ -414,7 +414,7 @@
+     /* A special noteOn with delay parameter, which is used to
+      * start note within control buffers.   
+      */
+-    protected void noteOn(int noteNumber, int velocity, int delay) {
++    void noteOn(int noteNumber, int velocity, int delay) {
+         noteNumber = restrict7Bit(noteNumber);
+         velocity = restrict7Bit(velocity);        
+         noteOn_internal(noteNumber, velocity, delay);
+@@ -707,7 +707,7 @@
+         }
+     }
+ 
+-    protected void applyInstrumentCustomization() {
++    void applyInstrumentCustomization() {
+         if (cds_control_connections == null
+                 && cds_channelpressure_connections == null
+                 && cds_polypressure_connections == null) {
+diff --git a/src/share/classes/com/sun/media/sound/SoftChannelProxy.java b/src/share/classes/com/sun/media/sound/SoftChannelProxy.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannelProxy.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChannelProxy.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -32,7 +32,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftChannelProxy implements MidiChannel {
++public final class SoftChannelProxy implements MidiChannel {
+ 
+     private MidiChannel channel = null;
+ 
+diff --git a/src/share/classes/com/sun/media/sound/SoftChorus.java b/src/share/classes/com/sun/media/sound/SoftChorus.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChorus.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftChorus.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -32,11 +32,11 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftChorus implements SoftAudioProcessor {
++public final class SoftChorus implements SoftAudioProcessor {
+ 
+     private static class VariableDelay {
+ 
+-        private float[] delaybuffer;
++        private final float[] delaybuffer;
+         private int rovepos = 0;
+         private float gain = 1;
+         private float rgain = 0;
+@@ -44,7 +44,7 @@
+         private float lastdelay = 0;
+         private float feedback = 0;
+ 
+-        public VariableDelay(int maxbuffersize) {
++        VariableDelay(int maxbuffersize) {
+             delaybuffer = new float[maxbuffersize];
+         }
+ 
+@@ -119,10 +119,10 @@
+         private double phase_step = 0;
+         private double depth = 0;
+         private VariableDelay vdelay;
+-        private double samplerate;
+-        private double controlrate;
++        private final double samplerate;
++        private final double controlrate;
+ 
+-        public LFODelay(double samplerate, double controlrate) {
++        LFODelay(double samplerate, double controlrate) {
+             this.samplerate = samplerate;
+             this.controlrate = controlrate;
+             // vdelay = new VariableDelay((int)(samplerate*4));
+diff --git a/src/share/classes/com/sun/media/sound/SoftCubicResampler.java b/src/share/classes/com/sun/media/sound/SoftCubicResampler.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,7 +29,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftCubicResampler extends SoftAbstractResampler {
++public final class SoftCubicResampler extends SoftAbstractResampler {
+ 
+     public int getPadding() {
+         return 3;
+diff --git a/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java b/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,7 +29,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftEnvelopeGenerator implements SoftProcess {
++public final class SoftEnvelopeGenerator implements SoftProcess {
+ 
+     public final static int EG_OFF = 0;
+     public final static int EG_DELAY = 1;
+@@ -42,23 +42,23 @@
+     public final static int EG_END = 8;
+     int max_count = 10;
+     int used_count = 0;
+-    private int[] stage = new int[max_count];
+-    private int[] stage_ix = new int[max_count];
+-    private double[] stage_v = new double[max_count];
+-    private int[] stage_count = new int[max_count];
+-    private double[][] on = new double[max_count][1];
+-    private double[][] active = new double[max_count][1];
+-    private double[][] out = new double[max_count][1];
+-    private double[][] delay = new double[max_count][1];
+-    private double[][] attack = new double[max_count][1];
+-    private double[][] hold = new double[max_count][1];
+-    private double[][] decay = new double[max_count][1];
+-    private double[][] sustain = new double[max_count][1];
+-    private double[][] release = new double[max_count][1];
+-    private double[][] shutdown = new double[max_count][1];
+-    private double[][] release2 = new double[max_count][1];
+-    private double[][] attack2 = new double[max_count][1];
+-    private double[][] decay2 = new double[max_count][1];
++    private final int[] stage = new int[max_count];
++    private final int[] stage_ix = new int[max_count];
++    private final double[] stage_v = new double[max_count];
++    private final int[] stage_count = new int[max_count];
++    private final double[][] on = new double[max_count][1];
++    private final double[][] active = new double[max_count][1];
++    private final double[][] out = new double[max_count][1];
++    private final double[][] delay = new double[max_count][1];
++    private final double[][] attack = new double[max_count][1];
++    private final double[][] hold = new double[max_count][1];
++    private final double[][] decay = new double[max_count][1];
++    private final double[][] sustain = new double[max_count][1];
++    private final double[][] release = new double[max_count][1];
++    private final double[][] shutdown = new double[max_count][1];
++    private final double[][] release2 = new double[max_count][1];
++    private final double[][] attack2 = new double[max_count][1];
++    private final double[][] decay2 = new double[max_count][1];
+     private double control_time = 0;
+ 
+     public void reset() {
+diff --git a/src/share/classes/com/sun/media/sound/SoftFilter.java b/src/share/classes/com/sun/media/sound/SoftFilter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,7 +33,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftFilter {
++public final class SoftFilter {
+ 
+     public final static int FILTERTYPE_LP6 = 0x00;
+     public final static int FILTERTYPE_LP12 = 0x01;
+@@ -55,7 +55,7 @@
+     // 0x30 = NP, Notch or Band Elimination Filter
+     //
+     private int filtertype = FILTERTYPE_LP6;
+-    private float samplerate;
++    private final float samplerate;
+     private float x1;
+     private float x2;
+     private float y1;
+diff --git a/src/share/classes/com/sun/media/sound/SoftInstrument.java b/src/share/classes/com/sun/media/sound/SoftInstrument.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftInstrument.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftInstrument.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -32,12 +32,12 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftInstrument extends Instrument {
++public final class SoftInstrument extends Instrument {
+ 
+     private SoftPerformer[] performers;
+     private ModelPerformer[] modelperformers;
+-    private Object data;
+-    private ModelInstrument ins;
++    private final Object data;
++    private final ModelInstrument ins;
+ 
+     public SoftInstrument(ModelInstrument ins) {
+         super(ins.getSoundbank(), ins.getPatch(), ins.getName(),
+diff --git a/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java b/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,7 +36,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftJitterCorrector extends AudioInputStream {
++public final class SoftJitterCorrector extends AudioInputStream {
+ 
+     private static class JitterStream extends InputStream {
+ 
+@@ -48,7 +48,7 @@
+         int writepos = 0;
+         int readpos = 0;
+         byte[][] buffers;
+-        Object buffers_mutex = new Object();
++        private final Object buffers_mutex = new Object();
+ 
+         // Adapative Drift Statistics
+         int w_count = 1000;
+@@ -112,7 +112,7 @@
+             }
+         }
+ 
+-        public JitterStream(AudioInputStream s, int buffersize,
++        JitterStream(AudioInputStream s, int buffersize,
+                 int smallbuffersize) {
+             this.w_count = 10 * (buffersize / smallbuffersize);
+             if (w_count < 100)
+diff --git a/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java b/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,7 +29,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftLanczosResampler extends SoftAbstractResampler {
++public final class SoftLanczosResampler extends SoftAbstractResampler {
+ 
+     float[][] sinc_table;
+     int sinc_table_fsize = 2000;
+diff --git a/src/share/classes/com/sun/media/sound/SoftLimiter.java b/src/share/classes/com/sun/media/sound/SoftLimiter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -30,7 +30,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftLimiter implements SoftAudioProcessor {
++public final class SoftLimiter implements SoftAudioProcessor {
+ 
+     float lastmax = 0;
+     float gain = 1;
+diff --git a/src/share/classes/com/sun/media/sound/SoftLinearResampler.java b/src/share/classes/com/sun/media/sound/SoftLinearResampler.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,7 +29,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftLinearResampler extends SoftAbstractResampler {
++public final class SoftLinearResampler extends SoftAbstractResampler {
+ 
+     public int getPadding() {
+         return 2;
+diff --git a/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java b/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -31,7 +31,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftLinearResampler2 extends SoftAbstractResampler {
++public final class SoftLinearResampler2 extends SoftAbstractResampler {
+ 
+     public int getPadding() {
+         return 2;
+diff --git a/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java b/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,21 +29,21 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftLowFrequencyOscillator implements SoftProcess {
++public final class SoftLowFrequencyOscillator implements SoftProcess {
+ 
+-    private int max_count = 10;
++    private final int max_count = 10;
+     private int used_count = 0;
+-    private double[][] out = new double[max_count][1];
+-    private double[][] delay = new double[max_count][1];
+-    private double[][] delay2 = new double[max_count][1];
+-    private double[][] freq = new double[max_count][1];
+-    private int[] delay_counter = new int[max_count];
+-    private double[] sin_phase = new double[max_count];
+-    private double[] sin_stepfreq = new double[max_count];
+-    private double[] sin_step = new double[max_count];
++    private final double[][] out = new double[max_count][1];
++    private final double[][] delay = new double[max_count][1];
++    private final double[][] delay2 = new double[max_count][1];
++    private final double[][] freq = new double[max_count][1];
++    private final int[] delay_counter = new int[max_count];
++    private final double[] sin_phase = new double[max_count];
++    private final double[] sin_stepfreq = new double[max_count];
++    private final double[] sin_step = new double[max_count];
+     private double control_time = 0;
+     private double sin_factor = 0;
+-    private static double PI2 = 2.0 * Math.PI;
++    private static final double PI2 = 2.0 * Math.PI;
+ 
+     public SoftLowFrequencyOscillator() {
+         // If sin_step is 0 then sin_stepfreq must be -INF
+diff --git a/src/share/classes/com/sun/media/sound/SoftMainMixer.java b/src/share/classes/com/sun/media/sound/SoftMainMixer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -43,7 +43,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftMainMixer {
++public final class SoftMainMixer {
+ 
+     // A private class thats contains a ModelChannelMixer and it's private buffers.
+     // This becomes necessary when we want to have separate delay buffers for each channel mixer.
+@@ -67,13 +67,13 @@
+     public final static int CHANNEL_RIGHT_DRY = 11;
+     public final static int CHANNEL_SCRATCH1 = 12;
+     public final static int CHANNEL_SCRATCH2 = 13;
+-    protected boolean active_sensing_on = false;
++    boolean active_sensing_on = false;
+     private long msec_last_activity = -1;
+     private boolean pusher_silent = false;
+     private int pusher_silent_count = 0;
+     private long sample_pos = 0;
+-    protected boolean readfully = true;
+-    private Object control_mutex;
++    boolean readfully = true;
++    private final Object control_mutex;
+     private SoftSynthesizer synth;
+     private float samplerate = 44100;
+     private int nrofchannels = 2;
+@@ -84,7 +84,7 @@
+     private SoftAudioProcessor agc;
+     private long msec_buffer_len = 0;
+     private int buffer_len = 0;
+-    protected TreeMap<Long, Object> midimessages = new TreeMap<Long, Object>();
++    TreeMap<Long, Object> midimessages = new TreeMap<Long, Object>();
+     private int delay_midievent = 0;
+     private int max_delay_midievent = 0;
+     double last_volume_left = 1.0;
+@@ -97,7 +97,7 @@
+     private Set<SoftChannelMixerContainer> registeredMixers = null;
+     private Set<ModelChannelMixer> stoppedMixers = null;
+     private SoftChannelMixerContainer[] cur_registeredMixers = null;
+-    protected SoftControl co_master = new SoftControl() {
++    SoftControl co_master = new SoftControl() {
+ 
+         double[] balance = co_master_balance;
+         double[] volume = co_master_volume;
+@@ -438,7 +438,7 @@
+         delay_midievent = 0;
+     }
+ 
+-    protected void processAudioBuffers() {
++    void processAudioBuffers() {
+ 
+         if(synth.weakstream != null && synth.weakstream.silent_samples != 0)
+         {
+@@ -860,16 +860,16 @@
+ 
+         InputStream in = new InputStream() {
+ 
+-            private SoftAudioBuffer[] buffers = SoftMainMixer.this.buffers;
+-            private int nrofchannels
++            private final SoftAudioBuffer[] buffers = SoftMainMixer.this.buffers;
++            private final int nrofchannels
+                     = SoftMainMixer.this.synth.getFormat().getChannels();
+-            private int buffersize = buffers[0].getSize();
+-            private byte[] bbuffer = new byte[buffersize
++            private final int buffersize = buffers[0].getSize();
++            private final byte[] bbuffer = new byte[buffersize
+                     * (SoftMainMixer.this.synth.getFormat()
+                         .getSampleSizeInBits() / 8)
+                     * nrofchannels];
+             private int bbuffer_pos = 0;
+-            private byte[] single = new byte[1];
++            private final byte[] single = new byte[1];
+ 
+             public void fillBuffer() {
+                 /*
+diff --git a/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java b/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -50,7 +50,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftMidiAudioFileReader extends AudioFileReader {
++public final class SoftMidiAudioFileReader extends AudioFileReader {
+ 
+     public static final Type MIDI = new Type("MIDI", "mid");
+     private static AudioFormat format = new AudioFormat(44100, 16, 2, true, false);
+diff --git a/src/share/classes/com/sun/media/sound/SoftMixingClip.java b/src/share/classes/com/sun/media/sound/SoftMixingClip.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -42,7 +42,7 @@
+  * 
+  * @author Karl Helgason
+  */
+-public class SoftMixingClip extends SoftMixingDataLine implements Clip {
++public final class SoftMixingClip extends SoftMixingDataLine implements Clip {
+ 
+     private AudioFormat format;
+ 
+@@ -50,7 +50,7 @@
+ 
+     private byte[] data;
+ 
+-    private InputStream datastream = new InputStream() {
++    private final InputStream datastream = new InputStream() {
+ 
+         public int read() throws IOException {
+             byte[] b = new byte[1];
+@@ -162,7 +162,7 @@
+ 
+     private AudioFloatInputStream afis;
+ 
+-    protected SoftMixingClip(SoftMixingMixer mixer, DataLine.Info info) {
++    SoftMixingClip(SoftMixingMixer mixer, DataLine.Info info) {
+         super(mixer, info);
+     }
+ 
+diff --git a/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java b/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -50,22 +50,22 @@
+             "Chorus Send") {
+     };
+ 
+-    protected static class AudioFloatInputStreamResampler extends
++    protected static final class AudioFloatInputStreamResampler extends
+             AudioFloatInputStream {
+ 
+-        private AudioFloatInputStream ais;
++        private final AudioFloatInputStream ais;
+ 
+-        private AudioFormat targetFormat;
++        private final AudioFormat targetFormat;
+ 
+         private float[] skipbuffer;
+ 
+         private SoftAbstractResampler resampler;
+ 
+-        private float[] pitch = new float[1];
++        private final float[] pitch = new float[1];
+ 
+-        private float[] ibuffer2;
++        private final float[] ibuffer2;
+ 
+-        private float[][] ibuffer;
++        private final float[][] ibuffer;
+ 
+         private float ibuffer_index = 0;
+ 
+@@ -75,15 +75,15 @@
+ 
+         private float[][] cbuffer;
+ 
+-        private int buffer_len = 512;
++        private final int buffer_len = 512;
+ 
+-        private int pad;
++        private final int pad;
+ 
+-        private int pad2;
++        private final int pad2;
+ 
+-        private float[] ix = new float[1];
++        private final float[] ix = new float[1];
+ 
+-        private int[] ox = new int[1];
++        private final int[] ox = new int[1];
+ 
+         private float[][] mark_ibuffer = null;
+ 
+@@ -294,7 +294,7 @@
+ 
+     }
+ 
+-    private class Gain extends FloatControl {
++    private final class Gain extends FloatControl {
+ 
+         private Gain() {
+ 
+@@ -308,7 +308,7 @@
+         }
+     }
+ 
+-    private class Mute extends BooleanControl {
++    private final class Mute extends BooleanControl {
+ 
+         private Mute() {
+             super(BooleanControl.Type.MUTE, false, "True", "False");
+@@ -320,7 +320,7 @@
+         }
+     }
+ 
+-    private class ApplyReverb extends BooleanControl {
++    private final class ApplyReverb extends BooleanControl {
+ 
+         private ApplyReverb() {
+             super(BooleanControl.Type.APPLY_REVERB, false, "True", "False");
+@@ -333,7 +333,7 @@
+ 
+     }
+ 
+-    private class Balance extends FloatControl {
++    private final class Balance extends FloatControl {
+ 
+         private Balance() {
+             super(FloatControl.Type.BALANCE, -1.0f, 1.0f, (1.0f / 128.0f), -1,
+@@ -347,7 +347,7 @@
+ 
+     }
+ 
+-    private class Pan extends FloatControl {
++    private final class Pan extends FloatControl {
+ 
+         private Pan() {
+             super(FloatControl.Type.PAN, -1.0f, 1.0f, (1.0f / 128.0f), -1,
+@@ -365,7 +365,7 @@
+ 
+     }
+ 
+-    private class ReverbSend extends FloatControl {
++    private final class ReverbSend extends FloatControl {
+ 
+         private ReverbSend() {
+             super(FloatControl.Type.REVERB_SEND, -80f, 6.0206f, 80f / 128.0f,
+@@ -379,7 +379,7 @@
+ 
+     }
+ 
+-    private class ChorusSend extends FloatControl {
++    private final class ChorusSend extends FloatControl {
+ 
+         private ChorusSend() {
+             super(CHORUS_SEND, -80f, 6.0206f, 80f / 128.0f, -1, -80f, "dB",
+@@ -393,43 +393,43 @@
+ 
+     }
+ 
+-    private Gain gain_control = new Gain();
++    private final Gain gain_control = new Gain();
+ 
+-    private Mute mute_control = new Mute();
++    private final Mute mute_control = new Mute();
+ 
+-    private Balance balance_control = new Balance();
++    private final Balance balance_control = new Balance();
+ 
+-    private Pan pan_control = new Pan();
++    private final Pan pan_control = new Pan();
+ 
+-    private ReverbSend reverbsend_control = new ReverbSend();
++    private final ReverbSend reverbsend_control = new ReverbSend();
+ 
+-    private ChorusSend chorussend_control = new ChorusSend();
++    private final ChorusSend chorussend_control = new ChorusSend();
+ 
+-    private ApplyReverb apply_reverb = new ApplyReverb();
++    private final ApplyReverb apply_reverb = new ApplyReverb();
+ 
+-    private Control[] controls;
++    private final Control[] controls;
+ 
+-    protected float leftgain = 1;
++    float leftgain = 1;
+ 
+-    protected float rightgain = 1;
++    float rightgain = 1;
+ 
+-    protected float eff1gain = 0;
++    float eff1gain = 0;
+ 
+-    protected float eff2gain = 0;
++    float eff2gain = 0;
+ 
+-    protected List<LineListener> listeners = new ArrayList<LineListener>();
++    List<LineListener> listeners = new ArrayList<LineListener>();
+ 
+-    protected Object control_mutex;
++    final Object control_mutex;
+ 
+-    protected SoftMixingMixer mixer;
++    SoftMixingMixer mixer;
+ 
+-    protected DataLine.Info info;
++    DataLine.Info info;
+ 
+     protected abstract void processControlLogic();
+ 
+     protected abstract void processAudioLogic(SoftAudioBuffer[] buffers);
+ 
+-    protected SoftMixingDataLine(SoftMixingMixer mixer, DataLine.Info info) {
++    SoftMixingDataLine(SoftMixingMixer mixer, DataLine.Info info) {
+         this.mixer = mixer;
+         this.info = info;
+         this.control_mutex = mixer.control_mutex;
+@@ -440,7 +440,7 @@
+         calcVolume();
+     }
+ 
+-    protected void calcVolume() {
++    final void calcVolume() {
+         synchronized (control_mutex) {
+             double gain = Math.pow(10.0, gain_control.getValue() / 20.0);
+             if (mute_control.getValue())
+@@ -466,7 +466,7 @@
+         }
+     }
+ 
+-    protected void sendEvent(LineEvent event) {
++    final void sendEvent(LineEvent event) {
+         if (listeners.size() == 0)
+             return;
+         LineListener[] listener_array = listeners
+@@ -476,23 +476,23 @@
+         }
+     }
+ 
+-    public void addLineListener(LineListener listener) {
++    public final void addLineListener(LineListener listener) {
+         synchronized (control_mutex) {
+             listeners.add(listener);
+         }
+     }
+ 
+-    public void removeLineListener(LineListener listener) {
++    public final void removeLineListener(LineListener listener) {
+         synchronized (control_mutex) {
+             listeners.add(listener);
+         }
+     }
+ 
+-    public javax.sound.sampled.Line.Info getLineInfo() {
++    public final javax.sound.sampled.Line.Info getLineInfo() {
+         return info;
+     }
+ 
+-    public Control getControl(Type control) {
++    public final Control getControl(Type control) {
+         if (control != null) {
+             for (int i = 0; i < controls.length; i++) {
+                 if (controls[i].getType() == control) {
+@@ -504,11 +504,11 @@
+                 + control);
+     }
+ 
+-    public Control[] getControls() {
++    public final Control[] getControls() {
+         return controls;
+     }
+ 
+-    public boolean isControlSupported(Type control) {
++    public final boolean isControlSupported(Type control) {
+         if (control != null) {
+             for (int i = 0; i < controls.length; i++) {
+                 if (controls[i].getType() == control) {
+diff --git a/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java b/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -37,7 +37,7 @@
+  * 
+  * @author Karl Helgason
+  */
+-public class SoftMixingMainMixer {
++public final class SoftMixingMainMixer {
+ 
+     public final static int CHANNEL_LEFT = 0;
+ 
+@@ -63,23 +63,23 @@
+ 
+     public final static int CHANNEL_CHANNELMIXER_RIGHT = 15;
+ 
+-    private SoftMixingMixer mixer;
++    private final SoftMixingMixer mixer;
+ 
+-    private AudioInputStream ais;
++    private final AudioInputStream ais;
+ 
+-    private SoftAudioBuffer[] buffers;
++    private final SoftAudioBuffer[] buffers;
+ 
+-    private SoftAudioProcessor reverb;
++    private final SoftAudioProcessor reverb;
+ 
+-    private SoftAudioProcessor chorus;
++    private final SoftAudioProcessor chorus;
+ 
+-    private SoftAudioProcessor agc;
++    private final SoftAudioProcessor agc;
+ 
+-    private int nrofchannels;
++    private final int nrofchannels;
+ 
+-    private Object control_mutex;
++    private final Object control_mutex;
+ 
+-    private List<SoftMixingDataLine> openLinesList = new ArrayList<SoftMixingDataLine>();
++    private final List<SoftMixingDataLine> openLinesList = new ArrayList<SoftMixingDataLine>();
+ 
+     private SoftMixingDataLine[] openLines = new SoftMixingDataLine[0];
+ 
+@@ -87,7 +87,7 @@
+         return ais;
+     }
+ 
+-    protected void processAudioBuffers() {
++    void processAudioBuffers() {
+         for (int i = 0; i < buffers.length; i++) {
+             buffers[i].clear();
+         }
+@@ -162,20 +162,20 @@
+ 
+         InputStream in = new InputStream() {
+ 
+-            private SoftAudioBuffer[] buffers = SoftMixingMainMixer.this.buffers;
++            private final SoftAudioBuffer[] buffers = SoftMixingMainMixer.this.buffers;
+ 
+-            private int nrofchannels = SoftMixingMainMixer.this.mixer
++            private final int nrofchannels = SoftMixingMainMixer.this.mixer
+                     .getFormat().getChannels();
+ 
+-            private int buffersize = buffers[0].getSize();
++            private final int buffersize = buffers[0].getSize();
+ 
+-            private byte[] bbuffer = new byte[buffersize
++            private final byte[] bbuffer = new byte[buffersize
+                     * (SoftMixingMainMixer.this.mixer.getFormat()
+                             .getSampleSizeInBits() / 8) * nrofchannels];
+ 
+             private int bbuffer_pos = 0;
+ 
+-            private byte[] single = new byte[1];
++            private final byte[] single = new byte[1];
+ 
+             public void fillBuffer() {
+                 processAudioBuffers();
+diff --git a/src/share/classes/com/sun/media/sound/SoftMixingMixer.java b/src/share/classes/com/sun/media/sound/SoftMixingMixer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -48,27 +48,27 @@
+  * 
+  * @author Karl Helgason
+  */
+-public class SoftMixingMixer implements Mixer {
++public final class SoftMixingMixer implements Mixer {
+ 
+     private static class Info extends Mixer.Info {
+-        public Info() {
++        Info() {
+             super(INFO_NAME, INFO_VENDOR, INFO_DESCRIPTION, INFO_VERSION);
+         }
+     }
+ 
+-    protected static final String INFO_NAME = "Gervill Sound Mixer";
++    static final String INFO_NAME = "Gervill Sound Mixer";
+ 
+-    protected static final String INFO_VENDOR = "OpenJDK Proposal";
++    static final String INFO_VENDOR = "OpenJDK Proposal";
+ 
+-    protected static final String INFO_DESCRIPTION = "Software Sound Mixer";
++    static final String INFO_DESCRIPTION = "Software Sound Mixer";
+ 
+-    protected static final String INFO_VERSION = "1.0";
++    static final String INFO_VERSION = "1.0";
+ 
+-    protected final static Mixer.Info info = new Info();
++    static final Mixer.Info info = new Info();
+ 
+-    protected Object control_mutex = this;
++    final Object control_mutex = this;
+ 
+-    protected boolean implicitOpen = false;
++    boolean implicitOpen = false;
+ 
+     private boolean open = false;
+ 
+@@ -82,15 +82,15 @@
+ 
+     private AudioInputStream pusher_stream = null;
+ 
+-    private float controlrate = 147f;
++    private final float controlrate = 147f;
+ 
+-    private long latency = 100000; // 100 msec
++    private final long latency = 100000; // 100 msec
+ 
+-    private boolean jitter_correction = false;
++    private final boolean jitter_correction = false;
+ 
+-    private List<LineListener> listeners = new ArrayList<LineListener>();
++    private final List<LineListener> listeners = new ArrayList<LineListener>();
+ 
+-    private javax.sound.sampled.Line.Info[] sourceLineInfo;
++    private final javax.sound.sampled.Line.Info[] sourceLineInfo;
+ 
+     public SoftMixingMixer() {
+ 
+@@ -516,11 +516,11 @@
+         }
+     }
+ 
+-    protected float getControlRate() {
++    float getControlRate() {
+         return controlrate;
+     }
+ 
+-    protected SoftMixingMainMixer getMainMixer() {
++    SoftMixingMainMixer getMainMixer() {
+         if (!isOpen())
+             return null;
+         return mainmixer;
+diff --git a/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java b/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,13 +33,13 @@
+  * 
+  * @author Karl Helgason
+  */
+-public class SoftMixingMixerProvider extends MixerProvider {
++public final class SoftMixingMixerProvider extends MixerProvider {
+ 
+     static SoftMixingMixer globalmixer = null;
+ 
+     static Thread lockthread = null;
+ 
+-    protected final static Object mutex = new Object();
++    static final Object mutex = new Object();
+ 
+     public Mixer getMixer(Info info) {
+         if (!(info == null || info == SoftMixingMixer.info)) {
+diff --git a/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java b/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -41,8 +41,8 @@
+  * 
+  * @author Karl Helgason
+  */
+-public class SoftMixingSourceDataLine extends SoftMixingDataLine implements
+-        SourceDataLine {
++public final class SoftMixingSourceDataLine extends SoftMixingDataLine
++        implements SourceDataLine {
+ 
+     private boolean open = false;
+ 
+@@ -72,7 +72,7 @@
+             AudioFloatInputStream {
+         AudioFloatInputStream ais;
+ 
+-        public NonBlockingFloatInputStream(AudioFloatInputStream ais) {
++        NonBlockingFloatInputStream(AudioFloatInputStream ais) {
+             this.ais = ais;
+         }
+ 
+@@ -120,7 +120,7 @@
+ 
+     }
+ 
+-    protected SoftMixingSourceDataLine(SoftMixingMixer mixer, DataLine.Info info) {
++    SoftMixingSourceDataLine(SoftMixingMixer mixer, DataLine.Info info) {
+         super(mixer, info);
+     }
+ 
+diff --git a/src/share/classes/com/sun/media/sound/SoftPerformer.java b/src/share/classes/com/sun/media/sound/SoftPerformer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -37,7 +37,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftPerformer {
++public final class SoftPerformer {
+ 
+     static ModelConnectionBlock[] defaultconnections
+             = new ModelConnectionBlock[42];
+diff --git a/src/share/classes/com/sun/media/sound/SoftPointResampler.java b/src/share/classes/com/sun/media/sound/SoftPointResampler.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftPointResampler.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftPointResampler.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,7 +29,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftPointResampler extends SoftAbstractResampler {
++public final class SoftPointResampler extends SoftAbstractResampler {
+ 
+     public int getPadding() {
+         return 100;
+diff --git a/src/share/classes/com/sun/media/sound/SoftProvider.java b/src/share/classes/com/sun/media/sound/SoftProvider.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftProvider.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftProvider.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,10 +33,10 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftProvider extends MidiDeviceProvider {
++public final class SoftProvider extends MidiDeviceProvider {
+ 
+-    protected final static Info softinfo = SoftSynthesizer.info;
+-    private static Info[] softinfos = {softinfo};
++    static final Info softinfo = SoftSynthesizer.info;
++    private static final Info[] softinfos = {softinfo};
+ 
+     public MidiDevice.Info[] getDeviceInfo() {
+         return softinfos;
+diff --git a/src/share/classes/com/sun/media/sound/SoftReceiver.java b/src/share/classes/com/sun/media/sound/SoftReceiver.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -35,13 +35,13 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftReceiver implements MidiDeviceReceiver {
++public final class SoftReceiver implements MidiDeviceReceiver {
+ 
+-    protected boolean open = true;
+-    private Object control_mutex;
+-    private SoftSynthesizer synth;
+-    protected TreeMap<Long, Object> midimessages;
+-    protected SoftMainMixer mainmixer;
++    boolean open = true;
++    private final Object control_mutex;
++    private final SoftSynthesizer synth;
++    TreeMap<Long, Object> midimessages;
++    SoftMainMixer mainmixer;
+ 
+     public SoftReceiver(SoftSynthesizer synth) {
+         this.control_mutex = synth.control_mutex;
+diff --git a/src/share/classes/com/sun/media/sound/SoftReverb.java b/src/share/classes/com/sun/media/sound/SoftReverb.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftReverb.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftReverb.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -33,14 +33,14 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftReverb implements SoftAudioProcessor {
++public final class SoftReverb implements SoftAudioProcessor {
+ 
+     private final static class Delay {
+ 
+         private float[] delaybuffer;
+         private int rovepos = 0;
+ 
+-        public Delay() {
++        Delay() {
+             delaybuffer = null;
+         }
+ 
+@@ -77,7 +77,7 @@
+         private int rovepos = 0;
+         private float feedback;
+ 
+-        public AllPass(int size) {
++        AllPass(int size) {
+             delaybuffer = new float[size];
+             delaybuffersize = size;
+         }
+@@ -127,7 +127,7 @@
+         private float filtercoeff1 = 0;
+         private float filtercoeff2 = 1;
+ 
+-        public Comb(int size) {
++        Comb(int size) {
+             delaybuffer = new float[size];
+             delaybuffersize = size;
+         }
+diff --git a/src/share/classes/com/sun/media/sound/SoftShortMessage.java b/src/share/classes/com/sun/media/sound/SoftShortMessage.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftShortMessage.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftShortMessage.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -32,7 +32,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftShortMessage extends ShortMessage {
++public final class SoftShortMessage extends ShortMessage {
+ 
+     int channel = 0;
+ 
+diff --git a/src/share/classes/com/sun/media/sound/SoftSincResampler.java b/src/share/classes/com/sun/media/sound/SoftSincResampler.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSincResampler.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSincResampler.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -31,7 +31,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftSincResampler extends SoftAbstractResampler {
++public final class SoftSincResampler extends SoftAbstractResampler {
+ 
+     float[][][] sinc_table;
+     int sinc_scale_size = 100;
+diff --git a/src/share/classes/com/sun/media/sound/SoftSynthesizer.java b/src/share/classes/com/sun/media/sound/SoftSynthesizer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -66,10 +66,10 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftSynthesizer implements AudioSynthesizer,
++public final class SoftSynthesizer implements AudioSynthesizer,
+         ReferenceCountingDevice {
+ 
+-    protected static class WeakAudioStream extends InputStream
++    protected static final class WeakAudioStream extends InputStream
+     {
+         private volatile AudioInputStream stream;
+         public SoftAudioPusher pusher = null;
+@@ -166,39 +166,39 @@
+     }
+ 
+     private static class Info extends MidiDevice.Info {
+-        public Info() {
++        Info() {
+             super(INFO_NAME, INFO_VENDOR, INFO_DESCRIPTION, INFO_VERSION);
+         }
+     }
+ 
+-    protected static final String INFO_NAME = "Gervill";
+-    protected static final String INFO_VENDOR = "OpenJDK";
+-    protected static final String INFO_DESCRIPTION = "Software MIDI Synthesizer";
+-    protected static final String INFO_VERSION = "1.0";
+-    protected final static MidiDevice.Info info = new Info();
++    static final String INFO_NAME = "Gervill";
++    static final String INFO_VENDOR = "OpenJDK";
++    static final String INFO_DESCRIPTION = "Software MIDI Synthesizer";
++    static final String INFO_VERSION = "1.0";
++    final static MidiDevice.Info info = new Info();
+ 
+     private static SourceDataLine testline = null;
+ 
+     private static Soundbank defaultSoundBank = null;
+ 
+-    protected WeakAudioStream weakstream = null;
++    WeakAudioStream weakstream = null;
+ 
+-    protected Object control_mutex = this;
++    final Object control_mutex = this;
+ 
+-    protected int voiceIDCounter = 0;
++    int voiceIDCounter = 0;
+ 
+     // 0: default
+     // 1: DLS Voice Allocation
+-    protected int voice_allocation_mode = 0;
++    int voice_allocation_mode = 0;
+ 
+-    protected boolean load_default_soundbank = false;
+-    protected boolean reverb_light = true;
+-    protected boolean reverb_on = true;
+-    protected boolean chorus_on = true;
+-    protected boolean agc_on = true;
++    boolean load_default_soundbank = false;
++    boolean reverb_light = true;
++    boolean reverb_on = true;
++    boolean chorus_on = true;
++    boolean agc_on = true;
+ 
+-    protected SoftChannel[] channels;
+-    protected SoftChannelProxy[] external_channels = null;
++    SoftChannel[] channels;
++    SoftChannelProxy[] external_channels = null;
+ 
+     private boolean largemode = false;
+ 
+@@ -371,7 +371,7 @@
+         this.format = format;
+     }
+ 
+-    protected void removeReceiver(Receiver recv) {
++    void removeReceiver(Receiver recv) {
+         boolean perform_close = false;
+         synchronized (control_mutex) {
+             if (recvslist.remove(recv)) {
+@@ -383,13 +383,13 @@
+             close();
+     }
+ 
+-    protected SoftMainMixer getMainMixer() {
++    SoftMainMixer getMainMixer() {
+         if (!isOpen())
+             return null;
+         return mainmixer;
+     }
+ 
+-    protected SoftInstrument findInstrument(int program, int bank, int channel) {
++    SoftInstrument findInstrument(int program, int bank, int channel) {
+ 
+         // Add support for GM2 banks 0x78 and 0x79
+         // as specified in DLS 2.2 in Section 1.4.6
+@@ -450,31 +450,31 @@
+         return null;
+     }
+ 
+-    protected int getVoiceAllocationMode() {
++    int getVoiceAllocationMode() {
+         return voice_allocation_mode;
+     }
+ 
+-    protected int getGeneralMidiMode() {
++    int getGeneralMidiMode() {
+         return gmmode;
+     }
+ 
+-    protected void setGeneralMidiMode(int gmmode) {
++    void setGeneralMidiMode(int gmmode) {
+         this.gmmode = gmmode;
+     }
+ 
+-    protected int getDeviceID() {
++    int getDeviceID() {
+         return deviceid;
+     }
+ 
+-    protected float getControlRate() {
++    float getControlRate() {
+         return controlrate;
+     }
+ 
+-    protected SoftVoice[] getVoices() {
++    SoftVoice[] getVoices() {
+         return voices;
+     }
+ 
+-    protected SoftTuning getTuning(Patch patch) {
++    SoftTuning getTuning(Patch patch) {
+         String t_id = patchToString(patch);
+         SoftTuning tuning = tunings.get(t_id);
+         if (tuning == null) {
+diff --git a/src/share/classes/com/sun/media/sound/SoftTuning.java b/src/share/classes/com/sun/media/sound/SoftTuning.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftTuning.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftTuning.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -34,10 +34,10 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftTuning {
++public final class SoftTuning {
+ 
+     private String name = null;
+-    private double[] tuning = new double[128];
++    private final double[] tuning = new double[128];
+     private Patch patch = null;
+ 
+     public SoftTuning() {
+diff --git a/src/share/classes/com/sun/media/sound/SoftVoice.java b/src/share/classes/com/sun/media/sound/SoftVoice.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -36,7 +36,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class SoftVoice extends VoiceStatus {
++public final class SoftVoice extends VoiceStatus {
+ 
+     public int exclusiveClass = 0;
+     public boolean releaseTriggered = false;
+@@ -44,32 +44,32 @@
+     private int noteOn_velocity = 0;
+     private int noteOff_velocity = 0;
+     private int delay = 0;
+-    protected ModelChannelMixer channelmixer = null;
+-    protected double tunedKey = 0;
+-    protected SoftTuning tuning = null;
+-    protected SoftChannel stealer_channel = null;
+-    protected ModelConnectionBlock[] stealer_extendedConnectionBlocks = null;
+-    protected SoftPerformer stealer_performer = null;
+-    protected ModelChannelMixer stealer_channelmixer = null;
+-    protected int stealer_voiceID = -1;
+-    protected int stealer_noteNumber = 0;
+-    protected int stealer_velocity = 0;
+-    protected boolean stealer_releaseTriggered = false;
+-    protected int voiceID = -1;
+-    protected boolean sustain = false;
+-    protected boolean sostenuto = false;
+-    protected boolean portamento = false;
+-    private SoftFilter filter_left;
+-    private SoftFilter filter_right;
+-    private SoftProcess eg = new SoftEnvelopeGenerator();
+-    private SoftProcess lfo = new SoftLowFrequencyOscillator();
+-    protected Map<String, SoftControl> objects =
++    ModelChannelMixer channelmixer = null;
++    double tunedKey = 0;
++    SoftTuning tuning = null;
++    SoftChannel stealer_channel = null;
++    ModelConnectionBlock[] stealer_extendedConnectionBlocks = null;
++    SoftPerformer stealer_performer = null;
++    ModelChannelMixer stealer_channelmixer = null;
++    int stealer_voiceID = -1;
++    int stealer_noteNumber = 0;
++    int stealer_velocity = 0;
++    boolean stealer_releaseTriggered = false;
++    int voiceID = -1;
++    boolean sustain = false;
++    boolean sostenuto = false;
++    boolean portamento = false;
++    private final SoftFilter filter_left;
++    private final SoftFilter filter_right;
++    private final SoftProcess eg = new SoftEnvelopeGenerator();
++    private final SoftProcess lfo = new SoftLowFrequencyOscillator();
++    Map<String, SoftControl> objects =
+             new HashMap<String, SoftControl>();
+-    protected SoftSynthesizer synthesizer;
+-    protected SoftInstrument instrument;
+-    protected SoftPerformer performer;
+-    protected SoftChannel softchannel = null;
+-    protected boolean on = false;
++    SoftSynthesizer synthesizer;
++    SoftInstrument instrument;
++    SoftPerformer performer;
++    SoftChannel softchannel = null;
++    boolean on = false;
+     private boolean audiostarted = false;
+     private boolean started = false;
+     private boolean stopping = false;
+@@ -87,7 +87,7 @@
+     private float last_out_mixer_right = 0;
+     private float last_out_mixer_effect1 = 0;
+     private float last_out_mixer_effect2 = 0;
+-    protected ModelConnectionBlock[] extendedConnectionBlocks = null;
++    ModelConnectionBlock[] extendedConnectionBlocks = null;
+     private ModelConnectionBlock[] connections;
+     // Last value added to destination
+     private double[] connections_last = new double[50];
+@@ -100,10 +100,10 @@
+     private boolean soundoff = false;
+     private float lastMuteValue = 0;
+     private float lastSoloMuteValue = 0;
+-    protected double[] co_noteon_keynumber = new double[1];
+-    protected double[] co_noteon_velocity = new double[1];
+-    protected double[] co_noteon_on = new double[1];
+-    private SoftControl co_noteon = new SoftControl() {
++    double[] co_noteon_keynumber = new double[1];
++    double[] co_noteon_velocity = new double[1];
++    double[] co_noteon_on = new double[1];
++    private final SoftControl co_noteon = new SoftControl() {
+         double[] keynumber = co_noteon_keynumber;
+         double[] velocity = co_noteon_velocity;
+         double[] on = co_noteon_on;
+@@ -119,13 +119,13 @@
+             return null;
+         }
+     };
+-    private double[] co_mixer_active = new double[1];
+-    private double[] co_mixer_gain = new double[1];
+-    private double[] co_mixer_pan = new double[1];
+-    private double[] co_mixer_balance = new double[1];
+-    private double[] co_mixer_reverb = new double[1];
+-    private double[] co_mixer_chorus = new double[1];
+-    private SoftControl co_mixer = new SoftControl() {
++    private final double[] co_mixer_active = new double[1];
++    private final double[] co_mixer_gain = new double[1];
++    private final double[] co_mixer_pan = new double[1];
++    private final double[] co_mixer_balance = new double[1];
++    private final double[] co_mixer_reverb = new double[1];
++    private final double[] co_mixer_chorus = new double[1];
++    private final SoftControl co_mixer = new SoftControl() {
+         double[] active = co_mixer_active;
+         double[] gain = co_mixer_gain;
+         double[] pan = co_mixer_pan;
+@@ -150,8 +150,8 @@
+             return null;
+         }
+     };
+-    private double[] co_osc_pitch = new double[1];
+-    private SoftControl co_osc = new SoftControl() {
++    private final double[] co_osc_pitch = new double[1];
++    private final SoftControl co_osc = new SoftControl() {
+         double[] pitch = co_osc_pitch;
+         public double[] get(int instance, String name) {
+             if (name == null)
+@@ -161,10 +161,10 @@
+             return null;
+         }
+     };
+-    private double[] co_filter_freq = new double[1];
+-    private double[] co_filter_type = new double[1];
+-    private double[] co_filter_q = new double[1];
+-    private SoftControl co_filter = new SoftControl() {
++    private final double[] co_filter_freq = new double[1];
++    private final double[] co_filter_type = new double[1];
++    private final double[] co_filter_q = new double[1];
++    private final SoftControl co_filter = new SoftControl() {
+         double[] freq = co_filter_freq;
+         double[] ftype = co_filter_type;
+         double[] q = co_filter_q;
+@@ -180,8 +180,8 @@
+             return null;
+         }
+     };
+-    protected SoftResamplerStreamer resampler;
+-    private int nrofchannels;
++    SoftResamplerStreamer resampler;
++    private final int nrofchannels;
+ 
+     public SoftVoice(SoftSynthesizer synth) {
+         synthesizer = synth;
+@@ -278,7 +278,7 @@
+         // co_mixer_gain[0] = 0;
+     }
+ 
+-    protected void updateTuning(SoftTuning newtuning) {
++    void updateTuning(SoftTuning newtuning) {
+         tuning = newtuning;
+         tunedKey = tuning.getTuning(note) / 100.0;
+         if (!portamento) {
+@@ -293,12 +293,12 @@
+         }
+     }
+ 
+-    protected void setNote(int noteNumber) {
++    void setNote(int noteNumber) {
+         note = noteNumber;
+         tunedKey = tuning.getTuning(noteNumber) / 100.0;
+     }
+ 
+-    protected void noteOn(int noteNumber, int velocity, int delay) {
++    void noteOn(int noteNumber, int velocity, int delay) {
+ 
+         sustain = false;
+         sostenuto = false;
+@@ -435,7 +435,7 @@
+ 
+     }
+ 
+-    protected void setPolyPressure(int pressure) {
++    void setPolyPressure(int pressure) {
+         if(performer == null)
+             return;
+         int[] c = performer.midi_connections[2];
+@@ -445,7 +445,7 @@
+             processConnection(c[i]);
+     }
+ 
+-    protected void setChannelPressure(int pressure) {
++    void setChannelPressure(int pressure) {
+         if(performer == null)
+             return;
+         int[] c = performer.midi_connections[1];
+@@ -455,7 +455,7 @@
+             processConnection(c[i]);
+     }
+ 
+-    protected void controlChange(int controller, int value) {
++    void controlChange(int controller, int value) {
+         if(performer == null)
+             return;
+         int[] c = performer.midi_ctrl_connections[controller];
+@@ -465,7 +465,7 @@
+             processConnection(c[i]);
+     }
+ 
+-    protected void nrpnChange(int controller, int value) {
++    void nrpnChange(int controller, int value) {
+         if(performer == null)
+             return;
+         int[] c = performer.midi_nrpn_connections.get(controller);
+@@ -475,7 +475,7 @@
+             processConnection(c[i]);
+     }
+ 
+-    protected void rpnChange(int controller, int value) {
++    void rpnChange(int controller, int value) {
+         if(performer == null)
+             return;
+         int[] c = performer.midi_rpn_connections.get(controller);
+@@ -485,7 +485,7 @@
+             processConnection(c[i]);
+     }
+ 
+-    protected void setPitchBend(int bend) {
++    void setPitchBend(int bend) {
+         if(performer == null)
+             return;
+         int[] c = performer.midi_connections[0];
+@@ -495,19 +495,19 @@
+             processConnection(c[i]);
+     }
+ 
+-    protected void setMute(boolean mute) {
++    void setMute(boolean mute) {
+         co_mixer_gain[0] -= lastMuteValue;
+         lastMuteValue = mute ? -960 : 0;
+         co_mixer_gain[0] += lastMuteValue;
+     }
+ 
+-    protected void setSoloMute(boolean mute) {
++    void setSoloMute(boolean mute) {
+         co_mixer_gain[0] -= lastSoloMuteValue;
+         lastSoloMuteValue = mute ? -960 : 0;
+         co_mixer_gain[0] += lastSoloMuteValue;
+     }
+ 
+-    protected void shutdown() {
++    void shutdown() {
+         if (co_noteon_on[0] < -0.5)
+             return;
+         on = false;
+@@ -523,12 +523,12 @@
+             processConnection(c[i]);
+     }
+ 
+-    protected void soundOff() {
++    void soundOff() {
+         on = false;
+         soundoff = true;
+     }
+ 
+-    protected void noteOff(int velocity) {
++    void noteOff(int velocity) {
+         if (!on)
+             return;
+         on = false;
+@@ -553,7 +553,7 @@
+             processConnection(c[i]);
+     }
+ 
+-    protected void redamp() {
++    void redamp() {
+         if (co_noteon_on[0] > 0.5)
+             return;
+         if (co_noteon_on[0] < -0.5)
+@@ -571,7 +571,7 @@
+             processConnection(c[i]);
+     }
+ 
+-    protected void processControlLogic() {
++    void processControlLogic() {
+         if (stopping) {
+             active = false;
+             stopping = false;
+@@ -760,9 +760,9 @@
+ 
+     }
+ 
+-    protected void mixAudioStream(SoftAudioBuffer in, SoftAudioBuffer out,
+-            SoftAudioBuffer dout,
+-            float amp_from, float amp_to) {
++    void mixAudioStream(SoftAudioBuffer in, SoftAudioBuffer out,
++                                SoftAudioBuffer dout, float amp_from,
++                                float amp_to) {
+         int bufferlen = in.getSize();
+         if (amp_from < 0.000000001 && amp_to < 0.000000001)
+             return;
+@@ -815,7 +815,7 @@
+ 
+     }
+ 
+-    protected void processAudioLogic(SoftAudioBuffer[] buffer) {
++    void processAudioLogic(SoftAudioBuffer[] buffer) {
+         if (!audiostarted)
+             return;
+ 
+diff --git a/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java b/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -26,22 +26,13 @@
+ package com.sun.media.sound;
+ 
+ import java.io.DataInputStream;
+-import java.io.DataOutputStream;
+-import java.io.PipedInputStream;
+-import java.io.PipedOutputStream;
+-import java.io.ByteArrayOutputStream;
+-import java.io.ByteArrayInputStream;
+-import java.io.SequenceInputStream;
+ import java.io.File;
+ import java.io.FileInputStream;
+ import java.io.InputStream;
+ import java.io.IOException;
+ import java.io.EOFException;
+-import java.io.OutputStream;
+-import java.io.RandomAccessFile;
+ import java.io.BufferedInputStream;
+ import java.net.URL;
+-import java.net.MalformedURLException;
+ 
+ import javax.sound.midi.MidiFileFormat;
+ import javax.sound.midi.InvalidMidiDataException;
+@@ -49,7 +40,6 @@
+ import javax.sound.midi.MidiEvent;
+ import javax.sound.midi.MidiMessage;
+ import javax.sound.midi.Sequence;
+-import javax.sound.midi.ShortMessage;
+ import javax.sound.midi.SysexMessage;
+ import javax.sound.midi.Track;
+ import javax.sound.midi.spi.MidiFileReader;
+@@ -64,23 +54,12 @@
+  * @author Florian Bomers
+  */
+ 
+-public class StandardMidiFileReader extends MidiFileReader {
++public final class StandardMidiFileReader extends MidiFileReader {
+ 
+     private static final int MThd_MAGIC = 0x4d546864;  // 'MThd'
+ 
+-    private static final int MIDI_TYPE_0 = 0;
+-    private static final int MIDI_TYPE_1 = 1;
+-
+     private static final int bisBufferSize = 1024; // buffer size in buffered input streams
+ 
+-    /**
+-     * MIDI parser types
+-     */
+-    private static final int types[] = {
+-        MIDI_TYPE_0,
+-        MIDI_TYPE_1
+-    };
+-
+     public MidiFileFormat getMidiFileFormat(InputStream stream) throws InvalidMidiDataException, IOException {
+         return getMidiFileFormatFromStream(stream, MidiFileFormat.UNKNOWN_LENGTH, null);
+     }
+@@ -253,7 +232,7 @@
+ /**
+  * State variables during parsing of a MIDI file
+  */
+-class SMFParser {
++final class SMFParser {
+     private static final int MTrk_MAGIC = 0x4d54726b;  // 'MTrk'
+ 
+     // set to true to not allow corrupt MIDI files tombe loaded
+@@ -268,7 +247,7 @@
+     private byte[] trackData = null;
+     private int pos = 0;
+ 
+-    public SMFParser() {
++    SMFParser() {
+     }
+ 
+     private int readUnsigned() throws IOException {
+diff --git a/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java b/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,7 +25,6 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.io.DataInputStream;
+ import java.io.DataOutputStream;
+ import java.io.PipedInputStream;
+ import java.io.PipedOutputStream;
+@@ -34,18 +33,13 @@
+ import java.io.SequenceInputStream;
+ import java.io.File;
+ import java.io.FileOutputStream;
+-import java.io.BufferedOutputStream;
+ import java.io.InputStream;
+ import java.io.IOException;
+-import java.lang.IllegalArgumentException;
+ import java.io.OutputStream;
+-import java.util.Vector;
+ 
+-import javax.sound.midi.MidiFileFormat;
+ import javax.sound.midi.InvalidMidiDataException;
+ import javax.sound.midi.MidiEvent;
+ import javax.sound.midi.MetaMessage;
+-import javax.sound.midi.MidiMessage;
+ import javax.sound.midi.Sequence;
+ import javax.sound.midi.ShortMessage;
+ import javax.sound.midi.SysexMessage;
+@@ -59,7 +53,7 @@
+  * @author Kara Kytle
+  * @author Jan Borgersen
+  */
+-public class StandardMidiFileWriter extends MidiFileWriter {
++public final class StandardMidiFileWriter extends MidiFileWriter {
+ 
+     private static final int MThd_MAGIC = 0x4d546864;  // 'MThd'
+     private static final int MTrk_MAGIC = 0x4d54726b;  // 'MTrk'
+diff --git a/src/share/classes/com/sun/media/sound/SunCodec.java b/src/share/classes/com/sun/media/sound/SunCodec.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SunCodec.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SunCodec.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,8 +25,6 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.io.InputStream;
+-
+ import javax.sound.sampled.AudioFormat;
+ import javax.sound.sampled.AudioInputStream;
+ 
+@@ -48,14 +46,14 @@
+  */
+ abstract class SunCodec extends FormatConversionProvider {
+ 
+-    AudioFormat.Encoding[] inputEncodings;
+-    AudioFormat.Encoding[] outputEncodings;
++    private final AudioFormat.Encoding[] inputEncodings;
++    private final AudioFormat.Encoding[] outputEncodings;
+ 
+     /**
+      * Constructs a new codec object.
+      */
+-    protected SunCodec(AudioFormat.Encoding[] inputEncodings, AudioFormat.Encoding[] outputEncodings) {
+-
++    SunCodec(final AudioFormat.Encoding[] inputEncodings,
++             final AudioFormat.Encoding[] outputEncodings) {
+         this.inputEncodings = inputEncodings;
+         this.outputEncodings = outputEncodings;
+     }
+@@ -63,16 +61,14 @@
+ 
+     /**
+      */
+-    public AudioFormat.Encoding[] getSourceEncodings() {
+-
++    public final AudioFormat.Encoding[] getSourceEncodings() {
+         AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[inputEncodings.length];
+         System.arraycopy(inputEncodings, 0, encodings, 0, inputEncodings.length);
+         return encodings;
+     }
+     /**
+      */
+-    public AudioFormat.Encoding[] getTargetEncodings() {
+-
++    public final AudioFormat.Encoding[] getTargetEncodings() {
+         AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[outputEncodings.length];
+         System.arraycopy(outputEncodings, 0, encodings, 0, outputEncodings.length);
+         return encodings;
+diff --git a/src/share/classes/com/sun/media/sound/SunFileReader.java b/src/share/classes/com/sun/media/sound/SunFileReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SunFileReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SunFileReader.java
+@@ -27,7 +27,6 @@
+ 
+ import java.io.File;
+ import java.io.InputStream;
+-import java.io.OutputStream;
+ import java.io.IOException;
+ import java.io.DataInputStream;
+ import java.net.URL;
+@@ -52,7 +51,7 @@
+     /**
+      * Constructs a new SunFileReader object.
+      */
+-    public SunFileReader() {
++    SunFileReader() {
+     }
+ 
+ 
+@@ -167,7 +166,7 @@
+      * @return 32 bits swapped value.
+      * @exception IOException
+      */
+-    protected int rllong(DataInputStream dis) throws IOException {
++    final int rllong(DataInputStream dis) throws IOException {
+ 
+         int b1, b2, b3, b4 ;
+         int i = 0;
+@@ -190,7 +189,7 @@
+      * @param int
+      * @return 32 bits swapped value
+      */
+-    protected int big2little(int i) {
++    final int big2little(int i) {
+ 
+         int b1, b2, b3, b4 ;
+ 
+@@ -211,7 +210,7 @@
+      * @return the swapped value.
+      * @exception IOException
+      */
+-    protected short rlshort(DataInputStream dis)  throws IOException {
++    final short rlshort(DataInputStream dis)  throws IOException {
+ 
+         short s=0;
+         short high, low;
+@@ -232,7 +231,7 @@
+      * @param int
+      * @return 16 bits swapped value
+      */
+-    protected short big2littleShort(short i) {
++    final short big2littleShort(short i) {
+ 
+         short high, low;
+ 
+@@ -244,16 +243,14 @@
+         return i;
+     }
+ 
+-
+-        /** Calculates the frame size for PCM frames.
+-         * Note that this method is appropriate for non-packed samples.
+-         * For instance, 12 bit, 2 channels will return 4 bytes, not 3.
+-         * @param sampleSizeInBits the size of a single sample in bits
+-         * @param channels the number of channels
+-         * @return the size of a PCM frame in bytes.
+-         */
+-        protected static int calculatePCMFrameSize(int sampleSizeInBits,
+-                                                                                        int channels) {
+-                return ((sampleSizeInBits + 7) / 8) * channels;
+-        }
++    /** Calculates the frame size for PCM frames.
++     * Note that this method is appropriate for non-packed samples.
++     * For instance, 12 bit, 2 channels will return 4 bytes, not 3.
++     * @param sampleSizeInBits the size of a single sample in bits
++     * @param channels the number of channels
++     * @return the size of a PCM frame in bytes.
++     */
++    static final int calculatePCMFrameSize(int sampleSizeInBits, int channels) {
++        return ((sampleSizeInBits + 7) / 8) * channels;
++    }
+ }
+diff --git a/src/share/classes/com/sun/media/sound/SunFileWriter.java b/src/share/classes/com/sun/media/sound/SunFileWriter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -74,8 +74,7 @@
+ 
+     // new, 10.27.99
+ 
+-    public AudioFileFormat.Type[] getAudioFileTypes(){
+-
++    public final AudioFileFormat.Type[] getAudioFileTypes(){
+         AudioFileFormat.Type[] localArray = new AudioFileFormat.Type[types.length];
+         System.arraycopy(types, 0, localArray, 0, types.length);
+         return localArray;
+@@ -100,7 +99,7 @@
+      * @return 32 bits swapped value.
+      * @exception IOException
+      */
+-    protected int rllong(DataInputStream dis) throws IOException {
++    final int rllong(DataInputStream dis) throws IOException {
+ 
+         int b1, b2, b3, b4 ;
+         int i = 0;
+@@ -123,7 +122,7 @@
+      * @param int
+      * @return 32 bits swapped value
+      */
+-    protected int big2little(int i) {
++    final int big2little(int i) {
+ 
+         int b1, b2, b3, b4 ;
+ 
+@@ -144,7 +143,7 @@
+      * @return the swapped value.
+      * @exception IOException
+      */
+-    protected short rlshort(DataInputStream dis)  throws IOException {
++    final short rlshort(DataInputStream dis)  throws IOException {
+ 
+         short s=0;
+         short high, low;
+@@ -165,7 +164,7 @@
+      * @param int
+      * @return 16 bits swapped value
+      */
+-    protected short big2littleShort(short i) {
++    final short big2littleShort(short i) {
+ 
+         short high, low;
+ 
+diff --git a/src/share/classes/com/sun/media/sound/Toolkit.java b/src/share/classes/com/sun/media/sound/Toolkit.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/Toolkit.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/Toolkit.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -35,8 +35,13 @@
+  * @author Kara Kytle
+  * @author Florian Bomers
+  */
+-public class Toolkit {
++public final class Toolkit {
+ 
++    /**
++     * Suppresses default constructor, ensuring non-instantiability.
++     */
++    private Toolkit() {
++    }
+ 
+     /**
+      * Converts bytes from signed to unsigned.
+diff --git a/src/share/classes/com/sun/media/sound/UlawCodec.java b/src/share/classes/com/sun/media/sound/UlawCodec.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,7 +25,6 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.io.InputStream;
+ import java.io.IOException;
+ 
+ import java.util.Vector;
+@@ -40,12 +39,12 @@
+  *
+  * @author Kara Kytle
+  */
+-public class UlawCodec extends SunCodec {
++public final class UlawCodec extends SunCodec {
+ 
+     /* Tables used for U-law decoding */
+ 
+-    final static byte ULAW_TABH[] = new byte[256];
+-    final static byte ULAW_TABL[] = new byte[256];
++    private final static byte[] ULAW_TABH = new byte[256];
++    private final static byte[] ULAW_TABL = new byte[256];
+ 
+     private static final AudioFormat.Encoding[] ulawEncodings = {AudioFormat.Encoding.ULAW,
+                                                                  AudioFormat.Encoding.PCM_SIGNED};
+diff --git a/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java b/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -46,7 +46,7 @@
+  * 
+  * @author Karl Helgason
+  */
+-public class WaveExtensibleFileReader extends AudioFileReader {
++public final class WaveExtensibleFileReader extends AudioFileReader {
+ 
+     static private class GUID {
+         long i1;
+@@ -74,7 +74,7 @@
+         private GUID() {
+         }
+ 
+-        public GUID(long i1, int s1, int s2, int x1, int x2, int x3, int x4,
++        GUID(long i1, int s1, int s2, int x1, int x2, int x3, int x4,
+                 int x5, int x6, int x7, int x8) {
+             this.i1 = i1;
+             this.s1 = s1;
+@@ -140,13 +140,13 @@
+ 
+     }
+ 
+-    private static String[] channelnames = { "FL", "FR", "FC", "LF",
++    private static final String[] channelnames = { "FL", "FR", "FC", "LF",
+             "BL",
+             "BR", // 5.1
+             "FLC", "FLR", "BC", "SL", "SR", "TC", "TFL", "TFC", "TFR", "TBL",
+             "TBC", "TBR" };
+ 
+-    private static String[] allchannelnames = { "w1", "w2", "w3", "w4", "w5",
++    private static final String[] allchannelnames = { "w1", "w2", "w3", "w4", "w5",
+             "w6", "w7", "w8", "w9", "w10", "w11", "w12", "w13", "w14", "w15",
+             "w16", "w17", "w18", "w19", "w20", "w21", "w22", "w23", "w24",
+             "w25", "w26", "w27", "w28", "w29", "w30", "w31", "w32", "w33",
+@@ -155,10 +155,10 @@
+             "w52", "w53", "w54", "w55", "w56", "w57", "w58", "w59", "w60",
+             "w61", "w62", "w63", "w64" };
+ 
+-    private static GUID SUBTYPE_PCM = new GUID(0x00000001, 0x0000, 0x0010,
++    private static final GUID SUBTYPE_PCM = new GUID(0x00000001, 0x0000, 0x0010,
+             0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 
+-    private static GUID SUBTYPE_IEEE_FLOAT = new GUID(0x00000003, 0x0000,
++    private static final GUID SUBTYPE_IEEE_FLOAT = new GUID(0x00000003, 0x0000,
+             0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 
+     private String decodeChannelMask(long channelmask) {
+diff --git a/src/share/classes/com/sun/media/sound/WaveFileFormat.java b/src/share/classes/com/sun/media/sound/WaveFileFormat.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFileFormat.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFileFormat.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,24 +25,8 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.util.Vector;
+-import java.io.File;
+-import java.io.InputStream;
+-import java.io.OutputStream;
+-import java.io.IOException;
+-import java.lang.IllegalArgumentException;
+-
+-import java.io.BufferedOutputStream;
+-import java.io.DataOutputStream;
+-import java.io.FileOutputStream;
+-import java.io.ByteArrayInputStream;
+-import java.io.ByteArrayOutputStream;
+-import java.io.SequenceInputStream;
+-
+ import javax.sound.sampled.AudioFileFormat;
+-import javax.sound.sampled.AudioInputStream;
+ import javax.sound.sampled.AudioFormat;
+-import javax.sound.sampled.AudioSystem;
+ 
+ 
+ /**
+@@ -51,12 +35,12 @@
+  * @author Jan Borgersen
+  */
+ 
+-class WaveFileFormat extends AudioFileFormat {
++final class WaveFileFormat extends AudioFileFormat {
+ 
+     /**
+      * Wave format type.
+      */
+-    private int waveType;
++    private final int waveType;
+ 
+     //$$fb 2001-07-13: added management of header size in this class
+     //$$fb 2002-04-16: Fix for 4636355: RIFF audio headers could be _more_ spec compliant
+diff --git a/src/share/classes/com/sun/media/sound/WaveFileReader.java b/src/share/classes/com/sun/media/sound/WaveFileReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFileReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFileReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,28 +25,17 @@
+ 
+ package com.sun.media.sound;
+ 
+-import java.util.Vector;
++import java.io.DataInputStream;
++import java.io.EOFException;
+ import java.io.File;
++import java.io.FileInputStream;
++import java.io.IOException;
+ import java.io.InputStream;
+-import java.io.OutputStream;
+-import java.io.IOException;
+-import java.io.EOFException;
+ import java.net.URL;
+-import java.net.MalformedURLException;
+-
+-import java.io.BufferedInputStream;
+-import java.io.BufferedOutputStream;
+-import java.io.DataInputStream;
+-import java.io.FileInputStream;
+-import java.io.DataOutputStream;
+-import java.io.FileOutputStream;
+-import java.io.ByteArrayInputStream;
+-import java.io.ByteArrayOutputStream;
+-import java.io.SequenceInputStream;
+ 
+ import javax.sound.sampled.AudioFileFormat;
++import javax.sound.sampled.AudioFormat;
+ import javax.sound.sampled.AudioInputStream;
+-import javax.sound.sampled.AudioFormat;
+ import javax.sound.sampled.AudioSystem;
+ import javax.sound.sampled.UnsupportedAudioFileException;
+ 
+@@ -59,20 +48,11 @@
+  * @author Jan Borgersen
+  * @author Florian Bomers
+  */
+-public class WaveFileReader extends SunFileReader {
++public final class WaveFileReader extends SunFileReader {
+ 
+     private static final int MAX_READ_LENGTH = 12;
+ 
+     /**
+-     * WAVE reader type
+-     */
+-
+-    public static final AudioFileFormat.Type types[] = {
+-        AudioFileFormat.Type.WAVE
+-    };
+-
+-
+-    /**
+      * Constructs a new WaveFileReader object.
+      */
+     public WaveFileReader() {
+diff --git a/src/share/classes/com/sun/media/sound/WaveFileWriter.java b/src/share/classes/com/sun/media/sound/WaveFileWriter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -52,7 +52,7 @@
+  *
+  * @author Jan Borgersen
+  */
+-public class WaveFileWriter extends SunFileWriter {
++public final class WaveFileWriter extends SunFileWriter {
+ 
+     // magic numbers
+     static  final int RIFF_MAGIC = 1380533830;
+@@ -76,18 +76,10 @@
+     static final int WAVE_FORMAT_SX7383    = 0x1C07;
+ 
+     /**
+-     * WAVE type
+-     */
+-    private static final AudioFileFormat.Type waveTypes[] = {
+-        AudioFileFormat.Type.WAVE
+-    };
+-
+-
+-    /**
+      * Constructs a new WaveFileWriter object.
+      */
+     public WaveFileWriter() {
+-        super(waveTypes);
++        super(new AudioFileFormat.Type[]{AudioFileFormat.Type.WAVE});
+     }
+ 
+ 
+diff --git a/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java b/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -43,7 +43,7 @@
+  *
+  * @author Karl Helgason
+  */
+-public class WaveFloatFileReader extends AudioFileReader {
++public final class WaveFloatFileReader extends AudioFileReader {
+ 
+     public AudioFileFormat getAudioFileFormat(InputStream stream)
+             throws UnsupportedAudioFileException, IOException {
+diff --git a/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java b/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -40,7 +40,7 @@
+  * 
+  * @author Karl Helgason
+  */
+-public class WaveFloatFileWriter extends AudioFileWriter {
++public final class WaveFloatFileWriter extends AudioFileWriter {
+ 
+     public Type[] getAudioFileTypes() {
+         return new Type[] { Type.WAVE };
+@@ -87,9 +87,9 @@
+     }
+ 
+     private static class NoCloseOutputStream extends OutputStream {
+-        OutputStream out;
++        final OutputStream out;
+ 
+-        public NoCloseOutputStream(OutputStream out) {
++        NoCloseOutputStream(OutputStream out) {
+             this.out = out;
+         }
+ 
+diff --git a/src/share/classes/javax/sound/midi/MetaMessage.java b/src/share/classes/javax/sound/midi/MetaMessage.java
+--- openjdk/jdk/src/share/classes/javax/sound/midi/MetaMessage.java
++++ openjdk/jdk/src/share/classes/javax/sound/midi/MetaMessage.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,10 +25,6 @@
+ 
+ package javax.sound.midi;
+ 
+-import java.io.ByteArrayOutputStream;
+-import java.io.DataOutputStream;
+-import java.io.IOException;
+-
+ 
+ /**
+  * A <code>MetaMessage</code> is a <code>{@link MidiMessage}</code> that is not meaningful to synthesizers, but
+@@ -71,14 +67,6 @@
+      */
+     public static final int META                                                = 0xFF; // 255
+ 
+-
+-    // Default meta message data: just the META status byte value
+-    // $$kk: 09.09.99: need a real event here!!
+-
+-    private static byte[] defaultMessage                                = { (byte)META, 0 };
+-
+-
+-
+     // Instance variables
+ 
+     /**
+@@ -98,8 +86,8 @@
+      * to set them subsequently.
+      */
+     public MetaMessage() {
+-        //super(defaultMessage);
+-        this(defaultMessage);
++        // Default meta message data: just the META status byte value
++        this(new byte[]{(byte) META, 0});
+     }
+ 
+ 
+diff --git a/src/share/classes/javax/sound/sampled/Mixer.java b/src/share/classes/javax/sound/sampled/Mixer.java
+--- openjdk/jdk/src/share/classes/javax/sound/sampled/Mixer.java
++++ openjdk/jdk/src/share/classes/javax/sound/sampled/Mixer.java
+@@ -253,22 +253,22 @@
+         /**
+          * Mixer name.
+          */
+-        private /*final*/ String name;
++        private final String name;
+ 
+         /**
+          * Mixer vendor.
+          */
+-        private /*final*/ String vendor;
++        private final String vendor;
+ 
+         /**
+          * Mixer description.
+          */
+-        private /*final*/ String description;
++        private final String description;
+ 
+         /**
+          * Mixer version.
+          */
+-        private /*final*/ String version;
++        private final String version;
+ 
+         /**
+          * Constructs a mixer's info object, passing it the given
+diff --git a/src/share/classes/sun/audio/AudioData.java b/src/share/classes/sun/audio/AudioData.java
+--- openjdk/jdk/src/share/classes/sun/audio/AudioData.java
++++ openjdk/jdk/src/share/classes/sun/audio/AudioData.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -48,7 +48,7 @@
+   */
+ 
+ 
+-public class AudioData {
++public final class AudioData {
+ 
+     private static final AudioFormat DEFAULT_FORMAT =
+         new AudioFormat(AudioFormat.Encoding.ULAW,
+diff --git a/src/share/classes/sun/audio/AudioDataStream.java b/src/share/classes/sun/audio/AudioDataStream.java
+--- openjdk/jdk/src/share/classes/sun/audio/AudioDataStream.java
++++ openjdk/jdk/src/share/classes/sun/audio/AudioDataStream.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -26,8 +26,6 @@
+ package sun.audio;
+ 
+ import java.io.*;
+-import javax.sound.sampled.*;
+-import javax.sound.midi.*;
+ 
+ /**
+  * An input stream to play AudioData.
+@@ -39,18 +37,18 @@
+  */
+ public class AudioDataStream extends ByteArrayInputStream {
+ 
+-    AudioData ad;
++    private final AudioData ad;
+ 
+     /**
+      * Constructor
+      */
+-    public AudioDataStream(AudioData data) {
++    public AudioDataStream(final AudioData data) {
+ 
+         super(data.buffer);
+         this.ad = data;
+     }
+ 
+-    AudioData getAudioData() {
++    final AudioData getAudioData() {
+         return ad;
+     }
+ }
+diff --git a/src/share/classes/sun/audio/AudioDevice.java b/src/share/classes/sun/audio/AudioDevice.java
+--- openjdk/jdk/src/share/classes/sun/audio/AudioDevice.java
++++ openjdk/jdk/src/share/classes/sun/audio/AudioDevice.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -27,12 +27,9 @@
+ 
+ import java.util.Hashtable;
+ import java.util.Vector;
+-import java.util.Enumeration;
+ import java.io.IOException;
+ import java.io.InputStream;
+ import java.io.BufferedInputStream;
+-import java.io.OutputStream;
+-import java.io.ByteArrayInputStream;
+ 
+ import javax.sound.sampled.*;
+ import javax.sound.midi.*;
+@@ -57,8 +54,7 @@
+  * @author Florian Bomers
+  */
+ 
+-public class
+-    AudioDevice {
++public final class AudioDevice {
+ 
+     private boolean DEBUG = false  /*true*/ ;
+ 
+@@ -404,11 +400,11 @@
+ 
+     // INFO CLASS
+ 
+-    class Info implements MetaEventListener {
++    final class Info implements MetaEventListener {
+ 
+-        Sequencer   sequencer;
+-        InputStream in;
+-        DataPusher  datapusher;
++        final Sequencer   sequencer;
++        final InputStream in;
++        final DataPusher  datapusher;
+ 
+         Info( Sequencer sequencer, InputStream in, DataPusher datapusher ) {
+ 
+diff --git a/src/share/classes/sun/audio/AudioPlayer.java b/src/share/classes/sun/audio/AudioPlayer.java
+--- openjdk/jdk/src/share/classes/sun/audio/AudioPlayer.java
++++ openjdk/jdk/src/share/classes/sun/audio/AudioPlayer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,13 +25,7 @@
+ 
+ package sun.audio;
+ 
+-import java.util.Vector;
+-import java.util.Enumeration;
+-import java.io.IOException;
+ import java.io.InputStream;
+-import java.io.OutputStream;
+-import java.io.FileOutputStream;
+-
+ import java.security.AccessController;
+ import java.security.PrivilegedAction;
+ 
+@@ -69,11 +63,10 @@
+  * @author Arthur van Hoff, Thomas Ball
+  */
+ 
+-public
+-    class AudioPlayer extends Thread {
++public final class AudioPlayer extends Thread {
+ 
+-        private AudioDevice devAudio;
+-        private static boolean DEBUG = false /*true*/;
++        private final AudioDevice devAudio;
++        private final static boolean DEBUG = false /*true*/;
+ 
+         /**
+          * The default audio player. This audio player is initialized
+diff --git a/src/share/classes/sun/audio/AudioStream.java b/src/share/classes/sun/audio/AudioStream.java
+--- openjdk/jdk/src/share/classes/sun/audio/AudioStream.java
++++ openjdk/jdk/src/share/classes/sun/audio/AudioStream.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -26,9 +26,7 @@
+ package sun.audio;
+ 
+ import java.io.InputStream;
+-import java.io.DataInputStream;
+ import java.io.FilterInputStream;
+-import java.io.ByteArrayInputStream;
+ import java.io.BufferedInputStream;
+ import java.io.IOException;
+ 
+@@ -41,13 +39,13 @@
+  */
+ 
+ 
+-public class AudioStream extends FilterInputStream {
++public final class AudioStream extends FilterInputStream {
+ 
+     // AudioContainerInputStream acis;
+-    protected AudioInputStream ais = null;
+-    protected AudioFormat format = null;
+-    protected MidiFileFormat midiformat = null;
+-    protected InputStream stream = null;
++    AudioInputStream ais = null;
++    AudioFormat format = null;
++    MidiFileFormat midiformat = null;
++    InputStream stream = null;
+ 
+ 
+     /*
+diff --git a/src/share/classes/sun/audio/AudioStreamSequence.java b/src/share/classes/sun/audio/AudioStreamSequence.java
+--- openjdk/jdk/src/share/classes/sun/audio/AudioStreamSequence.java
++++ openjdk/jdk/src/share/classes/sun/audio/AudioStreamSequence.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -25,7 +25,6 @@
+ 
+ package sun.audio;
+ 
+-import java.io.IOException;
+ import java.io.InputStream;
+ import java.io.SequenceInputStream;
+ import java.util.Enumeration;
+@@ -44,8 +43,8 @@
+  * @see AudioPlayer
+  * @author Arthur van Hoff
+  */
+-public
+-    class AudioStreamSequence extends SequenceInputStream {
++public final class AudioStreamSequence extends SequenceInputStream {
++
+         Enumeration e;
+         InputStream in;
+ 
+diff --git a/src/share/classes/sun/audio/AudioTranslatorStream.java b/src/share/classes/sun/audio/AudioTranslatorStream.java
+--- openjdk/jdk/src/share/classes/sun/audio/AudioTranslatorStream.java
++++ openjdk/jdk/src/share/classes/sun/audio/AudioTranslatorStream.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -26,18 +26,15 @@
+ package sun.audio;
+ 
+ import java.io.InputStream;
+-import java.io.DataInputStream;
+-import java.io.FilterInputStream;
+ import java.io.IOException;
+ 
+ /**
+  * Translator for native audio formats (not implemented in this release).
+  *
+  */
+-public
+-    class AudioTranslatorStream extends NativeAudioStream {
++public final class AudioTranslatorStream extends NativeAudioStream {
+ 
+-        private int length = 0;
++        private final int length = 0;
+ 
+         public AudioTranslatorStream(InputStream in) throws IOException {
+             super(in);
+diff --git a/src/share/classes/sun/audio/ContinuousAudioDataStream.java b/src/share/classes/sun/audio/ContinuousAudioDataStream.java
+--- openjdk/jdk/src/share/classes/sun/audio/ContinuousAudioDataStream.java
++++ openjdk/jdk/src/share/classes/sun/audio/ContinuousAudioDataStream.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -42,11 +42,10 @@
+  * @author Arthur van Hoff
+  */
+ 
+-public
+-    class ContinuousAudioDataStream extends AudioDataStream {
++public final class ContinuousAudioDataStream extends AudioDataStream {
+ 
+ 
+-        /**
++    /**
+          * Create a continuous stream of audio.
+          */
+         public ContinuousAudioDataStream(AudioData data) {
+diff --git a/src/share/classes/sun/audio/InvalidAudioFormatException.java b/src/share/classes/sun/audio/InvalidAudioFormatException.java
+--- openjdk/jdk/src/share/classes/sun/audio/InvalidAudioFormatException.java
++++ openjdk/jdk/src/share/classes/sun/audio/InvalidAudioFormatException.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -29,20 +29,20 @@
+ /**
+  * Signals an invalid audio stream for the stream handler.
+  */
+-class InvalidAudioFormatException extends IOException {
++final class InvalidAudioFormatException extends IOException {
+ 
+ 
+     /**
+      * Constructor.
+      */
+-    public InvalidAudioFormatException() {
++    InvalidAudioFormatException() {
+         super();
+     }
+ 
+     /**
+      * Constructor with a detail message.
+      */
+-    public InvalidAudioFormatException(String s) {
++    InvalidAudioFormatException(String s) {
+         super(s);
+     }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8006611-improve_scripting.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,78 @@
+# HG changeset patch
+# User sundar
+# Date 1365156565 -19800
+# Node ID 1d5eff0bd9b504b7191279bfc6a417f6a2e2251f
+# Parent  5c9fbf7443a24076a6545cb043102cb2527f62ca
+8006611: Improve scripting
+Reviewed-by: mchung, jdn
+
+diff --git a/src/share/classes/javax/script/ScriptEngineManager.java b/src/share/classes/javax/script/ScriptEngineManager.java
+--- openjdk/jdk/src/share/classes/javax/script/ScriptEngineManager.java
++++ openjdk/jdk/src/share/classes/javax/script/ScriptEngineManager.java
+@@ -30,8 +30,6 @@
+ import java.security.*;
+ import sun.misc.Service;
+ import sun.misc.ServiceConfigurationError;
+-import sun.reflect.Reflection;
+-import sun.security.util.SecurityConstants;
+ 
+ /**
+  * The <code>ScriptEngineManager</code> implements a discovery and instantiation
+@@ -64,13 +62,7 @@
+      */
+     public ScriptEngineManager() {
+         ClassLoader ctxtLoader = Thread.currentThread().getContextClassLoader();
+-        if (canCallerAccessLoader(ctxtLoader)) {
+-            if (DEBUG) System.out.println("using " + ctxtLoader);
+-            init(ctxtLoader);
+-        } else {
+-            if (DEBUG) System.out.println("using bootstrap loader");
+-            init(null);
+-        }
++        init(ctxtLoader);
+     }
+ 
+     /**
+@@ -418,42 +410,4 @@
+ 
+     /** Global bindings associated with script engines created by this manager. */
+     private Bindings globalScope;
+-
+-    private boolean canCallerAccessLoader(ClassLoader loader) {
+-        SecurityManager sm = System.getSecurityManager();
+-        if (sm != null) {
+-            ClassLoader callerLoader = getCallerClassLoader();
+-            if (callerLoader != null) {
+-                if (loader != callerLoader || !isAncestor(loader, callerLoader)) {
+-                    try {
+-                        sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
+-                    } catch (SecurityException exp) {
+-                        if (DEBUG) exp.printStackTrace();
+-                        return false;
+-                    }
+-                } // else fallthru..
+-            } // else fallthru..
+-        } // else fallthru..
+-
+-        return true;
+-    }
+-
+-    // Note that this code is same as ClassLoader.getCallerClassLoader().
+-    // But, that method is package private and hence we can't call here.
+-    private ClassLoader getCallerClassLoader() {
+-        Class caller = Reflection.getCallerClass(3);
+-        if (caller == null) {
+-            return null;
+-        }
+-        return caller.getClassLoader();
+-    }
+-
+-    // is cl1 ancestor of cl2?
+-    private boolean isAncestor(ClassLoader cl1, ClassLoader cl2) {
+-        do {
+-            cl2 = cl2.getParent();
+-            if (cl1 == cl2) return true;
+-        } while (cl2 != null);
+-        return false;
+-    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8007467-improve_jmx_internal_api_robustness.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,108 @@
+# HG changeset patch
+# User andrew
+# Date 1371404383 18000
+# Node ID 65ed365feeae0a68d89dd63143b6be3c0be11c81
+# Parent  1d5eff0bd9b504b7191279bfc6a417f6a2e2251f
+8007467: Improve robustness of JMX internal APIs
+Reviewed-by: dfuchs, mchung, skoivu
+
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java b/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java
+@@ -33,6 +33,7 @@
+ import javax.management.MBeanException;
+ import javax.management.openmbean.OpenDataException;
+ import javax.management.openmbean.OpenType;
++import sun.reflect.misc.MethodUtil;
+ 
+ final class ConvertingMethod {
+     static ConvertingMethod from(Method m) {
+@@ -177,7 +178,7 @@
+                 "from open values: " + e;
+             throw new MBeanException(e, msg);
+         }
+-        final Object javaReturn = method.invoke(obj, javaParams);
++        final Object javaReturn = MethodUtil.invoke(method, obj, javaParams);
+         try {
+             return returnConverter.toOpenValue(lookup, javaReturn);
+         } catch (OpenDataException e) {
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java b/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java
+@@ -38,6 +38,7 @@
+ import javax.management.NotCompliantMBeanException;
+ import javax.management.NotificationBroadcaster;
+ import javax.management.NotificationBroadcasterSupport;
++import sun.reflect.misc.MethodUtil;
+ 
+ /**
+  * @since 1.6
+@@ -108,7 +109,7 @@
+     Object invokeM2(Method m, Object target, Object[] args, Object cookie)
+             throws InvocationTargetException, IllegalAccessException,
+                    MBeanException {
+-        return m.invoke(target, args);
++        return MethodUtil.invoke(m, target, args);
+     }
+ 
+     @Override
+diff --git a/src/share/classes/javax/management/openmbean/CompositeDataInvocationHandler.java b/src/share/classes/javax/management/openmbean/CompositeDataInvocationHandler.java
+--- openjdk/jdk/src/share/classes/javax/management/openmbean/CompositeDataInvocationHandler.java
++++ openjdk/jdk/src/share/classes/javax/management/openmbean/CompositeDataInvocationHandler.java
+@@ -172,6 +172,8 @@
+                    the only non-final methods in Object that are not
+                    handled above are finalize and clone, and these
+                    are not overridden in generated proxies.  */
++                // this plain Method.invoke is called only if the declaring class
++                // is Object and so it's safe.
+                 return method.invoke(this, args);
+             }
+         }
+diff --git a/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java b/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
+--- openjdk/jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
++++ openjdk/jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
+@@ -45,6 +45,9 @@
+ import javax.management.ImmutableDescriptor;
+ import javax.management.MBeanAttributeInfo;
+ import com.sun.jmx.remote.util.EnvHelp;
++import sun.reflect.misc.ConstructorUtil;
++import sun.reflect.misc.MethodUtil;
++import sun.reflect.misc.ReflectUtil;
+ 
+ /**
+  * Describes an attribute of an open MBean.
+@@ -690,6 +693,7 @@
+     private static <T> T convertFromString(String s, OpenType<T> openType) {
+         Class<T> c;
+         try {
++            ReflectUtil.checkPackageAccess(openType.safeGetClassName());
+             c = cast(Class.forName(openType.safeGetClassName()));
+         } catch (ClassNotFoundException e) {
+             throw new NoClassDefFoundError(e.toString());  // can't happen
+@@ -698,6 +702,8 @@
+         // Look for: public static T valueOf(String)
+         Method valueOf;
+         try {
++            // It is safe to call this plain Class.getMethod because the class "c"
++            // was checked before by ReflectUtil.checkPackageAccess(openType.safeGetClassName());
+             valueOf = c.getMethod("valueOf", String.class);
+             if (!Modifier.isStatic(valueOf.getModifiers()) ||
+                     valueOf.getReturnType() != c)
+@@ -707,7 +713,7 @@
+         }
+         if (valueOf != null) {
+             try {
+-                return c.cast(valueOf.invoke(null, s));
++                return c.cast(MethodUtil.invoke(valueOf, null, new Object[] {s}));
+             } catch (Exception e) {
+                 final String msg =
+                     "Could not convert \"" + s + "\" using method: " + valueOf;
+@@ -718,6 +724,8 @@
+         // Look for: public T(String)
+         Constructor<T> con;
+         try {
++            // It is safe to call this plain Class.getConstructor because the class "c"
++            // was checked before by ReflectUtil.checkPackageAccess(openType.safeGetClassName());
+             con = c.getConstructor(String.class);
+         } catch (NoSuchMethodException e) {
+             con = null;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8007471-6_fixup.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,25 @@
+# HG changeset patch
+# User andrew
+# Date 1371827420 18000
+# Node ID ae1f55ff0e864d754b3dd7f2ad86fd93062e9744
+# Parent  ccd06d9c7258aea155d7053d399431bcd1af4405
+Fix up 8007471
+
+diff --git a/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java b/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java
+@@ -402,7 +402,13 @@
+                         try {
+                             ServerNotifForwarder.checkMBeanPermission(this.mBeanServer,
+                                                       candidate.getObjectName(),"addNotificationListener");
+-                        } catch (InstanceNotFoundException | SecurityException e) {
++                        } catch (InstanceNotFoundException e) {
++                            if (logger.debugOn()) {
++                                logger.debug("fetchNotifications", "candidate: " + candidate + " skipped. exception " + e);
++                            }
++                            ++nextSeq;
++                            continue;
++                        } catch (SecurityException e) {
+                             if (logger.debugOn()) {
+                                 logger.debug("fetchNotifications", "candidate: " + candidate + " skipped. exception " + e);
+                             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8007471-improve_mbean_notifications.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,89 @@
+# HG changeset patch
+# User andrew
+# Date 1371404736 18000
+# Node ID 5c4ab66b87e3b640978d71e1af2952f00e721ada
+# Parent  65ed365feeae0a68d89dd63143b6be3c0be11c81
+8007471: Improve MBean notifications
+Summary: Improve MBean notifications
+
+diff --git a/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java b/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/remote/internal/ArrayNotificationBuffer.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -397,6 +397,20 @@
+ 
+                 if (nextSeq < nextSequenceNumber()) {
+                     candidate = notificationAt(nextSeq);
++                    // Skip security check if NotificationBufferFilter is not overloaded
++                    if (!(filter instanceof ServerNotifForwarder.NotifForwarderBufferFilter)) {
++                        try {
++                            ServerNotifForwarder.checkMBeanPermission(this.mBeanServer,
++                                                      candidate.getObjectName(),"addNotificationListener");
++                        } catch (InstanceNotFoundException | SecurityException e) {
++                            if (logger.debugOn()) {
++                                logger.debug("fetchNotifications", "candidate: " + candidate + " skipped. exception " + e);
++                            }
++                            ++nextSeq;
++                            continue;
++                        }
++                    }
++
+                     if (logger.debugOn()) {
+                         logger.debug("fetchNotifications", "candidate: " +
+                                      candidate);
+diff --git a/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java b/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -228,8 +228,9 @@
+      * why we add the found notifications to a supplied List rather than
+      * just returning a boolean.
+      */
+-    private final NotificationBufferFilter bufferFilter =
+-            new NotificationBufferFilter() {
++    private final NotifForwarderBufferFilter bufferFilter = new NotifForwarderBufferFilter();
++
++    final class NotifForwarderBufferFilter implements NotificationBufferFilter {
+         public void apply(List<TargetedNotification> targetedNotifs,
+                           ObjectName source, Notification notif) {
+             // We proceed in two stages here, to avoid holding the listenerMap
+@@ -330,9 +331,16 @@
+      * Explicitly check the MBeanPermission for
+      * the current access control context.
+      */
+-    private void checkMBeanPermission(final ObjectName name,
+-        final String actions)
++    public final void checkMBeanPermission(
++             final ObjectName name, final String actions)
+         throws InstanceNotFoundException, SecurityException {
++        checkMBeanPermission(mbeanServer,name,actions);
++    }
++
++    static void checkMBeanPermission(
++            final MBeanServer mbs, final ObjectName name, final String actions)
++            throws InstanceNotFoundException, SecurityException {
++
+         SecurityManager sm = System.getSecurityManager();
+         if (sm != null) {
+             AccessControlContext acc = AccessController.getContext();
+@@ -342,7 +350,7 @@
+                     new PrivilegedExceptionAction<ObjectInstance>() {
+                         public ObjectInstance run()
+                         throws InstanceNotFoundException {
+-                            return mbeanServer.getObjectInstance(name);
++                            return mbs.getObjectInstance(name);
+                         }
+                 });
+             } catch (PrivilegedActionException e) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8007812-getenclosingmethod.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,89 @@
+# HG changeset patch
+# User andrew
+# Date 1371404993 18000
+# Node ID a9d86a9899a5ecfdb22e5ca279a834771684b0fe
+# Parent  5c4ab66b87e3b640978d71e1af2952f00e721ada
+8007812: (reflect) Class.getEnclosingMethod problematic for some classes
+Summary: Better checking in getEnclosing(Method|Constructor|Class)
+Reviewed-by: darcy, ahgross, mchung
+
+diff --git a/src/share/classes/java/lang/Class.java b/src/share/classes/java/lang/Class.java
+--- openjdk/jdk/src/share/classes/java/lang/Class.java
++++ openjdk/jdk/src/share/classes/java/lang/Class.java
+@@ -912,13 +912,22 @@
+             for(int i = 0; i < parameterClasses.length; i++)
+                 parameterClasses[i] = toClass(parameterTypes[i]);
+ 
++            // Perform access check
++            Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
++            // be very careful not to change the stack depth of this
++            // checkMemberAccess call for security reasons
++            // see java.lang.SecurityManager.checkMemberAccess
++            //
++            // Note that we need to do this on the enclosing class
++            enclosingCandidate.checkMemberAccess(Member.DECLARED,
++                        ClassLoader.getCallerClassLoader(), true);
+             /*
+              * Loop over all declared methods; match method name,
+              * number of and type of parameters, *and* return
+              * type.  Matching return type is also necessary
+              * because of covariant returns, etc.
+              */
+-            for(Method m: enclosingInfo.getEnclosingClass().getDeclaredMethods()) {
++            for(Method m: enclosingCandidate.getDeclaredMethods()) {
+                 if (m.getName().equals(enclosingInfo.getName()) ) {
+                     Class<?>[] candidateParamClasses = m.getParameterTypes();
+                     if (candidateParamClasses.length == parameterClasses.length) {
+@@ -1039,11 +1048,20 @@
+             for(int i = 0; i < parameterClasses.length; i++)
+                 parameterClasses[i] = toClass(parameterTypes[i]);
+ 
++            // Perform access check
++            Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
++            // be very careful not to change the stack depth of this
++            // checkMemberAccess call for security reasons
++            // see java.lang.SecurityManager.checkMemberAccess
++            //
++            // Note that we need to do this on the enclosing class
++            enclosingCandidate.checkMemberAccess(Member.DECLARED,
++                        ClassLoader.getCallerClassLoader(), true);
+             /*
+              * Loop over all declared constructors; match number
+              * of and type of parameters.
+              */
+-            for(Constructor c: enclosingInfo.getEnclosingClass().getDeclaredConstructors()) {
++            for(Constructor<?> c: enclosingCandidate.getDeclaredConstructors()) {
+                 Class<?>[] candidateParamClasses = c.getParameterTypes();
+                 if (candidateParamClasses.length == parameterClasses.length) {
+                     boolean matches = true;
+@@ -1098,18 +1116,28 @@
+         // attribute if and only if it is a local class or an
+         // anonymous class.
+         EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo();
++        Class<?> enclosingCandidate;
+ 
+         if (enclosingInfo == null) {
+             // This is a top level or a nested class or an inner class (a, b, or c)
+-            return getDeclaringClass();
++            enclosingCandidate = getDeclaringClass();
+         } else {
+             Class<?> enclosingClass = enclosingInfo.getEnclosingClass();
+             // This is a local class or an anonymous class (d or e)
+             if (enclosingClass == this || enclosingClass == null)
+                 throw new InternalError("Malformed enclosing method information");
+             else
+-                return enclosingClass;
++                enclosingCandidate = enclosingClass;
+         }
++
++        // be very careful not to change the stack depth of this
++        // checkMemberAccess call for security reasons
++        // see java.lang.SecurityManager.checkMemberAccess
++        if (enclosingCandidate != null) {
++            enclosingCandidate.checkMemberAccess(Member.DECLARED,
++                    ClassLoader.getCallerClassLoader(), true);
++        }
++        return enclosingCandidate;
+     }
+ 
+     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008120-improve_jmx_class_checking.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,332 @@
+# HG changeset patch
+# User andrew
+# Date 1371483960 18000
+# Node ID 100c93da24f90ae93063fdd0affbc29c691424e8
+# Parent  a9d86a9899a5ecfdb22e5ca279a834771684b0fe
+8008120: Improve JMX class checking
+Summary: Improve JMX class checking
+Reviewed-by: mchung, dfuchs, alanb, skoivu
+
+diff --git a/src/share/classes/javax/management/relation/RelationNotification.java b/src/share/classes/javax/management/relation/RelationNotification.java
+--- openjdk/jdk/src/share/classes/javax/management/relation/RelationNotification.java
++++ openjdk/jdk/src/share/classes/javax/management/relation/RelationNotification.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -28,6 +28,7 @@
+ import javax.management.Notification;
+ import javax.management.ObjectName;
+ 
++import java.io.InvalidObjectException;
+ import java.io.IOException;
+ import java.io.ObjectInputStream;
+ import java.io.ObjectOutputStream;
+@@ -37,8 +38,11 @@
+ import java.security.PrivilegedAction;
+ 
+ import java.util.ArrayList;
++import java.util.Arrays;
+ import java.util.Collections;
++import java.util.HashSet;
+ import java.util.List;
++import java.util.Set;
+ 
+ import com.sun.jmx.mbeanserver.GetPropertyAction;
+ import static com.sun.jmx.mbeanserver.Util.cast;
+@@ -256,21 +260,14 @@
+ 
+         super(notifType, sourceObj, sequence, timeStamp, message);
+ 
+-        // Can throw IllegalArgumentException
+-        initMembers(1,
+-                    notifType,
+-                    sourceObj,
+-                    sequence,
+-                    timeStamp,
+-                    message,
+-                    id,
+-                    typeName,
+-                    objectName,
+-                    unregMBeanList,
+-                    null,
+-                    null,
+-                    null);
+-        return;
++        if (!isValidBasic(notifType,sourceObj,id,typeName) || !isValidCreate(notifType)) {
++            throw new IllegalArgumentException("Invalid parameter.");
++        }
++
++        relationId = id;
++        relationTypeName = typeName;
++        relationObjName = safeGetObjectName(objectName);
++        unregisterMBeanList = safeGetObjectNameList(unregMBeanList);
+     }
+ 
+     /**
+@@ -313,21 +310,17 @@
+ 
+         super(notifType, sourceObj, sequence, timeStamp, message);
+ 
+-        // Can throw IllegalArgumentException
+-        initMembers(2,
+-                    notifType,
+-                    sourceObj,
+-                    sequence,
+-                    timeStamp,
+-                    message,
+-                    id,
+-                    typeName,
+-                    objectName,
+-                    null,
+-                    name,
+-                    newValue,
+-                    oldValue);
+-        return;
++        if (!isValidBasic(notifType,sourceObj,id,typeName) || !isValidUpdate(notifType,name,newValue,oldValue)) {
++            throw new IllegalArgumentException("Invalid parameter.");
++        }
++
++        relationId = id;
++        relationTypeName = typeName;
++        relationObjName = safeGetObjectName(objectName);
++
++        roleName = name;
++        oldRoleValue = safeGetObjectNameList(oldValue);
++        newRoleValue = safeGetObjectNameList(newValue);
+     }
+ 
+     //
+@@ -463,83 +456,64 @@
+     //  - no role name (for role update)
+     //  - no role old value (for role update)
+     //  - no role new value (for role update)
+-    private void initMembers(int notifKind,
+-                             String notifType,
+-                             Object sourceObj,
+-                             long sequence,
+-                             long timeStamp,
+-                             String message,
+-                             String id,
+-                             String typeName,
+-                             ObjectName objectName,
+-                             List<ObjectName> unregMBeanList,
+-                             String name,
+-                             List<ObjectName> newValue,
+-                             List<ObjectName> oldValue)
+-            throws IllegalArgumentException {
+ 
+-        boolean badInitFlg = false;
+-
+-        if (notifType == null ||
+-            sourceObj == null ||
+-            (!(sourceObj instanceof RelationService) &&
+-             !(sourceObj instanceof ObjectName)) ||
+-            id == null ||
+-            typeName == null) {
+-
+-            badInitFlg = true;
++    private boolean isValidBasic(String notifType, Object sourceObj, String id, String typeName){
++        if (notifType == null || sourceObj == null ||
++            id == null || typeName == null) {
++            return false;
+         }
+ 
+-        if (notifKind == 1) {
++        if (!(sourceObj instanceof RelationService) &&
++            !(sourceObj instanceof ObjectName)) {
++            return false;
++        }
+ 
+-            if ((!(notifType.equals(RelationNotification.RELATION_BASIC_CREATION)))
+-                &&
+-                (!(notifType.equals(RelationNotification.RELATION_MBEAN_CREATION)))
+-                &&
+-                (!(notifType.equals(RelationNotification.RELATION_BASIC_REMOVAL)))
+-                &&
+-                (!(notifType.equals(RelationNotification.RELATION_MBEAN_REMOVAL)))
+-                ) {
++        return true;
++    }
+ 
+-                // Creation/removal
+-                badInitFlg = true;
+-            }
++    private boolean isValidCreate(String notifType) {
++        String[] validTypes= {RelationNotification.RELATION_BASIC_CREATION,
++                              RelationNotification.RELATION_MBEAN_CREATION,
++                              RelationNotification.RELATION_BASIC_REMOVAL,
++                              RelationNotification.RELATION_MBEAN_REMOVAL};
+ 
+-        } else if (notifKind == 2) {
++        Set<String> ctSet = new HashSet<String>(Arrays.asList(validTypes));
++        return ctSet.contains(notifType);
++    }
+ 
+-            if (((!(notifType.equals(RelationNotification.RELATION_BASIC_UPDATE)))
+-                 &&
+-                 (!(notifType.equals(RelationNotification.RELATION_MBEAN_UPDATE))))
+-                || name == null ||
+-                oldValue == null ||
+-                newValue == null) {
++    private boolean isValidUpdate(String notifType, String name,
++                                  List<ObjectName> newValue, List<ObjectName> oldValue) {
+ 
+-                // Role update
+-                badInitFlg = true;
++        if (!(notifType.equals(RelationNotification.RELATION_BASIC_UPDATE)) &&
++            !(notifType.equals(RelationNotification.RELATION_MBEAN_UPDATE))) {
++            return false;
++        }
++
++        if (name == null || oldValue == null || newValue == null) {
++            return false;
++        }
++
++        return true;
++    }
++
++    private ArrayList<ObjectName> safeGetObjectNameList(List<ObjectName> src){
++        ArrayList<ObjectName> dest = null;
++        if (src != null) {
++            dest = new ArrayList<ObjectName>();
++            for (ObjectName item : src) {
++                // NPE thrown if we attempt to add null object
++                dest.add(ObjectName.getInstance(item));
+             }
+         }
++        return dest;
++    }
+ 
+-        if (badInitFlg) {
+-            String excMsg = "Invalid parameter.";
+-            throw new IllegalArgumentException(excMsg);
++    private ObjectName safeGetObjectName(ObjectName src){
++        ObjectName dest = null;
++        if (src != null) {
++            dest = ObjectName.getInstance(src);
+         }
+-
+-        relationId = id;
+-        relationTypeName = typeName;
+-        relationObjName = objectName;
+-        if (unregMBeanList != null) {
+-            unregisterMBeanList = new ArrayList<ObjectName>(unregMBeanList);
+-        }
+-        if (name != null) {
+-            roleName = name;
+-        }
+-        if (oldValue != null) {
+-            oldRoleValue = new ArrayList<ObjectName>(oldValue);
+-        }
+-        if (newValue != null) {
+-            newRoleValue = new ArrayList<ObjectName>(newValue);
+-        }
+-        return;
++        return dest;
+     }
+ 
+     /**
+@@ -547,53 +521,56 @@
+      */
+     private void readObject(ObjectInputStream in)
+             throws IOException, ClassNotFoundException {
+-      if (compat)
+-      {
+-        // Read an object serialized in the old serial form
+-        //
++
++        String tmpRelationId, tmpRelationTypeName, tmpRoleName;
++
++        ObjectName tmpRelationObjName;
++        List<ObjectName> tmpNewRoleValue, tmpOldRoleValue, tmpUnregMBeanList;
++
+         ObjectInputStream.GetField fields = in.readFields();
+-        newRoleValue = cast(fields.get("myNewRoleValue", null));
+-        if (fields.defaulted("myNewRoleValue"))
+-        {
+-          throw new NullPointerException("newRoleValue");
++
++        if (compat) {
++            tmpRelationId = (String)fields.get("myRelId", null);
++            tmpRelationTypeName = (String)fields.get("myRelTypeName", null);
++            tmpRoleName = (String)fields.get("myRoleName", null);
++
++            tmpRelationObjName = (ObjectName)fields.get("myRelObjName", null);
++            tmpNewRoleValue = cast(fields.get("myNewRoleValue", null));
++            tmpOldRoleValue = cast(fields.get("myOldRoleValue", null));
++            tmpUnregMBeanList = cast(fields.get("myUnregMBeanList", null));
+         }
+-        oldRoleValue = cast(fields.get("myOldRoleValue", null));
+-        if (fields.defaulted("myOldRoleValue"))
+-        {
+-          throw new NullPointerException("oldRoleValue");
++        else {
++            tmpRelationId = (String)fields.get("relationId", null);
++            tmpRelationTypeName = (String)fields.get("relationTypeName", null);
++            tmpRoleName = (String)fields.get("roleName", null);
++
++            tmpRelationObjName = (ObjectName)fields.get("relationObjName", null);
++            tmpNewRoleValue = cast(fields.get("newRoleValue", null));
++            tmpOldRoleValue = cast(fields.get("oldRoleValue", null));
++            tmpUnregMBeanList = cast(fields.get("unregisterMBeanList", null));
+         }
+-        relationId = (String) fields.get("myRelId", null);
+-        if (fields.defaulted("myRelId"))
+-        {
+-          throw new NullPointerException("relationId");
++
++        // Validate fields we just read, throw InvalidObjectException
++        // if something goes wrong
++
++        String notifType = super.getType();
++        if (!isValidBasic(notifType,super.getSource(),tmpRelationId,tmpRelationTypeName)  ||
++            (!isValidCreate(notifType) &&
++             !isValidUpdate(notifType,tmpRoleName,tmpNewRoleValue,tmpOldRoleValue))) {
++
++            super.setSource(null);
++            throw new InvalidObjectException("Invalid object read");
+         }
+-        relationObjName = (ObjectName) fields.get("myRelObjName", null);
+-        if (fields.defaulted("myRelObjName"))
+-        {
+-          throw new NullPointerException("relationObjName");
+-        }
+-        relationTypeName = (String) fields.get("myRelTypeName", null);
+-        if (fields.defaulted("myRelTypeName"))
+-        {
+-          throw new NullPointerException("relationTypeName");
+-        }
+-        roleName = (String) fields.get("myRoleName", null);
+-        if (fields.defaulted("myRoleName"))
+-        {
+-          throw new NullPointerException("roleName");
+-        }
+-        unregisterMBeanList = cast(fields.get("myUnregMBeanList", null));
+-        if (fields.defaulted("myUnregMBeanList"))
+-        {
+-          throw new NullPointerException("unregisterMBeanList");
+-        }
+-      }
+-      else
+-      {
+-        // Read an object serialized in the new serial form
+-        //
+-        in.defaultReadObject();
+-      }
++
++        // assign deserialized vaules to object fields
++        relationObjName = safeGetObjectName(tmpRelationObjName);
++        newRoleValue = safeGetObjectNameList(tmpNewRoleValue);
++        oldRoleValue = safeGetObjectNameList(tmpOldRoleValue);
++        unregisterMBeanList = safeGetObjectNameList(tmpUnregMBeanList);
++
++        relationId = tmpRelationId;
++        relationTypeName = tmpRelationTypeName;
++        roleName = tmpRoleName;
+     }
+ 
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008124-better_compliance_testing.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,20 @@
+# HG changeset patch
+# User dsamersoff
+# Date 1364499568 -14400
+# Node ID f880d5294bdd9d8d555fe3fbf06e39a5b80ad125
+# Parent  100c93da24f90ae93063fdd0affbc29c691424e8
+8008124: Better compliance testing
+Summary: Better compliance testing
+Reviewed-by: dfuchs, jfdenise, skoivu, alanb
+
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java b/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
+@@ -235,6 +235,7 @@
+             throws NotCompliantMBeanException {
+         if (mbeanInterface == null)
+             mbeanInterface = getStandardMBeanInterface(baseClass);
++        ReflectUtil.checkPackageAccess(mbeanInterface);
+         MBeanIntrospector<?> introspector = StandardMBeanIntrospector.getInstance();
+         return getClassMBeanInfo(introspector, baseClass, mbeanInterface);
+     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008128-better_jmx_api_coherence.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,110 @@
+# HG changeset patch
+# User andrew
+# Date 1370952792 -3600
+# Node ID 9bfe1c4dabb13428827ab592c4ee120593407603
+# Parent  f880d5294bdd9d8d555fe3fbf06e39a5b80ad125
+8008128: Better API coherence for JMX
+Summary: Permission for getting classloader
+Reviewed-by: alanb, dfuchs, skoivu
+Contributed-by: jean-francois.denise@oracle.com
+
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java b/src/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/ClassLoaderRepositorySupport.java
+@@ -27,12 +27,14 @@
+ 
+ 
+ import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
++import java.security.Permission;
+ import java.util.ArrayList;
+ import java.util.Arrays;
+ import java.util.Hashtable;
+ import java.util.List;
+ import java.util.Map;
+ import java.util.logging.Level;
++import javax.management.MBeanPermission;
+ 
+ import javax.management.ObjectName;
+ import javax.management.loading.PrivateClassLoader;
+@@ -300,7 +302,19 @@
+     }
+ 
+     public final ClassLoader getClassLoader(ObjectName name) {
+-        return loadersWithNames.get(name);
++        ClassLoader instance = loadersWithNames.get(name);
++        if (instance != null) {
++            SecurityManager sm = System.getSecurityManager();
++            if (sm != null) {
++                Permission perm =
++                        new MBeanPermission(instance.getClass().getName(),
++                        null,
++                        name,
++                        "getClassLoader");
++                sm.checkPermission(perm);
++            }
++        }
++        return instance;
+     }
+ 
+ }
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java b/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
+@@ -32,7 +32,12 @@
+ import java.io.ObjectInputStream;
+ import java.lang.reflect.Constructor;
+ import java.lang.reflect.InvocationTargetException;
++import java.security.AccessControlContext;
++import java.security.AccessController;
+ import java.security.Permission;
++import java.security.Permissions;
++import java.security.PrivilegedAction;
++import java.security.ProtectionDomain;
+ import java.util.Map;
+ import java.util.logging.Level;
+ 
+@@ -126,9 +131,8 @@
+ 
+         // Retrieve the class loader from the repository
+         ClassLoader loader = null;
+-        synchronized(this) {
+-            if (clr!=null)
+-                loader = clr.getClassLoader(aLoader);
++        synchronized (this) {
++            loader = getClassLoader(aLoader);
+         }
+         if (loader == null) {
+             throw new InstanceNotFoundException("The loader named " +
+@@ -429,8 +433,7 @@
+             try {
+                 ClassLoader instance = null;
+ 
+-                if (clr!=null)
+-                    instance = clr.getClassLoader(loaderName);
++                instance = getClassLoader(loaderName);
+                 if (instance == null)
+                     throw new ClassNotFoundException(className);
+                 theClass = Class.forName(className, false, instance);
+@@ -742,4 +745,22 @@
+             sm.checkPermission(perm);
+         }
+     }
++
++    private ClassLoader getClassLoader(final ObjectName name) {
++        if(clr == null){
++            return null;
++        }
++        // Restrict to getClassLoader permission only
++        Permissions permissions = new Permissions();
++        permissions.add(new MBeanPermission("*", null, name, "getClassLoader"));
++        ProtectionDomain protectionDomain = new ProtectionDomain(null, permissions);
++        ProtectionDomain[] domains = {protectionDomain};
++        AccessControlContext ctx = new AccessControlContext(domains);
++        ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
++            public ClassLoader run() {
++                return clr.getClassLoader(name);
++            }
++        }, ctx);
++        return loader;
++    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008132-better_serialization.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,121 @@
+# HG changeset patch
+# User Severin Gehwolf <sgehwolf@redhat.com>
+# Date 1371476865 -7200
+# Node ID 5dd7618fd14c647d21d765fcc2431c9ee6289ae4
+# Parent  60c57caf0348c7eed93900e4395607af759e6ba9
+8008132: Better serialization support
+Reviewed-by: alanb, hawtin
+
+diff --git a/src/share/classes/java/io/ObjectOutputStream.java b/src/share/classes/java/io/ObjectOutputStream.java
+--- openjdk/jdk/src/share/classes/java/io/ObjectOutputStream.java
++++ openjdk/jdk/src/share/classes/java/io/ObjectOutputStream.java
+@@ -36,6 +36,7 @@
+ import java.util.concurrent.ConcurrentMap;
+ import static java.io.ObjectStreamClass.processQueue;
+ import java.io.SerialCallbackContext;
++import sun.reflect.misc.ReflectUtil;
+ 
+ /**
+  * An ObjectOutputStream writes primitive data types and graphs of Java objects
+@@ -1228,6 +1229,12 @@
+         }
+     }
+ 
++    private boolean isCustomSubclass() {
++        // Return true if this class is a custom subclass of ObjectOutputStream
++        return getClass().getClassLoader()
++                   != ObjectOutputStream.class.getClassLoader();
++    }
++
+     /**
+      * Writes class descriptor representing a dynamic proxy class to stream.
+      */
+@@ -1245,6 +1252,9 @@
+         }
+ 
+         bout.setBlockDataMode(true);
++        if (isCustomSubclass()) {
++            ReflectUtil.checkPackageAccess(cl);
++        }
+         annotateProxyClass(cl);
+         bout.setBlockDataMode(false);
+         bout.writeByte(TC_ENDBLOCKDATA);
+@@ -1271,6 +1281,9 @@
+ 
+         Class cl = desc.forClass();
+         bout.setBlockDataMode(true);
++        if (isCustomSubclass()) {
++            ReflectUtil.checkPackageAccess(cl);
++        }
+         annotateClass(cl);
+         bout.setBlockDataMode(false);
+         bout.writeByte(TC_ENDBLOCKDATA);
+diff --git a/src/share/classes/java/io/ObjectStreamClass.java b/src/share/classes/java/io/ObjectStreamClass.java
+--- openjdk/jdk/src/share/classes/java/io/ObjectStreamClass.java
++++ openjdk/jdk/src/share/classes/java/io/ObjectStreamClass.java
+@@ -50,6 +50,7 @@
+ import java.util.concurrent.ConcurrentMap;
+ import sun.misc.Unsafe;
+ import sun.reflect.ReflectionFactory;
++import sun.reflect.misc.ReflectUtil;
+ 
+ /**
+  * Serialization's descriptor for classes.  It contains the name and
+@@ -234,6 +235,13 @@
+      * @return  the <code>Class</code> instance that this descriptor represents
+      */
+     public Class<?> forClass() {
++        if (cl == null) {
++            return null;
++        }
++        ClassLoader ccl = ObjectStreamField.getCallerClassLoader();
++        if (ReflectUtil.needsPackageAccessCheck(ccl, cl.getClassLoader())) {
++            ReflectUtil.checkPackageAccess(cl);
++        }
+         return cl;
+     }
+ 
+diff --git a/src/share/classes/java/io/ObjectStreamField.java b/src/share/classes/java/io/ObjectStreamField.java
+--- openjdk/jdk/src/share/classes/java/io/ObjectStreamField.java
++++ openjdk/jdk/src/share/classes/java/io/ObjectStreamField.java
+@@ -26,6 +26,8 @@
+ package java.io;
+ 
+ import java.lang.reflect.Field;
++import sun.reflect.Reflection;
++import sun.reflect.misc.ReflectUtil;
+ 
+ /**
+  * A description of a Serializable field from a Serializable class.  An array
+@@ -158,9 +160,31 @@
+      *          serializable field
+      */
+     public Class<?> getType() {
++        ClassLoader ccl = getCallerClassLoader();
++        if (ReflectUtil.needsPackageAccessCheck(ccl, type.getClassLoader())) {
++            ReflectUtil.checkPackageAccess(type);
++        }
+         return type;
+     }
+ 
++    // Returns the invoker's class loader.
++    // This is package private because it is accessed from ObjectStreamClass.
++    // NOTE: This must always be invoked when there is exactly one intervening
++    // frame from the core libraries on the stack between this method's
++    // invocation and the desired invoker. The frame count of 3 is determined
++    // as follows:
++    //
++    // 0: Reflection.getCallerClass
++    // 1: getCallerClassLoader()
++    // 2: ObjectStreamField.getType() or ObjectStreamClass.forClass()
++    // 3: the caller we want to check
++    //
++    // NOTE: copied from java.lang.ClassLoader and modified.
++    static ClassLoader getCallerClassLoader() {
++        Class caller = Reflection.getCallerClass(3);
++        return caller.getClassLoader();
++    }
++
+     /**
+      * Returns character encoding of field type.  The encoding is as follows:
+      * <blockquote><pre>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008585-jmx_data_handling.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,69 @@
+# HG changeset patch
+# User Severin Gehwolf <sgehwolf@redhat.com>
+# Date 1371477101 -7200
+# Node ID 1fd002800d60c1c6291d49f3a2d27ccc02b296ec
+# Parent  5dd7618fd14c647d21d765fcc2431c9ee6289ae4
+8008585: Better JMX data handling
+Reviewed-by: alanb, dfuchs, jfdenise, skoivu, sjiang
+
+diff --git a/src/share/classes/javax/management/remote/JMXConnectorFactory.java b/src/share/classes/javax/management/remote/JMXConnectorFactory.java
+--- openjdk/jdk/src/share/classes/javax/management/remote/JMXConnectorFactory.java
++++ openjdk/jdk/src/share/classes/javax/management/remote/JMXConnectorFactory.java
+@@ -39,6 +39,7 @@
+ 
+ import com.sun.jmx.remote.util.ClassLogger;
+ import com.sun.jmx.remote.util.EnvHelp;
++import sun.reflect.misc.ReflectUtil;
+ 
+ 
+ /**
+@@ -397,10 +398,10 @@
+     }
+ 
+     static <T> T getProvider(JMXServiceURL serviceURL,
+-                             Map<String, Object> environment,
++                             final Map<String, Object> environment,
+                              String providerClassName,
+                              Class<T> targetInterface,
+-                             ClassLoader loader)
++                             final ClassLoader loader)
+             throws IOException {
+ 
+         final String protocol = serviceURL.getProtocol();
+@@ -410,11 +411,14 @@
+         T instance = null;
+ 
+         if (pkgs != null) {
+-            environment.put(PROTOCOL_PROVIDER_CLASS_LOADER, loader);
+-
+             instance =
+                 getProvider(protocol, pkgs, loader, providerClassName,
+                             targetInterface);
++
++            if (instance != null) {
++                boolean needsWrap = (loader != instance.getClass().getClassLoader());
++                environment.put(PROTOCOL_PROVIDER_CLASS_LOADER, needsWrap ? wrap(loader) : loader);
++            }
+         }
+ 
+         return instance;
+@@ -428,6 +432,19 @@
+        return serviceLoader.iterator();
+     }
+ 
++    private static ClassLoader wrap(final ClassLoader parent) {
++        return parent != null ? AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
++            public ClassLoader run() {
++                return new ClassLoader(parent) {
++                    protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
++                        ReflectUtil.checkPackageAccess(name);
++                        return super.loadClass(name, resolve);
++                    }
++                };
++            }
++        }) : null;
++    }
++
+     private static JMXConnector getConnectorAsService(ClassLoader loader,
+                                                       JMXServiceURL url,
+                                                       Map<String, ?> map)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008593-better_urlclassloader.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,270 @@
+# HG changeset patch
+# User andrew
+# Date 1371485843 18000
+# Node ID 56bbd9db0a4965701dc64b41dac04507fa74f934
+# Parent  9bfe1c4dabb13428827ab592c4ee120593407603
+8008593: Better URLClassLoader resource management
+
+diff --git a/make/java/zip/mapfile-vers b/make/java/zip/mapfile-vers
+--- openjdk/jdk/make/java/zip/mapfile-vers
++++ openjdk/jdk/make/java/zip/mapfile-vers
+@@ -64,6 +64,7 @@
+ 		Java_java_util_zip_ZipFile_initIDs;
+ 		Java_java_util_zip_ZipFile_open;
+ 		Java_java_util_zip_ZipFile_read;
++		Java_java_util_zip_ZipFile_startsWithLOC;
+ 
+ 		ZIP_Close;
+ 		ZIP_CRC32;
+diff --git a/make/java/zip/reorder-i586 b/make/java/zip/reorder-i586
+--- openjdk/jdk/make/java/zip/reorder-i586
++++ openjdk/jdk/make/java/zip/reorder-i586
+@@ -19,6 +19,7 @@
+ text: .text%Java_java_util_zip_ZipFile_initIDs;
+ text: .text%Java_java_util_zip_ZipFile_open;
+ text: .text%Java_java_util_zip_ZipFile_getTotal;
++text: .text%Java_java_util_zip_ZipFile_startsWithLOC;
+ text: .text%Java_java_util_zip_ZipFile_getEntry;
+ text: .text%Java_java_util_zip_ZipEntry_initIDs;
+ text: .text%Java_java_util_zip_ZipEntry_initFields;
+diff --git a/make/java/zip/reorder-sparc b/make/java/zip/reorder-sparc
+--- openjdk/jdk/make/java/zip/reorder-sparc
++++ openjdk/jdk/make/java/zip/reorder-sparc
+@@ -18,6 +18,7 @@
+ text: .text%Java_java_util_zip_ZipFile_initIDs;
+ text: .text%Java_java_util_zip_ZipFile_open;
+ text: .text%Java_java_util_zip_ZipFile_getTotal;
++text: .text%Java_java_util_zip_ZipFile_startsWithLOC;
+ text: .text%Java_java_util_zip_ZipFile_getEntry;
+ text: .text%Java_java_util_zip_ZipEntry_initIDs;
+ text: .text%Java_java_util_zip_ZipEntry_initFields;
+diff --git a/make/java/zip/reorder-sparcv9 b/make/java/zip/reorder-sparcv9
+--- openjdk/jdk/make/java/zip/reorder-sparcv9
++++ openjdk/jdk/make/java/zip/reorder-sparcv9
+@@ -19,6 +19,7 @@
+ text: .text%Java_java_util_zip_ZipFile_initIDs;
+ text: .text%Java_java_util_zip_ZipFile_open;
+ text: .text%Java_java_util_zip_ZipFile_getTotal;
++text: .text%Java_java_util_zip_ZipFile_startsWithLOC;
+ text: .text%Java_java_util_zip_ZipFile_getEntry;
+ text: .text%Java_java_util_zip_ZipEntry_initIDs;
+ text: .text%Java_java_util_zip_ZipEntry_initFields;
+diff --git a/src/share/classes/java/util/zip/ZipFile.java b/src/share/classes/java/util/zip/ZipFile.java
+--- openjdk/jdk/src/share/classes/java/util/zip/ZipFile.java
++++ openjdk/jdk/src/share/classes/java/util/zip/ZipFile.java
+@@ -44,9 +44,10 @@
+  */
+ public
+ class ZipFile implements ZipConstants {
+-    private long jzfile;  // address of jzfile data
+-    private String name;  // zip file name
+-    private int total;    // total number of entries
++    private long jzfile;           // address of jzfile data
++    private final String name;     // zip file name
++    private final int total;       // total number of entries
++    private final boolean locsig;  // if zip file starts with LOCSIG (usually true)
+     private boolean closeRequested;
+ 
+     private static final int STORED = ZipEntry.STORED;
+@@ -132,10 +133,30 @@
+ 
+         this.name = name;
+         this.total = getTotal(jzfile);
++        this.locsig = startsWithLOC(jzfile);
++    }
++
++    static {
++        sun.misc.SharedSecrets.setJavaUtilZipFileAccess(
++            new sun.misc.JavaUtilZipFileAccess() {
++                public boolean startsWithLocHeader(ZipFile zip) {
++                    return zip.startsWithLocHeader();
++                }
++             }
++        );
++    }
++
++    /**
++     * Returns {@code true} if, and only if, the zip file begins with {@code
++     * LOCSIG}.
++     */
++    private boolean startsWithLocHeader() {
++        return locsig;
+     }
+ 
+     private static native long open(String name, int mode, long lastModified);
+     private static native int getTotal(long jzfile);
++    private static native boolean startsWithLOC(long jzfile);
+ 
+ 
+     /**
+diff --git a/src/share/classes/sun/misc/JavaUtilZipFileAccess.java b/src/share/classes/sun/misc/JavaUtilZipFileAccess.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/sun/misc/JavaUtilZipFileAccess.java
+@@ -0,0 +1,32 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++package sun.misc;
++
++import java.util.zip.ZipFile;
++
++public interface JavaUtilZipFileAccess {
++    public boolean startsWithLocHeader(ZipFile zip);
++}
+diff --git a/src/share/classes/sun/misc/SharedSecrets.java b/src/share/classes/sun/misc/SharedSecrets.java
+--- openjdk/jdk/src/share/classes/sun/misc/SharedSecrets.java
++++ openjdk/jdk/src/share/classes/sun/misc/SharedSecrets.java
+@@ -52,6 +52,7 @@
+     private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
+     private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess;
+     private static JavaSecurityAccess javaSecurityAccess;
++    private static JavaUtilZipFileAccess javaUtilZipFileAccess;
+     private static JavaAWTAccess javaAWTAccess;
+     private static JavaIOFileAccess javaIOFileAccess;
+ 
+@@ -141,6 +142,16 @@
+         return javaSecurityAccess;
+     }
+ 
++    public static JavaUtilZipFileAccess getJavaUtilZipFileAccess() {
++        if (javaUtilZipFileAccess == null)
++            unsafe.ensureClassInitialized(java.util.zip.ZipFile.class);
++        return javaUtilZipFileAccess;
++    }
++
++    public static void setJavaUtilZipFileAccess(JavaUtilZipFileAccess access) {
++        javaUtilZipFileAccess = access;
++    }
++
+     public static void setJavaAWTAccess(JavaAWTAccess jaa) {
+         javaAWTAccess = jaa;
+     }
+diff --git a/src/share/classes/sun/misc/URLClassPath.java b/src/share/classes/sun/misc/URLClassPath.java
+--- openjdk/jdk/src/share/classes/sun/misc/URLClassPath.java
++++ openjdk/jdk/src/share/classes/sun/misc/URLClassPath.java
+@@ -77,12 +77,16 @@
+     final static String USER_AGENT_JAVA_VERSION = "UA-Java-Version";
+     final static String JAVA_VERSION;
+     private static final boolean DEBUG;
++    private static final boolean DISABLE_JAR_CHECKING;
+ 
+     static {
+         JAVA_VERSION = java.security.AccessController.doPrivileged(
+             new sun.security.action.GetPropertyAction("java.version"));
+         DEBUG        = (java.security.AccessController.doPrivileged(
+             new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.debug")) != null);
++        String p = java.security.AccessController.doPrivileged(
++            new sun.security.action.GetPropertyAction("sun.misc.URLClassPath.disableJarChecking"));
++        DISABLE_JAR_CHECKING = p != null ? p.equals("true") || p.equals("") : false;
+     }
+ 
+     /* The original search path of URLs. */
+@@ -559,6 +563,8 @@
+         private MetaIndex metaIndex;
+         private URLStreamHandler handler;
+         private HashMap lmap;
++        private static final sun.misc.JavaUtilZipFileAccess zipAccess =
++                sun.misc.SharedSecrets.getJavaUtilZipFileAccess();
+ 
+         /*
+          * Creates a new JarLoader for the specified URL referring to
+@@ -650,6 +656,14 @@
+             }
+         }
+ 
++        /* Throws if the given jar file is does not start with the correct LOC */
++        static JarFile checkJar(JarFile jar) throws IOException {
++            if (System.getSecurityManager() != null && !DISABLE_JAR_CHECKING
++                && !zipAccess.startsWithLocHeader(jar))
++                throw new IOException("Invalid Jar file");
++            return jar;
++        }
++
+         private JarFile getJarFile(URL url) throws IOException {
+             // Optimize case where url refers to a local jar file
+             if (isOptimizable(url)) {
+@@ -657,11 +671,12 @@
+                 if (!p.exists()) {
+                     throw new FileNotFoundException(p.getPath());
+                 }
+-                return new JarFile (p.getPath());
++                return checkJar(new JarFile(p.getPath()));
+             }
+             URLConnection uc = getBaseURL().openConnection();
+             uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION);
+-            return ((JarURLConnection)uc).getJarFile();
++            JarFile jarFile = ((JarURLConnection)uc).getJarFile();
++            return checkJar(jarFile);
+         }
+ 
+         /*
+diff --git a/src/share/native/java/util/zip/ZipFile.c b/src/share/native/java/util/zip/ZipFile.c
+--- openjdk/jdk/src/share/native/java/util/zip/ZipFile.c
++++ openjdk/jdk/src/share/native/java/util/zip/ZipFile.c
+@@ -133,6 +133,14 @@
+     return zip->total;
+ }
+ 
++JNIEXPORT jboolean JNICALL
++Java_java_util_zip_ZipFile_startsWithLOC(JNIEnv *env, jclass cls, jlong zfile)
++{
++    jzfile *zip = jlong_to_ptr(zfile);
++
++    return zip->locsig;
++}
++
+ JNIEXPORT void JNICALL
+ Java_java_util_zip_ZipFile_close(JNIEnv *env, jclass cls, jlong zfile)
+ {
+diff --git a/src/share/native/java/util/zip/zip_util.c b/src/share/native/java/util/zip/zip_util.c
+--- openjdk/jdk/src/share/native/java/util/zip/zip_util.c
++++ openjdk/jdk/src/share/native/java/util/zip/zip_util.c
+@@ -721,6 +721,14 @@
+         return NULL;
+     }
+ 
++    // Assumption, zfd refers to start of file. Trivially, reuse errbuf.
++    if (readFully(zfd, errbuf, 4) != -1) {  // errors will be handled later
++        if (GETSIG(errbuf) == LOCSIG)
++            zip->locsig = JNI_TRUE;
++        else
++            zip->locsig = JNI_FALSE;
++    }
++
+     len = zip->len = ZFILE_Lseek(zfd, 0, SEEK_END);
+     if (len == -1) {
+         if (pmsg && JVM_GetLastErrorString(errbuf, sizeof(errbuf)) > 0)
+diff --git a/src/share/native/java/util/zip/zip_util.h b/src/share/native/java/util/zip/zip_util.h
+--- openjdk/jdk/src/share/native/java/util/zip/zip_util.h
++++ openjdk/jdk/src/share/native/java/util/zip/zip_util.h
+@@ -179,6 +179,7 @@
+ #else
+     cencache cencache;    /* CEN header cache */
+ #endif
++    jboolean locsig;      /* if zip file starts with LOCSIG */
+     ZFILE zfd;            /* open file descriptor */
+     void *lock;           /* read lock */
+     char *comment;        /* zip file comment */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008603-jmx_provider_provision.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,29 @@
+# HG changeset patch
+# User andrew
+# Date 1371485992 18000
+# Node ID cd93c29052e6930c24a0350b8fe607ac1f1be068
+# Parent  56bbd9db0a4965701dc64b41dac04507fa74f934
+8008603: Improve provision of JMX providers
+Reviewed-by: alanb, dfuchs, jfdenise, skoivu
+
+diff --git a/src/share/classes/javax/management/remote/JMXConnectorFactory.java b/src/share/classes/javax/management/remote/JMXConnectorFactory.java
+--- openjdk/jdk/src/share/classes/javax/management/remote/JMXConnectorFactory.java
++++ openjdk/jdk/src/share/classes/javax/management/remote/JMXConnectorFactory.java
+@@ -527,14 +527,9 @@
+             }
+         }
+ 
+-        if (loader == null)
+-            loader =
+-                AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+-                        public ClassLoader run() {
+-                            return
+-                                Thread.currentThread().getContextClassLoader();
+-                        }
+-                    });
++        if (loader == null) {
++            loader = Thread.currentThread().getContextClassLoader();
++        }
+ 
+         return loader;
+     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008611-6_fixup.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,20 @@
+# HG changeset patch
+# User andrew
+# Date 1371827429 18000
+# Node ID 059ac6834c32c540ad86b99c0e5339554398def2
+# Parent  ae1f55ff0e864d754b3dd7f2ad86fd93062e9744
+Fix up 8008611
+
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java b/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
+@@ -44,6 +44,9 @@
+ 
+ import com.sun.jmx.mbeanserver.Util;
+ 
++import sun.reflect.misc.MethodUtil;
++import sun.reflect.misc.ReflectUtil;
++
+ /**
+  * This class contains the methods for performing all the tests needed to verify
+  * that a class represents a JMX compliant MBean.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008611-jmx_annotations.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,32 @@
+# HG changeset patch
+# User egahlin
+# Date 1363870588 -3600
+# Node ID 0ffc0656881cac6747ac1a62895e855750d1a04e
+# Parent  cd93c29052e6930c24a0350b8fe607ac1f1be068
+8008611: Better handling of annotations in JMX
+Reviewed-by: skoivu, dholmes, jfdenise
+
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java b/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
+@@ -359,13 +359,19 @@
+         for (Annotation a : annots) {
+             Class<? extends Annotation> c = a.annotationType();
+             Method[] elements = c.getMethods();
++            boolean packageAccess = false;
+             for (Method element : elements) {
+                 DescriptorKey key = element.getAnnotation(DescriptorKey.class);
+                 if (key != null) {
+                     String name = key.value();
+                     Object value;
+                     try {
+-                        value = element.invoke(a);
++                        // Avoid checking access more than once per annotation
++                        if (!packageAccess) {
++                            ReflectUtil.checkPackageAccess(c);
++                            packageAccess = true;
++                        }
++                        value = MethodUtil.invoke(element, a, null);
+                     } catch (RuntimeException e) {
+                         // we don't expect this - except for possibly
+                         // security exceptions?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008615-jmx_internal_api_robustness.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,70 @@
+# HG changeset patch
+# User andrew
+# Date 1371486356 18000
+# Node ID 9d9e6637b14441f87a7561fe23981abb4beaf5c4
+# Parent  0ffc0656881cac6747ac1a62895e855750d1a04e
+8008615: Improve robustness of JMX internal APIs
+Reviewed-by: dfuchs, skoivu, dholmes
+
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/ObjectInputStreamWithLoader.java b/src/share/classes/com/sun/jmx/mbeanserver/ObjectInputStreamWithLoader.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/ObjectInputStreamWithLoader.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/ObjectInputStreamWithLoader.java
+@@ -30,7 +30,7 @@
+ import java.io.InputStream;
+ import java.io.ObjectInputStream;
+ import java.io.ObjectStreamClass;
+-import java.io.StreamCorruptedException;
++import sun.reflect.misc.ReflectUtil;
+ 
+ /**
+  * This class deserializes an object in the context of a specific class loader.
+@@ -60,6 +60,7 @@
+             return super.resolveClass(aClass);
+         } else {
+             String name = aClass.getName();
++            ReflectUtil.checkPackageAccess(name);
+             // Query the class loader ...
+             return Class.forName(name, false, loader);
+         }
+diff --git a/src/share/classes/javax/management/MBeanServerFactory.java b/src/share/classes/javax/management/MBeanServerFactory.java
+--- openjdk/jdk/src/share/classes/javax/management/MBeanServerFactory.java
++++ openjdk/jdk/src/share/classes/javax/management/MBeanServerFactory.java
+@@ -34,6 +34,7 @@
+ import java.util.ArrayList;
+ import java.util.logging.Level;
+ import javax.management.loading.ClassLoaderRepository;
++import sun.reflect.misc.ReflectUtil;
+ 
+ /**
+  * <p>Provides MBean server references.  There are no instances of
+@@ -442,7 +443,7 @@
+         }
+ 
+         // No context class loader? Try with Class.forName()
+-        return Class.forName(builderClassName);
++        return ReflectUtil.forName(builderClassName);
+     }
+ 
+     /**
+diff --git a/src/share/classes/javax/management/remote/rmi/RMIConnector.java b/src/share/classes/javax/management/remote/rmi/RMIConnector.java
+--- openjdk/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java
++++ openjdk/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java
+@@ -104,6 +104,7 @@
+ import javax.rmi.PortableRemoteObject;
+ import javax.rmi.ssl.SslRMIClientSocketFactory;
+ import javax.security.auth.Subject;
++import sun.reflect.misc.ReflectUtil;
+ import org.omg.CORBA.BAD_OPERATION;
+ import org.omg.CORBA.ORB;
+ import sun.rmi.server.UnicastRef2;
+@@ -1970,7 +1971,9 @@
+ 
+         protected Class resolveClass(ObjectStreamClass classDesc)
+                 throws IOException, ClassNotFoundException {
+-            return Class.forName(classDesc.getName(), false, loader);
++            String name = classDesc.getName();
++            ReflectUtil.checkPackageAccess(name);
++            return Class.forName(name, false, loader);
+         }
+ 
+         private final ClassLoader loader;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008623-mbeanserver_handling.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,121 @@
+# HG changeset patch
+# User andrew
+# Date 1371486568 18000
+# Node ID 299b73e94d28adb15d73b943104ac2562ed8b189
+# Parent  9d9e6637b14441f87a7561fe23981abb4beaf5c4
+8008623: Better handling of MBeanServers
+
+diff --git a/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java b/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java
+@@ -449,8 +449,7 @@
+         Object resource = getResource(instance);
+         if (resource instanceof ClassLoader
+             && resource != server.getClass().getClassLoader()) {
+-            final ModifiableClassLoaderRepository clr =
+-                instantiator.getClassLoaderRepository();
++	    final ModifiableClassLoaderRepository clr = getInstantiatorCLR();
+             if (clr != null) clr.removeClassLoader(name);
+         }
+ 
+@@ -1008,7 +1007,7 @@
+         final Object resource = getResource(mbean);
+         if (resource instanceof ClassLoader) {
+             final ModifiableClassLoaderRepository clr =
+-                instantiator.getClassLoaderRepository();
++                getInstantiatorCLR();
+             if (clr == null) {
+                 final RuntimeException wrapped =
+                     new IllegalArgumentException(
+@@ -1869,4 +1868,12 @@
+         }
+     }
+ 
++    private ModifiableClassLoaderRepository getInstantiatorCLR() {
++        return AccessController.doPrivileged(new PrivilegedAction<ModifiableClassLoaderRepository>() {
++            @Override
++            public ModifiableClassLoaderRepository run() {
++                return instantiator != null ? instantiator.getClassLoaderRepository() : null;
++            }
++        });
++    }
+ }
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java b/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java
+@@ -31,6 +31,7 @@
+ import java.io.ObjectInputStream;
+ import java.security.AccessController;
+ import java.security.Permission;
++import java.security.PrivilegedAction;
+ import java.security.PrivilegedExceptionAction;
+ 
+ // RI import
+@@ -231,8 +232,16 @@
+                 clr = new ClassLoaderRepositorySupport();
+             instantiator = new MBeanInstantiator(clr);
+         }
++
++        final MBeanInstantiator fInstantiator = instantiator;
+         this.secureClr = new
+-          SecureClassLoaderRepository(instantiator.getClassLoaderRepository());
++            SecureClassLoaderRepository(AccessController.doPrivileged(new PrivilegedAction<ClassLoaderRepository>() {
++                @Override
++                public ClassLoaderRepository run() {
++                    return fInstantiator.getClassLoaderRepository();
++                }
++            })
++        );
+         if (delegate == null)
+             delegate = new MBeanServerDelegateImpl();
+         if (outer == null)
+@@ -1246,8 +1255,14 @@
+            class loader.  The ClassLoaderRepository knows how
+            to handle that case.  */
+         ClassLoader myLoader = outerShell.getClass().getClassLoader();
+-        final ModifiableClassLoaderRepository loaders =
+-            instantiator.getClassLoaderRepository();
++        final ModifiableClassLoaderRepository loaders = AccessController.doPrivileged(new PrivilegedAction<ModifiableClassLoaderRepository>() {
++
++            @Override
++            public ModifiableClassLoaderRepository run() {
++                return instantiator.getClassLoaderRepository();
++            }
++        });
++
+         if (loaders != null) {
+             loaders.addClassLoader(myLoader);
+ 
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java b/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
+@@ -625,6 +625,7 @@
+      * Return the Default Loader Repository used by this instantiator object.
+      **/
+     public ModifiableClassLoaderRepository getClassLoaderRepository() {
++        checkMBeanPermission((String)null, null, null, "getClassLoaderRepository");
+         return clr;
+     }
+ 
+@@ -736,9 +737,19 @@
+                                              String member,
+                                              ObjectName objectName,
+                                              String actions) {
++        if (clazz != null) {
++            checkMBeanPermission(clazz.getName(), member, objectName, actions);
++        }
++    }
++
++    private static void checkMBeanPermission(String classname,
++                                             String member,
++                                             ObjectName objectName,
++                                             String actions)
++        throws SecurityException {
+         SecurityManager sm = System.getSecurityManager();
+-        if (clazz != null && sm != null) {
+-            Permission perm = new MBeanPermission(clazz.getName(),
++        if (sm != null) {
++            Permission perm = new MBeanPermission(classname,
+                                                   member,
+                                                   objectName,
+                                                   actions);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008744-6741606_rework.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,882 @@
+# HG changeset patch
+# User mullan
+# Date 1367443144 14400
+# Node ID ebb30aed90ea44ffadd97b3c462b14e328b5dfd2
+# Parent  299b73e94d28adb15d73b943104ac2562ed8b189
+8008744: Rework part of fix for JDK-6741606
+Reviewed-by: xuelei, ahgross
+
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/ClassLoaderUtils.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/ClassLoaderUtils.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/ClassLoaderUtils.java
+@@ -0,0 +1,280 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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.
++ */
++
++package com.sun.org.apache.xml.internal.security.algorithms;
++
++import java.io.IOException;
++import java.io.InputStream;
++import java.net.URL;
++import java.util.ArrayList;
++import java.util.Enumeration;
++import java.util.List;
++
++/**
++ * This class is extremely useful for loading resources and classes in a fault
++ * tolerant manner that works across different applications servers. Do not
++ * touch this unless you're a grizzled classloading guru veteran who is going to
++ * verify any change on 6 different application servers.
++ */
++// NOTE! This is a duplicate of utils.ClassLoaderUtils with public
++// modifiers changed to package-private. Make sure to integrate any future
++// changes to utils.ClassLoaderUtils to this file.
++final class ClassLoaderUtils {
++
++    /** {@link org.apache.commons.logging} logging facility */
++    private static final java.util.logging.Logger log =
++        java.util.logging.Logger.getLogger(ClassLoaderUtils.class.getName());
++
++    private ClassLoaderUtils() {
++    }
++
++    /**
++     * Load a given resource. <p/> This method will try to load the resource
++     * using the following methods (in order):
++     * <ul>
++     * <li>From Thread.currentThread().getContextClassLoader()
++     * <li>From ClassLoaderUtil.class.getClassLoader()
++     * <li>callingClass.getClassLoader()
++     * </ul>
++     *
++     * @param resourceName The name of the resource to load
++     * @param callingClass The Class object of the calling object
++     */
++    static URL getResource(String resourceName, Class<?> callingClass) {
++        URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
++        if (url == null && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            url =
++                Thread.currentThread().getContextClassLoader().getResource(
++                    resourceName.substring(1)
++                );
++        }
++
++        ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
++        if (cluClassloader == null) {
++            cluClassloader = ClassLoader.getSystemClassLoader();
++        }
++        if (url == null) {
++            url = cluClassloader.getResource(resourceName);
++        }
++        if (url == null && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            url = cluClassloader.getResource(resourceName.substring(1));
++        }
++
++        if (url == null) {
++            ClassLoader cl = callingClass.getClassLoader();
++
++            if (cl != null) {
++                url = cl.getResource(resourceName);
++            }
++        }
++
++        if (url == null) {
++            url = callingClass.getResource(resourceName);
++        }
++
++        if ((url == null) && (resourceName != null) && (resourceName.charAt(0) != '/')) {
++            return getResource('/' + resourceName, callingClass);
++        }
++
++        return url;
++    }
++
++    /**
++     * Load a given resources. <p/> This method will try to load the resources
++     * using the following methods (in order):
++     * <ul>
++     * <li>From Thread.currentThread().getContextClassLoader()
++     * <li>From ClassLoaderUtil.class.getClassLoader()
++     * <li>callingClass.getClassLoader()
++     * </ul>
++     *
++     * @param resourceName The name of the resource to load
++     * @param callingClass The Class object of the calling object
++     */
++    static List<URL> getResources(String resourceName, Class<?> callingClass) {
++        List<URL> ret = new ArrayList<URL>();
++        Enumeration<URL> urls = new Enumeration<URL>() {
++            public boolean hasMoreElements() {
++                return false;
++            }
++            public URL nextElement() {
++                return null;
++            }
++
++        };
++        try {
++            urls = Thread.currentThread().getContextClassLoader().getResources(resourceName);
++        } catch (IOException e) {
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++            }
++            //ignore
++        }
++        if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            try {
++                urls =
++                    Thread.currentThread().getContextClassLoader().getResources(
++                        resourceName.substring(1)
++                    );
++            } catch (IOException e) {
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                }
++                // ignore
++            }
++        }
++
++        ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
++        if (cluClassloader == null) {
++            cluClassloader = ClassLoader.getSystemClassLoader();
++        }
++        if (!urls.hasMoreElements()) {
++            try {
++                urls = cluClassloader.getResources(resourceName);
++            } catch (IOException e) {
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                }
++                // ignore
++            }
++        }
++        if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            try {
++                urls = cluClassloader.getResources(resourceName.substring(1));
++            } catch (IOException e) {
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                }
++                // ignore
++            }
++        }
++
++        if (!urls.hasMoreElements()) {
++            ClassLoader cl = callingClass.getClassLoader();
++
++            if (cl != null) {
++                try {
++                    urls = cl.getResources(resourceName);
++                } catch (IOException e) {
++                    if (log.isLoggable(java.util.logging.Level.FINE)) {
++                        log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                    }
++                    // ignore
++                }
++            }
++        }
++
++        if (!urls.hasMoreElements()) {
++            URL url = callingClass.getResource(resourceName);
++            if (url != null) {
++                ret.add(url);
++            }
++        }
++        while (urls.hasMoreElements()) {
++            ret.add(urls.nextElement());
++        }
++
++
++        if (ret.isEmpty() && (resourceName != null) && (resourceName.charAt(0) != '/')) {
++            return getResources('/' + resourceName, callingClass);
++        }
++        return ret;
++    }
++
++
++    /**
++     * This is a convenience method to load a resource as a stream. <p/> The
++     * algorithm used to find the resource is given in getResource()
++     *
++     * @param resourceName The name of the resource to load
++     * @param callingClass The Class object of the calling object
++     */
++    static InputStream getResourceAsStream(String resourceName, Class<?> callingClass) {
++        URL url = getResource(resourceName, callingClass);
++
++        try {
++            return (url != null) ? url.openStream() : null;
++        } catch (IOException e) {
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++            }
++            return null;
++        }
++    }
++
++    /**
++     * Load a class with a given name. <p/> It will try to load the class in the
++     * following order:
++     * <ul>
++     * <li>From Thread.currentThread().getContextClassLoader()
++     * <li>Using the basic Class.forName()
++     * <li>From ClassLoaderUtil.class.getClassLoader()
++     * <li>From the callingClass.getClassLoader()
++     * </ul>
++     *
++     * @param className The name of the class to load
++     * @param callingClass The Class object of the calling object
++     * @throws ClassNotFoundException If the class cannot be found anywhere.
++     */
++    static Class<?> loadClass(String className, Class<?> callingClass)
++        throws ClassNotFoundException {
++        try {
++            ClassLoader cl = Thread.currentThread().getContextClassLoader();
++
++            if (cl != null) {
++                return cl.loadClass(className);
++            }
++        } catch (ClassNotFoundException e) {
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++            }
++            //ignore
++        }
++        return loadClass2(className, callingClass);
++    }
++
++    private static Class<?> loadClass2(String className, Class<?> callingClass)
++        throws ClassNotFoundException {
++        try {
++            return Class.forName(className);
++        } catch (ClassNotFoundException ex) {
++            try {
++                if (ClassLoaderUtils.class.getClassLoader() != null) {
++                    return ClassLoaderUtils.class.getClassLoader().loadClass(className);
++                }
++            } catch (ClassNotFoundException exc) {
++                if (callingClass != null && callingClass.getClassLoader() != null) {
++                    return callingClass.getClassLoader().loadClass(className);
++                }
++            }
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, ex.getMessage(), ex);
++            }
++            throw ex;
++        }
++    }
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java b/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
+@@ -36,7 +36,6 @@
+ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
+ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
+-import com.sun.org.apache.xml.internal.security.utils.ClassLoaderUtils;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderUtils.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderUtils.java
+new file mode 100644
+--- /dev/null
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/ClassLoaderUtils.java
+@@ -0,0 +1,280 @@
++/*
++ * reserved comment block
++ * DO NOT REMOVE OR ALTER!
++ */
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you 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.
++ */
++
++package com.sun.org.apache.xml.internal.security.transforms;
++
++import java.io.IOException;
++import java.io.InputStream;
++import java.net.URL;
++import java.util.ArrayList;
++import java.util.Enumeration;
++import java.util.List;
++
++/**
++ * This class is extremely useful for loading resources and classes in a fault
++ * tolerant manner that works across different applications servers. Do not
++ * touch this unless you're a grizzled classloading guru veteran who is going to
++ * verify any change on 6 different application servers.
++ */
++// NOTE! This is a duplicate of utils.ClassLoaderUtils with public
++// modifiers changed to package-private. Make sure to integrate any future
++// changes to utils.ClassLoaderUtils to this file.
++final class ClassLoaderUtils {
++
++    /** {@link org.apache.commons.logging} logging facility */
++    private static final java.util.logging.Logger log =
++        java.util.logging.Logger.getLogger(ClassLoaderUtils.class.getName());
++
++    private ClassLoaderUtils() {
++    }
++
++    /**
++     * Load a given resource. <p/> This method will try to load the resource
++     * using the following methods (in order):
++     * <ul>
++     * <li>From Thread.currentThread().getContextClassLoader()
++     * <li>From ClassLoaderUtil.class.getClassLoader()
++     * <li>callingClass.getClassLoader()
++     * </ul>
++     *
++     * @param resourceName The name of the resource to load
++     * @param callingClass The Class object of the calling object
++     */
++    static URL getResource(String resourceName, Class<?> callingClass) {
++        URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
++        if (url == null && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            url =
++                Thread.currentThread().getContextClassLoader().getResource(
++                    resourceName.substring(1)
++                );
++        }
++
++        ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
++        if (cluClassloader == null) {
++            cluClassloader = ClassLoader.getSystemClassLoader();
++        }
++        if (url == null) {
++            url = cluClassloader.getResource(resourceName);
++        }
++        if (url == null && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            url = cluClassloader.getResource(resourceName.substring(1));
++        }
++
++        if (url == null) {
++            ClassLoader cl = callingClass.getClassLoader();
++
++            if (cl != null) {
++                url = cl.getResource(resourceName);
++            }
++        }
++
++        if (url == null) {
++            url = callingClass.getResource(resourceName);
++        }
++
++        if ((url == null) && (resourceName != null) && (resourceName.charAt(0) != '/')) {
++            return getResource('/' + resourceName, callingClass);
++        }
++
++        return url;
++    }
++
++    /**
++     * Load a given resources. <p/> This method will try to load the resources
++     * using the following methods (in order):
++     * <ul>
++     * <li>From Thread.currentThread().getContextClassLoader()
++     * <li>From ClassLoaderUtil.class.getClassLoader()
++     * <li>callingClass.getClassLoader()
++     * </ul>
++     *
++     * @param resourceName The name of the resource to load
++     * @param callingClass The Class object of the calling object
++     */
++    static List<URL> getResources(String resourceName, Class<?> callingClass) {
++        List<URL> ret = new ArrayList<URL>();
++        Enumeration<URL> urls = new Enumeration<URL>() {
++            public boolean hasMoreElements() {
++                return false;
++            }
++            public URL nextElement() {
++                return null;
++            }
++
++        };
++        try {
++            urls = Thread.currentThread().getContextClassLoader().getResources(resourceName);
++        } catch (IOException e) {
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++            }
++            //ignore
++        }
++        if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            try {
++                urls =
++                    Thread.currentThread().getContextClassLoader().getResources(
++                        resourceName.substring(1)
++                    );
++            } catch (IOException e) {
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                }
++                // ignore
++            }
++        }
++
++        ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
++        if (cluClassloader == null) {
++            cluClassloader = ClassLoader.getSystemClassLoader();
++        }
++        if (!urls.hasMoreElements()) {
++            try {
++                urls = cluClassloader.getResources(resourceName);
++            } catch (IOException e) {
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                }
++                // ignore
++            }
++        }
++        if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
++            //certain classloaders need it without the leading /
++            try {
++                urls = cluClassloader.getResources(resourceName.substring(1));
++            } catch (IOException e) {
++                if (log.isLoggable(java.util.logging.Level.FINE)) {
++                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                }
++                // ignore
++            }
++        }
++
++        if (!urls.hasMoreElements()) {
++            ClassLoader cl = callingClass.getClassLoader();
++
++            if (cl != null) {
++                try {
++                    urls = cl.getResources(resourceName);
++                } catch (IOException e) {
++                    if (log.isLoggable(java.util.logging.Level.FINE)) {
++                        log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++                    }
++                    // ignore
++                }
++            }
++        }
++
++        if (!urls.hasMoreElements()) {
++            URL url = callingClass.getResource(resourceName);
++            if (url != null) {
++                ret.add(url);
++            }
++        }
++        while (urls.hasMoreElements()) {
++            ret.add(urls.nextElement());
++        }
++
++
++        if (ret.isEmpty() && (resourceName != null) && (resourceName.charAt(0) != '/')) {
++            return getResources('/' + resourceName, callingClass);
++        }
++        return ret;
++    }
++
++
++    /**
++     * This is a convenience method to load a resource as a stream. <p/> The
++     * algorithm used to find the resource is given in getResource()
++     *
++     * @param resourceName The name of the resource to load
++     * @param callingClass The Class object of the calling object
++     */
++    static InputStream getResourceAsStream(String resourceName, Class<?> callingClass) {
++        URL url = getResource(resourceName, callingClass);
++
++        try {
++            return (url != null) ? url.openStream() : null;
++        } catch (IOException e) {
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++            }
++            return null;
++        }
++    }
++
++    /**
++     * Load a class with a given name. <p/> It will try to load the class in the
++     * following order:
++     * <ul>
++     * <li>From Thread.currentThread().getContextClassLoader()
++     * <li>Using the basic Class.forName()
++     * <li>From ClassLoaderUtil.class.getClassLoader()
++     * <li>From the callingClass.getClassLoader()
++     * </ul>
++     *
++     * @param className The name of the class to load
++     * @param callingClass The Class object of the calling object
++     * @throws ClassNotFoundException If the class cannot be found anywhere.
++     */
++    static Class<?> loadClass(String className, Class<?> callingClass)
++        throws ClassNotFoundException {
++        try {
++            ClassLoader cl = Thread.currentThread().getContextClassLoader();
++
++            if (cl != null) {
++                return cl.loadClass(className);
++            }
++        } catch (ClassNotFoundException e) {
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
++            }
++            //ignore
++        }
++        return loadClass2(className, callingClass);
++    }
++
++    private static Class<?> loadClass2(String className, Class<?> callingClass)
++        throws ClassNotFoundException {
++        try {
++            return Class.forName(className);
++        } catch (ClassNotFoundException ex) {
++            try {
++                if (ClassLoaderUtils.class.getClassLoader() != null) {
++                    return ClassLoaderUtils.class.getClassLoader().loadClass(className);
++                }
++            } catch (ClassNotFoundException exc) {
++                if (callingClass != null && callingClass.getClassLoader() != null) {
++                    return callingClass.getClassLoader().loadClass(className);
++                }
++            }
++            if (log.isLoggable(java.util.logging.Level.FINE)) {
++                log.log(java.util.logging.Level.FINE, ex.getMessage(), ex);
++            }
++            throw ex;
++        }
++    }
++}
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java b/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
+@@ -44,7 +44,6 @@
+ import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformXPath;
+ import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformXPath2Filter;
+ import com.sun.org.apache.xml.internal.security.transforms.implementations.TransformXSLT;
+-import com.sun.org.apache.xml.internal.security.utils.ClassLoaderUtils;
+ import com.sun.org.apache.xml.internal.security.utils.Constants;
+ import com.sun.org.apache.xml.internal.security.utils.HelperNodeList;
+ import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ClassLoaderUtils.java b/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ClassLoaderUtils.java
+deleted file mode 100644
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/ClassLoaderUtils.java
++++ /dev/null
+@@ -1,277 +0,0 @@
+-/*
+- * reserved comment block
+- * DO NOT REMOVE OR ALTER!
+- */
+-/**
+- * Licensed to the Apache Software Foundation (ASF) under one
+- * or more contributor license agreements. See the NOTICE file
+- * distributed with this work for additional information
+- * regarding copyright ownership. The ASF licenses this file
+- * to you 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.
+- */
+-
+-package com.sun.org.apache.xml.internal.security.utils;
+-
+-import java.io.IOException;
+-import java.io.InputStream;
+-import java.net.URL;
+-import java.util.ArrayList;
+-import java.util.Enumeration;
+-import java.util.List;
+-
+-/**
+- * This class is extremely useful for loading resources and classes in a fault
+- * tolerant manner that works across different applications servers. Do not
+- * touch this unless you're a grizzled classloading guru veteran who is going to
+- * verify any change on 6 different application servers.
+- */
+-public final class ClassLoaderUtils {
+-
+-    /** {@link org.apache.commons.logging} logging facility */
+-    private static final java.util.logging.Logger log =
+-        java.util.logging.Logger.getLogger(ClassLoaderUtils.class.getName());
+-
+-    private ClassLoaderUtils() {
+-    }
+-
+-    /**
+-     * Load a given resource. <p/> This method will try to load the resource
+-     * using the following methods (in order):
+-     * <ul>
+-     * <li>From Thread.currentThread().getContextClassLoader()
+-     * <li>From ClassLoaderUtil.class.getClassLoader()
+-     * <li>callingClass.getClassLoader()
+-     * </ul>
+-     *
+-     * @param resourceName The name of the resource to load
+-     * @param callingClass The Class object of the calling object
+-     */
+-    public static URL getResource(String resourceName, Class<?> callingClass) {
+-        URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
+-        if (url == null && resourceName.startsWith("/")) {
+-            //certain classloaders need it without the leading /
+-            url =
+-                Thread.currentThread().getContextClassLoader().getResource(
+-                    resourceName.substring(1)
+-                );
+-        }
+-
+-        ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
+-        if (cluClassloader == null) {
+-            cluClassloader = ClassLoader.getSystemClassLoader();
+-        }
+-        if (url == null) {
+-            url = cluClassloader.getResource(resourceName);
+-        }
+-        if (url == null && resourceName.startsWith("/")) {
+-            //certain classloaders need it without the leading /
+-            url = cluClassloader.getResource(resourceName.substring(1));
+-        }
+-
+-        if (url == null) {
+-            ClassLoader cl = callingClass.getClassLoader();
+-
+-            if (cl != null) {
+-                url = cl.getResource(resourceName);
+-            }
+-        }
+-
+-        if (url == null) {
+-            url = callingClass.getResource(resourceName);
+-        }
+-
+-        if ((url == null) && (resourceName != null) && (resourceName.charAt(0) != '/')) {
+-            return getResource('/' + resourceName, callingClass);
+-        }
+-
+-        return url;
+-    }
+-
+-    /**
+-     * Load a given resources. <p/> This method will try to load the resources
+-     * using the following methods (in order):
+-     * <ul>
+-     * <li>From Thread.currentThread().getContextClassLoader()
+-     * <li>From ClassLoaderUtil.class.getClassLoader()
+-     * <li>callingClass.getClassLoader()
+-     * </ul>
+-     *
+-     * @param resourceName The name of the resource to load
+-     * @param callingClass The Class object of the calling object
+-     */
+-    public static List<URL> getResources(String resourceName, Class<?> callingClass) {
+-        List<URL> ret = new ArrayList<URL>();
+-        Enumeration<URL> urls = new Enumeration<URL>() {
+-            public boolean hasMoreElements() {
+-                return false;
+-            }
+-            public URL nextElement() {
+-                return null;
+-            }
+-
+-        };
+-        try {
+-            urls = Thread.currentThread().getContextClassLoader().getResources(resourceName);
+-        } catch (IOException e) {
+-            if (log.isLoggable(java.util.logging.Level.FINE)) {
+-                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+-            }
+-            //ignore
+-        }
+-        if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
+-            //certain classloaders need it without the leading /
+-            try {
+-                urls =
+-                    Thread.currentThread().getContextClassLoader().getResources(
+-                        resourceName.substring(1)
+-                    );
+-            } catch (IOException e) {
+-                if (log.isLoggable(java.util.logging.Level.FINE)) {
+-                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+-                }
+-                // ignore
+-            }
+-        }
+-
+-        ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
+-        if (cluClassloader == null) {
+-            cluClassloader = ClassLoader.getSystemClassLoader();
+-        }
+-        if (!urls.hasMoreElements()) {
+-            try {
+-                urls = cluClassloader.getResources(resourceName);
+-            } catch (IOException e) {
+-                if (log.isLoggable(java.util.logging.Level.FINE)) {
+-                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+-                }
+-                // ignore
+-            }
+-        }
+-        if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
+-            //certain classloaders need it without the leading /
+-            try {
+-                urls = cluClassloader.getResources(resourceName.substring(1));
+-            } catch (IOException e) {
+-                if (log.isLoggable(java.util.logging.Level.FINE)) {
+-                    log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+-                }
+-                // ignore
+-            }
+-        }
+-
+-        if (!urls.hasMoreElements()) {
+-            ClassLoader cl = callingClass.getClassLoader();
+-
+-            if (cl != null) {
+-                try {
+-                    urls = cl.getResources(resourceName);
+-                } catch (IOException e) {
+-                    if (log.isLoggable(java.util.logging.Level.FINE)) {
+-                        log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+-                    }
+-                    // ignore
+-                }
+-            }
+-        }
+-
+-        if (!urls.hasMoreElements()) {
+-            URL url = callingClass.getResource(resourceName);
+-            if (url != null) {
+-                ret.add(url);
+-            }
+-        }
+-        while (urls.hasMoreElements()) {
+-            ret.add(urls.nextElement());
+-        }
+-
+-
+-        if (ret.isEmpty() && (resourceName != null) && (resourceName.charAt(0) != '/')) {
+-            return getResources('/' + resourceName, callingClass);
+-        }
+-        return ret;
+-    }
+-
+-
+-    /**
+-     * This is a convenience method to load a resource as a stream. <p/> The
+-     * algorithm used to find the resource is given in getResource()
+-     *
+-     * @param resourceName The name of the resource to load
+-     * @param callingClass The Class object of the calling object
+-     */
+-    public static InputStream getResourceAsStream(String resourceName, Class<?> callingClass) {
+-        URL url = getResource(resourceName, callingClass);
+-
+-        try {
+-            return (url != null) ? url.openStream() : null;
+-        } catch (IOException e) {
+-            if (log.isLoggable(java.util.logging.Level.FINE)) {
+-                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+-            }
+-            return null;
+-        }
+-    }
+-
+-    /**
+-     * Load a class with a given name. <p/> It will try to load the class in the
+-     * following order:
+-     * <ul>
+-     * <li>From Thread.currentThread().getContextClassLoader()
+-     * <li>Using the basic Class.forName()
+-     * <li>From ClassLoaderUtil.class.getClassLoader()
+-     * <li>From the callingClass.getClassLoader()
+-     * </ul>
+-     *
+-     * @param className The name of the class to load
+-     * @param callingClass The Class object of the calling object
+-     * @throws ClassNotFoundException If the class cannot be found anywhere.
+-     */
+-    public static Class<?> loadClass(String className, Class<?> callingClass)
+-        throws ClassNotFoundException {
+-        try {
+-            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+-
+-            if (cl != null) {
+-                return cl.loadClass(className);
+-            }
+-        } catch (ClassNotFoundException e) {
+-            if (log.isLoggable(java.util.logging.Level.FINE)) {
+-                log.log(java.util.logging.Level.FINE, e.getMessage(), e);
+-            }
+-            //ignore
+-        }
+-        return loadClass2(className, callingClass);
+-    }
+-
+-    private static Class<?> loadClass2(String className, Class<?> callingClass)
+-        throws ClassNotFoundException {
+-        try {
+-            return Class.forName(className);
+-        } catch (ClassNotFoundException ex) {
+-            try {
+-                if (ClassLoaderUtils.class.getClassLoader() != null) {
+-                    return ClassLoaderUtils.class.getClassLoader().loadClass(className);
+-                }
+-            } catch (ClassNotFoundException exc) {
+-                if (callingClass != null && callingClass.getClassLoader() != null) {
+-                    return callingClass.getClassLoader().loadClass(className);
+-                }
+-            }
+-            if (log.isLoggable(java.util.logging.Level.FINE)) {
+-                log.log(java.util.logging.Level.FINE, ex.getMessage(), ex);
+-            }
+-            throw ex;
+-        }
+-    }
+-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8008982-jmx_interface_changes.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,168 @@
+# HG changeset patch
+# User andrew
+# Date 1371487600 18000
+# Node ID a844309d9f0a490f8ac56d21f1323e8deb65ffd1
+# Parent  ebb30aed90ea44ffadd97b3c462b14e328b5dfd2
+8008982: Adjust JMX for underlying interface changes
+Reviewed-by: mchung, dholmes, dfuchs, skoivu
+
+diff --git a/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java b/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
+@@ -215,6 +215,11 @@
+         MXBeanIntrospector.getInstance().getAnalyzer(interfaceClass);
+     }
+ 
++    public static void testComplianceMBeanInterface(Class<?> interfaceClass)
++            throws NotCompliantMBeanException{
++        StandardMBeanIntrospector.getInstance().getAnalyzer(interfaceClass);
++    }
++
+     /**
+      * Basic method for testing if a given class is a JMX compliant
+      * Standard MBean.  This method is only called by the legacy code
+diff --git a/src/share/classes/javax/management/JMX.java b/src/share/classes/javax/management/JMX.java
+--- openjdk/jdk/src/share/classes/javax/management/JMX.java
++++ openjdk/jdk/src/share/classes/javax/management/JMX.java
+@@ -27,7 +27,9 @@
+ 
+ import com.sun.jmx.mbeanserver.Introspector;
+ import java.lang.reflect.InvocationHandler;
++import java.lang.reflect.Modifier;
+ import java.lang.reflect.Proxy;
++import sun.reflect.misc.ReflectUtil;
+ 
+ /**
+  * Static methods from the JMX API.  There are no instances of this class.
+@@ -203,11 +205,7 @@
+                                       ObjectName objectName,
+                                       Class<T> interfaceClass,
+                                       boolean notificationBroadcaster) {
+-        return MBeanServerInvocationHandler.newProxyInstance(
+-                connection,
+-                objectName,
+-                interfaceClass,
+-                notificationBroadcaster);
++        return createProxy(connection, objectName, interfaceClass, notificationBroadcaster, false);
+     }
+ 
+     /**
+@@ -345,26 +343,7 @@
+                                        ObjectName objectName,
+                                        Class<T> interfaceClass,
+                                        boolean notificationBroadcaster) {
+-        // Check interface for MXBean compliance
+-        //
+-        try {
+-            Introspector.testComplianceMXBeanInterface(interfaceClass);
+-        } catch (NotCompliantMBeanException e) {
+-            throw new IllegalArgumentException(e);
+-        }
+-        InvocationHandler handler = new MBeanServerInvocationHandler(
+-                connection, objectName, true);
+-        final Class[] interfaces;
+-        if (notificationBroadcaster) {
+-            interfaces =
+-                new Class<?>[] {interfaceClass, NotificationEmitter.class};
+-        } else
+-            interfaces = new Class[] {interfaceClass};
+-        Object proxy = Proxy.newProxyInstance(
+-                interfaceClass.getClassLoader(),
+-                interfaces,
+-                handler);
+-        return interfaceClass.cast(proxy);
++        return createProxy(connection, objectName, interfaceClass, notificationBroadcaster, true);
+     }
+ 
+     /**
+@@ -392,4 +371,65 @@
+         // exactly the string "MXBean" since that would mean there
+         // was no package name, which is pretty unlikely in practice.
+     }
++
++    /**
++     * Centralised M(X)Bean proxy creation code
++     * @param connection {@linkplain MBeanServerConnection} to use
++     * @param objectName M(X)Bean object name
++     * @param interfaceClass M(X)Bean interface class
++     * @param notificationEmitter Is a notification emitter?
++     * @param isMXBean Is an MXBean?
++     * @return Returns an M(X)Bean proxy generated for the provided interface class
++     * @throws SecurityException
++     * @throws IllegalArgumentException
++     */
++    private static <T> T createProxy(MBeanServerConnection connection,
++                                     ObjectName objectName,
++                                     Class<T> interfaceClass,
++                                     boolean notificationEmitter,
++                                     boolean isMXBean) {
++
++        if (System.getSecurityManager() != null) {
++            checkProxyInterface(interfaceClass);
++        }
++        try {
++            if (isMXBean) {
++                // Check interface for MXBean compliance
++                Introspector.testComplianceMXBeanInterface(interfaceClass);
++            } else {
++                // Check interface for MBean compliance
++                Introspector.testComplianceMBeanInterface(interfaceClass);
++            }
++        } catch (NotCompliantMBeanException e) {
++            throw new IllegalArgumentException(e);
++        }
++
++        InvocationHandler handler = new MBeanServerInvocationHandler(
++                connection, objectName, isMXBean);
++        final Class<?>[] interfaces;
++        if (notificationEmitter) {
++            interfaces =
++                new Class<?>[] {interfaceClass, NotificationEmitter.class};
++        } else
++            interfaces = new Class<?>[] {interfaceClass};
++
++        Object proxy = Proxy.newProxyInstance(
++                interfaceClass.getClassLoader(),
++                interfaces,
++                handler);
++        return interfaceClass.cast(proxy);
++    }
++
++    /**
++     * Checks for the M(X)Bean proxy interface being public and not restricted
++     * @param interfaceClass MBean proxy interface
++     * @throws SecurityException when the proxy interface comes from a restricted
++     *                           package or is not public
++     */
++    private static void checkProxyInterface(Class<?> interfaceClass) {
++        if (!Modifier.isPublic(interfaceClass.getModifiers())) {
++            throw new SecurityException("mbean proxy interface non-public");
++        }
++        ReflectUtil.checkPackageAccess(interfaceClass);
++    }
+ }
+diff --git a/src/share/classes/javax/management/MBeanServerInvocationHandler.java b/src/share/classes/javax/management/MBeanServerInvocationHandler.java
+--- openjdk/jdk/src/share/classes/javax/management/MBeanServerInvocationHandler.java
++++ openjdk/jdk/src/share/classes/javax/management/MBeanServerInvocationHandler.java
+@@ -231,20 +231,7 @@
+                                          ObjectName objectName,
+                                          Class<T> interfaceClass,
+                                          boolean notificationBroadcaster) {
+-        final InvocationHandler handler =
+-            new MBeanServerInvocationHandler(connection, objectName);
+-        final Class[] interfaces;
+-        if (notificationBroadcaster) {
+-            interfaces =
+-                new Class[] {interfaceClass, NotificationEmitter.class};
+-        } else
+-            interfaces = new Class[] {interfaceClass};
+-
+-        Object proxy =
+-            Proxy.newProxyInstance(interfaceClass.getClassLoader(),
+-                                   interfaces,
+-                                   handler);
+-        return interfaceClass.cast(proxy);
++        return JMX.newMBeanProxy(connection, objectName, interfaceClass, notificationBroadcaster);
+     }
+ 
+     public Object invoke(Object proxy, Method method, Object[] args)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8009004-rmi_connection_improvement.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,54 @@
+# HG changeset patch
+# User andrew
+# Date 1371555603 18000
+# Node ID 546df033118c15bdfb5cc08f73db87805bc56277
+# Parent  60c57caf0348c7eed93900e4395607af759e6ba9
+8009004: Better implementation of RMI connections
+Summary: Better class handling.
+Reviewed-by: alanb, dfuchs, skoivu, jbachorik
+Contributed-by: jean-francois.denise@oracle.com
+
+diff --git a/src/share/classes/com/sun/jmx/remote/util/OrderClassLoaders.java b/src/share/classes/com/sun/jmx/remote/util/OrderClassLoaders.java
+--- openjdk/jdk/src/share/classes/com/sun/jmx/remote/util/OrderClassLoaders.java
++++ openjdk/jdk/src/share/classes/com/sun/jmx/remote/util/OrderClassLoaders.java
+@@ -25,6 +25,8 @@
+ 
+ package com.sun.jmx.remote.util;
+ 
++import sun.reflect.misc.ReflectUtil;
++
+ public class OrderClassLoaders extends ClassLoader {
+     public OrderClassLoaders(ClassLoader cl1, ClassLoader cl2) {
+         super(cl1);
+@@ -32,9 +34,10 @@
+         this.cl2 = cl2;
+     }
+ 
+-    protected Class findClass(String name) throws ClassNotFoundException {
++    protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
++        ReflectUtil.checkPackageAccess(name);
+         try {
+-            return super.findClass(name);
++            return super.loadClass(name, resolve);
+         } catch (ClassNotFoundException cne) {
+             if (cl2 != null) {
+                 return cl2.loadClass(name);
+diff --git a/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java b/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
+--- openjdk/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
++++ openjdk/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java
+@@ -80,6 +80,7 @@
+ import javax.management.remote.NotificationResult;
+ import javax.management.remote.TargetedNotification;
+ import javax.security.auth.Subject;
++import sun.reflect.misc.ReflectUtil;
+ 
+ /**
+  * <p>Implementation of the {@link RMIConnection} interface.  User
+@@ -1804,6 +1805,7 @@
+         @Override
+         protected Class<?> loadClass(String name, boolean resolve)
+         throws ClassNotFoundException {
++            ReflectUtil.checkPackageAccess(name);
+             try {
+                 super.loadClass(name, resolve);
+             } catch(Exception e) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8009013-t2k_glyphs.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,39 @@
+# HG changeset patch
+# User bae
+# Date 1364284560 -14400
+# Node ID 7311e449c298f769d7e9761678d28741f6cd1537
+# Parent  546df033118c15bdfb5cc08f73db87805bc56277
+8009013: Better handling of T2K glyphs
+Reviewed-by: bae, prr
+Contributed-by: jia-hong.chen@oracle.com
+
+diff --git a/src/share/native/sun/font/freetypeScaler.c b/src/share/native/sun/font/freetypeScaler.c
+--- openjdk/jdk/src/share/native/sun/font/freetypeScaler.c
++++ openjdk/jdk/src/share/native/sun/font/freetypeScaler.c
+@@ -1350,17 +1350,22 @@
+     FTScalerInfo *scalerInfo =
+              (FTScalerInfo*) jlong_to_ptr(pScaler);
+ 
+-    glyphs = (jint*) malloc(numGlyphs*sizeof(jint));
++    glyphs = NULL;
++    if (numGlyphs > 0 && 0xffffffffu / sizeof(jint) >= numGlyphs) {
++        glyphs = (jint*) malloc(numGlyphs*sizeof(jint));
++    }
+     if (glyphs == NULL) {
++        // We reach here if:
++        // 1. numGlyphs <= 0,
++        // 2. overflow check failed, or
++        // 3. malloc failed.
+         gp = (*env)->NewObject(env, sunFontIDs.gpClass, sunFontIDs.gpCtrEmpty);
+-        if (!isNullScalerContext(context) && scalerInfo != NULL) {
+-            invalidateJavaScaler(env, scaler, scalerInfo);
+-        }
+         return gp;
+     }
+ 
+     (*env)->GetIntArrayRegion(env, glyphArray, 0, numGlyphs, glyphs);
+ 
++    gpdata.numCoords = 0;
+     for (i=0; i<numGlyphs;i++) {
+         if (glyphs[i] >= INVISIBLE_GLYPHS) {
+             continue;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8009034-jmx_notification_improvement.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,30 @@
+# HG changeset patch
+# User jbachorik
+# Date 1363082977 -3600
+# Node ID 4b57646ef873f1b5db05907da8e410e8a937957c
+# Parent  7311e449c298f769d7e9761678d28741f6cd1537
+8009034: Improve resulting notifications in JMX
+Summary: Disallowing access to mutable shared arrays
+Reviewed-by: dfuchs, mchung, skoivu
+
+diff --git a/src/share/classes/javax/management/remote/NotificationResult.java b/src/share/classes/javax/management/remote/NotificationResult.java
+--- openjdk/jdk/src/share/classes/javax/management/remote/NotificationResult.java
++++ openjdk/jdk/src/share/classes/javax/management/remote/NotificationResult.java
+@@ -89,7 +89,7 @@
+ 
+         this.earliestSequenceNumber = earliestSequenceNumber;
+         this.nextSequenceNumber = nextSequenceNumber;
+-        this.targetedNotifications = targetedNotifications;
++        this.targetedNotifications = (targetedNotifications.length == 0 ? targetedNotifications : targetedNotifications.clone());
+     }
+ 
+     /**
+@@ -122,7 +122,7 @@
+      * listeners they correspond to.  This array can be empty.
+      */
+     public TargetedNotification[] getTargetedNotifications() {
+-        return targetedNotifications;
++        return targetedNotifications.length == 0 ? targetedNotifications : targetedNotifications.clone();
+     }
+ 
+     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8009038-jmx_notification_support_improvement.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,89 @@
+# HG changeset patch
+# User jbachorik
+# Date 1363077266 -3600
+# Node ID ae61ba2bcdfa02807ead8b20311953a52f5ae96e
+# Parent  4b57646ef873f1b5db05907da8e410e8a937957c
+8009038: Improve JMX notification support
+Summary: Disallowing access to mutable shared arrays
+Reviewed-by: dfuchs, mchung, skoivu
+
+diff --git a/src/share/classes/javax/management/StandardEmitterMBean.java b/src/share/classes/javax/management/StandardEmitterMBean.java
+--- openjdk/jdk/src/share/classes/javax/management/StandardEmitterMBean.java
++++ openjdk/jdk/src/share/classes/javax/management/StandardEmitterMBean.java
+@@ -64,6 +64,9 @@
+ public class StandardEmitterMBean extends StandardMBean
+         implements NotificationEmitter {
+ 
++    private static final MBeanNotificationInfo[] NO_NOTIFICATION_INFO =
++        new MBeanNotificationInfo[0];
++
+     private final NotificationEmitter emitter;
+     private final MBeanNotificationInfo[] notificationInfo;
+ 
+@@ -99,11 +102,7 @@
+      */
+     public <T> StandardEmitterMBean(T implementation, Class<T> mbeanInterface,
+                                     NotificationEmitter emitter) {
+-        super(implementation, mbeanInterface, false);
+-        if (emitter == null)
+-            throw new IllegalArgumentException("Null emitter");
+-        this.emitter = emitter;
+-        this.notificationInfo = emitter.getNotificationInfo();
++        this(implementation, mbeanInterface, false, emitter);
+     }
+ 
+     /**
+@@ -148,7 +147,12 @@
+         if (emitter == null)
+             throw new IllegalArgumentException("Null emitter");
+         this.emitter = emitter;
+-        this.notificationInfo = emitter.getNotificationInfo();
++        MBeanNotificationInfo[] infos = emitter.getNotificationInfo();
++        if (infos == null || infos.length == 0) {
++            this.notificationInfo = NO_NOTIFICATION_INFO;
++        } else {
++            this.notificationInfo = infos.clone();
++        }
+     }
+ 
+     /**
+@@ -184,11 +188,7 @@
+      */
+     protected StandardEmitterMBean(Class<?> mbeanInterface,
+                                    NotificationEmitter emitter) {
+-        super(mbeanInterface, false);
+-        if (emitter == null)
+-            throw new IllegalArgumentException("Null emitter");
+-        this.emitter = emitter;
+-        this.notificationInfo = emitter.getNotificationInfo();
++        this(mbeanInterface, false, emitter);
+     }
+ 
+     /**
+@@ -231,7 +231,12 @@
+         if (emitter == null)
+             throw new IllegalArgumentException("Null emitter");
+         this.emitter = emitter;
+-        this.notificationInfo = emitter.getNotificationInfo();
++        MBeanNotificationInfo[] infos = emitter.getNotificationInfo();
++        if (infos == null || infos.length == 0) {
++            this.notificationInfo = NO_NOTIFICATION_INFO;
++        } else {
++            this.notificationInfo = infos.clone();
++        }
+     }
+ 
+     public void removeNotificationListener(NotificationListener listener)
+@@ -253,7 +258,11 @@
+     }
+ 
+     public MBeanNotificationInfo[] getNotificationInfo() {
+-        return notificationInfo;
++        if (notificationInfo.length == 0) {
++            return notificationInfo;
++        } else {
++            return notificationInfo.clone();
++        }
+     }
+ 
+     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8009067-improve_key_storing.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,20 @@
+# HG changeset patch
+# User vinnie
+# Date 1363862556 0
+# Node ID 3bb3933b9704ad855b64933be52c6aa252a04d83
+# Parent  ae61ba2bcdfa02807ead8b20311953a52f5ae96e
+8009067: Improve storing keys in KeyStore
+Reviewed-by: mullan, skoivu
+
+diff --git a/src/share/classes/java/security/KeyStore.java b/src/share/classes/java/security/KeyStore.java
+--- openjdk/jdk/src/share/classes/java/security/KeyStore.java
++++ openjdk/jdk/src/share/classes/java/security/KeyStore.java
+@@ -1716,7 +1716,7 @@
+                              oldException);
+                     }
+                     try {
+-                        return AccessController.doPrivileged(action);
++                        return AccessController.doPrivileged(action, context);
+                     } catch (PrivilegedActionException e) {
+                         Throwable cause = e.getCause();
+                         throw new KeyStoreException
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8009071-improve_shape_handling.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,1006 @@
+diff -Nru openjdk.orig/jdk/src/share/native/common/sizecalc.h openjdk/jdk/src/share/native/common/sizecalc.h
+--- openjdk.orig/jdk/src/share/native/common/sizecalc.h	1969-12-31 18:00:00.000000000 -0600
++++ openjdk/jdk/src/share/native/common/sizecalc.h	2013-06-22 03:34:36.084702677 -0500
+@@ -0,0 +1,118 @@
++/*
++ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
++ *
++ * This code is free software; you can redistribute it and/or modify it
++ * under the terms of the GNU General Public License version 2 only, as
++ * published by the Free Software Foundation.  Oracle designates this
++ * particular file as subject to the "Classpath" exception as provided
++ * by Oracle in the LICENSE file that accompanied this code.
++ *
++ * This code is distributed in the hope that it will be useful, but WITHOUT
++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
++ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
++ * version 2 for more details (a copy is included in the LICENSE file that
++ * accompanied this code).
++ *
++ * You should have received a copy of the GNU General Public License version
++ * 2 along with this work; if not, write to the Free Software Foundation,
++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
++ *
++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
++ * or visit www.oracle.com if you need additional information or have any
++ * questions.
++ */
++
++#ifndef SIZECALC_H
++#define SIZECALC_H
++
++/*
++ * A machinery for safe calculation of sizes used when allocating memory.
++ *
++ * All size checks are performed against the SIZE_MAX (the maximum value for
++ * size_t). All numerical arguments as well as the result of calculation must
++ * be non-negative integers less than or equal to SIZE_MAX, otherwise the
++ * calculated size is considered unsafe.
++ *
++ * If the SIZECALC_ALLOC_THROWING_BAD_ALLOC macro is defined, then _ALLOC_
++ * helper macros throw the std::bad_alloc instead of returning NULL.
++ */
++
++#include <stdint.h> /* SIZE_MAX for C99+ */
++/* http://stackoverflow.com/questions/3472311/what-is-a-portable-method-to-find-the-maximum-value-of-size-t */
++#ifndef SIZE_MAX
++#define SIZE_MAX ((size_t)-1)
++#endif
++
++#define IS_SAFE_SIZE_T(x) ((x) >= 0 && (unsigned long long)(x) <= SIZE_MAX)
++
++#define IS_SAFE_SIZE_MUL(m, n) \
++    (IS_SAFE_SIZE_T(m) && IS_SAFE_SIZE_T(n) && ((m) == 0 || (n) == 0 || (size_t)(n) <= (SIZE_MAX / (size_t)(m))))
++
++#define IS_SAFE_SIZE_ADD(a, b) \
++    (IS_SAFE_SIZE_T(a) && IS_SAFE_SIZE_T(b) && (size_t)(b) <= (SIZE_MAX - (size_t)(a)))
++
++
++
++/* Helper macros */
++
++#ifdef SIZECALC_ALLOC_THROWING_BAD_ALLOC
++#define FAILURE_RESULT throw std::bad_alloc()
++#else
++#define FAILURE_RESULT NULL
++#endif
++
++/*
++ * A helper macro to safely allocate an array of size m*n.
++ * Example usage:
++ *    int* p = (int*)SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(int), n);
++ *    if (!p) throw OutOfMemory;
++ *    // Use the allocated array...
++ */
++#define SAFE_SIZE_ARRAY_ALLOC(func, m, n) \
++    (IS_SAFE_SIZE_MUL((m), (n)) ? ((func)((m) * (n))) : FAILURE_RESULT)
++
++#define SAFE_SIZE_ARRAY_REALLOC(func, p, m, n) \
++    (IS_SAFE_SIZE_MUL((m), (n)) ? ((func)((p), (m) * (n))) : FAILURE_RESULT)
++
++/*
++ * A helper macro to safely allocate an array of type 'type' with 'n' items
++ * using the C++ new[] operator.
++ * Example usage:
++ *    MyClass* p = SAFE_SIZE_NEW_ARRAY(MyClass, n);
++ *    // Use the pointer.
++ * This macro throws the std::bad_alloc C++ exception to indicate
++ * a failure.
++ * NOTE: if 'n' is calculated, the calling code is responsible for using the
++ * IS_SAFE_... macros to check if the calculations are safe.
++ */
++#define SAFE_SIZE_NEW_ARRAY(type, n) \
++    (IS_SAFE_SIZE_MUL(sizeof(type), (n)) ? (new type[(n)]) : throw std::bad_alloc())
++
++#define SAFE_SIZE_NEW_ARRAY2(type, n, m) \
++    (IS_SAFE_SIZE_MUL((m), (n)) && IS_SAFE_SIZE_MUL(sizeof(type), (n) * (m)) ? \
++     (new type[(n) * (m)]) : throw std::bad_alloc())
++
++/*
++ * Checks if a data structure of size (a + m*n) can be safely allocated
++ * w/o producing an integer overflow when calculating its size.
++ */
++#define IS_SAFE_STRUCT_SIZE(a, m, n) \
++    ( \
++      IS_SAFE_SIZE_MUL((m), (n)) && IS_SAFE_SIZE_ADD((m) * (n), (a)) \
++    )
++
++/*
++ * A helper macro for implementing safe memory allocation for a data structure
++ * of size (a + m * n).
++ * Example usage:
++ *    void * p = SAFE_SIZE_ALLOC(malloc, header, num, itemSize);
++ *    if (!p) throw OutOfMemory;
++ *    // Use the allocated memory...
++ */
++#define SAFE_SIZE_STRUCT_ALLOC(func, a, m, n) \
++    (IS_SAFE_STRUCT_SIZE((a), (m), (n)) ? ((func)((a) + (m) * (n))) : FAILURE_RESULT)
++
++
++#endif /* SIZECALC_H */
++
+diff -Nru openjdk.orig/jdk/src/share/native/sun/awt/splashscreen/java_awt_SplashScreen.c openjdk/jdk/src/share/native/sun/awt/splashscreen/java_awt_SplashScreen.c
+--- openjdk.orig/jdk/src/share/native/sun/awt/splashscreen/java_awt_SplashScreen.c	2011-11-14 16:12:12.000000000 -0600
++++ openjdk/jdk/src/share/native/sun/awt/splashscreen/java_awt_SplashScreen.c	2013-06-22 03:34:36.084702677 -0500
+@@ -26,6 +26,7 @@
+ #include "splashscreen_impl.h"
+ #include <jni.h>
+ #include <jlong_md.h>
++#include <sizecalc.h>
+ 
+ JNIEXPORT jint JNICALL
+ JNI_OnLoad(JavaVM * vm, void *reserved)
+@@ -57,7 +58,7 @@
+     if (splash->overlayData) {
+         free(splash->overlayData);
+     }
+-    splash->overlayData = malloc(dataSize * sizeof(rgbquad_t));
++    splash->overlayData = SAFE_SIZE_ARRAY_ALLOC(malloc, dataSize, sizeof(rgbquad_t));
+     if (splash->overlayData) {
+         /* we need a copy anyway, so we'll be using GetIntArrayRegion */
+         (*env)->GetIntArrayRegion(env, data, 0, dataSize,
+diff -Nru openjdk.orig/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c openjdk/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c
+--- openjdk.orig/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c	2011-11-14 16:12:12.000000000 -0600
++++ openjdk/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gif.c	2013-06-22 03:34:36.084702677 -0500
+@@ -120,7 +120,7 @@
+     splash->height = gif->SHeight;
+     splash->frameCount = gif->ImageCount;
+     splash->frames = (SplashImage *)
+-        malloc(sizeof(SplashImage) * gif->ImageCount);
++        SAFE_SIZE_ARRAY_ALLOC(malloc, sizeof(SplashImage), gif->ImageCount);
+     if (!splash->frames) {
+       free(pBitmapBits);
+       free(pOldBitmapBits);
+diff -Nru openjdk.orig/jdk/src/share/native/sun/java2d/pipe/Region.c openjdk/jdk/src/share/native/sun/java2d/pipe/Region.c
+--- openjdk.orig/jdk/src/share/native/sun/java2d/pipe/Region.c	2011-11-14 16:12:13.000000000 -0600
++++ openjdk/jdk/src/share/native/sun/java2d/pipe/Region.c	2013-06-22 03:34:36.085702679 -0500
+@@ -28,6 +28,7 @@
+ #include "jni_util.h"
+ 
+ #include "Region.h"
++#include "sizecalc.h"
+ 
+ static jfieldID endIndexID;
+ static jfieldID bandsID;
+@@ -260,8 +261,8 @@
+         }
+         Region_StartIteration(env, &clipInfo);
+         numrects = Region_CountIterationRects(&clipInfo);
+-        if (numrects > initialBufferSize) {
+-            *pRect = (RECT_T *) malloc(numrects * sizeof(RECT_T));
++        if ((unsigned long)numrects > initialBufferSize) {
++            *pRect = (RECT_T *) SAFE_SIZE_ARRAY_ALLOC(malloc, numrects, sizeof(RECT_T));
+             if (*pRect == NULL) {
+                 Region_EndIteration(env, &clipInfo);
+                 JNU_ThrowOutOfMemoryError(env,
+diff -Nru openjdk.orig/jdk/src/solaris/native/sun/awt/awt_Robot.c openjdk/jdk/src/solaris/native/sun/awt/awt_Robot.c
+--- openjdk.orig/jdk/src/solaris/native/sun/awt/awt_Robot.c	2011-11-14 16:12:15.000000000 -0600
++++ openjdk/jdk/src/solaris/native/sun/awt/awt_Robot.c	2013-06-22 03:34:36.085702679 -0500
+@@ -40,6 +40,7 @@
+ #include <X11/extensions/XInput.h>
+ #include <X11/extensions/XI.h>
+ #include <jni.h>
++#include <sizecalc.h>
+ #include "robot_common.h"
+ #include "canvas.h"
+ #include "wsutils.h"
+@@ -266,8 +267,9 @@
+     image = getWindowImage(awt_display, rootWindow, x, y, width, height);
+ 
+     /* Array to use to crunch around the pixel values */
+-    ary = (jint *) malloc(width * height * sizeof (jint));
+-    if (ary == NULL) {
++    if (!IS_SAFE_SIZE_MUL(width, height) ||
++        !(ary = (jint *) SAFE_SIZE_ARRAY_ALLOC(malloc, width * height, sizeof (jint))))
++    {
+         JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
+         XDestroyImage(image);
+         AWT_UNLOCK();
+diff -Nru openjdk.orig/jdk/src/solaris/native/sun/awt/awt_UNIXToolkit.c openjdk/jdk/src/solaris/native/sun/awt/awt_UNIXToolkit.c
+--- openjdk.orig/jdk/src/solaris/native/sun/awt/awt_UNIXToolkit.c	2011-11-14 16:12:16.000000000 -0600
++++ openjdk/jdk/src/solaris/native/sun/awt/awt_UNIXToolkit.c	2013-06-22 03:34:36.085702679 -0500
+@@ -29,6 +29,7 @@
+ #include <dlfcn.h>
+ 
+ #include <jni.h>
++#include <sizecalc.h>
+ #include "sun_awt_UNIXToolkit.h"
+ 
+ #ifndef HEADLESS
+@@ -148,7 +149,8 @@
+     }
+ 
+     len = (*env)->GetStringUTFLength(env, filename);
+-    filename_str = (char *)malloc(sizeof(char) * (len + 1));
++    filename_str = (char *)SAFE_SIZE_ARRAY_ALLOC(malloc,
++            sizeof(char), len + 1);
+     if (filename_str == NULL) {
+         JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
+         return JNI_FALSE;
+@@ -189,7 +191,8 @@
+     }
+ 
+     len = (*env)->GetStringUTFLength(env, stock_id);
+-    stock_id_str = (char *)malloc(sizeof(char) * (len + 1));
++    stock_id_str = (char *)SAFE_SIZE_ARRAY_ALLOC(malloc,
++            sizeof(char), len + 1);
+     if (stock_id_str == NULL) {
+         JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
+         return JNI_FALSE;
+@@ -200,7 +203,8 @@
+     if (detail != NULL)
+     {
+         len = (*env)->GetStringUTFLength(env, detail);
+-        detail_str = (char *)malloc(sizeof(char) * (len + 1));
++        detail_str = (char *)SAFE_SIZE_ARRAY_ALLOC(malloc,
++                sizeof(char), len + 1);
+         if (detail_str == NULL) {
+             JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
+             return JNI_FALSE;
+diff -Nru openjdk.orig/jdk/src/solaris/native/sun/awt/fontpath.c openjdk/jdk/src/solaris/native/sun/awt/fontpath.c
+--- openjdk.orig/jdk/src/solaris/native/sun/awt/fontpath.c	2013-06-22 15:43:08.458839780 -0500
++++ openjdk/jdk/src/solaris/native/sun/awt/fontpath.c	2013-06-22 03:34:36.085702679 -0500
+@@ -40,6 +40,7 @@
+ 
+ #include <jni.h>
+ #include <jni_util.h>
++#include <sizecalc.h>
+ #include <sun_font_FontManager.h>
+ #ifndef HEADLESS
+ #include <X11/Xlib.h>
+@@ -182,7 +183,7 @@
+ 
+     if ( fDirP->num == 0 ) return;
+ 
+-    appendDirList = malloc ( fDirP->num * sizeof ( int ));
++    appendDirList = SAFE_SIZE_ARRAY_ALLOC(malloc, fDirP->num, sizeof ( int ));
+     if ( appendDirList == NULL ) {
+       return;  /* if it fails we cannot do much */
+     }
+@@ -239,7 +240,7 @@
+     }
+ 
+ 
+-    newFontPath = malloc ( totalDirCount * sizeof ( char **) );
++    newFontPath = SAFE_SIZE_ARRAY_ALLOC(malloc, totalDirCount, sizeof ( char **) );
+     /* if it fails free things and get out */
+     if ( newFontPath == NULL ) {
+       free ( ( void *) appendDirList );
+@@ -260,7 +261,12 @@
+ 
+         /* printf ( "Appending %s\n", fDirP->name[index] ); */
+ 
+-        onePath = malloc ( ( strlen (fDirP->name[index]) + 2 )* sizeof( char ) );
++        onePath = SAFE_SIZE_ARRAY_ALLOC(malloc, strlen (fDirP->name[index]) + 2, sizeof( char ) );
++        if (onePath == NULL) {
++            free ( ( void *) appendDirList );
++            XFreeFontPath ( origFontPath );
++            return;
++        }
+         strcpy ( onePath, fDirP->name[index] );
+         strcat ( onePath, "/" );
+         newFontPath[nPaths++] = onePath;
+diff -Nru openjdk.orig/jdk/src/solaris/native/sun/awt/gtk2_interface.c openjdk/jdk/src/solaris/native/sun/awt/gtk2_interface.c
+--- openjdk.orig/jdk/src/solaris/native/sun/awt/gtk2_interface.c	2011-11-14 16:12:16.000000000 -0600
++++ openjdk/jdk/src/solaris/native/sun/awt/gtk2_interface.c	2013-06-22 10:35:00.508880273 -0500
+@@ -30,6 +30,7 @@
+ #include <string.h>
+ #include "gtk2_interface.h"
+ #include "java_awt_Transparency.h"
++#include "sizecalc.h"
+ 
+ #define GTK2_LIB "libgtk-x11-2.0.so.0"
+ 
+@@ -637,7 +638,8 @@
+     {
+         gchar *tmp_env = strdup (gtk_modules_env);
+         /* the new env will be smaller than the old one */
+-        gchar *s, *new_env = malloc (sizeof(ENV_PREFIX)+strlen (gtk_modules_env));
++        gchar *s, *new_env = SAFE_SIZE_STRUCT_ALLOC(malloc,
++                sizeof(ENV_PREFIX), 1, strlen (gtk_modules_env));
+ 
+         if (new_env != NULL )
+         {
+diff -Nru openjdk.orig/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c openjdk/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c
+--- openjdk.orig/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c	2011-11-14 16:12:16.000000000 -0600
++++ openjdk/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_sys.c	2013-06-22 10:35:17.128937870 -0500
+@@ -40,6 +40,7 @@
+ #include <langinfo.h>
+ #include <locale.h>
+ #include <fcntl.h>
++#include <sizecalc.h>
+ 
+ static Bool shapeSupported;
+ static int shapeEventBase, shapeErrorBase;
+@@ -75,9 +76,12 @@
+         goto done;
+     }
+     inSize = strlen(in);
++    buf = SAFE_SIZE_ARRAY_ALLOC(malloc, inSize, 2);
++    if (!buf) {
++        return NULL;
++    }
+     bufSize = inSize*2; // need 2 bytes per char for UCS-2, this is
+                         // 2 bytes per source byte max
+-    buf = malloc(bufSize);
+     out = buf; outSize = bufSize;
+     /* linux iconv wants char** source and solaris wants const char**...
+        cast to void* */
+@@ -113,12 +117,20 @@
+     initRect(&maskRect, 0, 0, splash->width, splash->height, 1,
+             splash->width * splash->imageFormat.depthBytes,
+             splash->frames[imageIndex].bitmapBits, &splash->imageFormat);
+-    rects =
+-        malloc(sizeof(XRectangle) * (splash->width / 2 + 1) * splash->height);
++    if (!IS_SAFE_SIZE_MUL(splash->width / 2 + 1, splash->height)) {
++        return;
++    }
++    rects = SAFE_SIZE_ARRAY_ALLOC(malloc,
++            sizeof(XRectangle), (splash->width / 2 + 1) * splash->height);
++    if (!rects) {
++        return;
++    }
+ 
+     frame->numRects = BitmapToYXBandedRectangles(&maskRect, rects);
+-    frame->rects = malloc(frame->numRects * sizeof(XRectangle));
+-    memcpy(frame->rects, rects, frame->numRects * sizeof(XRectangle));
++    frame->rects = SAFE_SIZE_ARRAY_ALLOC(malloc, frame->numRects, sizeof(XRectangle));
++    if (frame->rects) { // handle the error after the if(){}
++        memcpy(frame->rects, rects, frame->numRects * sizeof(XRectangle));
++    }
+     free(rects);
+ }
+ 
+diff -Nru openjdk.orig/jdk/src/solaris/native/sun/xawt/XlibWrapper.c openjdk/jdk/src/solaris/native/sun/xawt/XlibWrapper.c
+--- openjdk.orig/jdk/src/solaris/native/sun/xawt/XlibWrapper.c	2013-06-22 15:43:09.066839271 -0500
++++ openjdk/jdk/src/solaris/native/sun/xawt/XlibWrapper.c	2013-06-22 10:37:06.731315811 -0500
+@@ -37,6 +37,7 @@
+ #include <jni.h>
+ #include <jni_util.h>
+ #include <jlong.h>
++#include <sizecalc.h>
+ 
+ #include <awt.h>
+ #include <jvm.h>
+@@ -1991,6 +1992,10 @@
+     size_t worstBufferSize = (size_t)((width / 2 + 1) * height);
+     RECT_T * pRect;
+ 
++    if (!IS_SAFE_SIZE_MUL(width / 2 + 1, height)) {
++        return;
++    }
++
+     AWT_CHECK_HAVE_LOCK();
+ 
+     len = (*env)->GetArrayLength(env, bitmap);
+@@ -2003,7 +2008,10 @@
+         return;
+     }
+ 
+-    pRect = (RECT_T *)malloc(worstBufferSize * sizeof(RECT_T));
++    pRect = (RECT_T *)SAFE_SIZE_ARRAY_ALLOC(malloc, worstBufferSize, sizeof(RECT_T));
++    if (!pRect) {
++        return;
++    }
+ 
+     /* Note: the values[0] and values[1] are supposed to contain the width
+      * and height (see XIconInfo.getIntData() for details). So, we do +2.
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/awt/splashscreen/splashscreen_sys.c openjdk/jdk/src/windows/native/sun/awt/splashscreen/splashscreen_sys.c
+--- openjdk.orig/jdk/src/windows/native/sun/awt/splashscreen/splashscreen_sys.c	2011-11-14 16:12:17.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/awt/splashscreen/splashscreen_sys.c	2013-06-22 10:33:22.939540596 -0500
+@@ -27,6 +27,7 @@
+ #include <windowsx.h>
+ #include <windows.h>
+ #include <winuser.h>
++#include "sizecalc.h"
+ 
+ /* layered windows api prototypes. wouldn't be needed if we could use an updated version of the MS PSDK. */
+ 
+@@ -85,7 +86,10 @@
+     len = strlen(in);
+     outChars = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, in, len,
+                                        NULL, 0);
+-    buf = malloc(outChars*sizeof(WCHAR));
++    buf = (WCHAR*) SAFE_SIZE_ARRAY_ALLOC(malloc, outChars, sizeof(WCHAR));
++    if (!buf) {
++        return NULL;
++    }
+     rc = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, in, len,
+                                  buf, outChars);
+     if (rc==0) {
+@@ -116,8 +120,14 @@
+         return;
+ 
+     /* reserving memory for the worst case */
+-    pRgnData = (RGNDATA *) malloc(sizeof(RGNDATAHEADER) +
+-            sizeof(RECT) * (splash->width / 2 + 1) * splash->height);
++    if (!IS_SAFE_SIZE_MUL(splash->width / 2 + 1, splash->height)) {
++        return;
++    }
++    pRgnData = (RGNDATA *) SAFE_SIZE_STRUCT_ALLOC(malloc, sizeof(RGNDATAHEADER),
++            sizeof(RECT), (splash->width / 2 + 1) * splash->height);
++    if (!pRgnData) {
++        return;
++    }
+     pRgnHdr = (RGNDATAHEADER *) pRgnData;
+     initRect(&maskRect, 0, 0, splash->width, splash->height, 1,
+             splash->width * splash->imageFormat.depthBytes,
+@@ -148,7 +158,6 @@
+ {
+     unsigned numColors = splash->screenFormat.colorMap ?
+         splash->screenFormat.numColors : 0;
+-    unsigned bmiSize;
+     BITMAPV4HEADER *pBmi;
+     HPALETTE hOldPal = NULL;
+ 
+@@ -156,8 +165,11 @@
+         return;
+     if (splash->currentFrame < 0 || splash->currentFrame >= splash->frameCount)
+         return;
+-    bmiSize = sizeof(BITMAPV4HEADER) + sizeof(RGBQUAD) * numColors;
+-    pBmi = (BITMAPV4HEADER *) alloca(bmiSize);
++    pBmi = (BITMAPV4HEADER *) SAFE_SIZE_STRUCT_ALLOC(alloca, sizeof(BITMAPV4HEADER),
++            sizeof(RGBQUAD), numColors);
++    if (!pBmi) {
++        return;
++    }
+     memset(pBmi, 0, sizeof(BITMAPV4HEADER));
+     if (splash->screenFormat.colorMap)
+         memcpy(((BYTE *) pBmi) + sizeof(BITMAPV4HEADER),
+@@ -181,8 +193,11 @@
+        here on demand */
+     if (!splash->hPalette) {
+         unsigned i;
+-        LOGPALETTE *pLogPal =
+-            malloc(sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * numColors);
++        LOGPALETTE *pLogPal = (LOGPALETTE *) SAFE_SIZE_STRUCT_ALLOC(malloc,
++                sizeof(LOGPALETTE), sizeof(PALETTEENTRY), numColors);
++        if (!pLogPal) {
++            return;
++        }
+ 
+         pLogPal->palVersion = 0x300;
+         pLogPal->palNumEntries = (WORD) numColors;
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/font/lcdglyph.c openjdk/jdk/src/windows/native/sun/font/lcdglyph.c
+--- openjdk.orig/jdk/src/windows/native/sun/font/lcdglyph.c	2013-06-22 15:43:09.297839077 -0500
++++ openjdk/jdk/src/windows/native/sun/font/lcdglyph.c	2013-06-22 03:34:36.262702877 -0500
+@@ -54,6 +54,7 @@
+ #include <jni.h>
+ #include <jni_util.h>
+ #include <jlong_md.h>
++#include <sizecalc.h>
+ #include <sun_font_FileFontStrike.h>
+ 
+ #include "fontscalerdefs.h"
+@@ -374,11 +375,11 @@
+     bmi.bmiHeader.biBitCount = 24;
+     bmi.bmiHeader.biCompression = BI_RGB;
+ 
+-    dibImageSize = dibBytesWidth*height;
+-    dibImage = malloc(dibImageSize);
++    dibImage = SAFE_SIZE_ARRAY_ALLOC(malloc, dibBytesWidth, height);
+     if (dibImage == NULL) {
+         FREE_AND_RETURN;
+     }
++    dibImageSize = dibBytesWidth*height;
+     memset(dibImage, 0, dibImageSize);
+ 
+     err = GetDIBits(hMemoryDC, hBitmap, 0, height, dibImage,
+@@ -407,11 +408,12 @@
+      * that extra "1" was added as padding, so the sub-pixel positioning of
+      * fractional metrics could index into it.
+      */
+-    imageSize = bytesWidth*height;
+-    glyphInfo = (GlyphInfo*)malloc(sizeof(GlyphInfo)+imageSize);
++    glyphInfo = (GlyphInfo*)SAFE_SIZE_STRUCT_ALLOC(malloc, sizeof(GlyphInfo),
++            bytesWidth, height);
+     if (malloc == NULL) {
+         FREE_AND_RETURN;
+     }
++    imageSize = bytesWidth*height;
+     glyphInfo->cellInfo = NULL;
+     glyphInfo->rowBytes = bytesWidth;
+     glyphInfo->width = width;
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c openjdk/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c
+--- openjdk.orig/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c	2013-06-22 15:43:08.634839633 -0500
++++ openjdk/jdk/src/windows/native/sun/java2d/opengl/WGLSurfaceData.c	2013-06-22 03:34:36.262702877 -0500
+@@ -30,6 +30,7 @@
+ #include "jni.h"
+ #include "jlong.h"
+ #include "jni_util.h"
++#include "sizecalc.h"
+ #include "OGLRenderQueue.h"
+ #include "WGLGraphicsConfig.h"
+ #include "WGLSurfaceData.h"
+@@ -593,7 +594,7 @@
+     height = h;
+     srcx = srcy = dstx = dsty = 0;
+ 
+-    pDst = malloc(height * scanStride);
++    pDst = SAFE_SIZE_ARRAY_ALLOC(malloc, height, scanStride);
+     if (pDst == NULL) {
+         return JNI_FALSE;
+     }
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/java2d/windows/GDIBlitLoops.cpp openjdk/jdk/src/windows/native/sun/java2d/windows/GDIBlitLoops.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/java2d/windows/GDIBlitLoops.cpp	2013-06-22 15:43:08.370839854 -0500
++++ openjdk/jdk/src/windows/native/sun/java2d/windows/GDIBlitLoops.cpp	2013-06-22 03:34:36.262702877 -0500
+@@ -157,6 +157,7 @@
+                 // when using ByteGray surfaces.  Eventually, we should use
+                 // the new Disposer mechanism to delete this native memory.
+                 if (byteGrayPalette == NULL) {
++                    // assert (256 * sizeof(RGBQUAD)) <= SIZE_MAX
+                     byteGrayPalette = (RGBQUAD *)safe_Malloc(256 * sizeof(RGBQUAD));
+                     for (int i = 0; i < 256; ++i) {
+                         byteGrayPalette[i].rgbRed = i;
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/java2d/windows/GDIRenderer.cpp openjdk/jdk/src/windows/native/sun/java2d/windows/GDIRenderer.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/java2d/windows/GDIRenderer.cpp	2013-06-22 15:43:08.735839548 -0500
++++ openjdk/jdk/src/windows/native/sun/java2d/windows/GDIRenderer.cpp	2013-06-22 03:34:36.263702878 -0500
+@@ -86,7 +86,7 @@
+         *pNpoints = outpoints;
+     }
+     if (outpoints > POLYTEMPSIZE) {
+-        pPoints = (POINT *) safe_Malloc(sizeof(POINT) * outpoints);
++        pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints);
+     }
+     BOOL isempty = fixend;
+     for (int i = 0; i < npoints; i++) {
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp openjdk/jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp	2013-06-22 15:43:08.370839855 -0500
++++ openjdk/jdk/src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.cpp	2013-06-22 03:34:36.263702878 -0500
+@@ -1036,8 +1036,9 @@
+             int topInset = wsdo->insets.top;
+             Region_StartIteration(env, &clipInfo);
+             jint numrects = Region_CountIterationRects(&clipInfo);
+-            DWORD nCount = sizeof(RGNDATAHEADER) + numrects * sizeof(RECT);
+-            RGNDATA *lpRgnData = (RGNDATA *) safe_Malloc(nCount);
++            RGNDATA *lpRgnData = (RGNDATA *) SAFE_SIZE_STRUCT_ALLOC(safe_Malloc,
++                    sizeof(RGNDATAHEADER), numrects, sizeof(RECT));
++            const DWORD nCount = sizeof(RGNDATAHEADER) + numrects * sizeof(RECT);
+             lpRgnData->rdh.dwSize = sizeof(RGNDATAHEADER);
+             lpRgnData->rdh.iType = RDH_RECTANGLES;
+             lpRgnData->rdh.nCount = numrects;
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/alloc.h openjdk/jdk/src/windows/native/sun/windows/alloc.h
+--- openjdk.orig/jdk/src/windows/native/sun/windows/alloc.h	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/alloc.h	2013-06-22 03:34:36.264702879 -0500
+@@ -35,6 +35,9 @@
+     class bad_alloc {};
+ }
+ 
++#define SIZECALC_ALLOC_THROWING_BAD_ALLOC
++#include "sizecalc.h"
++
+ class awt_toolkit_shutdown {};
+ 
+ // Disable "C++ Exception Specification ignored" warnings.
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/awt_BitmapUtil.cpp openjdk/jdk/src/windows/native/sun/windows/awt_BitmapUtil.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_BitmapUtil.cpp	2013-06-22 15:43:08.635839632 -0500
++++ openjdk/jdk/src/windows/native/sun/windows/awt_BitmapUtil.cpp	2013-06-22 03:34:36.264702879 -0500
+@@ -39,13 +39,13 @@
+ HBITMAP BitmapUtil::CreateTransparencyMaskFromARGB(int width, int height, int* imageData)
+ {
+     //Scan lines should be aligned to word boundary
+-    int bufLength = ((width + 15) / 16 * 2) * height;//buf length (bytes)
++    if (!IS_SAFE_SIZE_ADD(width, 15)) return NULL;
++    char* buf = SAFE_SIZE_NEW_ARRAY2(char, (width + 15) / 16 * 2, height);
++    if (buf == NULL) return NULL;
+     int* srcPos = imageData;
+-    char* buf = new char[bufLength];
+     char* bufPos = buf;
+     int tmp = 0;
+     int cbit = 0x80;
+-    if (buf == NULL) return NULL;
+     for (int i = 0; i < height; i++) {
+         for (int j = 0; j < width; j++) {
+             //cbit is shifted right for every pixel
+@@ -251,8 +251,12 @@
+             reinterpret_cast<BITMAPINFO*>(&bi), DIB_RGB_COLORS);
+ 
+     /* reserving memory for the worst case */
+-    RGNDATA * pRgnData = (RGNDATA *) safe_Malloc(sizeof(RGNDATAHEADER) +
+-            sizeof(RECT) * (width / 2 + 1) * height);
++    if (!IS_SAFE_SIZE_MUL(width / 2 + 1, height)) {
++        throw std::bad_alloc();
++    }
++    RGNDATA * pRgnData = (RGNDATA *) SAFE_SIZE_STRUCT_ALLOC(safe_Malloc,
++            sizeof(RGNDATAHEADER),
++            sizeof(RECT), (width / 2 + 1) * height);
+     RGNDATAHEADER * pRgnHdr = (RGNDATAHEADER *) pRgnData;
+     pRgnHdr->dwSize = sizeof(RGNDATAHEADER);
+     pRgnHdr->iType = RDH_RECTANGLES;
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/awt_Component.cpp openjdk/jdk/src/windows/native/sun/windows/awt_Component.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_Component.cpp	2013-06-22 15:43:09.068839269 -0500
++++ openjdk/jdk/src/windows/native/sun/windows/awt_Component.cpp	2013-06-22 10:30:17.853888796 -0500
+@@ -2362,12 +2362,12 @@
+         if (insets != NULL) {
+             ::OffsetRgn(rgn, insets->left, insets->top);
+         }
+-        int size = ::GetRegionData(rgn, 0, NULL);
++        DWORD size = ::GetRegionData(rgn, 0, NULL);
+         if (size == 0) {
+             ::DeleteObject((HGDIOBJ)rgn);
+             return;
+         }
+-        char* buffer = new char[size];
++        char* buffer = new char[size]; // safe because sizeof(char)==1
+         memset(buffer, 0, size);
+         LPRGNDATA rgndata = (LPRGNDATA)buffer;
+         rgndata->rdh.dwSize = sizeof(RGNDATAHEADER);
+@@ -6314,18 +6314,30 @@
+     c = (AwtComponent *)pData;
+     if (::IsWindow(c->GetHWnd())) {
+         HRGN hRgn = NULL;
+-        if (region || x1 || x2 || y1 || y2) {
++
+             // If all the params are zeros, the shape must be simply reset.
+             // Otherwise, convert it into a region.
+-            RGNDATA *pRgnData = NULL;
+-            RGNDATAHEADER *pRgnHdr;
++        if (region || x1 || x2 || y1 || y2) {
++	    RECT_T rects[256];
++	    RECT_T *pRect = rects;
+ 
+-            /* reserving memory for the worst case */
+-            size_t worstBufferSize = size_t(((x2 - x1) / 2 + 1) * (y2 - y1));
+-            pRgnData = (RGNDATA *) safe_Malloc(sizeof(RGNDATAHEADER) +
+-                    sizeof(RECT_T) * worstBufferSize);
+-            pRgnHdr = (RGNDATAHEADER *) pRgnData;
++	    const int numrects = RegionToYXBandedRectangles(env, x1, y1, x2, y2,
++                        region, &pRect, sizeof(rects)/sizeof(rects[0]));
++	    if (!pRect) {
++		// RegionToYXBandedRectangles doesn't use safe_Malloc(),
++		// so throw the exception explicitly
++		throw std::bad_alloc();
++	    }
++
++	    RGNDATA *pRgnData = (RGNDATA *) SAFE_SIZE_STRUCT_ALLOC(safe_Malloc,
++                        sizeof(RGNDATAHEADER), sizeof(RECT_T), numrects);
++	    memcpy(pRgnData + sizeof(RGNDATAHEADER), pRect, sizeof(RECT_T) * numrects);
++	    if (pRect != rects) {
++		free(pRect);
++	    }
++	    pRect = NULL;
+ 
++	    RGNDATAHEADER *pRgnHdr = (RGNDATAHEADER *) pRgnData;
+             pRgnHdr->dwSize = sizeof(RGNDATAHEADER);
+             pRgnHdr->iType = RDH_RECTANGLES;
+             pRgnHdr->nRgnSize = 0;
+@@ -6333,9 +6345,7 @@
+             pRgnHdr->rcBound.left = 0;
+             pRgnHdr->rcBound.bottom = LONG(y2 - y1);
+             pRgnHdr->rcBound.right = LONG(x2 - x1);
+-
+-            RECT_T * pRect = (RECT_T *) (((BYTE *) pRgnData) + sizeof(RGNDATAHEADER));
+-            pRgnHdr->nCount = RegionToYXBandedRectangles(env, x1, y1, x2, y2, region, &pRect, worstBufferSize);
++            pRgnHdr->nCount = numrects;
+ 
+             hRgn = ::ExtCreateRegion(NULL,
+                     sizeof(RGNDATAHEADER) + sizeof(RECT_T) * pRgnHdr->nCount, pRgnData);
+@@ -7344,3 +7354,4 @@
+         delete tmpDCList;
+     }
+ }
++
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/awt_Cursor.cpp openjdk/jdk/src/windows/native/sun/windows/awt_Cursor.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_Cursor.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/awt_Cursor.cpp	2013-06-22 03:34:36.266702881 -0500
+@@ -379,14 +379,14 @@
+         return;
+     }
+ 
+-    int length = env->GetArrayLength(andMask);
+-    jbyte *andMaskPtr = new jbyte[length];
++    jsize length = env->GetArrayLength(andMask);
++    jbyte *andMaskPtr = new jbyte[length]; // safe because sizeof(jbyte)==1
+     env->GetByteArrayRegion(andMask, 0, length, andMaskPtr);
+ 
+     HBITMAP hMask = ::CreateBitmap(nW, nH, 1, 1, (BYTE *)andMaskPtr);
+     ::GdiFlush();
+ 
+-    int *cols = new int[nW*nH];
++    int *cols = SAFE_SIZE_NEW_ARRAY2(int, nW, nH);
+ 
+     jint *intRasterDataPtr = NULL;
+     HBITMAP hColor = NULL;
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/awt_DataTransferer.cpp openjdk/jdk/src/windows/native/sun/windows/awt_DataTransferer.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_DataTransferer.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/awt_DataTransferer.cpp	2013-06-22 10:32:57.350451069 -0500
+@@ -284,13 +284,13 @@
+         }
+ 
+         UINT bufsize = 512; // in characters, not in bytes
+-        buffer = (LPTSTR)safe_Malloc(bufsize*sizeof(TCHAR));
++        buffer = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, bufsize, sizeof(TCHAR));
+ 
+         for (UINT i = 0; i < nFilenames; i++) {
+             UINT size = (*do_drag_query_file)(hdrop, i, NULL, 0);
+             if (size > bufsize) {
+                 bufsize = size;
+-                buffer = (LPTSTR)safe_Realloc(buffer, bufsize*sizeof(TCHAR));
++                buffer = (LPTSTR)SAFE_SIZE_ARRAY_REALLOC(safe_Realloc, buffer, bufsize, sizeof(TCHAR));
+             }
+             (*do_drag_query_file)(hdrop, i, buffer, bufsize);
+ 
+@@ -362,7 +362,7 @@
+         return NULL;
+     }
+ 
+-    jbyte* bBytes = (jbyte*)safe_Malloc(size * sizeof(jbyte));
++    jbyte* bBytes = (jbyte*)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, size, sizeof(jbyte));
+ 
+     try {
+ 
+@@ -779,9 +779,9 @@
+                         } else {
+                             LPBYTE lpbMfBuffer = NULL;
+                             try {
+-                                UINT uMfSizeWithHead = uMfSize + sizeof(METAFILEPICT);
+-
+-                                lpbMfBuffer = (LPBYTE)safe_Malloc(uMfSizeWithHead);
++                                lpbMfBuffer = (LPBYTE)SAFE_SIZE_STRUCT_ALLOC(safe_Malloc,
++                                        sizeof(METAFILEPICT), uMfSize, 1);
++                                const UINT uMfSizeWithHead = uMfSize + sizeof(METAFILEPICT);
+                                 VERIFY(::GetMetaFileBitsEx(hmf, uMfSize,
+                                                             lpbMfBuffer + sizeof(METAFILEPICT)) == uMfSize);
+                                 bytes = env->NewByteArray(uMfSizeWithHead);
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp openjdk/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	2013-06-22 03:34:36.267702882 -0500
+@@ -174,7 +174,7 @@
+     if (*valueType == REG_EXPAND_SZ) {
+         // Pending: buffer must be null-terminated at this point
+         valueChar = ExpandEnvironmentStrings(buffer, NULL, 0);
+-        LPTSTR buffer2 = (LPTSTR)safe_Malloc(valueChar*sizeof(TCHAR));
++        LPTSTR buffer2 = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, valueChar, sizeof(TCHAR));
+         ExpandEnvironmentStrings(buffer, buffer2, valueChar);
+         free(buffer);
+         return buffer2;
+@@ -604,11 +604,11 @@
+     }
+ 
+     LPTSTR valueName = TEXT("PlaceN");
+-    LPTSTR valueNameBuf = (LPTSTR)safe_Malloc((lstrlen(valueName) + 1) * sizeof(TCHAR));
++    LPTSTR valueNameBuf = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, (lstrlen(valueName) + 1), sizeof(TCHAR));
+     lstrcpy(valueNameBuf, valueName);
+ 
+     LPTSTR propKey = TEXT("win.comdlg.placesBarPlaceN");
+-    LPTSTR propKeyBuf = (LPTSTR)safe_Malloc((lstrlen(propKey) + 1) * sizeof(TCHAR));
++    LPTSTR propKeyBuf = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, (lstrlen(propKey) + 1), sizeof(TCHAR));
+     lstrcpy(propKeyBuf, propKey);
+ 
+     int i = 0;
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/awt_DnDDT.cpp openjdk/jdk/src/windows/native/sun/windows/awt_DnDDT.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_DnDDT.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/awt_DnDDT.cpp	2013-06-22 03:34:36.267702882 -0500
+@@ -815,8 +815,8 @@
+         if (m_dataObject->QueryGetData(&tmp) != S_OK) continue;
+ 
+         if (m_nformats % CACHE_INCR == 0) {
+-            m_formats = (FORMATETC *)safe_Realloc(m_formats,
+-                                                  (CACHE_INCR + m_nformats) *
++            m_formats = (FORMATETC *)SAFE_SIZE_ARRAY_REALLOC(safe_Realloc, m_formats,
++                                                  CACHE_INCR + m_nformats,
+                                                   sizeof(FORMATETC));
+         }
+ 
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/awt_InputMethod.cpp openjdk/jdk/src/windows/native/sun/windows/awt_InputMethod.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_InputMethod.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/awt_InputMethod.cpp	2013-06-22 03:34:36.267702882 -0500
+@@ -334,7 +334,7 @@
+     // list which is returned by GetKeyboardLayoutList ensures to match first when
+     // looking up suitable layout.
+     int layoutCount = ::GetKeyboardLayoutList(0, NULL) + 1;  // +1 for user's preferred HKL
+-    HKL FAR * hKLList = (HKL FAR *)safe_Malloc(sizeof(HKL)*layoutCount);
++    HKL FAR * hKLList = (HKL FAR *)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(HKL), layoutCount);
+     DASSERT(!safe_ExceptionOccurred(env));
+     ::GetKeyboardLayoutList(layoutCount - 1, &(hKLList[1]));
+     hKLList[0] = getDefaultKeyboardLayout(); // put user's preferred layout on top of the list
+@@ -438,7 +438,7 @@
+ 
+     // get list of available HKLs
+     int layoutCount = ::GetKeyboardLayoutList(0, NULL);
+-    HKL FAR * hKLList = (HKL FAR *)safe_Malloc(sizeof(HKL)*layoutCount);
++    HKL FAR * hKLList = (HKL FAR *)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(HKL), layoutCount);
+     DASSERT(!safe_ExceptionOccurred(env));
+     ::GetKeyboardLayoutList(layoutCount, hKLList);
+ 
+@@ -447,7 +447,7 @@
+     int destIndex = 0;
+     int javaLocaleNameCount = 0;
+     int current = 0;
+-    const char ** javaLocaleNames = (const char **)safe_Malloc(sizeof(char *)*layoutCount);
++    const char ** javaLocaleNames = (const char **)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(char *), layoutCount);
+     DASSERT(!safe_ExceptionOccurred(env));
+     for (; srcIndex < layoutCount; srcIndex++) {
+         const char * srcLocaleName = getJavaIDFromLangID(LOWORD(hKLList[srcIndex]));
+@@ -510,7 +510,7 @@
+     jstring infojStr = NULL;
+ 
+     if ((buffSize = ::ImmGetDescription(hkl, szImmDescription, 0)) > 0) {
+-        szImmDescription = (LPTSTR) safe_Malloc(buffSize * sizeof(TCHAR));
++        szImmDescription = (LPTSTR) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, (buffSize+1), sizeof(TCHAR));
+ 
+         if (szImmDescription != NULL) {
+             ImmGetDescription(hkl, szImmDescription, buffSize);
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/awt_PrintControl.cpp openjdk/jdk/src/windows/native/sun/windows/awt_PrintControl.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_PrintControl.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/awt_PrintControl.cpp	2013-06-22 03:34:36.267702882 -0500
+@@ -502,8 +502,8 @@
+                                               NULL, NULL);
+ 
+     if (numPaperSizes > 0) {
+-        papers = (WORD*)safe_Malloc(sizeof(WORD) * numPaperSizes);
+-        paperSizes = (POINT *)safe_Malloc(sizeof(*paperSizes) *
++        papers = (WORD*)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(WORD), numPaperSizes);
++        paperSizes = (POINT *)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(*paperSizes),
+                                           numPaperSizes);
+ 
+         DWORD result1 = DeviceCapabilities(printer, port,
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp openjdk/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp	2013-06-22 03:34:36.268702883 -0500
+@@ -433,7 +433,7 @@
+         int measure = PSD_INTHOUSANDTHSOFINCHES;
+         int sz = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, NULL, 0);
+         if (sz > 0) {
+-          LPTSTR str = (LPTSTR)safe_Malloc(sizeof(TCHAR) * sz);
++          LPTSTR str = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(TCHAR), sz);
+           if (str != NULL) {
+             sz = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, str, sz);
+             if (sz > 0) {
+@@ -643,7 +643,7 @@
+           int sz = GetLocaleInfo(LOCALE_USER_DEFAULT,
+                                  LOCALE_IMEASURE, NULL, 0);
+           if (sz > 0) {
+-            LPTSTR str = (LPTSTR)safe_Malloc(sizeof(TCHAR) * sz);
++            LPTSTR str = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(TCHAR), sz);
+             if (str != NULL) {
+               sz = GetLocaleInfo(LOCALE_USER_DEFAULT,
+                                  LOCALE_IMEASURE, str, sz);
+@@ -2314,8 +2314,8 @@
+      * rounded advances will drift away from the true advance.
+      */
+     if (glyphPos != NULL && strLen > 0) {
+-         xadvances = (int*)safe_Malloc(strLen * sizeof(int));
+-         xyadvances = (int*)safe_Malloc(strLen * sizeof(int) * 2);
++         xadvances = (int*)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, strLen, sizeof(int));
++         xyadvances = (int*)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, strLen, sizeof(int) * 2);
+     }
+     if (xadvances != NULL && xyadvances != NULL) {
+         int *inxAdvances = xadvances;
+@@ -2523,8 +2523,9 @@
+     if ((imgWidthByteSz % sizeof(DWORD)) != 0)
+         padBytes = sizeof(DWORD) - (imgWidthByteSz % sizeof(DWORD));
+ 
++    jbyte* alignedImage = (jbyte*) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc,
++            imgWidthByteSz+padBytes, ROUND_TO_LONG(srcHeight));
+     long newImgSize = (imgWidthByteSz+padBytes) * ROUND_TO_LONG(srcHeight);
+-    jbyte* alignedImage = (jbyte*) safe_Malloc(newImgSize);
+ 
+     if (alignedImage != NULL) {
+         memset(alignedImage, 0xff, newImgSize);
+@@ -3122,7 +3123,7 @@
+                                        DC_PAPERSIZE, NULL, NULL);
+ 
+     if (numPaperSizes > 0) {
+-        paperSizes = (POINT *)safe_Malloc(sizeof(*paperSizes) * numPaperSizes);
++        paperSizes = (POINT *)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(*paperSizes), numPaperSizes);
+ 
+         DWORD result = DeviceCapabilities(deviceName, portName,
+                                           DC_PAPERSIZE, (LPTSTR) paperSizes,
+@@ -3770,8 +3771,8 @@
+     numPaperSizes = (int)DeviceCapabilities(printer, port, DC_PAPERSIZE,
+                                             NULL, NULL);
+     if (numPaperSizes > 0) {
+-        papers = (WORD*)safe_Malloc(sizeof(WORD) * numPaperSizes);
+-        paperSizes = (POINT *)safe_Malloc(sizeof(*paperSizes) * numPaperSizes);
++        papers = (WORD*)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(WORD), numPaperSizes);
++        paperSizes = (POINT *)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(*paperSizes), numPaperSizes);
+ 
+         DWORD result1 = DeviceCapabilities(printer, port,
+                                            DC_PAPERS, (LPTSTR) papers, NULL);
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/awt_Robot.cpp openjdk/jdk/src/windows/native/sun/windows/awt_Robot.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/awt_Robot.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/awt_Robot.cpp	2013-06-22 03:34:36.268702883 -0500
+@@ -234,7 +234,9 @@
+     static const int BITS_PER_PIXEL = 32;
+     static const int BYTES_PER_PIXEL = BITS_PER_PIXEL/8;
+ 
++    if (!IS_SAFE_SIZE_MUL(width, height)) throw std::bad_alloc();
+     int numPixels = width*height;
++    if (!IS_SAFE_SIZE_MUL(BYTES_PER_PIXEL, numPixels)) throw std::bad_alloc();
+     int pixelDataSize = BYTES_PER_PIXEL*numPixels;
+     DASSERT(pixelDataSize > 0 && pixelDataSize % 4 == 0);
+     // allocate memory for BITMAPINFO + pixel data
+@@ -244,6 +246,9 @@
+     // end of our block of memory.  Now we allocate sufficient memory.
+     // See MSDN docs for BITMAPINFOHEADER -bchristi
+ 
++    if (!IS_SAFE_SIZE_ADD(sizeof(BITMAPINFOHEADER) + 3 * sizeof(RGBQUAD), pixelDataSize)) {
++        throw std::bad_alloc();
++    }
+     BITMAPINFO * pinfo = (BITMAPINFO *)(new BYTE[sizeof(BITMAPINFOHEADER) + 3 * sizeof(RGBQUAD) + pixelDataSize]);
+ 
+     // pixel data starts after 3 RGBQUADS for color masks
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/CmdIDList.cpp openjdk/jdk/src/windows/native/sun/windows/CmdIDList.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/CmdIDList.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/CmdIDList.cpp	2013-06-22 03:34:36.263702878 -0500
+@@ -39,7 +39,7 @@
+ {
+     m_capacity = ARRAY_INITIAL_SIZE;
+     m_first_free = -1;
+-    m_array = (CmdIDEntry *)safe_Malloc(m_capacity * sizeof(AwtObject*));
++    m_array = (CmdIDEntry *)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, m_capacity, sizeof(AwtObject*));
+     BuildFreeList(0);
+ }
+ 
+@@ -80,8 +80,8 @@
+             m_capacity += ARRAY_SIZE_INCREMENT;
+             if (m_capacity > ARRAY_MAXIMUM_SIZE)
+                 m_capacity = ARRAY_MAXIMUM_SIZE;
+-            m_array = (CmdIDEntry *)safe_Realloc(m_array,
+-                                        m_capacity * sizeof(CmdIDEntry*));
++            m_array = (CmdIDEntry *)SAFE_SIZE_ARRAY_REALLOC(safe_Realloc, m_array,
++                                        m_capacity, sizeof(CmdIDEntry*));
+             BuildFreeList(old_capacity);
+         }
+     }
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/Devices.cpp openjdk/jdk/src/windows/native/sun/windows/Devices.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/Devices.cpp	2013-06-22 15:43:08.377839847 -0500
++++ openjdk/jdk/src/windows/native/sun/windows/Devices.cpp	2013-06-22 10:32:18.591315108 -0500
+@@ -97,8 +97,8 @@
+     J2dTraceLn1(J2D_TRACE_INFO, "Devices::Devices numDevices=%d", numDevices);
+     this->numDevices = numDevices;
+     this->refCount = 0;
+-    devices = (AwtWin32GraphicsDevice**)safe_Malloc
+-        (numDevices * sizeof(AwtWin32GraphicsDevice *));
++    devices = (AwtWin32GraphicsDevice**)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc,
++        numDevices, sizeof(AwtWin32GraphicsDevice *));
+ }
+ 
+ /**
+@@ -114,7 +114,8 @@
+     J2dTraceLn(J2D_TRACE_INFO, "Devices::UpdateInstance");
+ 
+     int numScreens = ::CountMonitors();
+-    MHND *monHds = (MHND *)safe_Malloc(numScreens * sizeof(MHND));
++    MHND *monHds = (MHND *)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc,
++            numScreens, sizeof(MHND));
+     if (numScreens != ::CollectMonitors(monHds, numScreens)) {
+         J2dRlsTraceLn(J2D_TRACE_ERROR,
+                       "Devices::UpdateInstance: Failed to get all "\
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/ShellFolder2.cpp openjdk/jdk/src/windows/native/sun/windows/ShellFolder2.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/ShellFolder2.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/ShellFolder2.cpp	2013-06-22 03:34:36.264702879 -0500
+@@ -385,6 +385,9 @@
+     if (cb == 0)
+         return 0;
+ 
++    if (!IS_SAFE_SIZE_ADD(cb, sizeof(SHITEMID))) {
++        return 0;
++    }
+     // Allocate space for this as well as null-terminating entry.
+     LPITEMIDLIST newPIDL = (LPITEMIDLIST)pMalloc->Alloc(cb + sizeof(SHITEMID));
+ 
+@@ -425,6 +428,9 @@
+     int len1 = pidlLength(parentPIDL);
+     int len2 = pidlLength(relativePIDL);
+ 
++    if (!IS_SAFE_SIZE_ADD(len1, len2) || !IS_SAFE_SIZE_ADD(len1 + len2, sizeof(SHITEMID))) {
++        return 0;
++    }
+     LPITEMIDLIST newPIDL = (LPITEMIDLIST)pMalloc->Alloc(len1 + len2 + sizeof(SHITEMID));
+     memcpy(newPIDL, parentPIDL, len1);
+     memcpy(((LPBYTE) newPIDL) + len1, relativePIDL, len2);
+diff -Nru openjdk.orig/jdk/src/windows/native/sun/windows/WPrinterJob.cpp openjdk/jdk/src/windows/native/sun/windows/WPrinterJob.cpp
+--- openjdk.orig/jdk/src/windows/native/sun/windows/WPrinterJob.cpp	2011-11-14 16:12:18.000000000 -0600
++++ openjdk/jdk/src/windows/native/sun/windows/WPrinterJob.cpp	2013-06-22 10:38:43.325646229 -0500
+@@ -872,7 +872,7 @@
+       int numSizes = ::DeviceCapabilities(printerName, printerPort,
+                                           DC_PAPERS, NULL, NULL);
+       if (numSizes > 0) {
+-          LPWORD papers = (LPWORD)safe_Malloc(numSizes * sizeof(WORD));
++          LPWORD papers = (LPWORD)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, numSizes, sizeof(WORD));
+           if (papers != NULL &&
+               ::DeviceCapabilities(printerName, printerPort,
+                                    DC_PAPERS, papers, NULL) != -1) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8009235-improve_tsa_data_handling.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,80 @@
+# HG changeset patch
+# User andrew
+# Date 1371556240 18000
+# Node ID 97f318cdfb834385beb7370348582daebccc8987
+# Parent  3bb3933b9704ad855b64933be52c6aa252a04d83
+8009235: Improve handling of TSA data
+Reviewed-by: ahgross, mullan
+
+diff --git a/src/share/classes/sun/security/timestamp/TimestampToken.java b/src/share/classes/sun/security/timestamp/TimestampToken.java
+--- openjdk/jdk/src/share/classes/sun/security/timestamp/TimestampToken.java
++++ openjdk/jdk/src/share/classes/sun/security/timestamp/TimestampToken.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -115,6 +115,10 @@
+         return nonce;
+     }
+ 
++    public BigInteger getSerialNumber() {
++        return serialNumber;
++    }
++
+     /*
+      * Parses the timestamp token info.
+      *
+diff --git a/src/share/classes/sun/security/util/SignatureFileVerifier.java b/src/share/classes/sun/security/util/SignatureFileVerifier.java
+--- openjdk/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java
++++ openjdk/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -541,6 +541,8 @@
+                 // Create a timestamp token info object
+                 TimestampToken timestampTokenInfo =
+                     new TimestampToken(encodedTimestampTokenInfo);
++                // Check that the signature timestamp applies to this signature
++                verifyTimestamp(timestampTokenInfo, info.getEncryptedDigest());
+                 // Create a timestamp object
+                 timestamp =
+                     new Timestamp(timestampTokenInfo.getDate(), tsaChain);
+@@ -549,6 +551,31 @@
+         return timestamp;
+     }
+ 
++    /*
++     * Check that the signature timestamp applies to this signature.
++     * Match the hash present in the signature timestamp token against the hash
++     * of this signature.
++     */
++    private void verifyTimestamp(TimestampToken token, byte[] signature)
++        throws NoSuchAlgorithmException, SignatureException {
++
++        MessageDigest md =
++            MessageDigest.getInstance(token.getHashAlgorithm().getName());
++
++        if (!Arrays.equals(token.getHashedMessage(), md.digest(signature))) {
++            throw new SignatureException("Signature timestamp (#" +
++                token.getSerialNumber() + ") generated on " + token.getDate() +
++                " is inapplicable");
++        }
++
++        if (debug != null) {
++            debug.println();
++            debug.println("Detected signature timestamp (#" +
++                token.getSerialNumber() + ") generated on " + token.getDate());
++            debug.println();
++        }
++    }
++
+     // for the toHex function
+     private static final char[] hexc =
+             {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8009554-serialjavaobject.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,78 @@
+# HG changeset patch
+# User andrew
+# Date 1371556350 18000
+# Node ID 5fcac0fe0ace5584b980a35afb582519f8434617
+# Parent  97f318cdfb834385beb7370348582daebccc8987
+8009554: Improve SerialJavaObject.getFields
+Reviewed-by: alanb, skoivu
+
+diff --git a/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java b/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java
+--- openjdk/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java
++++ openjdk/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -30,6 +30,7 @@
+ import java.util.Map;
+ import java.lang.reflect.*;
+ import javax.sql.rowset.RowSetWarning;
++import sun.reflect.Reflection;
+ 
+ /**
+  * A serializable mapping in the Java programming language of an SQL
+@@ -136,10 +137,12 @@
+      * @return an array of <code>Field</code> objects
+      * @throws SerialException if an error is encountered accessing
+      * the serialized object
++     * @see Class#getFields
+      */
+     public Field[] getFields() throws SerialException {
+         if (fields != null) {
+             Class c = this.obj.getClass();
++            checkPackageAccess(c);
+             //the following has to be commented before mustang integration
+             //return c.getFields();
+             //the following has to be uncommented before mustang integration
+@@ -172,4 +175,38 @@
+         }
+         chain.add(e);
+     }
++
++    /*
++     * Check if the caller is allowed to access the specified class's package.  If access is denied,
++     * throw a SecurityException.
++     *
++     */
++    private void checkPackageAccess(Class<?> clz) {
++        SecurityManager s = System.getSecurityManager();
++        if (s != null) {
++            if (sun.reflect.misc.ReflectUtil.needsPackageAccessCheck(
++                    getCallerClassLoader(), clz.getClassLoader())) {
++                String name = clz.getName();
++                int i = name.lastIndexOf('.');
++                if (i != -1) {
++                    s.checkPackageAccess(name.substring(0, i));
++                }
++            }
++        }
++    }
++
++    /* Internal method used to get the caller's caller class loader.
++     * Caution is required if you attempt to make changes as this method assumes
++     * the following stack frame count:
++     * 0: Reflection
++     * 1: getCallerClassLoader
++     * 2: checkPackageAccess
++     * 3: getFields
++     * 4: caller of getFields
++     */
++    private static ClassLoader getCallerClassLoader() {
++        Class<?> cc = Reflection.getCallerClass(4);
++        ClassLoader cl = (cc != null) ? cc.getClassLoader() : null;
++        return cl;
++    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8011243-improve_imaginglib.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,618 @@
+# HG changeset patch
+# User bae
+# Date 1365505409 -14400
+# Node ID 8d4760ec16ecfc5abb647dfb1a28d5b3c01f6a12
+# Parent  0f5e355fe68c0ff29e28a962199185e4bd3d7e04
+8011243: Improve ImagingLib
+Reviewed-by: mschoene, prr, vadim
+
+diff --git a/src/share/native/sun/awt/medialib/awt_ImagingLib.c b/src/share/native/sun/awt/medialib/awt_ImagingLib.c
+--- openjdk/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
++++ openjdk/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
+@@ -1152,22 +1152,127 @@
+     return retStatus;
+ }
+ 
++typedef struct {
++    jobject jArray;
++    jsize length;
++    unsigned char *table;
++} LookupArrayInfo;
++
++#define NLUT 8
++
++#ifdef _LITTLE_ENDIAN
++#define INDEXES    { 3, 2, 1, 0, 7, 6, 5, 4 }
++#else
++#define INDEXES    { 0, 1, 2, 3, 4, 5, 6, 7 }
++#endif
++
++static int lookupShortData(mlib_image* src, mlib_image* dst,
++    LookupArrayInfo* lookup)
++{
++    int x, y;
++    unsigned int mask = NLUT-1;
++
++    unsigned short* srcLine = (unsigned short*)src->data;
++    unsigned char* dstLine = (unsigned char*)dst->data;
++
++    static int indexes[NLUT] = INDEXES;
++
++    for (y=0; y < src->height; y++) {
++        int nloop, nx;
++        int npix = src->width;
++
++        unsigned short* srcPixel = srcLine;
++        unsigned char* dstPixel = dstLine;
++
++#ifdef SIMPLE_LOOKUP_LOOP
++        for (x=0; status && x < width; x++) {
++            unsigned short s = *srcPixel++;
++            if (s >= lookup->length) {
++                /* we can not handle source image using
++                * byte lookup table. Fall back to processing
++                * images in java
++                */
++                return 0;
++            }
++            *dstPixel++ = lookup->table[s];
++        }
++#else
++        /* Get to 32 bit-aligned point */
++        while(((uintptr_t)dstPixel & 0x3) != 0 && npix>0) {
++            unsigned short s = *srcPixel++;
++            if (s >= lookup->length) {
++                return 0;
++            }
++            *dstPixel++ = lookup->table[s];
++            npix--;
++        }
++
++        /*
++         * Do NLUT pixels per loop iteration.
++         * Pack into ints and write out 2 at a time.
++         */
++        nloop = npix/NLUT;
++        nx = npix%NLUT;
++
++        for(x=nloop; x!=0; x--) {
++            int i = 0;
++            int* dstP = (int*)dstPixel;
++
++            for (i = 0; i < NLUT; i++) {
++                if (srcPixel[i] >= lookup->length) {
++                    return 0;
++                }
++            }
++
++            dstP[0] = (int)
++                ((lookup->table[srcPixel[indexes[0]]] << 24) |
++                 (lookup->table[srcPixel[indexes[1]]] << 16) |
++                 (lookup->table[srcPixel[indexes[2]]] << 8)  |
++                  lookup->table[srcPixel[indexes[3]]]);
++            dstP[1] = (int)
++                ((lookup->table[srcPixel[indexes[4]]] << 24) |
++                 (lookup->table[srcPixel[indexes[5]]] << 16) |
++                 (lookup->table[srcPixel[indexes[6]]] << 8)  |
++                  lookup->table[srcPixel[indexes[7]]]);
++
++
++            dstPixel += NLUT;
++            srcPixel += NLUT;
++        }
++
++        /*
++         * Complete any remaining pixels
++         */
++        for(x=nx; x!=0; x--) {
++            unsigned short s = *srcPixel++;
++            if (s >= lookup->length) {
++                return 0;
++            }
++            *dstPixel++ = lookup->table[s];
++        }
++#endif
++
++        dstLine += dst->stride;     // array of bytes, scan stride in bytes
++        srcLine += src->stride / 2; // array of shorts, scan stride in bytes
++    }
++    return 1;
++}
++
+ JNIEXPORT jint JNICALL
+-Java_sun_awt_image_ImagingLib_lookupByteBI(JNIEnv *env, jobject this,
++Java_sun_awt_image_ImagingLib_lookupByteBI(JNIEnv *env, jobject thisLib,
+                                            jobject jsrc, jobject jdst,
+                                            jobjectArray jtableArrays)
+ {
+     mlib_image *src;
+     mlib_image *dst;
+     void *sdata, *ddata;
+-    unsigned char **table;
+     unsigned char **tbl;
+     unsigned char lut[256];
+     int retStatus = 1;
+     int i;
+     mlib_status status;
+-    int jlen;
+-    jobject *jtable;
++    int lut_nbands;
++    LookupArrayInfo *jtable;
+     BufImageS_t *srcImageP, *dstImageP;
+     int nbands;
+     int ncomponents;
+@@ -1193,12 +1298,29 @@
+         return 0;
+     }
+ 
+-    jlen = (*env)->GetArrayLength(env, jtableArrays);
++    lut_nbands = (*env)->GetArrayLength(env, jtableArrays);
+ 
+     ncomponents = srcImageP->cmodel.isDefaultCompatCM
+         ? 4
+         : srcImageP->cmodel.numComponents;
+ 
++    if (lut_nbands > ncomponents) {
++        lut_nbands = ncomponents;
++    }
++
++    /* Make sure that color order can be used for
++     * re-ordering of lookup arrays.
++     */
++    for (i = 0; i < ncomponents; i++) {
++        int idx = srcImageP->hints.colorOrder[i];
++
++        if (idx < 0 || idx >= ncomponents) {
++            awt_freeParsedImage(srcImageP, TRUE);
++            awt_freeParsedImage(dstImageP, TRUE);
++            return 0;
++        }
++    }
++
+     tbl = NULL;
+     if (SAFE_TO_ALLOC_2(ncomponents, sizeof(unsigned char *))) {
+         tbl = (unsigned char **)
+@@ -1206,18 +1328,12 @@
+     }
+ 
+     jtable = NULL;
+-    if (SAFE_TO_ALLOC_2(jlen, sizeof(jobject *))) {
+-        jtable = (jobject *)malloc(jlen * sizeof (jobject *));
++    if (SAFE_TO_ALLOC_2(lut_nbands, sizeof(LookupArrayInfo))) {
++        jtable = (LookupArrayInfo *)malloc(lut_nbands * sizeof (LookupArrayInfo));
+     }
+ 
+-    table = NULL;
+-    if (SAFE_TO_ALLOC_2(jlen, sizeof(unsigned char *))) {
+-        table = (unsigned char **)malloc(jlen * sizeof(unsigned char *));
+-    }
+-
+-    if (tbl == NULL || table == NULL || jtable == NULL) {
++    if (tbl == NULL || jtable == NULL) {
+         if (tbl != NULL) free(tbl);
+-        if (table != NULL) free(table);
+         if (jtable != NULL) free(jtable);
+         awt_freeParsedImage(srcImageP, TRUE);
+         awt_freeParsedImage(dstImageP, TRUE);
+@@ -1225,11 +1341,21 @@
+         return 0;
+     }
+     /* Need to grab these pointers before we lock down arrays */
+-    for (i=0; i < jlen; i++) {
+-        jtable[i] = (*env)->GetObjectArrayElement(env, jtableArrays, i);
+-        if (jtable[i] == NULL) {
++    for (i=0; i < lut_nbands; i++) {
++        jtable[i].jArray = (*env)->GetObjectArrayElement(env, jtableArrays, i);
++
++        if (jtable[i].jArray != NULL) {
++            jtable[i].length = (*env)->GetArrayLength(env, jtable[i].jArray);
++            jtable[i].table = NULL;
++
++            if (jtable[i].length < 256) {
++                /* we may read outside the table during lookup */
++                jtable[i].jArray = NULL;
++                jtable[i].length = 0;
++            }
++        }
++        if (jtable[i].jArray == NULL) {
+             free(tbl);
+-            free(table);
+             free(jtable);
+             awt_freeParsedImage(srcImageP, TRUE);
+             awt_freeParsedImage(dstImageP, TRUE);
+@@ -1242,7 +1368,6 @@
+     if (nbands < 1) {
+         /* Can't handle any custom images */
+         free(tbl);
+-        free(table);
+         free(jtable);
+         awt_freeParsedImage(srcImageP, TRUE);
+         awt_freeParsedImage(dstImageP, TRUE);
+@@ -1253,7 +1378,6 @@
+     if (allocateArray(env, srcImageP, &src, &sdata, TRUE, FALSE, FALSE) < 0) {
+         /* Must be some problem */
+         free(tbl);
+-        free(table);
+         free(jtable);
+         awt_freeParsedImage(srcImageP, TRUE);
+         awt_freeParsedImage(dstImageP, TRUE);
+@@ -1262,7 +1386,6 @@
+     if (allocateArray(env, dstImageP, &dst, &ddata, FALSE, FALSE, FALSE) < 0) {
+         /* Must be some problem */
+         free(tbl);
+-        free(table);
+         free(jtable);
+         freeArray(env, srcImageP, src, sdata, NULL, NULL, NULL);
+         awt_freeParsedImage(srcImageP, TRUE);
+@@ -1278,7 +1401,7 @@
+      * sufficient number of lookup arrays we add references to identity
+      * lookup array to make medialib happier.
+      */
+-    if (jlen < ncomponents) {
++    if (lut_nbands < ncomponents) {
+         int j;
+         /* REMIND: This should be the size of the input lut!! */
+         for (j=0; j < 256; j++) {
+@@ -1287,65 +1410,45 @@
+         for (j=0; j < ncomponents; j++) {
+             tbl[j] = lut;
+         }
+-
+     }
+ 
+-    for (i=0; i < jlen; i++) {
+-        table[i] = (unsigned char *)
+-            (*env)->GetPrimitiveArrayCritical(env, jtable[i], NULL);
+-        if (table[i] == NULL) {
++    for (i=0; i < lut_nbands; i++) {
++        jtable[i].table = (unsigned char *)
++            (*env)->GetPrimitiveArrayCritical(env, jtable[i].jArray, NULL);
++        if (jtable[i].table == NULL) {
+             /* Free what we've got so far. */
+             int j;
+             for (j = 0; j < i; j++) {
+                 (*env)->ReleasePrimitiveArrayCritical(env,
+-                                                      jtable[j],
+-                                                      (jbyte *) table[j],
++                                                      jtable[j].jArray,
++                                                      (jbyte *) jtable[j].table,
+                                                       JNI_ABORT);
+             }
+             free(tbl);
+-            free(table);
+             free(jtable);
+             freeArray(env, srcImageP, src, sdata, NULL, NULL, NULL);
+             awt_freeParsedImage(srcImageP, TRUE);
+             awt_freeParsedImage(dstImageP, TRUE);
+             return 0;
+         }
+-        tbl[srcImageP->hints.colorOrder[i]] = table[i];
++        tbl[srcImageP->hints.colorOrder[i]] = jtable[i].table;
+     }
+ 
+-    if (jlen == 1) {
++    if (lut_nbands == 1) {
+         for (i=1; i < nbands -
+                  srcImageP->cmodel.supportsAlpha; i++) {
+-            tbl[srcImageP->hints.colorOrder[i]] = table[0];
++                     tbl[srcImageP->hints.colorOrder[i]] = jtable[0].table;
+         }
+     }
+ 
+     /* Mlib needs 16bit lookuptable and must be signed! */
+     if (src->type == MLIB_SHORT) {
+-        unsigned short *sdataP = (unsigned short *) src->data;
+-        unsigned short *sP;
+         if (dst->type == MLIB_BYTE) {
+-            unsigned char *cdataP  = (unsigned char *)  dst->data;
+-            unsigned char *cP;
+             if (nbands > 1) {
+                 retStatus = 0;
+             }
+             else {
+-                int x, y;
+-                for (y=0; y < src->height; y++) {
+-                    cP = cdataP;
+-                    sP = sdataP;
+-                    for (x=0; x < src->width; x++) {
+-                        *cP++ = table[0][*sP++];
+-                    }
+-
+-                    /*
+-                     * 4554571: increment pointers using the scanline stride
+-                     * in pixel units (not byte units)
+-                     */
+-                    cdataP += dstImageP->raster.scanlineStride;
+-                    sdataP += srcImageP->raster.scanlineStride;
+-                }
++                retStatus = lookupShortData(src, dst, &jtable[0]);
+             }
+         }
+         /* How about ddata == null? */
+@@ -1370,12 +1473,11 @@
+     }
+ 
+     /* Release the LUT */
+-    for (i=0; i < jlen; i++) {
+-        (*env)->ReleasePrimitiveArrayCritical(env, jtable[i],
+-                                              (jbyte *) table[i], JNI_ABORT);
++    for (i=0; i < lut_nbands; i++) {
++        (*env)->ReleasePrimitiveArrayCritical(env, jtable[i].jArray,
++            (jbyte *) jtable[i].table, JNI_ABORT);
+     }
+     free ((void *) jtable);
+-    free ((void *) table);
+     free ((void *) tbl);
+ 
+     /* Release the pinned memory */
+@@ -1389,7 +1491,6 @@
+     return retStatus;
+ }
+ 
+-
+ JNIEXPORT jint JNICALL
+ Java_sun_awt_image_ImagingLib_lookupByteRaster(JNIEnv *env,
+                                                jobject this,
+@@ -1403,8 +1504,8 @@
+     mlib_image*    dst;
+     void*          sdata;
+     void*          ddata;
+-    jobject        jtable[4];
+-    unsigned char* table[4];
++    LookupArrayInfo jtable[4];
++    unsigned char* mlib_lookupTable[4];
+     int            i;
+     int            retStatus = 1;
+     mlib_status    status;
+@@ -1452,6 +1553,11 @@
+     src_nbands = srcRasterP->numBands;
+     dst_nbands = dstRasterP->numBands;
+ 
++    /* adjust number of lookup bands */
++    if (lut_nbands > src_nbands) {
++        lut_nbands = src_nbands;
++    }
++
+     /* MediaLib can't do more than 4 bands */
+     if (src_nbands <= 0 || src_nbands > 4 ||
+         dst_nbands <= 0 || dst_nbands > 4 ||
+@@ -1516,22 +1622,37 @@
+     /* Get references to the lookup table arrays */
+     /* Need to grab these pointers before we lock down arrays */
+     for (i=0; i < lut_nbands; i++) {
+-        jtable[i] = (*env)->GetObjectArrayElement(env, jtableArrays, i);
+-        if (jtable[i] == NULL) {
++        jtable[i].jArray = (*env)->GetObjectArrayElement(env, jtableArrays, i);
++        jtable[i].table = NULL;
++        if (jtable[i].jArray != NULL) {
++            jtable[i].length = (*env)->GetArrayLength(env, jtable[i].jArray);
++            if (jtable[i].length < 256) {
++                 /* we may read outside the table during lookup */
++                jtable[i].jArray = NULL;
++            }
++        }
++
++        if (jtable[i].jArray == NULL)
++        {
++            freeDataArray(env, srcRasterP->jdata, src, sdata,
++                          dstRasterP->jdata, dst, ddata);
++
++            awt_freeParsedRaster(srcRasterP, TRUE);
++            awt_freeParsedRaster(dstRasterP, TRUE);
+             return 0;
+         }
+     }
+ 
+     for (i=0; i < lut_nbands; i++) {
+-        table[i] = (unsigned char *)
+-            (*env)->GetPrimitiveArrayCritical(env, jtable[i], NULL);
+-        if (table[i] == NULL) {
++        jtable[i].table = (unsigned char *)
++            (*env)->GetPrimitiveArrayCritical(env, jtable[i].jArray, NULL);
++        if (jtable[i].table == NULL) {
+             /* Free what we've got so far. */
+             int j;
+             for (j = 0; j < i; j++) {
+                 (*env)->ReleasePrimitiveArrayCritical(env,
+-                                                      jtable[j],
+-                                                      (jbyte *) table[j],
++                                                      jtable[j].jArray,
++                                                      (jbyte *) jtable[j].table,
+                                                       JNI_ABORT);
+             }
+             freeDataArray(env, srcRasterP->jdata, src, sdata,
+@@ -1540,6 +1661,7 @@
+             awt_freeParsedRaster(dstRasterP, TRUE);
+             return 0;
+         }
++        mlib_lookupTable[i] = jtable[i].table;
+     }
+ 
+     /*
+@@ -1548,107 +1670,28 @@
+      * contains single lookup array.
+      */
+     for (i = lut_nbands; i < src_nbands; i++) {
+-        table[i] = table[0];
++        mlib_lookupTable[i] = jtable[0].table;
+     }
+ 
+     /*
+      * Setup lookup array for "extra" channels
+      */
+     for ( ; i < src->channels; i++) {
+-        table[i] = ilut;
++        mlib_lookupTable[i] = ilut;
+     }
+ 
+-#define NLUT 8
+     /* Mlib needs 16bit lookuptable and must be signed! */
+     if (src->type == MLIB_SHORT) {
+-        unsigned short *sdataP = (unsigned short *) src->data;
+-        unsigned short *sP;
+         if (dst->type == MLIB_BYTE) {
+-            unsigned char *cdataP  = (unsigned char *)  dst->data;
+-            unsigned char *cP;
+             if (lut_nbands > 1) {
+                 retStatus = 0;
+             } else {
+-                int x, y;
+-                unsigned int mask = NLUT-1;
+-                unsigned char* pLut = table[0];
+-                unsigned int endianTest = 0xff000000;
+-                for (y=0; y < src->height; y++) {
+-                    int nloop, nx;
+-                    unsigned short* srcP;
+-                    int* dstP;
+-                    int npix = src->width;
+-                    cP = cdataP;
+-                    sP = sdataP;
+-                    /* Get to 32 bit-aligned point */
+-                    while(((uintptr_t)cP & 0x3) != 0 && npix>0) {
+-                          *cP++ = pLut[*sP++];
+-                          npix--;
+-                    }
+-
+-                    /*
+-                     * Do NLUT pixels per loop iteration.
+-                     * Pack into ints and write out 2 at a time.
+-                     */
+-                    nloop = npix/NLUT;
+-                    nx = npix%NLUT;
+-                    srcP = sP;
+-                    dstP = (int*)cP;
+-
+-                    if(((char*)(&endianTest))[0] != 0) {
+-                        /* Big endian loop */
+-                        for(x=nloop; x!=0; x--) {
+-                            dstP[0] = (int)
+-                                    ((pLut[srcP[0]] << 24) |
+-                                     (pLut[srcP[1]] << 16) |
+-                                     (pLut[srcP[2]] << 8)  |
+-                                      pLut[srcP[3]]);
+-                            dstP[1] = (int)
+-                                    ((pLut[srcP[4]] << 24) |
+-                                     (pLut[srcP[5]] << 16) |
+-                                     (pLut[srcP[6]] << 8)  |
+-                                      pLut[srcP[7]]);
+-                            dstP += NLUT/4;
+-                            srcP += NLUT;
+-                        }
+-                    } else {
+-                        /* Little endian loop */
+-                        for(x=nloop; x!=0; x--) {
+-                            dstP[0] = (int)
+-                                    ((pLut[srcP[3]] << 24) |
+-                                     (pLut[srcP[2]] << 16) |
+-                                     (pLut[srcP[1]] << 8)  |
+-                                      pLut[srcP[0]]);
+-                            dstP[1] = (int)
+-                                    ((pLut[srcP[7]] << 24) |
+-                                     (pLut[srcP[6]] << 16) |
+-                                     (pLut[srcP[5]] << 8)  |
+-                                      pLut[srcP[4]]);
+-                            dstP += NLUT/4;
+-                            srcP += NLUT;
+-                        }
+-                    }
+-                    /*
+-                     * Complete any remaining pixels
+-                     */
+-                    cP = cP + NLUT * nloop;
+-                    sP = sP + NLUT * nloop;
+-                    for(x=nx; x!=0; x--) {
+-                        *cP++ = pLut[*sP++];
+-                    }
+-
+-                    /*
+-                     * 4554571: increment pointers using the scanline stride
+-                     * in pixel units (not byte units)
+-                     */
+-                    cdataP += dstRasterP->scanlineStride;
+-                    sdataP += srcRasterP->scanlineStride;
+-                }
++                retStatus = lookupShortData(src, dst, &jtable[0]);
+             }
+         }
+         /* How about ddata == null? */
+     } else if ((status = (*sMlibFns[MLIB_LOOKUP].fptr)(dst, src,
+-                                      (void **)table) != MLIB_SUCCESS)) {
++                                      (void **)mlib_lookupTable) != MLIB_SUCCESS)) {
+         printMedialibError(status);
+         retStatus = 0;
+     }
+@@ -1677,8 +1720,8 @@
+ 
+     /* Release the LUT */
+     for (i=0; i < lut_nbands; i++) {
+-        (*env)->ReleasePrimitiveArrayCritical(env, jtable[i],
+-                                              (jbyte *) table[i], JNI_ABORT);
++        (*env)->ReleasePrimitiveArrayCritical(env, jtable[i].jArray,
++                                              (jbyte *) jtable[i].table, JNI_ABORT);
+     }
+ 
+     /* Release the pinned memory */
+diff --git a/src/share/native/sun/awt/medialib/mlib_ImageCreate.c b/src/share/native/sun/awt/medialib/mlib_ImageCreate.c
+--- openjdk/jdk/src/share/native/sun/awt/medialib/mlib_ImageCreate.c
++++ openjdk/jdk/src/share/native/sun/awt/medialib/mlib_ImageCreate.c
+@@ -160,27 +160,46 @@
+ /* Check if stride == width
+    * If it is then image can be treated as a 1-D vector
+  */
++
++  if (!SAFE_TO_MULT(width, channels)) {
++    return NULL;
++  }
++
++  wb = width * channels;
++
+   switch (type) {
+     case MLIB_DOUBLE:
+-      wb = width * channels * 8;
++      if (!SAFE_TO_MULT(wb, 8)) {
++        return NULL;
++      }
++      wb *= 8;
+       mask = 7;
+       break;
+     case MLIB_FLOAT:
+     case MLIB_INT:
+-      wb = width * channels * 4;
++      if (!SAFE_TO_MULT(wb, 4)) {
++        return NULL;
++      }
++      wb *= 4;
+       mask = 3;
+       break;
+     case MLIB_USHORT:
+     case MLIB_SHORT:
+-      wb = width * channels * 2;
++      if (!SAFE_TO_MULT(wb, 2)) {
++        return NULL;
++      }
++      wb *= 2;
+       mask = 1;
+       break;
+     case MLIB_BYTE:
+-      wb = width * channels;
++      // wb is ready
+       mask = 0;
+       break;
+     case MLIB_BIT:
+-      wb = (width * channels + 7) / 8;
++      if (!SAFE_TO_ADD(7, wb)) {
++        return NULL;
++      }
++      wb = (wb + 7) / 8;
+       mask = 0;
+       break;
+     default:
+@@ -270,7 +289,7 @@
+       break;
+     case MLIB_USHORT:
+     case MLIB_SHORT:
+-      if (!SAFE_TO_MULT(wb, 4)) {
++      if (!SAFE_TO_MULT(wb, 2)) {
+         return NULL;
+       }
+       wb *= 2;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8011248-better_component_rasters.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,51 @@
+# HG changeset patch
+# User prr
+# Date 1365450069 25200
+# Node ID 7024e2f3b69c998420d5d765c056048b8b6b5c2b
+# Parent  8d4760ec16ecfc5abb647dfb1a28d5b3c01f6a12
+8011248: Better Component Rasters
+Reviewed-by: bae, vadim, mschoene
+
+diff --git a/src/share/classes/sun/awt/image/IntegerComponentRaster.java b/src/share/classes/sun/awt/image/IntegerComponentRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java
+@@ -654,9 +654,6 @@
+                                             ") must be >= 0");
+         }
+ 
+-        int maxSize = 0;
+-        int size;
+-
+         // we can be sure that width and height are greater than 0
+         if (scanlineStride < 0 ||
+             scanlineStride > (Integer.MAX_VALUE / height))
+@@ -682,21 +679,23 @@
+         }
+         lastPixelOffset += lastScanOffset;
+ 
++        int index;
++        int maxIndex = 0;
+         for (int i = 0; i < numDataElements; i++) {
+             if (dataOffsets[i] > (Integer.MAX_VALUE - lastPixelOffset)) {
+                 throw new RasterFormatException("Incorrect band offset: "
+                             + dataOffsets[i]);
+             }
+ 
+-            size = lastPixelOffset + dataOffsets[i];
++            index = lastPixelOffset + dataOffsets[i];
+ 
+-            if (size > maxSize) {
+-                maxSize = size;
++            if (index > maxIndex) {
++                maxIndex = index;
+             }
+         }
+-        if (data.length < maxSize) {
+-            throw new RasterFormatException("Data array too small (should be "
+-                    + maxSize + " )");
++        if (data.length <= maxIndex) {
++            throw new RasterFormatException("Data array too small (should be > "
++                    + maxIndex + " )");
+         }
+     }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8011253-better_short_component_rasters.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,140 @@
+# HG changeset patch
+# User prr
+# Date 1365450380 25200
+# Node ID 02f545e014b0b73094bd295643f8b33965fe8bcf
+# Parent  7024e2f3b69c998420d5d765c056048b8b6b5c2b
+8011253: Better Short Component Rasters
+Reviewed-by: bae, vadim, mschoene
+
+diff --git a/src/share/classes/sun/awt/image/ShortBandedRaster.java b/src/share/classes/sun/awt/image/ShortBandedRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/ShortBandedRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/ShortBandedRaster.java
+@@ -156,7 +156,7 @@
+             throw new RasterFormatException("ShortBandedRasters must have "+
+                 "BandedSampleModels");
+         }
+-        verify(false);
++        verify();
+     }
+ 
+     /**
+@@ -730,16 +730,30 @@
+     }
+ 
+     /**
+-     * Verify that the layout parameters are consistent with
+-     * the data.  If strictCheck
+-     * is false, this method will check for ArrayIndexOutOfBounds conditions.  If
+-     * strictCheck is true, this method will check for additional error
+-     * conditions such as line wraparound (width of a line greater than
+-     * the scanline stride).
+-     * @return   String   Error string, if the layout is incompatible with
+-     *                    the data.  Otherwise returns null.
++     * Verify that the layout parameters are consistent with the data.
++     * Verifies whether the data buffer has enough data for the raster,
++     * taking into account offsets, after ensuring all offsets are >=0.
++     * @throws RasterFormatException if a problem is detected.
+      */
+-    private void verify (boolean strictCheck) {
++    private void verify() {
++
++        /* Need to re-verify the dimensions since a sample model may be
++         * specified to the constructor
++         */
++        if (width <= 0 || height <= 0 ||
++            height > (Integer.MAX_VALUE / width))
++        {
++            throw new RasterFormatException("Invalid raster dimension");
++        }
++
++        if (scanlineStride < 0 ||
++            scanlineStride > (Integer.MAX_VALUE / height))
++        {
++            // integer overflow
++            throw new RasterFormatException("Incorrect scanline stride: "
++                    + scanlineStride);
++        }
++
+         // Make sure data for Raster is in a legal range
+         for (int i=0; i < dataOffsets.length; i++) {
+             if (dataOffsets[i] < 0) {
+@@ -749,19 +763,28 @@
+             }
+         }
+ 
+-        int maxSize = 0;
+-        int size;
++        int lastScanOffset = (height - 1) * scanlineStride;
++        int lastPixelOffset = lastScanOffset + (width-1);
++        if (lastPixelOffset < lastScanOffset) {
++            throw new RasterFormatException("Invalid raster dimension");
++        }
++
++        int maxIndex = 0;
++        int index;
+ 
+         for (int i=0; i < numDataElements; i++) {
+-            size = (height-1)*scanlineStride + (width-1) + dataOffsets[i];
+-            if (size > maxSize) {
+-                maxSize = size;
++            index = lastPixelOffset + dataOffsets[i];
++            if (index < lastPixelOffset) {
++                throw new RasterFormatException("Invalid raster dimension");
++            }
++            if (index > maxIndex) {
++                maxIndex = index;
+             }
+         }
+         for (int i=0; i < numDataElements; i++) {
+-            if (data[i].length < maxSize) {
+-                throw new RasterFormatException("Data array too small (should be "+
+-                                                maxSize+" )");
++            if (data[i].length <= maxIndex) {
++                throw new RasterFormatException("Data array too small " +
++                      "(should be > "+ maxIndex+" )");
+             }
+         }
+     }
+diff --git a/src/share/classes/sun/awt/image/ShortComponentRaster.java b/src/share/classes/sun/awt/image/ShortComponentRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/ShortComponentRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/ShortComponentRaster.java
+@@ -819,9 +819,6 @@
+             }
+         }
+ 
+-        int maxSize = 0;
+-        int size;
+-
+         // we can be sure that width and height are greater than 0
+         if (scanlineStride < 0 ||
+             scanlineStride > (Integer.MAX_VALUE / height))
+@@ -847,21 +844,23 @@
+         }
+         lastPixelOffset += lastScanOffset;
+ 
++        int index;
++        int maxIndex = 0;
+         for (int i = 0; i < numDataElements; i++) {
+             if (dataOffsets[i] > (Integer.MAX_VALUE - lastPixelOffset)) {
+                 throw new RasterFormatException("Incorrect band offset: "
+                             + dataOffsets[i]);
+             }
+ 
+-            size = lastPixelOffset + dataOffsets[i];
++            index = lastPixelOffset + dataOffsets[i];
+ 
+-            if (size > maxSize) {
+-                maxSize = size;
++            if (index > maxIndex) {
++                maxIndex = index;
+             }
+         }
+-        if (data.length < maxSize) {
+-            throw new RasterFormatException("Data array too small (should be "
+-                    + maxSize + " )");
++        if (data.length <= maxIndex) {
++            throw new RasterFormatException("Data array too small (should be > "
++                    + maxIndex + " )");
+         }
+     }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8011257-better_byte_component_rasters.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,157 @@
+# HG changeset patch
+# User prr
+# Date 1365450499 25200
+# Node ID b606e9565b5d9deed95c621829673ae930e7d596
+# Parent  02f545e014b0b73094bd295643f8b33965fe8bcf
+8011257: Better Byte Component Rasters
+Reviewed-by: bae, vadim, mschoene
+
+diff --git a/src/share/classes/sun/awt/image/ByteBandedRaster.java b/src/share/classes/sun/awt/image/ByteBandedRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/ByteBandedRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/ByteBandedRaster.java
+@@ -159,7 +159,7 @@
+             throw new RasterFormatException("ByteBandedRasters must have"+
+                 "BandedSampleModels");
+         }
+-        verify(false);
++        verify();
+     }
+ 
+ 
+@@ -731,16 +731,30 @@
+     }
+ 
+     /**
+-     * Verify that the layout parameters are consistent with
+-     * the data.  If strictCheck
+-     * is false, this method will check for ArrayIndexOutOfBounds conditions.  If
+-     * strictCheck is true, this method will check for additional error
+-     * conditions such as line wraparound (width of a line greater than
+-     * the scanline stride).
+-     * @return   String   Error string, if the layout is incompatible with
+-     *                    the data.  Otherwise returns null.
++     * Verify that the layout parameters are consistent with the data.
++     * Verifies whether the data buffer has enough data for the raster,
++     * taking into account offsets, after ensuring all offsets are >=0.
++     * @throws RasterFormatException if a problem is detected.
+      */
+-    private void verify (boolean strictCheck) {
++    private void verify() {
++
++        /* Need to re-verify the dimensions since a sample model may be
++         * specified to the constructor
++         */
++        if (width <= 0 || height <= 0 ||
++            height > (Integer.MAX_VALUE / width))
++        {
++            throw new RasterFormatException("Invalid raster dimension");
++        }
++
++        if (scanlineStride < 0 ||
++            scanlineStride > (Integer.MAX_VALUE / height))
++        {
++            // integer overflow
++            throw new RasterFormatException("Incorrect scanline stride: "
++                    + scanlineStride);
++        }
++
+         // Make sure data for Raster is in a legal range
+         for (int i=0; i < dataOffsets.length; i++) {
+             if (dataOffsets[i] < 0) {
+@@ -750,32 +764,41 @@
+             }
+         }
+ 
+-        int maxSize = 0;
+-        int size;
++        int lastScanOffset = (height - 1) * scanlineStride;
++        int lastPixelOffset = lastScanOffset + (width-1);
++        if (lastPixelOffset < lastScanOffset) {
++            throw new RasterFormatException("Invalid raster dimension");
++        }
++
++        int maxIndex = 0;
++        int index;
+ 
+         for (int i=0; i < numDataElements; i++) {
+-            size = (height-1)*scanlineStride + (width-1) + dataOffsets[i];
+-            if (size > maxSize) {
+-                maxSize = size;
++            index = lastPixelOffset + dataOffsets[i];
++            if (index < lastPixelOffset) {
++                throw new RasterFormatException("Invalid raster dimension");
++            }
++            if (index > maxIndex) {
++                maxIndex = index;
+             }
+         }
+ 
+         if (data.length == 1) {
+-            if (data[0].length < maxSize*numDataElements) {
++            if (data[0].length <= maxIndex*numDataElements) {
+                 throw new RasterFormatException("Data array too small "+
+                                                 "(it is "+data[0].length+
+-                                                " and should be "+
+-                                                (maxSize*numDataElements)+
++                                                " and should be > "+
++                                                (maxIndex*numDataElements)+
+                                                 " )");
+             }
+         }
+         else {
+             for (int i=0; i < numDataElements; i++) {
+-                if (data[i].length < maxSize) {
++                if (data[i].length <= maxIndex) {
+                     throw new RasterFormatException("Data array too small "+
+                                                     "(it is "+data[i].length+
+-                                                    " and should be "+
+-                                                    maxSize+" )");
++                                                    " and should be > "+
++                                                    maxIndex+" )");
+                 }
+             }
+         }
+diff --git a/src/share/classes/sun/awt/image/ByteComponentRaster.java b/src/share/classes/sun/awt/image/ByteComponentRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/ByteComponentRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/ByteComponentRaster.java
+@@ -885,9 +885,6 @@
+             }
+         }
+ 
+-        int maxSize = 0;
+-        int size;
+-
+         // we can be sure that width and height are greater than 0
+         if (scanlineStride < 0 ||
+             scanlineStride > (Integer.MAX_VALUE / height))
+@@ -913,6 +910,8 @@
+         }
+         lastPixelOffset += lastScanOffset;
+ 
++        int index;
++        int maxIndex = 0;
+         for (int i = 0; i < numDataElements; i++) {
+             if (dataOffsets[i] > (Integer.MAX_VALUE - lastPixelOffset)) {
+                 throw new RasterFormatException("Incorrect band offset: "
+@@ -920,15 +919,15 @@
+ 
+             }
+ 
+-            size = lastPixelOffset + dataOffsets[i];
++            index = lastPixelOffset + dataOffsets[i];
+ 
+-            if (size > maxSize) {
+-                maxSize = size;
++            if (index > maxIndex) {
++                maxIndex = index;
+             }
+         }
+-        if (data.length < maxSize) {
+-            throw new RasterFormatException("Data array too small (should be "
+-                    + maxSize + " )");
++        if (data.length <= maxIndex) {
++            throw new RasterFormatException("Data array too small (should be > "
++                    + maxIndex + " )");
+         }
+     }
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8011557-improve_reflection.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,132 @@
+# HG changeset patch
+# User andrew
+# Date 1371562105 18000
+# Node ID 3b7e8e89595d6f0f967981d3e08fe170fd3898ef
+# Parent  b606e9565b5d9deed95c621829673ae930e7d596
+8011557: Improve reflection utility classes
+Reviewed-by: ahgross, alanb
+
+diff --git a/src/share/classes/java/lang/Class.java b/src/share/classes/java/lang/Class.java
+--- openjdk/jdk/src/share/classes/java/lang/Class.java
++++ openjdk/jdk/src/share/classes/java/lang/Class.java
+@@ -2210,7 +2210,7 @@
+                 if (i != -1) {
+                     // skip the package access check on a proxy class in default proxy package
+                     String pkg = name.substring(0, i);
+-                    if (!Proxy.isProxyClass(this) || !pkg.equals(ReflectUtil.PROXY_PACKAGE)) {
++                    if (!Proxy.isProxyClass(this) || ReflectUtil.isNonPublicProxyClass(this)) {
+                         s.checkPackageAccess(pkg);
+                     }
+                 }
+diff --git a/src/share/classes/java/lang/reflect/Proxy.java b/src/share/classes/java/lang/reflect/Proxy.java
+--- openjdk/jdk/src/share/classes/java/lang/reflect/Proxy.java
++++ openjdk/jdk/src/share/classes/java/lang/reflect/Proxy.java
+@@ -300,13 +300,11 @@
+                 return false;
+             }
+  
+-            if (proxyClass.getName().startsWith(ReflectUtil.PROXY_PACKAGE + ".")) {
+-                // all proxy interfaces are public
+-                return false;
+-            }
+-            for (Class<?> intf : proxyClass.getInterfaces()) {
+-                if (!Modifier.isPublic(intf.getModifiers())) {
+-                    return true;
++            if (ReflectUtil.isNonPublicProxyClass(proxyClass)) {
++                for (Class<?> intf : proxyClass.getInterfaces()) {
++                    if (!Modifier.isPublic(intf.getModifiers())) {
++                        return true;
++                    }
+                 }
+             }
+             return false;
+diff --git a/src/share/classes/sun/reflect/misc/ReflectUtil.java b/src/share/classes/sun/reflect/misc/ReflectUtil.java
+--- openjdk/jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java
++++ openjdk/jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java
+@@ -27,6 +27,7 @@
+ package sun.reflect.misc;
+ 
+ import java.lang.reflect.Modifier;
++import java.lang.reflect.Proxy;
+ import sun.reflect.Reflection;
+ 
+ public final class ReflectUtil {
+@@ -123,10 +124,26 @@
+     }
+ 
+ 
+-    public static void checkPackageAccess(Class clazz) {
++    /**
++     * Checks package access on the given class.
++     *
++     * If it is a {@link Proxy#isProxyClass(java.lang.Class)} that implements
++     * a non-public interface (i.e. may be in a non-restricted package),
++     * also check the package access on the proxy interfaces.
++     */
++    public static void checkPackageAccess(Class<?> clazz) {
+         checkPackageAccess(clazz.getName());
++        if (isNonPublicProxyClass(clazz)) {
++            checkProxyPackageAccess(clazz);
++        }
+     }
+ 
++    /**
++     * Checks package access on the given classname.
++     * This method is typically called when the Class instance is not
++     * available and the caller attempts to load a class on behalf
++     * the true caller (application).
++     */
+     public static void checkPackageAccess(String name) {
+         SecurityManager s = System.getSecurityManager();
+         if (s != null) {
+@@ -188,13 +205,30 @@
+     }
+ 
+     /**
++     * Check package access on the proxy interfaces that the given proxy class
++     * implements.
++     *
++     * @param clazz Proxy class object
++     */
++    public static void checkProxyPackageAccess(Class<?> clazz) {
++        SecurityManager s = System.getSecurityManager();
++        if (s != null) {
++            // check proxy interfaces if the given class is a proxy class
++            if (Proxy.isProxyClass(clazz)) {
++                for (Class<?> intf : clazz.getInterfaces()) {
++                    checkPackageAccess(intf);
++                }
++            }
++        }
++    }
++
++    /**
+      * Access check on the interfaces that a proxy class implements and throw
+-     * {@code SecurityException} if it accesses a restricted package.
++     * {@code SecurityException} if it accesses a restricted package from
++     * the caller's class loader.
+      *
+      * @param ccl the caller's class loader
+      * @param interfaces the list of interfaces that a proxy class implements
+-     *
+-     * @see Proxy#checkProxyAccess
+      */
+     public static void checkProxyPackageAccess(ClassLoader ccl,
+                                                Class<?>... interfaces)
+@@ -211,4 +245,16 @@
+     }
+ 
+     public static final String PROXY_PACKAGE = "sun.proxy";
++
++    /**
++     * Test if the given class is a proxy class that implements
++     * non-public interface.  Such proxy class may be in a non-restricted
++     * package that bypasses checkPackageAccess.
++     */
++    public static boolean isNonPublicProxyClass(Class<?> cls) {
++        String name = cls.getName();
++        int i = name.lastIndexOf('.');
++        String pkg = (i != -1) ? name.substring(0, i) : "";
++        return Proxy.isProxyClass(cls) && !pkg.equals(PROXY_PACKAGE);
++    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8012375-javadoc_framing.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,61 @@
+# HG changeset patch
+# User andrew
+# Date 1371731018 18000
+# Node ID b4954380fa25058f1a6cfb9cb96f78d90cf0fc5c
+# Parent  445134ee98c84b6d139fab0f9a9d8718c686c63b
+8012375: Improve Javadoc framing
+Reviewed-by: mduigou, jlaskey
+
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
++ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -309,8 +309,41 @@
+         String scriptCode = DocletConstants.NL + "    targetPage = \"\" + window.location.search;" + DocletConstants.NL +
+                 "    if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
+                 "        targetPage = targetPage.substring(1);" + DocletConstants.NL +
+-                "    if (targetPage.indexOf(\":\") != -1)" + DocletConstants.NL +
++                "    if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + DocletConstants.NL +
+                 "        targetPage = \"undefined\";" + DocletConstants.NL +
++                "    function validURL(url) {" + DocletConstants.NL +
++                "        if (!(url.indexOf(\".html\") == url.length - 5))" + DocletConstants.NL +
++                "            return false;" + DocletConstants.NL +
++                "        var allowNumber = false;" + DocletConstants.NL +
++                "        var allowSep = false;" + DocletConstants.NL +
++                "        var seenDot = false;" + DocletConstants.NL +
++                "        for (var i = 0; i < url.length - 5; i++) {" + DocletConstants.NL +
++                "            var ch = url.charAt(i);" + DocletConstants.NL +
++                "            if ('a' <= ch && ch <= 'z' ||" + DocletConstants.NL +
++                "                    'A' <= ch && ch <= 'Z' ||" + DocletConstants.NL +
++                "                    ch == '$' ||" + DocletConstants.NL +
++                "                    ch == '_') {" + DocletConstants.NL +
++                "                allowNumber = true;" + DocletConstants.NL +
++                "                allowSep = true;" + DocletConstants.NL +
++                "            } else if ('0' <= ch && ch <= '9'" + DocletConstants.NL +
++                "                    || ch == '-') {" + DocletConstants.NL +
++                "                if (!allowNumber)" + DocletConstants.NL +
++                "                     return false;" + DocletConstants.NL +
++                "            } else if (ch == '/' || ch == '.') {" + DocletConstants.NL +
++                "                if (!allowSep)" + DocletConstants.NL +
++                "                    return false;" + DocletConstants.NL +
++                "                allowNumber = false;" + DocletConstants.NL +
++                "                allowSep = false;" + DocletConstants.NL +
++                "                if (ch == '.')" + DocletConstants.NL +
++                "                     seenDot = true;" + DocletConstants.NL +
++                "                if (ch == '/' && seenDot)" + DocletConstants.NL +
++                "                     return false;" + DocletConstants.NL +
++                "            } else {" + DocletConstants.NL +
++                "                return false;"+ DocletConstants.NL +
++                "            }" + DocletConstants.NL +
++                "        }" + DocletConstants.NL +
++                "        return true;" + DocletConstants.NL +
++                "    }" + DocletConstants.NL +
+                 "    function loadFrames() {" + DocletConstants.NL +
+                 "        if (targetPage != \"\" && targetPage != \"undefined\")" + DocletConstants.NL +
+                 "             top.classFrame.location = top.targetPage;" + DocletConstants.NL +
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8012421-better_positioning.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,100 @@
+# HG changeset patch
+# User prr
+# Date 1366411203 25200
+# Node ID 92ad159889b19b66a64cd3c89b628132fe089354
+# Parent  3b7e8e89595d6f0f967981d3e08fe170fd3898ef
+8012421: Better positioning of PairPositioning
+Reviewed-by: srl, mschoene, vadim
+
+diff --git a/src/share/native/sun/font/layout/PairPositioningSubtables.cpp b/src/share/native/sun/font/layout/PairPositioningSubtables.cpp
+--- openjdk/jdk/src/share/native/sun/font/layout/PairPositioningSubtables.cpp
++++ openjdk/jdk/src/share/native/sun/font/layout/PairPositioningSubtables.cpp
+@@ -76,23 +76,30 @@
+ {
+     LEGlyphID firstGlyph = glyphIterator->getCurrGlyphID();
+     le_int32 coverageIndex = getGlyphCoverage(base, firstGlyph, success);
++
++    if (LE_FAILURE(success)) {
++      return 0;
++    }
+     GlyphIterator tempIterator(*glyphIterator);
+ 
+     if (coverageIndex >= 0 && glyphIterator->next()) {
+         Offset pairSetTableOffset = SWAPW(pairSetTableOffsetArray[coverageIndex]);
+-        PairSetTable *pairSetTable = (PairSetTable *) ((char *) this + pairSetTableOffset);
++        LEReferenceTo<PairSetTable> pairSetTable(base, success, ((char *) this + pairSetTableOffset));
++        if (LE_FAILURE(success)) {
++          return 0;
++        }
+         le_uint16 pairValueCount = SWAPW(pairSetTable->pairValueCount);
+         le_int16 valueRecord1Size = ValueRecord::getSize(SWAPW(valueFormat1));
+         le_int16 valueRecord2Size = ValueRecord::getSize(SWAPW(valueFormat2));
+         le_int16 recordSize = sizeof(PairValueRecord) - sizeof(ValueRecord) + valueRecord1Size + valueRecord2Size;
+         LEGlyphID secondGlyph = glyphIterator->getCurrGlyphID();
+-        const PairValueRecord *pairValueRecord = NULL;
++        LEReferenceTo<PairValueRecord> pairValueRecord;
+ 
+         if (pairValueCount != 0) {
+-            pairValueRecord = findPairValueRecord((TTGlyphID) LE_GET_GLYPH(secondGlyph), pairSetTable->pairValueRecordArray, pairValueCount, recordSize);
++            pairValueRecord = findPairValueRecord(base, (TTGlyphID) LE_GET_GLYPH(secondGlyph), pairSetTable->pairValueRecordArray, pairValueCount, recordSize, success);
+         }
+ 
+-        if (pairValueRecord == NULL) {
++        if (pairValueRecord.isEmpty()) {
+             return 0;
+         }
+ 
+@@ -154,22 +161,26 @@
+     return 0;
+ }
+ 
+-const PairValueRecord *PairPositioningFormat1Subtable::findPairValueRecord(TTGlyphID glyphID, const PairValueRecord *records, le_uint16 recordCount, le_uint16 recordSize) const
++LEReferenceTo<PairValueRecord> PairPositioningFormat1Subtable::findPairValueRecord(const LETableReference &base, TTGlyphID glyphID, const PairValueRecord *records, le_uint16 recordCount, le_uint16 recordSize, LEErrorCode &success) const
+ {
+ #if 1
+         // The OpenType spec. says that the ValueRecord table is
+         // sorted by secondGlyph. Unfortunately, there are fonts
+         // around that have an unsorted ValueRecord table.
+-        const PairValueRecord *record = records;
++        LEReferenceTo<PairValueRecord> record(base, success, records);
++        record.verifyLength(0, recordSize, success);
+ 
+         for(le_int32 r = 0; r < recordCount; r += 1) {
++           if (LE_FAILURE(success)) return (const PairValueRecord*)NULL;
+                 if (SWAPW(record->secondGlyph) == glyphID) {
+                         return record;
+                 }
+ 
+-                record = (const PairValueRecord *) ((char *) record + recordSize);
++                record =  LEReferenceTo<PairValueRecord>(base, success, ((const char*)record.getAlias())+ recordSize);
++                record.verifyLength(0, recordSize, success);
+         }
+ #else
++  #error dead code - not updated.
+     le_uint8 bit = OpenTypeUtilities::highBit(recordCount);
+     le_uint16 power = 1 << bit;
+     le_uint16 extra = (recordCount - power) * recordSize;
+@@ -195,7 +206,7 @@
+     }
+ #endif
+ 
+-    return NULL;
++    return (const PairValueRecord*)NULL;
+ }
+ 
+ U_NAMESPACE_END
+diff --git a/src/share/native/sun/font/layout/PairPositioningSubtables.h b/src/share/native/sun/font/layout/PairPositioningSubtables.h
+--- openjdk/jdk/src/share/native/sun/font/layout/PairPositioningSubtables.h
++++ openjdk/jdk/src/share/native/sun/font/layout/PairPositioningSubtables.h
+@@ -77,8 +77,9 @@
+     le_uint32  process(const LEReferenceTo<PairPositioningFormat1Subtable> &base, GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode &success) const;
+ 
+ private:
+-    const PairValueRecord *findPairValueRecord(TTGlyphID glyphID, const PairValueRecord *records,
+-        le_uint16 recordCount, le_uint16 recordSize) const;
++    LEReferenceTo<PairValueRecord> findPairValueRecord(const LETableReference &base, TTGlyphID glyphID, const PairValueRecord *records,
++        le_uint16 recordCount, le_uint16 recordSize, LEErrorCode &success) const;
++
+ };
+ LE_VAR_ARRAY(PairPositioningFormat1Subtable, pairSetTableOffsetArray)
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8012438-better_image_validation.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,283 @@
+# HG changeset patch
+# User bae
+# Date 1366802624 -14400
+# Node ID 63028eef41bcd0e7ea49d333dc25ad27cd5e33a4
+# Parent  92ad159889b19b66a64cd3c89b628132fe089354
+8012438: Better image validation
+Reviewed-by: mschoene, prr, vadim
+
+diff --git a/src/share/classes/java/awt/image/ComponentSampleModel.java b/src/share/classes/java/awt/image/ComponentSampleModel.java
+--- openjdk/jdk/src/share/classes/java/awt/image/ComponentSampleModel.java
++++ openjdk/jdk/src/share/classes/java/awt/image/ComponentSampleModel.java
+@@ -148,7 +148,7 @@
+         this.pixelStride = pixelStride;
+         this.scanlineStride  = scanlineStride;
+         this.bandOffsets = (int[])bandOffsets.clone();
+-        numBands = bandOffsets.length;
++        numBands = this.bandOffsets.length;
+         if (pixelStride < 0) {
+             throw new IllegalArgumentException("Pixel stride must be >= 0");
+         }
+@@ -223,24 +223,24 @@
+             (dataType > DataBuffer.TYPE_DOUBLE)) {
+             throw new IllegalArgumentException("Unsupported dataType.");
+         }
+-        int maxBank = bankIndices[0];
++        int maxBank = this.bankIndices[0];
+         if (maxBank < 0) {
+             throw new IllegalArgumentException("Index of bank 0 is less than "+
+                                                "0 ("+maxBank+")");
+         }
+-        for (int i=1; i < bankIndices.length; i++) {
+-            if (bankIndices[i] > maxBank) {
+-                maxBank = bankIndices[i];
++        for (int i=1; i < this.bankIndices.length; i++) {
++            if (this.bankIndices[i] > maxBank) {
++                maxBank = this.bankIndices[i];
+             }
+-            else if (bankIndices[i] < 0) {
++            else if (this.bankIndices[i] < 0) {
+                 throw new IllegalArgumentException("Index of bank "+i+
+                                                    " is less than 0 ("+
+                                                    maxBank+")");
+             }
+         }
+         numBanks         = maxBank+1;
+-        numBands         = bandOffsets.length;
+-        if (bandOffsets.length != bankIndices.length) {
++        numBands         = this.bandOffsets.length;
++        if (this.bandOffsets.length != this.bankIndices.length) {
+             throw new IllegalArgumentException("Length of bandOffsets must "+
+                                                "equal length of bankIndices.");
+         }
+diff --git a/src/share/classes/java/awt/image/PixelInterleavedSampleModel.java b/src/share/classes/java/awt/image/PixelInterleavedSampleModel.java
+--- openjdk/jdk/src/share/classes/java/awt/image/PixelInterleavedSampleModel.java
++++ openjdk/jdk/src/share/classes/java/awt/image/PixelInterleavedSampleModel.java
+@@ -85,11 +85,11 @@
+                                        int scanlineStride,
+                                        int bandOffsets[]) {
+         super(dataType, w, h, pixelStride, scanlineStride, bandOffsets);
+-        int minBandOff=bandOffsets[0];
+-        int maxBandOff=bandOffsets[0];
+-        for (int i=1; i<bandOffsets.length; i++) {
+-            minBandOff = Math.min(minBandOff,bandOffsets[i]);
+-            maxBandOff = Math.max(maxBandOff,bandOffsets[i]);
++        int minBandOff=this.bandOffsets[0];
++        int maxBandOff=this.bandOffsets[0];
++        for (int i=1; i<this.bandOffsets.length; i++) {
++            minBandOff = Math.min(minBandOff,this.bandOffsets[i]);
++            maxBandOff = Math.max(maxBandOff,this.bandOffsets[i]);
+         }
+         maxBandOff -= minBandOff;
+         if (maxBandOff > scanlineStride) {
+diff --git a/src/share/classes/java/awt/image/Raster.java b/src/share/classes/java/awt/image/Raster.java
+--- openjdk/jdk/src/share/classes/java/awt/image/Raster.java
++++ openjdk/jdk/src/share/classes/java/awt/image/Raster.java
+@@ -257,15 +257,10 @@
+                                                          int bandOffsets[],
+                                                          Point location) {
+         DataBuffer d;
+-        int bands = bandOffsets.length;
+ 
+-        int maxBandOff = bandOffsets[0];
+-        for (int i=1; i < bands; i++) {
+-            if (bandOffsets[i] > maxBandOff) {
+-                maxBandOff = bandOffsets[i];
+-            }
+-        }
+-        int size = maxBandOff + scanlineStride*(h-1) + pixelStride*(w-1) + 1;
++        int size = scanlineStride * (h - 1) + // fisrt (h - 1) scans
++            pixelStride * w; // last scan
++
+         switch(dataType) {
+         case DataBuffer.TYPE_BYTE:
+             d = new DataBufferByte(size);
+@@ -397,7 +392,8 @@
+             }
+         }
+         int banks = maxBank + 1;
+-        int size = maxBandOff + scanlineStride*(h-1) + (w-1) + 1;
++        int size = scanlineStride * (h - 1) + // fisrt (h - 1) scans
++            w; // last scan
+ 
+         switch(dataType) {
+         case DataBuffer.TYPE_BYTE:
+diff --git a/src/share/classes/sun/awt/image/ByteBandedRaster.java b/src/share/classes/sun/awt/image/ByteBandedRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/ByteBandedRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/ByteBandedRaster.java
+@@ -755,6 +755,13 @@
+                     + scanlineStride);
+         }
+ 
++        for (int i = 0; i < data.length; i++) {
++            if (scanlineStride > data[i].length) {
++                throw new RasterFormatException("Incorrect scanline stride: "
++                    + scanlineStride);
++            }
++        }
++
+         // Make sure data for Raster is in a legal range
+         for (int i=0; i < dataOffsets.length; i++) {
+             if (dataOffsets[i] < 0) {
+@@ -765,19 +772,20 @@
+         }
+ 
+         int lastScanOffset = (height - 1) * scanlineStride;
+-        int lastPixelOffset = lastScanOffset + (width-1);
+-        if (lastPixelOffset < lastScanOffset) {
++
++        if ((width - 1) > (Integer.MAX_VALUE - lastScanOffset)) {
+             throw new RasterFormatException("Invalid raster dimension");
+         }
++        int lastPixelOffset = lastScanOffset + (width-1);
+ 
+         int maxIndex = 0;
+         int index;
+ 
+         for (int i=0; i < numDataElements; i++) {
+-            index = lastPixelOffset + dataOffsets[i];
+-            if (index < lastPixelOffset) {
++            if (dataOffsets[i] > (Integer.MAX_VALUE - lastPixelOffset)) {
+                 throw new RasterFormatException("Invalid raster dimension");
+             }
++            index = lastPixelOffset + dataOffsets[i];
+             if (index > maxIndex) {
+                 maxIndex = index;
+             }
+diff --git a/src/share/classes/sun/awt/image/ByteComponentRaster.java b/src/share/classes/sun/awt/image/ByteComponentRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/ByteComponentRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/ByteComponentRaster.java
+@@ -887,7 +887,8 @@
+ 
+         // we can be sure that width and height are greater than 0
+         if (scanlineStride < 0 ||
+-            scanlineStride > (Integer.MAX_VALUE / height))
++            scanlineStride > (Integer.MAX_VALUE / height) ||
++            scanlineStride > data.length)
+         {
+             // integer overflow
+             throw new RasterFormatException("Incorrect scanline stride: "
+@@ -896,7 +897,8 @@
+         int lastScanOffset = (height - 1) * scanlineStride;
+ 
+         if (pixelStride < 0 ||
+-            pixelStride > (Integer.MAX_VALUE / width))
++            pixelStride > (Integer.MAX_VALUE / width) ||
++            pixelStride > data.length)
+         {
+             // integer overflow
+             throw new RasterFormatException("Incorrect pixel stride: "
+diff --git a/src/share/classes/sun/awt/image/BytePackedRaster.java b/src/share/classes/sun/awt/image/BytePackedRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/BytePackedRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/BytePackedRaster.java
+@@ -1387,7 +1387,8 @@
+         }
+ 
+         if (scanlineStride < 0 ||
+-            scanlineStride > (Integer.MAX_VALUE / height))
++            scanlineStride > (Integer.MAX_VALUE / height) ||
++            scanlineStride > data.length)
+         {
+             throw new RasterFormatException("Invalid scanline stride");
+         }
+diff --git a/src/share/classes/sun/awt/image/IntegerComponentRaster.java b/src/share/classes/sun/awt/image/IntegerComponentRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java
+@@ -656,7 +656,8 @@
+ 
+         // we can be sure that width and height are greater than 0
+         if (scanlineStride < 0 ||
+-            scanlineStride > (Integer.MAX_VALUE / height))
++            scanlineStride > (Integer.MAX_VALUE / height) ||
++            scanlineStride > data.length)
+         {
+             // integer overflow
+             throw new RasterFormatException("Incorrect scanline stride: "
+@@ -665,7 +666,8 @@
+         int lastScanOffset = (height - 1) * scanlineStride;
+ 
+         if (pixelStride < 0 ||
+-            pixelStride > (Integer.MAX_VALUE / width))
++            pixelStride > (Integer.MAX_VALUE / width) ||
++            pixelStride > data.length)
+         {
+             // integer overflow
+             throw new RasterFormatException("Incorrect pixel stride: "
+diff --git a/src/share/classes/sun/awt/image/ShortBandedRaster.java b/src/share/classes/sun/awt/image/ShortBandedRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/ShortBandedRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/ShortBandedRaster.java
+@@ -754,6 +754,13 @@
+                     + scanlineStride);
+         }
+ 
++        for (int i = 0; i < data.length; i++) {
++            if (scanlineStride > data[i].length) {
++                throw new RasterFormatException("Incorrect scanline stride: "
++                    + scanlineStride);
++            }
++        }
++
+         // Make sure data for Raster is in a legal range
+         for (int i=0; i < dataOffsets.length; i++) {
+             if (dataOffsets[i] < 0) {
+@@ -764,19 +771,19 @@
+         }
+ 
+         int lastScanOffset = (height - 1) * scanlineStride;
+-        int lastPixelOffset = lastScanOffset + (width-1);
+-        if (lastPixelOffset < lastScanOffset) {
++        if ((width - 1) > (Integer.MAX_VALUE - lastScanOffset)) {
+             throw new RasterFormatException("Invalid raster dimension");
+         }
++        int lastPixelOffset = lastScanOffset + (width - 1);
+ 
+         int maxIndex = 0;
+         int index;
+ 
+         for (int i=0; i < numDataElements; i++) {
+-            index = lastPixelOffset + dataOffsets[i];
+-            if (index < lastPixelOffset) {
++            if (dataOffsets[i] > (Integer.MAX_VALUE - lastPixelOffset)) {
+                 throw new RasterFormatException("Invalid raster dimension");
+             }
++            index = lastPixelOffset + dataOffsets[i];
+             if (index > maxIndex) {
+                 maxIndex = index;
+             }
+diff --git a/src/share/classes/sun/awt/image/ShortComponentRaster.java b/src/share/classes/sun/awt/image/ShortComponentRaster.java
+--- openjdk/jdk/src/share/classes/sun/awt/image/ShortComponentRaster.java
++++ openjdk/jdk/src/share/classes/sun/awt/image/ShortComponentRaster.java
+@@ -821,7 +821,8 @@
+ 
+         // we can be sure that width and height are greater than 0
+         if (scanlineStride < 0 ||
+-            scanlineStride > (Integer.MAX_VALUE / height))
++            scanlineStride > (Integer.MAX_VALUE / height) ||
++            scanlineStride > data.length)
+         {
+             // integer overflow
+             throw new RasterFormatException("Incorrect scanline stride: "
+@@ -830,7 +831,8 @@
+         int lastScanOffset = (height - 1) * scanlineStride;
+ 
+         if (pixelStride < 0 ||
+-            pixelStride > (Integer.MAX_VALUE / width))
++            pixelStride > (Integer.MAX_VALUE / width) ||
++            pixelStride > data.length)
+         {
+             // integer overflow
+             throw new RasterFormatException("Incorrect pixel stride: "
+diff --git a/src/share/native/sun/awt/medialib/awt_ImagingLib.c b/src/share/native/sun/awt/medialib/awt_ImagingLib.c
+--- openjdk/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
++++ openjdk/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
+@@ -1177,6 +1177,10 @@
+ 
+     static int indexes[NLUT] = INDEXES;
+ 
++    if (src->width != dst->width || src->height != dst->height) {
++        return 0;
++    }
++
+     for (y=0; y < src->height; y++) {
+         int nloop, nx;
+         int npix = src->width;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8012597-better_image_channel_validation.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,597 @@
+# HG changeset patch
+# User bae
+# Date 1367281246 -14400
+# Node ID 940eac3712db0f139069d1048f021f0e70cbbb3a
+# Parent  63028eef41bcd0e7ea49d333dc25ad27cd5e33a4
+8012597: Better image channel verification
+Reviewed-by: ahgross, vadim, prr
+
+diff --git a/src/share/classes/java/awt/image/BufferedImage.java b/src/share/classes/java/awt/image/BufferedImage.java
+--- openjdk/jdk/src/share/classes/java/awt/image/BufferedImage.java
++++ openjdk/jdk/src/share/classes/java/awt/image/BufferedImage.java
+@@ -654,17 +654,19 @@
+         int csType = cs.getType();
+         if (csType != ColorSpace.TYPE_RGB) {
+             if (csType == ColorSpace.TYPE_GRAY
+-                && cm instanceof ComponentColorModel) {
++                && ComponentColorModel.class.equals(cm.getClass())) {
+                 // Check if this might be a child raster (fix for bug 4240596)
+                 if (sm instanceof ComponentSampleModel &&
+                     ((ComponentSampleModel)sm).getPixelStride() != numBands) {
+                     imageType = TYPE_CUSTOM;
+                 } else if (raster instanceof ByteComponentRaster &&
++                       PixelInterleavedSampleModel.class.equals(sm.getClass()) &&
+                        raster.getNumBands() == 1 &&
+                        cm.getComponentSize(0) == 8 &&
+                        ((ByteComponentRaster)raster).getPixelStride() == 1) {
+                     imageType = TYPE_BYTE_GRAY;
+                 } else if (raster instanceof ShortComponentRaster &&
++                       PixelInterleavedSampleModel.class.equals(sm.getClass()) &&
+                        raster.getNumBands() == 1 &&
+                        cm.getComponentSize(0) == 16 &&
+                        ((ShortComponentRaster)raster).getPixelStride() == 1) {
+@@ -684,7 +686,8 @@
+             // are correct
+             int pixSize = cm.getPixelSize();
+             if (iraster.getPixelStride() == 1 &&
+-                cm instanceof DirectColorModel  &&
++                DirectColorModel.class.equals(cm.getClass())  &&
++                SinglePixelPackedSampleModel.class.equals(sm.getClass()) &&
+                 (pixSize == 32 || pixSize == 24))
+             {
+                 // Now check on the DirectColorModel params
+@@ -715,16 +718,21 @@
+                 }  // if (rmask == DCM_BGR_RED_MASK &&
+             }   // if (iraster.getPixelStride() == 1
+         }   // ((raster instanceof IntegerComponentRaster) &&
+-        else if ((cm instanceof IndexColorModel) && (numBands == 1) &&
++        else if ((IndexColorModel.class.equals(cm.getClass())) &&
++                 (numBands == 1) &&
+                  (!cm.hasAlpha() || !isAlphaPre))
+         {
+             IndexColorModel icm = (IndexColorModel) cm;
+             int pixSize = icm.getPixelSize();
+ 
+-            if (raster instanceof BytePackedRaster) {
++            if (raster instanceof BytePackedRaster &&
++                MultiPixelPackedSampleModel.class.equals(sm.getClass()))
++            {
+                 imageType = TYPE_BYTE_BINARY;
+             }   // if (raster instanceof BytePackedRaster)
+-            else if (raster instanceof ByteComponentRaster) {
++            else if (raster instanceof ByteComponentRaster &&
++                     PixelInterleavedSampleModel.class.equals(sm.getClass()))
++            {
+                 ByteComponentRaster braster = (ByteComponentRaster) raster;
+                 if (braster.getPixelStride() == 1 && pixSize <= 8) {
+                     imageType = TYPE_BYTE_INDEXED;
+@@ -732,7 +740,8 @@
+             }
+         }   // else if (cm instanceof IndexColorModel) && (numBands == 1))
+         else if ((raster instanceof ShortComponentRaster)
+-                 && (cm instanceof DirectColorModel)
++                 && (DirectColorModel.class.equals(cm.getClass()))
++                 && (SinglePixelPackedSampleModel.class.equals(sm.getClass()))
+                  && (numBands == 3)
+                  && !cm.hasAlpha())
+         {
+@@ -778,12 +787,14 @@
+             if (is8bit &&
+                 offs[0] == numBands-1 &&
+                 offs[1] == numBands-2 &&
+-                offs[2] == numBands-3)
++                offs[2] == numBands-3 &&
++                ComponentColorModel.class.equals(ccm.getClass()) &&
++                PixelInterleavedSampleModel.class.equals(csm.getClass()))
+             {
+-                if (numBands == 3) {
++                if (numBands == 3 && !ccm.hasAlpha()) {
+                     imageType = TYPE_3BYTE_BGR;
+                 }
+-                else if (offs[3] == 0) {
++                else if (offs[3] == 0 && ccm.hasAlpha()) {
+                     imageType = (isAlphaPre
+                                  ? TYPE_4BYTE_ABGR_PRE
+                                  : TYPE_4BYTE_ABGR);
+diff --git a/src/share/native/sun/awt/image/awt_parseImage.c b/src/share/native/sun/awt/image/awt_parseImage.c
+--- openjdk/jdk/src/share/native/sun/awt/image/awt_parseImage.c
++++ openjdk/jdk/src/share/native/sun/awt/image/awt_parseImage.c
+@@ -385,10 +385,39 @@
+     return 1;
+ }
+ 
++static int getColorModelType(JNIEnv *env, jobject jcmodel) {
++    int type = UNKNOWN_CM_TYPE;
++
++    if ((*env)->IsInstanceOf(env, jcmodel,
++                 (*env)->FindClass(env, "java/awt/image/IndexColorModel")))
++    {
++        type = INDEX_CM_TYPE;
++    } else if ((*env)->IsInstanceOf(env, jcmodel,
++                 (*env)->FindClass(env, "java/awt/image/PackedColorModel")))
++    {
++        if  ((*env)->IsInstanceOf(env, jcmodel,
++                (*env)->FindClass(env, "java/awt/image/DirectColorModel"))) {
++            type = DIRECT_CM_TYPE;
++        }
++        else {
++            type = PACKED_CM_TYPE;
++        }
++    }
++    else if ((*env)->IsInstanceOf(env, jcmodel,
++                 (*env)->FindClass(env, "java/awt/image/ComponentColorModel")))
++    {
++        type = COMPONENT_CM_TYPE;
++    }
++
++    return type;
++}
++
+ int awt_parseColorModel (JNIEnv *env, jobject jcmodel, int imageType,
+                          ColorModelS_t *cmP) {
+     /*jmethodID jID;   */
+     jobject jnBits;
++    jsize   nBitsLength;
++
+     int i;
+     static jobject s_jdefCM = NULL;
+ 
+@@ -410,15 +439,55 @@
+     cmP->transparency = (*env)->GetIntField(env, jcmodel,
+                                             g_CMtransparencyID);
+ 
++    jnBits = (*env)->GetObjectField(env, jcmodel, g_CMnBitsID);
++    if (jnBits == NULL) {
++        JNU_ThrowNullPointerException(env, "null nBits structure in CModel");
++        return -1;
++    }
++
++    nBitsLength = (*env)->GetArrayLength(env, jnBits);
++    if (nBitsLength != cmP->numComponents) {
++        // invalid number of components?
++        return -1;
++    }
++
++    cmP->nBits = NULL;
++    if (SAFE_TO_ALLOC_2(cmP->numComponents, sizeof(jint))) {
++        cmP->nBits = (jint *)malloc(cmP->numComponents * sizeof(jint));
++    }
++
++    if (cmP->nBits == NULL){
++        JNU_ThrowOutOfMemoryError(env, "Out of memory");
++        return -1;
++    }
++    (*env)->GetIntArrayRegion(env, jnBits, 0, cmP->numComponents,
++                              cmP->nBits);
++    cmP->maxNbits = 0;
++    for (i=0; i < cmP->numComponents; i++) {
++        if (cmP->maxNbits < cmP->nBits[i]) {
++            cmP->maxNbits = cmP->nBits[i];
++        }
++    }
++
++    cmP->is_sRGB = (*env)->GetBooleanField(env, cmP->jcmodel, g_CMis_sRGBID);
++
++    cmP->csType = (*env)->GetIntField(env, cmP->jcmodel, g_CMcsTypeID);
++
++    cmP->cmType = getColorModelType(env, jcmodel);
++
++    cmP->isDefaultCM = FALSE;
++    cmP->isDefaultCompatCM = FALSE;
++
++    /* look for standard cases */
+     if (imageType == java_awt_image_BufferedImage_TYPE_INT_ARGB) {
+         cmP->isDefaultCM = TRUE;
+         cmP->isDefaultCompatCM = TRUE;
+     } else if (imageType == java_awt_image_BufferedImage_TYPE_INT_ARGB_PRE ||
+-             imageType == java_awt_image_BufferedImage_TYPE_INT_RGB) {
+-        cmP->isDefaultCompatCM = TRUE;
+-    } else if (imageType == java_awt_image_BufferedImage_TYPE_INT_BGR ||
++               imageType == java_awt_image_BufferedImage_TYPE_INT_RGB ||
++               imageType == java_awt_image_BufferedImage_TYPE_INT_BGR ||
+                imageType == java_awt_image_BufferedImage_TYPE_4BYTE_ABGR ||
+-               imageType == java_awt_image_BufferedImage_TYPE_4BYTE_ABGR_PRE){
++               imageType == java_awt_image_BufferedImage_TYPE_4BYTE_ABGR_PRE)
++    {
+         cmP->isDefaultCompatCM = TRUE;
+     }
+     else {
+@@ -439,50 +508,25 @@
+         cmP->isDefaultCompatCM = cmP->isDefaultCM;
+     }
+ 
++    /* check whether image attributes correspond to default cm */
+     if (cmP->isDefaultCompatCM) {
+-        cmP->cmType = DIRECT_CM_TYPE;
+-        cmP->nBits = (jint *) malloc(sizeof(jint)*4);
+-        cmP->nBits[0] = cmP->nBits[1] = cmP->nBits[2] = cmP->nBits[3] = 8;
+-        cmP->maxNbits = 8;
+-        cmP->is_sRGB = TRUE;
+-        cmP->csType  = java_awt_color_ColorSpace_TYPE_RGB;
++        if (cmP->csType != java_awt_color_ColorSpace_TYPE_RGB ||
++            !cmP->is_sRGB)
++        {
++            return -1;
++        }
+ 
+-        return 1;
+-    }
+-
+-    jnBits = (*env)->GetObjectField(env, jcmodel, g_CMnBitsID);
+-    if (jnBits == NULL) {
+-        JNU_ThrowNullPointerException(env, "null nBits structure in CModel");
+-        return -1;
+-    }
+-
+-    cmP->nBits = NULL;
+-    if (SAFE_TO_ALLOC_2(cmP->numComponents, sizeof(jint))) {
+-        cmP->nBits = (jint *)malloc(cmP->numComponents * sizeof(jint));
+-    }
+-    if (cmP->nBits == NULL){
+-        JNU_ThrowOutOfMemoryError(env, "Out of memory");
+-        return -1;
+-    }
+-    (*env)->GetIntArrayRegion(env, jnBits, 0, cmP->numComponents,
+-                              cmP->nBits);
+-    cmP->maxNbits = 0;
+-    for (i=0; i < cmP->numComponents; i++) {
+-        if (cmP->maxNbits < cmP->nBits[i]) {
+-            cmP->maxNbits = cmP->nBits[i];
++        for (i = 0; i < cmP->numComponents; i++) {
++            if (cmP->nBits[i] != 8) {
++                return -1;
++            }
+         }
+     }
+ 
+-    cmP->is_sRGB = (*env)->GetBooleanField(env, cmP->jcmodel, g_CMis_sRGBID);
+-
+-    cmP->csType = (*env)->GetIntField(env, cmP->jcmodel, g_CMcsTypeID);
+-
+-    /* Find out what type of colol model */
++    /* Get index color model attributes */
+     if (imageType == java_awt_image_BufferedImage_TYPE_BYTE_INDEXED ||
+-        (*env)->IsInstanceOf(env, jcmodel,
+-                 (*env)->FindClass(env, "java/awt/image/IndexColorModel")))
++        cmP->cmType == INDEX_CM_TYPE)
+     {
+-        cmP->cmType = INDEX_CM_TYPE;
+         cmP->transIdx = (*env)->GetIntField(env, jcmodel, g_ICMtransIdxID);
+         cmP->mapSize = (*env)->GetIntField(env, jcmodel, g_ICMmapSizeID);
+         cmP->jrgb    = (*env)->GetObjectField(env, jcmodel, g_ICMrgbID);
+@@ -508,31 +552,6 @@
+             }
+         }
+     }
+-    else if ((*env)->IsInstanceOf(env, jcmodel,
+-                 (*env)->FindClass(env, "java/awt/image/PackedColorModel")))
+-    {
+-        if  ((*env)->IsInstanceOf(env, jcmodel,
+-                (*env)->FindClass(env, "java/awt/image/DirectColorModel"))){
+-            cmP->cmType = DIRECT_CM_TYPE;
+-        }
+-        else {
+-            cmP->cmType = PACKED_CM_TYPE;
+-        }
+-    }
+-    else if ((*env)->IsInstanceOf(env, jcmodel,
+-                 (*env)->FindClass(env, "java/awt/image/ComponentColorModel")))
+-    {
+-        cmP->cmType = COMPONENT_CM_TYPE;
+-    }
+-    else if ((*env)->IsInstanceOf(env, jcmodel,
+-              (*env)->FindClass(env, "java/awt/image/PackedColorModel")))
+-    {
+-        cmP->cmType = PACKED_CM_TYPE;
+-    }
+-    else {
+-        cmP->cmType = UNKNOWN_CM_TYPE;
+-    }
+-
+ 
+     return 1;
+ }
+@@ -572,6 +591,13 @@
+     ColorModelS_t *cmodelP = &imageP->cmodel;
+     int imageType = imageP->imageType;
+ 
++    // check whether raster and color model are compatible
++    if (cmodelP->numComponents != rasterP->numBands) {
++        if (cmodelP->cmType != INDEX_CM_TYPE) {
++            return -1;
++        }
++    }
++
+     hintP->numChans = imageP->cmodel.numComponents;
+     hintP->colorOrder = NULL;
+     if (SAFE_TO_ALLOC_2(hintP->numChans, sizeof(int))) {
+@@ -1063,6 +1089,10 @@
+     jsm = (*env)->GetObjectField(env, rasterP->jraster, g_RasterSampleModelID);
+     jdatabuffer = (*env)->GetObjectField(env, rasterP->jraster,
+                                          g_RasterDataBufferID);
++    if (band >= numBands) {
++        JNU_ThrowInternalError(env, "Band out of range.");
++        return -1;
++    }
+     /* Here is the generic code */
+     jdata = (*env)->NewIntArray(env, maxBytes*rasterP->numBands*maxLines);
+     if (JNU_IsNull(env, jdata)) {
+@@ -1071,11 +1101,6 @@
+     }
+     if (band >= 0) {
+         int dOff;
+-        if (band >= numBands) {
+-            (*env)->DeleteLocalRef(env, jdata);
+-            JNU_ThrowInternalError(env, "Band out of range.");
+-            return -1;
+-        }
+         off = 0;
+         for (y=0; y < h; y+=maxLines) {
+             if (y+maxLines > h) {
+diff --git a/src/share/native/sun/awt/medialib/awt_ImagingLib.c b/src/share/native/sun/awt/medialib/awt_ImagingLib.c
+--- openjdk/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
++++ openjdk/jdk/src/share/native/sun/awt/medialib/awt_ImagingLib.c
+@@ -2605,6 +2605,41 @@
+     return 0;
+ }
+ 
++#define ERR_BAD_IMAGE_LAYOUT (-2)
++
++#define CHECK_DST_ARRAY(start_offset, elements_per_pixel)             \
++    do {                                                              \
++        int offset = (start_offset);                                  \
++        int lastScanOffset;                                           \
++                                                                      \
++        if (!SAFE_TO_MULT(rasterP->scanlineStride,                    \
++                          (rasterP->height - 1)))                     \
++        {                                                             \
++            return ERR_BAD_IMAGE_LAYOUT;                              \
++        }                                                             \
++        lastScanOffset = rasterP->scanlineStride *                    \
++            (rasterP->height - 1);                                    \
++                                                                      \
++        if (!SAFE_TO_ADD(offset, lastScanOffset)) {                   \
++            return ERR_BAD_IMAGE_LAYOUT;                              \
++        }                                                             \
++        lastScanOffset += offset;                                     \
++                                                                      \
++        if (!SAFE_TO_MULT((elements_per_pixel), rasterP->width)) {    \
++            return ERR_BAD_IMAGE_LAYOUT;                              \
++        }                                                             \
++        offset = (elements_per_pixel) * rasterP->width;               \
++                                                                      \
++        if (!SAFE_TO_ADD(offset, lastScanOffset)) {                   \
++            return ERR_BAD_IMAGE_LAYOUT;                              \
++        }                                                             \
++        lastScanOffset += offset;                                     \
++                                                                      \
++        if (dataArrayLength < lastScanOffset) {                       \
++            return ERR_BAD_IMAGE_LAYOUT;                              \
++        }                                                             \
++    } while(0);                                                       \
++
+ static int
+ storeImageArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
+                 mlib_image *mlibImP) {
+@@ -2612,6 +2647,7 @@
+     unsigned char *cmDataP, *dataP, *cDataP;
+     HintS_t *hintP = &dstP->hints;
+     RasterS_t *rasterP = &dstP->raster;
++    jsize dataArrayLength = (*env)->GetArrayLength(env, rasterP->jdata);
+     int y;
+ 
+     /* REMIND: Store mlib data type? */
+@@ -2630,14 +2666,15 @@
+ 
+     if (hintP->packing == BYTE_INTERLEAVED) {
+         /* Write it back to the destination */
++        CHECK_DST_ARRAY(hintP->channelOffset, hintP->numChans);
+         cmDataP = (unsigned char *) mlib_ImageGetData(mlibImP);
+         mStride = mlib_ImageGetStride(mlibImP);
+         dataP = (unsigned char *)(*env)->GetPrimitiveArrayCritical(env,
+                                                       rasterP->jdata, NULL);
+         if (dataP == NULL) return 0;
+-        cDataP = dataP + hintP->dataOffset;
++        cDataP = dataP + hintP->channelOffset;
+         for (y=0; y < rasterP->height;
+-             y++, cmDataP += mStride, cDataP += hintP->sStride)
++             y++, cmDataP += mStride, cDataP += rasterP->scanlineStride)
+         {
+             memcpy(cDataP, cmDataP, rasterP->width*hintP->numChans);
+         }
+@@ -2648,13 +2685,14 @@
+         /* Write it back to the destination */
+         unsigned short *sdataP, *sDataP;
+         unsigned short *smDataP = (unsigned short *)mlib_ImageGetData(mlibImP);
++        CHECK_DST_ARRAY(hintP->channelOffset, hintP->numChans);
+         mStride = mlib_ImageGetStride(mlibImP);
+         sdataP = (unsigned short *)(*env)->GetPrimitiveArrayCritical(env,
+                                                       rasterP->jdata, NULL);
+         if (sdataP == NULL) return -1;
+-        sDataP = sdataP + hintP->dataOffset;
++        sDataP = sdataP + hintP->channelOffset;
+         for (y=0; y < rasterP->height;
+-             y++, smDataP += mStride, sDataP += hintP->sStride)
++            y++, smDataP += mStride, sDataP += rasterP->scanlineStride)
+         {
+             memcpy(sDataP, smDataP, rasterP->width*hintP->numChans);
+         }
+@@ -3447,7 +3485,8 @@
+     unsigned char *inP = inDataP;
+     unsigned char *lineOutP, *outP;
+     jarray jOutDataP;
+-    jint   *outDataP;
++    jsize dataArrayLength;
++    unsigned char *outDataP;
+     int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS];
+ 
+     if (rasterP->numBands > MAX_NUMBANDS) {
+@@ -3456,11 +3495,18 @@
+ 
+     /* Grab data ptr, strides, offsets from raster */
+     jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_BCRdataID);
++    if (JNU_IsNull(env, jOutDataP)) {
++        return -1;
++    }
++
++    dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
++    CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
++
+     outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
+     if (outDataP == NULL) {
+         return -1;
+     }
+-    lineOutP =  (unsigned char *)outDataP + rasterP->chanOffsets[0];
++    lineOutP = outDataP + rasterP->chanOffsets[0];
+ 
+     if (component < 0) {
+         for (c=0; c < rasterP->numBands; c++) {
+@@ -3515,7 +3561,8 @@
+     unsigned char *inP = inDataP;
+     unsigned short *lineOutP, *outP;
+     jarray jOutDataP;
+-    jint   *outDataP;
++    jsize dataArrayLength;
++    unsigned short *outDataP;
+     int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS];
+ 
+     if (rasterP->numBands > MAX_NUMBANDS) {
+@@ -3524,11 +3571,18 @@
+ 
+     /* Grab data ptr, strides, offsets from raster */
+     jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_SCRdataID);
++    if (JNU_IsNull(env, jOutDataP)) {
++        return -1;
++    }
++
++    dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
++    CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
++
+     outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
+     if (outDataP == NULL) {
+         return -1;
+     }
+-    lineOutP =  (unsigned short *)outDataP + rasterP->chanOffsets[0];
++    lineOutP = outDataP + rasterP->chanOffsets[0];
+ 
+     if (component < 0) {
+         for (c=0; c < rasterP->numBands; c++) {
+@@ -3583,7 +3637,8 @@
+     unsigned char *inP = inDataP;
+     unsigned int *lineOutP, *outP;
+     jarray jOutDataP;
+-    jint   *outDataP;
++    jsize dataArrayLength;
++    unsigned int *outDataP;
+     int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS];
+ 
+     if (rasterP->numBands > MAX_NUMBANDS) {
+@@ -3592,11 +3647,18 @@
+ 
+     /* Grab data ptr, strides, offsets from raster */
+     jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_ICRdataID);
++    if (JNU_IsNull(env, jOutDataP)) {
++        return -1;
++    }
++
++    dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
++    CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
++
+     outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
+     if (outDataP == NULL) {
+         return -1;
+     }
+-    lineOutP =  (unsigned int *)outDataP + rasterP->chanOffsets[0];
++    lineOutP = outDataP + rasterP->chanOffsets[0];
+ 
+     if (component < 0) {
+         for (c=0; c < rasterP->numBands; c++) {
+@@ -3653,7 +3715,8 @@
+     unsigned char *inP = inDataP;
+     unsigned char *lineOutP, *outP;
+     jarray jOutDataP;
+-    jint   *outDataP;
++    jsize  dataArrayLength;
++    unsigned char *outDataP;
+     int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS];
+     int a = rasterP->numBands - 1;
+ 
+@@ -3663,11 +3726,18 @@
+ 
+     /* Grab data ptr, strides, offsets from raster */
+     jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_BCRdataID);
++    if (JNU_IsNull(env, jOutDataP)) {
++        return -1;
++    }
++
++    dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
++    CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
++
+     outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
+     if (outDataP == NULL) {
+         return -1;
+     }
+-    lineOutP =  (unsigned char *)outDataP + rasterP->chanOffsets[0];
++    lineOutP = outDataP + rasterP->chanOffsets[0];
+ 
+     if (component < 0) {
+         for (c=0; c < rasterP->numBands; c++) {
+@@ -3743,7 +3813,8 @@
+     unsigned char *inP = inDataP;
+     unsigned short *lineOutP, *outP;
+     jarray jOutDataP;
+-    jint   *outDataP;
++    jsize dataArrayLength;
++    unsigned short *outDataP;
+     int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS];
+     int a = rasterP->numBands - 1;
+ 
+@@ -3753,11 +3824,17 @@
+ 
+     /* Grab data ptr, strides, offsets from raster */
+     jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_SCRdataID);
++    if (JNU_IsNull(env, jOutDataP)) {
++        return -1;
++    }
++    dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
++    CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
++
+     outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
+     if (outDataP == NULL) {
+         return -1;
+     }
+-    lineOutP =  (unsigned short *)outDataP + rasterP->chanOffsets[0];
++    lineOutP = outDataP + rasterP->chanOffsets[0];
+ 
+     if (component < 0) {
+         for (c=0; c < rasterP->numBands; c++) {
+@@ -3833,7 +3910,8 @@
+     unsigned char *inP = inDataP;
+     unsigned int *lineOutP, *outP;
+     jarray jOutDataP;
+-    jint   *outDataP;
++    jsize dataArrayLength;
++    unsigned int *outDataP;
+     int loff[MAX_NUMBANDS], roff[MAX_NUMBANDS];
+     int a = rasterP->numBands - 1;
+ 
+@@ -3843,11 +3921,18 @@
+ 
+     /* Grab data ptr, strides, offsets from raster */
+     jOutDataP = (*env)->GetObjectField(env, rasterP->jraster, g_ICRdataID);
++    if (JNU_IsNull(env, jOutDataP)) {
++        return -1;
++    }
++
++    dataArrayLength = (*env)->GetArrayLength(env, jOutDataP);
++    CHECK_DST_ARRAY(rasterP->chanOffsets[0], 1);
++
+     outDataP = (*env)->GetPrimitiveArrayCritical(env, jOutDataP, 0);
+     if (outDataP == NULL) {
+         return -1;
+     }
+-    lineOutP =  (unsigned int *)outDataP + rasterP->chanOffsets[0];
++    lineOutP = outDataP + rasterP->chanOffsets[0];
+ 
+     if (component < 0) {
+         for (c=0; c < rasterP->numBands; c++) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8012601-better_layout_validation.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,125 @@
+# HG changeset patch
+# User bae
+# Date 1366954254 -14400
+# Node ID 81cfa2275a01fdc479901031e089c76c892d1c03
+# Parent  940eac3712db0f139069d1048f021f0e70cbbb3a
+8012601: Better validation of image layouts
+Reviewed-by: mschoene, prr, vadim
+
+diff --git a/src/share/classes/java/awt/image/BufferedImage.java b/src/share/classes/java/awt/image/BufferedImage.java
+--- openjdk/jdk/src/share/classes/java/awt/image/BufferedImage.java
++++ openjdk/jdk/src/share/classes/java/awt/image/BufferedImage.java
+@@ -785,6 +785,7 @@
+                 }
+             }
+             if (is8bit &&
++                braster.getPixelStride() == numBands &&
+                 offs[0] == numBands-1 &&
+                 offs[1] == numBands-2 &&
+                 offs[2] == numBands-3 &&
+diff --git a/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java b/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java
+--- openjdk/jdk/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java
++++ openjdk/jdk/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java
+@@ -96,6 +96,7 @@
+     int width;
+     int height;
+     int nextRowOffset;
++    private int nextPixelOffset;
+     int offset;
+ 
+     Object dataArray;
+@@ -107,6 +108,7 @@
+         this.pixelType = pixelType;
+         width = np;
+         height = 1;
++        nextPixelOffset = pixelSize;
+         nextRowOffset = safeMult(pixelSize, np);
+         offset = 0;
+     }
+@@ -118,6 +120,7 @@
+         this.pixelType = pixelType;
+         this.width = width;
+         this.height = height;
++        nextPixelOffset = pixelSize;
+         nextRowOffset = safeMult(pixelSize, width);
+         offset = 0;
+     }
+@@ -213,6 +216,7 @@
+                 intRaster = (IntegerComponentRaster)image.getRaster();
+ 
+                 nextRowOffset = safeMult(4, intRaster.getScanlineStride());
++                nextPixelOffset = safeMult(4, intRaster.getPixelStride());
+ 
+                 offset = safeMult(4, intRaster.getDataOffset(0));
+ 
+@@ -225,6 +229,8 @@
+             case BufferedImage.TYPE_4BYTE_ABGR:
+                 byteRaster = (ByteComponentRaster)image.getRaster();
+                 nextRowOffset = byteRaster.getScanlineStride();
++                nextPixelOffset = byteRaster.getPixelStride();
++
+                 int firstBand = image.getSampleModel().getNumBands() - 1;
+                 offset = byteRaster.getDataOffset(firstBand);
+                 dataArray = byteRaster.getDataStorage();
+@@ -235,6 +241,8 @@
+             case BufferedImage.TYPE_BYTE_GRAY:
+                 byteRaster = (ByteComponentRaster)image.getRaster();
+                 nextRowOffset = byteRaster.getScanlineStride();
++                nextPixelOffset = byteRaster.getPixelStride();
++
+                 offset = byteRaster.getDataOffset(0);
+                 dataArray = byteRaster.getDataStorage();
+                 dataArrayLength = byteRaster.getDataStorage().length;
+@@ -244,6 +252,8 @@
+             case BufferedImage.TYPE_USHORT_GRAY:
+                 shortRaster = (ShortComponentRaster)image.getRaster();
+                 nextRowOffset = safeMult(2, shortRaster.getScanlineStride());
++                nextPixelOffset = safeMult(2, shortRaster.getPixelStride());
++
+                 offset = safeMult(2, shortRaster.getDataOffset(0));
+                 dataArray = shortRaster.getDataStorage();
+                 dataArrayLength = 2 * shortRaster.getDataStorage().length;
+@@ -273,9 +283,15 @@
+             throw new ImageLayoutException("Invalid image layout");
+         }
+ 
+-        int lastPixelOffset = safeMult(nextRowOffset, (height - 1));
++        if (nextPixelOffset != getBytesPerPixel(pixelType)) {
++            throw new ImageLayoutException("Invalid image layout");
++        }
+ 
+-        lastPixelOffset = safeAdd(lastPixelOffset, (width - 1));
++        int lastScanOffset = safeMult(nextRowOffset, (height - 1));
++
++        int lastPixelOffset = safeMult(nextPixelOffset, (width -1 ));
++
++        lastPixelOffset = safeAdd(lastPixelOffset, lastScanOffset);
+ 
+         int off = safeAdd(offset, lastPixelOffset);
+ 
+@@ -307,4 +323,25 @@
+             super(message);
+         }
+     }
++
++    /**
++     * Derives number of bytes per pixel from the pixel format.
++     * Following bit fields are used here:
++     *  [0..2] - bytes per sample
++     *  [3..6] - number of color samples per pixel
++     *  [7..9] - number of non-color samples per pixel
++     *
++     * A complete description of the pixel format can be found
++     * here: lcms2.h, lines 651 - 667.
++     *
++     * @param pixelType pixel format in lcms2 notation.
++     * @return number of bytes per pixel for given pixel format.
++     */
++    private static int getBytesPerPixel(int pixelType) {
++        int bytesPerSample = (0x7 & pixelType);
++        int colorSamplesPerPixel = 0xF & (pixelType >> 3);
++        int extraSamplesPerPixel = 0x7 & (pixelType >> 7);
++
++        return bytesPerSample * (colorSamplesPerPixel + extraSamplesPerPixel);
++    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8014281-better_xml_signature_checking.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,49 @@
+# HG changeset patch
+# User xuelei
+# Date 1368495045 25200
+# Node ID 0e01465ca15f49a2b5ebfca89d85c2f0575b96e4
+# Parent  81cfa2275a01fdc479901031e089c76c892d1c03
+8014281: Better checking of XML signature
+Summary: also reviewed by Andrew Gross and Christophe Ravel
+Reviewed-by: mullan
+
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/DOMCanonicalizationMethod.java
+@@ -51,6 +51,11 @@
+     public DOMCanonicalizationMethod(TransformService spi)
+         throws InvalidAlgorithmParameterException {
+         super(spi);
++        if (!(spi instanceof ApacheCanonicalizer) &&
++                !isC14Nalg(spi.getAlgorithm())) {
++            throw new InvalidAlgorithmParameterException(
++                "Illegal CanonicalizationMethod");
++        }
+     }
+ 
+     /**
+@@ -63,6 +68,10 @@
+     public DOMCanonicalizationMethod(Element cmElem, XMLCryptoContext context,
+         Provider provider) throws MarshalException {
+         super(cmElem, context, provider);
++        if (!(spi instanceof ApacheCanonicalizer) &&
++                !isC14Nalg(spi.getAlgorithm())) {
++            throw new MarshalException("Illegal CanonicalizationMethod");
++        }
+     }
+ 
+     /**
+@@ -101,4 +110,13 @@
+         return (getAlgorithm().equals(ocm.getAlgorithm()) &&
+             DOMUtils.paramsEqual(getParameterSpec(), ocm.getParameterSpec()));
+     }
++
++    private static boolean isC14Nalg(String alg) {
++        return (alg.equals(CanonicalizationMethod.INCLUSIVE) ||
++                alg.equals(CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS) ||
++                alg.equals(CanonicalizationMethod.EXCLUSIVE) ||
++                alg.equals(CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS) ||
++                alg.equals(DOMCanonicalXMLC14N11Method.C14N_11) ||
++                alg.equals(DOMCanonicalXMLC14N11Method.C14N_11_WITH_COMMENTS));
++     }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/8015997-more_javadoc_framing.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,21 @@
+# HG changeset patch
+# User bpatel
+# Date 1370467914 25200
+# Node ID f422c843b477501acc2526c69609fd94204cdce1
+# Parent  b4954380fa25058f1a6cfb9cb96f78d90cf0fc5c
+8015997: Additional improvement in Javadoc framing
+Reviewed-by: jjg
+
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/markup/HtmlWriter.java
+@@ -312,7 +312,8 @@
+                 "    if (targetPage.indexOf(\":\") != -1 || (targetPage != \"\" && !validURL(targetPage)))" + DocletConstants.NL +
+                 "        targetPage = \"undefined\";" + DocletConstants.NL +
+                 "    function validURL(url) {" + DocletConstants.NL +
+-                "        if (!(url.indexOf(\".html\") == url.length - 5))" + DocletConstants.NL +
++                "        var pos = url.indexOf(\".html\");" + DocletConstants.NL +
++                "        if (pos == -1 || pos != url.length - 5)" + DocletConstants.NL +
+                 "            return false;" + DocletConstants.NL +
+                 "        var allowNumber = false;" + DocletConstants.NL +
+                 "        var allowSep = false;" + DocletConstants.NL +
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/diamond_fix.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,55 @@
+# HG changeset patch
+# User andrew
+# Date 1371488944 18000
+# Node ID 60c57caf0348c7eed93900e4395607af759e6ba9
+# Parent  a844309d9f0a490f8ac56d21f1323e8deb65ffd1
+Fix introduction of diamond operator in some classes.
+
+diff --git a/src/share/classes/com/sun/media/sound/AbstractLine.java b/src/share/classes/com/sun/media/sound/AbstractLine.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java
+@@ -54,7 +54,7 @@
+      * Contains event dispatcher per thread group.
+      */
+     private static final Map<ThreadGroup, EventDispatcher> dispatchers =
+-            new WeakHashMap<>();
++      new WeakHashMap<ThreadGroup, EventDispatcher>();
+ 
+     /**
+      * Constructs a new AbstractLine.
+diff --git a/src/share/classes/com/sun/media/sound/RealTimeSequencer.java b/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
+--- openjdk/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
++++ openjdk/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java
+@@ -59,7 +59,7 @@
+      * dispatcher instance with a factory in EventDispatcher
+      */
+     private static final Map<ThreadGroup, EventDispatcher> dispatchers =
+-            new WeakHashMap<>();
++      new WeakHashMap<ThreadGroup, EventDispatcher>();
+ 
+     /**
+      * All RealTimeSequencers share this info object.
+diff --git a/src/share/classes/java/io/ObjectStreamClass.java b/src/share/classes/java/io/ObjectStreamClass.java
+--- openjdk/jdk/src/share/classes/java/io/ObjectStreamClass.java
++++ openjdk/jdk/src/share/classes/java/io/ObjectStreamClass.java
+@@ -1135,7 +1135,7 @@
+             end = end.getSuperclass();
+         }
+ 
+-        HashSet<String> oscNames = new HashSet<>(3);
++        HashSet<String> oscNames = new HashSet<String>(3);
+ 
+         for (ObjectStreamClass d = this; d != null; d = d.superDesc) {
+             if (oscNames.contains(d.name)) {
+diff --git a/src/share/classes/sun/font/CreatedFontTracker.java b/src/share/classes/sun/font/CreatedFontTracker.java
+--- openjdk/jdk/src/share/classes/sun/font/CreatedFontTracker.java
++++ openjdk/jdk/src/share/classes/sun/font/CreatedFontTracker.java
+@@ -106,7 +106,7 @@
+      * Note that this only applies to createFont() from an InputStream object.
+      */
+     private static class TempFileDeletionHook {
+-        private static HashMap<File, OutputStream> files = new HashMap<>();
++        private static HashMap<File, OutputStream> files = new HashMap<File, OutputStream>();
+ 
+         private static Thread t = null;
+         static void init() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/handle_npe.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,21 @@
+# HG changeset patch
+# User andrew
+# Date 1371200704 -3600
+# Node ID 662fbd43808413b2bd7ae4ae95683da98999023e
+# Parent  0e01465ca15f49a2b5ebfca89d85c2f0575b96e4
+Handle NullPointerException in getNotificationInfo
+
+diff --git a/src/share/classes/javax/management/StandardEmitterMBean.java b/src/share/classes/javax/management/StandardEmitterMBean.java
+--- openjdk/jdk/src/share/classes/javax/management/StandardEmitterMBean.java
++++ openjdk/jdk/src/share/classes/javax/management/StandardEmitterMBean.java
+@@ -258,8 +258,8 @@
+     }
+ 
+     public MBeanNotificationInfo[] getNotificationInfo() {
+-        if (notificationInfo.length == 0) {
+-            return notificationInfo;
++        if (notificationInfo == null || notificationInfo.length == 0) {
++            return NO_NOTIFICATION_INFO;
+         } else {
+             return notificationInfo.clone();
+         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/hs_merge-01.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,284 @@
+# HG changeset patch
+# User andrew
+# Date 1371815475 18000
+# Node ID 4215483da6f258a04b3a8ce6015d57ecbc296eac
+# Parent  f105c2b7da46999930ae40ac8661a56d6ce1c5cd
+Fix merge issues
+
+diff --git a/src/share/vm/classfile/classFileParser.cpp b/src/share/vm/classfile/classFileParser.cpp
+--- openjdk/hotspot/src/share/vm/classfile/classFileParser.cpp
++++ openjdk/hotspot/src/share/vm/classfile/classFileParser.cpp
+@@ -2638,54 +2638,6 @@
+ }
+ 
+ 
+-static void initialize_static_field(fieldDescriptor* fd, TRAPS) {
+-  KlassHandle h_k (THREAD, fd->field_holder());
+-  assert(h_k.not_null() && fd->is_static(), "just checking");
+-  if (fd->has_initial_value()) {
+-    BasicType t = fd->field_type();
+-    switch (t) {
+-      case T_BYTE:
+-        h_k()->byte_field_put(fd->offset(), fd->int_initial_value());
+-              break;
+-      case T_BOOLEAN:
+-        h_k()->bool_field_put(fd->offset(), fd->int_initial_value());
+-              break;
+-      case T_CHAR:
+-        h_k()->char_field_put(fd->offset(), fd->int_initial_value());
+-              break;
+-      case T_SHORT:
+-        h_k()->short_field_put(fd->offset(), fd->int_initial_value());
+-              break;
+-      case T_INT:
+-        h_k()->int_field_put(fd->offset(), fd->int_initial_value());
+-        break;
+-      case T_FLOAT:
+-        h_k()->float_field_put(fd->offset(), fd->float_initial_value());
+-        break;
+-      case T_DOUBLE:
+-        h_k()->double_field_put(fd->offset(), fd->double_initial_value());
+-        break;
+-      case T_LONG:
+-        h_k()->long_field_put(fd->offset(), fd->long_initial_value());
+-        break;
+-      case T_OBJECT:
+-        {
+-          #ifdef ASSERT
+-          TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
+-          assert(fd->signature() == sym, "just checking");
+-          #endif
+-          oop string = fd->string_initial_value(CHECK);
+-          h_k()->obj_field_put(fd->offset(), string);
+-        }
+-        break;
+-      default:
+-        THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
+-                  "Illegal ConstantValue attribute in class file");
+-    }
+-  }
+-}
+-
+-
+ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
+                                                     Handle class_loader,
+                                                     Handle protection_domain,
+diff --git a/src/share/vm/classfile/symbolTable.cpp b/src/share/vm/classfile/symbolTable.cpp
+--- openjdk/hotspot/src/share/vm/classfile/symbolTable.cpp
++++ openjdk/hotspot/src/share/vm/classfile/symbolTable.cpp
+@@ -40,6 +40,7 @@
+ 
+ SymbolTable* SymbolTable::_the_table = NULL;
+ bool SymbolTable::_needs_rehashing = false;
++jint SymbolTable::_seed = 0;
+ 
+ Symbol* SymbolTable::allocate_symbol(const u1* name, int len, TRAPS) {
+   // Don't allow symbols to be created which cannot fit in a Symbol*.
+@@ -121,17 +122,25 @@
+   }
+ }
+ 
++unsigned int SymbolTable::new_hash(Symbol* sym) {
++  ResourceMark rm;
++  // Use alternate hashing algorithm on this symbol.
++  return AltHashing::murmur3_32(seed(), (const jbyte*)sym->as_C_string(), sym->utf8_length());
++}
+ 
+ // Create a new table and using alternate hash code, populate the new table
+ // with the existing strings.   Set flag to use the alternate hash code afterwards.
+ void SymbolTable::rehash_table() {
+ 
+   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
+-  // This should never happen with -Xshare:dump but it might in testing mode.
+-  if (DumpSharedSpaces) return;
++  assert(!DumpSharedSpaces, "this should never happen with -Xshare:dump");
+   // Create a new symbol table
+   SymbolTable* new_table = new SymbolTable();
+ 
++  // Initialize the global seed for hashing.
++  _seed = AltHashing::compute_seed();
++  assert(seed() != 0, "shouldn't be zero");
++
+   the_table()->move_to(new_table);
+ 
+   // Delete the table and buckets (entries are reused in new table).
+diff --git a/src/share/vm/classfile/symbolTable.hpp b/src/share/vm/classfile/symbolTable.hpp
+--- openjdk/hotspot/src/share/vm/classfile/symbolTable.hpp
++++ openjdk/hotspot/src/share/vm/classfile/symbolTable.hpp
+@@ -88,6 +88,7 @@
+ 
+   // Set if one bucket is out of balance due to hash algorithm deficiency
+   static bool _needs_rehashing;
++  static jint _seed;
+ 
+   // Adding elements
+   Symbol* basic_add(int index, u1* name, int len,
+@@ -120,6 +121,10 @@
+     : Hashtable<Symbol*>(symbol_table_size, sizeof (HashtableEntry<Symbol*>), t,
+                 number_of_entries) {}
+ 
++  static bool use_alternate_hashcode()  { return _seed != 0; }
++  static jint seed()                    { return _seed; }
++ 
++  unsigned int new_hash(Symbol* sym);
+ public:
+   enum {
+     symbol_alloc_batch_size = 8
+@@ -225,6 +230,7 @@
+ 
+   // Set if one bucket is out of balance due to hash algorithm deficiency
+   static bool _needs_rehashing;
++  static jint _seed;
+ 
+   static oop intern(Handle string_or_null, jchar* chars, int length, TRAPS);
+   oop basic_add(int index, Handle string_or_null, jchar* name, int len,
+@@ -243,6 +249,10 @@
+     : Hashtable<oop>(string_table_size, sizeof (HashtableEntry<oop>), t,
+                 number_of_entries) {}
+ 
++  static bool use_alternate_hashcode()  { return _seed != 0; }
++  static jint seed()                    { return _seed; }
++
++  unsigned int new_hash(oop s);
+ public:
+   // The string table
+   static StringTable* the_table() { return _the_table; }
+diff --git a/src/share/vm/oops/instanceKlassKlass.cpp b/src/share/vm/oops/instanceKlassKlass.cpp
+--- openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
++++ openjdk/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
+@@ -347,35 +347,6 @@
+   return ik->object_size();
+ }
+ 
+-int instanceKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
+-                                            HeapWord* beg_addr,
+-                                            HeapWord* end_addr) {
+-  assert(obj->is_klass(),"must be a klass");
+-  assert(klassOop(obj)->klass_part()->oop_is_instance_slow(),
+-         "must be instance klass");
+-
+-  instanceKlass* ik = instanceKlass::cast(klassOop(obj));
+-  ik->update_static_fields(beg_addr, end_addr);
+-  ik->vtable()->oop_update_pointers(cm, beg_addr, end_addr);
+-  ik->itable()->oop_update_pointers(cm, beg_addr, end_addr);
+-
+-  oop* const beg_oop = MAX2((oop*)beg_addr, ik->oop_block_beg());
+-  oop* const end_oop = MIN2((oop*)end_addr, ik->oop_block_end());
+-  for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) {
+-    PSParallelCompact::adjust_pointer(cur_oop);
+-  }
+-
+-  // The oop_map_cache, jni_ids and jni_id_map are allocated from the C heap,
+-  // and so don't lie within any 'Chunk' boundaries.  Update them when the
+-  // lowest addressed oop in the instanceKlass 'oop_block' is updated.
+-  if (beg_oop == ik->oop_block_beg()) {
+-    OopClosure* closure = PSParallelCompact::adjust_root_pointer_closure();
+-    iterate_c_heap_oops(ik, closure);
+-  }
+-
+-  klassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr);
+-  return ik->object_size();
+-}
+ #endif // SERIALGC
+ 
+ klassOop
+diff --git a/src/share/vm/prims/methodHandles.cpp b/src/share/vm/prims/methodHandles.cpp
+--- openjdk/hotspot/src/share/vm/prims/methodHandles.cpp
++++ openjdk/hotspot/src/share/vm/prims/methodHandles.cpp
+@@ -646,7 +646,7 @@
+       }
+     }
+   }
+-  assert(java_lang_invoke_MethodTypeForm::vmslots(mtform()) == argument_slot_count(mtype()), "must agree");
++  assert(java_dyn_MethodTypeForm::vmslots(mtform()) == argument_slot_count(mtype()), "must agree");
+ }
+ 
+ // Conversely, a member name which is only initialized from JVM internals
+diff --git a/src/share/vm/utilities/hashtable.cpp b/src/share/vm/utilities/hashtable.cpp
+--- openjdk/hotspot/src/share/vm/utilities/hashtable.cpp
++++ openjdk/hotspot/src/share/vm/utilities/hashtable.cpp
+@@ -1,4 +1,5 @@
+-/* * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
++/* 
++* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+@@ -96,38 +97,18 @@
+   return false;
+ }
+ 
+-unsigned int Hashtable::new_hash(oop string) {
+-  ResourceMark rm;
+-  int length;
+-  if (java_lang_String::is_instance(string)) {
+-    jchar* chars = java_lang_String::as_unicode_string(string, length);
+-    // Use alternate hashing algorithm on the string
+-    return AltHashing::murmur3_32(seed(), chars, length);
+-  } else {
+-    // Use alternate hashing algorithm on this symbol.
+-    symbolOop symOop = (symbolOop) string;
+-    return AltHashing::murmur3_32(seed(), (const jbyte*)symOop->bytes(), symOop->utf8_length());
+-  }
+-}
+-
+ // Create a new table and using alternate hash code, populate the new table
+ // with the existing elements.   This can be used to change the hash code
+ // and could in the future change the size of the table.
+ 
+-void Hashtable::move_to(Hashtable* new_table) {
+-  // Initialize the global seed for hashing.
+-  assert(new_table->seed() == 0, "should be zero");
+-  _seed = AltHashing::compute_seed();
+-  assert(seed() != 0, "shouldn't be zero");
+-  new_table->set_seed(_seed);
+-
++template <class T> void Hashtable<T>::move_to(Hashtable<T>* new_table) {
+   int saved_entry_count = this->number_of_entries();
+   
+   // Iterate through the table and create a new entry for the new table
+   for (int i = 0; i < new_table->table_size(); ++i) {
+-    for (HashtableEntry* p = bucket(i); p != NULL; ) {
+-      HashtableEntry* next = p->next();
+-      oop string = p->literal();
++    for (HashtableEntry<T>* p = bucket(i); p != NULL; ) {
++      HashtableEntry<T>* next = p->next();
++      T string = p->literal();
+       // Use alternate hashing algorithm on the symbol in the first table
+       unsigned int hashValue = new_hash(string);
+       // Get a new index relative to the new table (can also change size)
+diff --git a/src/share/vm/utilities/hashtable.hpp b/src/share/vm/utilities/hashtable.hpp
+--- openjdk/hotspot/src/share/vm/utilities/hashtable.hpp
++++ openjdk/hotspot/src/share/vm/utilities/hashtable.hpp
+@@ -240,11 +240,11 @@
+ 
+ public:
+   Hashtable(int table_size, int entry_size)
+-    : BasicHashtable(table_size, entry_size), _seed(0)  { }
++    : BasicHashtable(table_size, entry_size) { }
+ 
+   Hashtable(int table_size, int entry_size,
+                    HashtableBucket* buckets, int number_of_entries)
+-    : BasicHashtable(table_size, entry_size, buckets, number_of_entries), _seed(0) { }
++    : BasicHashtable(table_size, entry_size, buckets, number_of_entries) { }
+ 
+   // Debugging
+   void print()               PRODUCT_RETURN;
+@@ -279,15 +279,8 @@
+   }
+ 
+   // Function to move these elements into the new table.
+-  void move_to(Hashtable* new_table);
+-  bool use_alternate_hashcode()  { return _seed != 0; }
+-  jint seed()                    { return _seed; }
+-  void set_seed(jint seed)       { _seed = seed; }
+-
+- private:
+-  jint _seed;
+-
+-  unsigned int new_hash(oop string);
++  void move_to(Hashtable<T>* new_table);
++  virtual unsigned int new_hash(T) { ShouldNotReachHere(); return 0; } // should be overridden
+ };
+ 
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/hs_merge-02.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,155 @@
+# HG changeset patch
+# User andrew
+# Date 1371820239 18000
+# Node ID f97b2cef7f861a3eb6d78e70cdb2cef1517bb968
+# Parent  4215483da6f258a04b3a8ce6015d57ecbc296eac
+Fix JSR292
+
+diff --git a/src/share/vm/classfile/javaClasses.cpp b/src/share/vm/classfile/javaClasses.cpp
+--- openjdk/hotspot/src/share/vm/classfile/javaClasses.cpp
++++ openjdk/hotspot/src/share/vm/classfile/javaClasses.cpp
+@@ -2324,7 +2324,6 @@
+ int java_dyn_MethodHandle::_type_offset;
+ int java_dyn_MethodHandle::_vmtarget_offset;
+ int java_dyn_MethodHandle::_vmentry_offset;
+-int java_dyn_MethodHandle::_vmslots_offset;
+ 
+ int sun_dyn_MemberName::_clazz_offset;
+ int sun_dyn_MemberName::_name_offset;
+@@ -2345,11 +2344,6 @@
+   if (k != NULL && EnableMethodHandles) {
+     compute_offset(_type_offset,      k, vmSymbols::type_name(),      vmSymbols::java_dyn_MethodType_signature(), true);
+     compute_offset(_vmtarget_offset,  k, vmSymbols::vmtarget_name(),  vmSymbols::object_signature(), true);
+-    compute_offset(_vmentry_offset,   k, vmSymbols::vmentry_name(),   vmSymbols::machine_word_signature(), true);
+-
+-    // Note:  MH.vmslots (if it is present) is a hoisted copy of MH.type.form.vmslots.
+-    // It is optional pending experiments to keep or toss.
+-    compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), true);
+   }
+ }
+ 
+@@ -2395,31 +2389,9 @@
+   mh->obj_field_put(_type_offset, mtype);
+ }
+ 
+-int java_dyn_MethodHandle::vmslots(oop mh) {
+-  int vmslots_offset = _vmslots_offset;
+-  if (vmslots_offset != 0) {
+-#ifdef ASSERT
+-    int x = mh->int_field(vmslots_offset);
+-    int y = compute_vmslots(mh);
+-    assert(x == y, "correct hoisted value");
+-#endif
+-    return mh->int_field(vmslots_offset);
+-  } else {
+-    return compute_vmslots(mh);
+-  }
+-}
+-
+-// if MH.vmslots exists, hoist into it the value of type.form.vmslots
+-void java_dyn_MethodHandle::init_vmslots(oop mh) {
+-  int vmslots_offset = _vmslots_offset;
+-  if (vmslots_offset != 0) {
+-    mh->int_field_put(vmslots_offset, compute_vmslots(mh));
+-  }
+-}
+-
+ // fetch type.form.vmslots, which is the number of JVM stack slots
+ // required to carry the arguments of this MH
+-int java_dyn_MethodHandle::compute_vmslots(oop mh) {
++int java_dyn_MethodHandle::vmslots(oop mh) {
+   oop mtype = type(mh);
+   if (mtype == NULL)  return 0;  // Java code would get NPE
+   oop form = java_dyn_MethodType::form(mtype);
+@@ -2648,16 +2620,12 @@
+ // Support for java_dyn_CallSite
+ 
+ int java_dyn_CallSite::_target_offset;
+-int java_dyn_CallSite::_caller_method_offset;
+-int java_dyn_CallSite::_caller_bci_offset;
+ 
+ void java_dyn_CallSite::compute_offsets() {
+   if (!EnableInvokeDynamic)  return;
+   klassOop k = SystemDictionary::CallSite_klass();
+   if (k != NULL) {
+     compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_dyn_MethodHandle_signature());
+-    compute_offset(_caller_method_offset, k, vmSymbols::vmmethod_name(), vmSymbols::sun_dyn_MemberName_signature());
+-    compute_offset(_caller_bci_offset, k, vmSymbols::vmindex_name(), vmSymbols::int_signature());
+   }
+ }
+ 
+@@ -2669,23 +2637,6 @@
+   site->obj_field_put(_target_offset, target);
+ }
+ 
+-oop java_dyn_CallSite::caller_method(oop site) {
+-  return site->obj_field(_caller_method_offset);
+-}
+-
+-void java_dyn_CallSite::set_caller_method(oop site, oop ref) {
+-  site->obj_field_put(_caller_method_offset, ref);
+-}
+-
+-jint java_dyn_CallSite::caller_bci(oop site) {
+-  return site->int_field(_caller_bci_offset);
+-}
+-
+-void java_dyn_CallSite::set_caller_bci(oop site, jint bci) {
+-  site->int_field_put(_caller_bci_offset, bci);
+-}
+-
+-
+ // Support for java_security_AccessControlContext
+ 
+ int java_security_AccessControlContext::_context_offset = 0;
+diff --git a/src/share/vm/classfile/javaClasses.hpp b/src/share/vm/classfile/javaClasses.hpp
+--- openjdk/hotspot/src/share/vm/classfile/javaClasses.hpp
++++ openjdk/hotspot/src/share/vm/classfile/javaClasses.hpp
+@@ -872,7 +872,7 @@
+ };
+ 
+ #define DIRECTMETHODHANDLE_INJECTED_FIELDS(macro)                          \
+-  macro(java_dyn_DirectMethodHandle, vmindex, int_signature, true)
++  macro(sun_dyn_DirectMethodHandle, vmindex, int_signature, true)
+ 
+ class sun_dyn_DirectMethodHandle: public java_dyn_MethodHandle {
+   friend class JavaClasses;
+@@ -1090,8 +1090,7 @@
+ };
+ 
+ #define METHODTYPEFORM_INJECTED_FIELDS(macro)                              \
+-  macro(java_dyn_MethodTypeForm, vmslots,  int_signature,    true) \
+-  macro(java_dyn_MethodTypeForm, vmlayout, object_signature, true)
++  macro(java_dyn_MethodTypeForm, vmslots,  int_signature,    true)
+ 
+ class java_dyn_MethodTypeForm: AllStatic {
+   friend class JavaClasses;
+diff --git a/src/share/vm/classfile/symbolTable.cpp b/src/share/vm/classfile/symbolTable.cpp
+--- openjdk/hotspot/src/share/vm/classfile/symbolTable.cpp
++++ openjdk/hotspot/src/share/vm/classfile/symbolTable.cpp
+@@ -291,7 +291,6 @@
+   if (!added) {
+     // do it the hard way
+     for (int i=0; i<names_count; i++) {
+-      assert(!Universe::heap()->is_in_reserved(names[i]) || GC_locker::is_active(),
+       int index = table->hash_to_index(hashValues[i]);
+       Symbol* sym = table->basic_add(index, (u1*)names[i], lengths[i],
+                                        hashValues[i], CHECK);
+@@ -300,7 +299,7 @@
+   }
+ }
+ 
+-Symbol* SymbolTable::basic_add(int index, u1 *name, int len,
++Symbol* SymbolTable::basic_add(int index_arg, u1 *name, int len,
+                                  unsigned int hashValue_arg, TRAPS) {
+   assert(!Universe::heap()->is_in_reserved(name) || GC_locker::is_active(),
+          "proposed name of symbol must be stable");
+@@ -591,7 +590,7 @@
+ }
+ 
+ 
+-oop StringTable::basic_add(int index, Handle string_or_null, jchar* name,
++oop StringTable::basic_add(int index_arg, Handle string_or_null, jchar* name,
+                            int len, unsigned int hashValue_arg, TRAPS) {
+   debug_only(StableMemoryChecker smc(name, len * sizeof(name[0])));
+   assert(!Universe::heap()->is_in_reserved(name) || GC_locker::is_active(),
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/hs_merge-03.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,18 @@
+# HG changeset patch
+# User andrew
+# Date 1371822495 18000
+# Node ID cdce92891bfbc17372d8e5d5d2cccf319cf73589
+# Parent  f97b2cef7f861a3eb6d78e70cdb2cef1517bb968
+Add missing _seed variable
+
+diff --git a/src/share/vm/classfile/symbolTable.cpp b/src/share/vm/classfile/symbolTable.cpp
+--- openjdk/hotspot/src/share/vm/classfile/symbolTable.cpp
++++ openjdk/hotspot/src/share/vm/classfile/symbolTable.cpp
+@@ -564,6 +564,7 @@
+ StringTable* StringTable::_the_table = NULL;
+ 
+ bool StringTable::_needs_rehashing = false;
++jint StringTable::_seed = 0;
+ 
+ // Pick hashing algorithm
+ unsigned int StringTable::hash_string(const jchar* s, int len) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/hs_merge-04.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,44 @@
+# HG changeset patch
+# User andrew
+# Date 1371823968 18000
+# Node ID 23feb1f1b3033e87b9bad1f88f663ec3e1ac5ca9
+# Parent  81575d3cbd95714395c022a7f7ca622bab432b2b
+Hashing cleanup
+
+diff --git a/src/share/vm/classfile/symbolTable.cpp b/src/share/vm/classfile/symbolTable.cpp
+--- openjdk/hotspot/src/share/vm/classfile/symbolTable.cpp
++++ openjdk/hotspot/src/share/vm/classfile/symbolTable.cpp
+@@ -176,8 +176,8 @@
+ 
+ // Pick hashing algorithm.
+ unsigned int SymbolTable::hash_symbol(const char* s, int len) {
+-  return the_table()->use_alternate_hashcode() ?
+-           AltHashing::murmur3_32(the_table()->seed(), (const jbyte*)s, len) :
++  return use_alternate_hashcode() ?
++           AltHashing::murmur3_32(seed(), (const jbyte*)s, len) :
+            java_lang_String::to_hash(s, len);
+ }
+ 
+@@ -568,7 +568,7 @@
+ 
+ // Pick hashing algorithm
+ unsigned int StringTable::hash_string(const jchar* s, int len) {
+-  return the_table()->use_alternate_hashcode() ? AltHashing::murmur3_32(the_table()->seed(), s, len) :
++  return use_alternate_hashcode() ? AltHashing::murmur3_32(seed(), s, len) :
+                                     java_lang_String::to_hash(s, len);
+ }
+ 
+@@ -770,6 +770,13 @@
+   st->print_cr("Maximum bucket size     : %7.0f", summary.maximum());
+ }
+ 
++unsigned int StringTable::new_hash(oop string) {
++  ResourceMark rm;
++  int length;
++  jchar* chars = java_lang_String::as_unicode_string(string, length);
++  // Use alternate hashing algorithm on the string
++  return AltHashing::murmur3_32(seed(), chars, length);
++}
+ 
+ // Create a new table and using alternate hash code, populate the new table
+ // with the existing strings.   Set flag to use the alternate hash code afterwards.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/javac_issue.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,60 @@
+# HG changeset patch
+# User andrew
+# Date 1371835374 18000
+# Node ID 471dd797c10d400a89503d94ab3832ab1cdb67ad
+# Parent  9892a997b49abd5ae9a5e1ec8fef1f93631f87ae
+Workaround javac issue
+
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/Canonicalizer20010315Excl.java
+@@ -207,7 +207,7 @@
+          * @param inclusiveNamespaces
+          * @throws CanonicalizationException
+          */
+-        public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet,
++        public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet,
+                         String inclusiveNamespaces) throws CanonicalizationException {
+ 
+ 
+diff --git a/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java b/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
+--- openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
++++ openjdk/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/CanonicalizerBase.java
+@@ -97,7 +97,7 @@
+    List nodeFilter;
+ 
+    boolean _includeComments;
+-   Set _xpathNodeSet = null;
++   Set<Node> _xpathNodeSet = null;
+    /**
+     * The node to be skiped/excluded from the DOM tree
+     * in subtree canonicalizations.
+@@ -130,7 +130,7 @@
+     * @param xpathNodeSet
+     * @throws CanonicalizationException
+     */
+-   public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
++   public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
+            throws CanonicalizationException {
+            this._xpathNodeSet = xpathNodeSet;
+            return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet));
+diff --git a/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java b/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
+--- openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
++++ openjdk/jdk/src/share/classes/org/jcp/xml/dsig/internal/dom/ApacheCanonicalizer.java
+@@ -48,6 +48,7 @@
+ import com.sun.org.apache.xml.internal.security.transforms.Transform;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
++import org.w3c.dom.Node;
+ import org.w3c.dom.NodeList;
+ 
+ public abstract class ApacheCanonicalizer extends TransformService {
+@@ -119,7 +120,7 @@
+         }
+ 
+         try {
+-            Set nodeSet = null;
++            Set<Node> nodeSet = null;
+             if (data instanceof ApacheData) {
+                 XMLSignatureInput in =
+                     ((ApacheData) data).getXMLSignatureInput();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/langtools_generics.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,600 @@
+# HG changeset patch
+# User andrew
+# Date 1371740021 18000
+# Node ID a5c99fd80b4c9f5049351bf5bff8517dd6d3b613
+# Parent  335cdc9887c56f560991275fe8d32e6edb6b3f1e
+Add generics
+
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+@@ -41,29 +41,29 @@
+ public class ClassUseWriter extends SubWriterHolderWriter {
+ 
+     final ClassDoc classdoc;
+-    Set pkgToPackageAnnotations = null;
+-    final Map pkgToClassTypeParameter;
+-    final Map pkgToClassAnnotations;
+-    final Map pkgToMethodTypeParameter;
+-    final Map pkgToMethodArgTypeParameter;
+-    final Map pkgToMethodReturnTypeParameter;
+-    final Map pkgToMethodAnnotations;
+-    final Map pkgToMethodParameterAnnotations;
+-    final Map pkgToFieldTypeParameter;
+-    final Map pkgToFieldAnnotations;
+-    final Map pkgToSubclass;
+-    final Map pkgToSubinterface;
+-    final Map pkgToImplementingClass;
+-    final Map pkgToField;
+-    final Map pkgToMethodReturn;
+-    final Map pkgToMethodArgs;
+-    final Map pkgToMethodThrows;
+-    final Map pkgToConstructorAnnotations;
+-    final Map pkgToConstructorParameterAnnotations;
+-    final Map pkgToConstructorArgs;
+-    final Map pkgToConstructorArgTypeParameter;
+-    final Map pkgToConstructorThrows;
+-    final SortedSet pkgSet;
++    Set<PackageDoc> pkgToPackageAnnotations = null;
++    final Map<String,List<ProgramElementDoc>> pkgToClassTypeParameter;
++    final Map<String,List<ProgramElementDoc>> pkgToClassAnnotations;
++    final Map<String,List<ProgramElementDoc>> pkgToMethodTypeParameter;
++    final Map<String,List<ProgramElementDoc>> pkgToMethodArgTypeParameter;
++    final Map<String,List<ProgramElementDoc>> pkgToMethodReturnTypeParameter;
++    final Map<String,List<ProgramElementDoc>> pkgToMethodAnnotations;
++    final Map<String,List<ProgramElementDoc>> pkgToMethodParameterAnnotations;
++    final Map<String,List<ProgramElementDoc>> pkgToFieldTypeParameter;
++    final Map<String,List<ProgramElementDoc>> pkgToFieldAnnotations;
++    final Map<String,List<ProgramElementDoc>> pkgToSubclass;
++    final Map<String,List<ProgramElementDoc>> pkgToSubinterface;
++    final Map<String,List<ProgramElementDoc>> pkgToImplementingClass;
++    final Map<String,List<ProgramElementDoc>> pkgToField;
++    final Map<String,List<ProgramElementDoc>> pkgToMethodReturn;
++    final Map<String,List<ProgramElementDoc>> pkgToMethodArgs;
++    final Map<String,List<ProgramElementDoc>> pkgToMethodThrows;
++    final Map<String,List<ProgramElementDoc>> pkgToConstructorAnnotations;
++    final Map<String,List<ProgramElementDoc>> pkgToConstructorParameterAnnotations;
++    final Map<String,List<ProgramElementDoc>> pkgToConstructorArgs;
++    final Map<String,List<ProgramElementDoc>> pkgToConstructorArgTypeParameter;
++    final Map<String,List<ProgramElementDoc>> pkgToConstructorThrows;
++    final SortedSet<PackageDoc> pkgSet;
+     final MethodWriterImpl methodSubWriter;
+     final ConstructorWriterImpl constrSubWriter;
+     final FieldWriterImpl fieldSubWriter;
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java
+@@ -52,12 +52,12 @@
+      *
+      * @see Group
+      */
+-    private Map groupPackageMap;
++    private Map<String,List<PackageDoc>> groupPackageMap;
+ 
+     /**
+      * List to store the order groups as specified on the command line.
+      */
+-    private List groupList;
++    private List<String> groupList;
+ 
+     /**
+      * Construct the PackageIndexWriter. Also constructs the grouping
+@@ -103,8 +103,8 @@
+      */
+     protected void addIndex(Content body) {
+         for (int i = 0; i < groupList.size(); i++) {
+-        String groupname = (String)groupList.get(i);
+-        List list = (List)groupPackageMap.get(groupname);
++        String groupname = groupList.get(i);
++        List<PackageDoc> list = groupPackageMap.get(groupname);
+             if (list != null && list.size() > 0) {
+                 addIndexContents(list.toArray(new PackageDoc[list.size()]),
+                         groupname, configuration.getText("doclet.Member_Table_Summary",
+diff --git a/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+@@ -41,7 +41,7 @@
+ public class PackageUseWriter extends SubWriterHolderWriter {
+ 
+     final PackageDoc pkgdoc;
+-    final SortedMap usingPackageToUsedClasses = new TreeMap();
++    final SortedMap<String,Set<ClassDoc>> usingPackageToUsedClasses = new TreeMap<String,Set<ClassDoc>>();
+ 
+     /**
+      * Constructor.
+@@ -64,15 +64,15 @@
+         ClassDoc[] content = pkgdoc.allClasses();
+         for (int i = 0; i < content.length; ++i) {
+             ClassDoc usedClass = content[i];
+-            Set usingClasses = (Set)mapper.classToClass.get(usedClass.qualifiedName());
++            Set<ClassDoc> usingClasses = mapper.classToClass.get(usedClass.qualifiedName());
+             if (usingClasses != null) {
+-                for (Iterator it = usingClasses.iterator(); it.hasNext(); ) {
+-                    ClassDoc usingClass = (ClassDoc)it.next();
++                for (Iterator<ClassDoc> it = usingClasses.iterator(); it.hasNext(); ) {
++                    ClassDoc usingClass = it.next();
+                     PackageDoc usingPackage = usingClass.containingPackage();
+-                    Set usedClasses = (Set)usingPackageToUsedClasses
++                    Set<ClassDoc> usedClasses = (Set)usingPackageToUsedClasses
+                         .get(usingPackage.name());
+                     if (usedClasses == null) {
+-                        usedClasses = new TreeSet();
++                        usedClasses = new TreeSet<ClassDoc>();
+                         usingPackageToUsedClasses.put(Util.getPackageName(usingPackage),
+                                                       usedClasses);
+                     }
+@@ -153,9 +153,9 @@
+                 getPackageLinkString(pkgdoc, Util.getPackageName(pkgdoc), false))));
+         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
+         Content tbody = new HtmlTree(HtmlTag.TBODY);
+-        Iterator it = usingPackageToUsedClasses.keySet().iterator();
++        Iterator<String> it = usingPackageToUsedClasses.keySet().iterator();
+         for (int i = 0; it.hasNext(); i++) {
+-            PackageDoc pkg = configuration.root.packageNamed((String)it.next());
++            PackageDoc pkg = configuration.root.packageNamed(it.next());
+             HtmlTree tr = new HtmlTree(HtmlTag.TR);
+             if (i % 2 == 0) {
+                 tr.addStyle(HtmlStyle.altColor);
+@@ -181,9 +181,9 @@
+                     configuration.getText("doclet.Class"),
+                     configuration.getText("doclet.Description"))
+         };
+-        Iterator itp = usingPackageToUsedClasses.keySet().iterator();
++        Iterator<String> itp = usingPackageToUsedClasses.keySet().iterator();
+         while (itp.hasNext()) {
+-            String packageName = (String)itp.next();
++            String packageName = itp.next();
+             PackageDoc usingPackage = configuration.root.packageNamed(packageName);
+             HtmlTree li = new HtmlTree(HtmlTag.LI);
+             li.addStyle(HtmlStyle.blockList);
+@@ -199,9 +199,8 @@
+                     getPackageLinkString(usingPackage,Util.getPackageName(usingPackage), false))));
+             table.addContent(getSummaryTableHeader(classTableHeader, "col"));
+             Content tbody = new HtmlTree(HtmlTag.TBODY);
+-            Iterator itc =
+-                ((Collection)usingPackageToUsedClasses.get(packageName))
+-                .iterator();
++            Iterator<ClassDoc> itc =
++		usingPackageToUsedClasses.get(packageName).iterator();
+             for (int i = 0; itc.hasNext(); i++) {
+                 HtmlTree tr = new HtmlTree(HtmlTag.TR);
+                 if (i % 2 == 0) {
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java
+@@ -97,7 +97,7 @@
+      * @param node the XML element that specifies which component to document.
+      * @param contentTree content tree to which the documentation will be added
+      */
+-    protected void build(XMLNode node) {
++    protected void build(XMLNode node, Content contentTree) {
+         String component = node.name;
+         try {
+             invokeMethod("build" + component,
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/LayoutParser.java
+@@ -80,7 +80,7 @@
+      */
+     public XMLNode parseXML(String root) {
+         if (xmlElementsMap.containsKey(root)) {
+-            return (List) xmlElementsMap.get(root);
++            return xmlElementsMap.get(root);
+         }
+         try {
+             currentRoot = root;
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java
+@@ -375,8 +375,7 @@
+      */
+     public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) {
+         if (classDoc.definesSerializableFields()) {
+-            FieldDoc serialPersistentField =
+-                Util.asList(classDoc.serializableFields()).get(0);
++            FieldDoc serialPersistentField = classDoc.serializableFields()[0];
+             // Check to see if there are inline comments, tags or deprecation
+             // information to be printed.
+             if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/ClassUseMapper.java
+@@ -46,150 +46,150 @@
+      * Mapping of ClassDocs to set of PackageDoc used by that class.
+      * Entries may be null.
+      */
+-    public Map classToPackage = new HashMap();
++    public Map<String,Set<PackageDoc>> classToPackage = new HashMap<String,Set<PackageDoc>>();
+ 
+     /**
+      * Mapping of Annotations to set of PackageDoc that use the annotation.
+      */
+-    public Map classToPackageAnnotations = new HashMap();
++    public Map<String,List<PackageDoc>> classToPackageAnnotations = new HashMap<String,List<PackageDoc>>();
+ 
+     /**
+      * Mapping of ClassDocs to set of ClassDoc used by that class.
+      * Entries may be null.
+      */
+-    public Map classToClass = new HashMap();
++    public Map<String,Set<ClassDoc>> classToClass = new HashMap<String,Set<ClassDoc>>();
+ 
+     /**
+      * Mapping of ClassDocs to list of ClassDoc which are direct or
+      * indirect subclasses of that class.
+      * Entries may be null.
+      */
+-    public Map classToSubclass = new HashMap();
++    public Map<String,List<ClassDoc>> classToSubclass = new HashMap<String,List<ClassDoc>>();
+ 
+     /**
+      * Mapping of ClassDocs to list of ClassDoc which are direct or
+      * indirect subinterfaces of that interface.
+      * Entries may be null.
+      */
+-    public Map classToSubinterface = new HashMap();
++    public Map<String,List<ClassDoc>> classToSubinterface = new HashMap<String,List<ClassDoc>>();
+ 
+     /**
+      * Mapping of ClassDocs to list of ClassDoc which implement
+      * this interface.
+      * Entries may be null.
+      */
+-    public Map classToImplementingClass = new HashMap();
++    public Map<String,List<ClassDoc>> classToImplementingClass = new HashMap<String,List<ClassDoc>>();
+ 
+     /**
+      * Mapping of ClassDocs to list of FieldDoc declared as that class.
+      * Entries may be null.
+      */
+-    public Map classToField = new HashMap();
++    public Map<String,List<FieldDoc>> classToField = new HashMap<String,List<FieldDoc>>();
+ 
+     /**
+      * Mapping of ClassDocs to list of MethodDoc returning that class.
+      * Entries may be null.
+      */
+-    public Map classToMethodReturn = new HashMap();
++    public Map<String,List<MethodDoc>> classToMethodReturn = new HashMap<String,List<MethodDoc>>();
+ 
+     /**
+      * Mapping of ClassDocs to list of MethodDoc having that class
+      * as an arg.
+      * Entries may be null.
+      */
+-    public Map classToMethodArgs = new HashMap();
++    public Map<String,List<ExecutableMemberDoc>> classToMethodArgs = new HashMap<String,List<ExecutableMemberDoc>>();
+ 
+     /**
+      * Mapping of ClassDocs to list of MethodDoc which throws that class.
+      * Entries may be null.
+      */
+-    public Map classToMethodThrows = new HashMap();
++    public Map<String,List<ExecutableMemberDoc>> classToMethodThrows = new HashMap<String,List<ExecutableMemberDoc>>();
+ 
+     /**
+      * Mapping of ClassDocs to list of ConstructorDoc having that class
+      * as an arg.
+      * Entries may be null.
+      */
+-    public Map classToConstructorArgs = new HashMap();
++    public Map<String,List<ExecutableMemberDoc>> classToConstructorArgs = new HashMap<String,List<ExecutableMemberDoc>>();
+ 
+     /**
+      * Mapping of ClassDocs to list of ConstructorDoc which throws that class.
+      * Entries may be null.
+      */
+-    public Map classToConstructorThrows = new HashMap();
++    public Map<String,List<ExecutableMemberDoc>> classToConstructorThrows = new HashMap<String,List<ExecutableMemberDoc>>();
+ 
+     /**
+      * The mapping of AnnotationTypeDocs to constructors that use them.
+      */
+-    public Map classToConstructorAnnotations = new HashMap();
+-
+-    /**
+-     * The mapping of AnnotationTypeDocs to Constructor parameters that use them.
+-     */
+-    public Map classToConstructorParamAnnotation = new HashMap();
++    public Map<String,List<ConstructorDoc>> classToConstructorAnnotations = new HashMap<String,List<ConstructorDoc>>();
++ 
++     /**
++      * The mapping of AnnotationTypeDocs to Constructor parameters that use them.
++      */
++    public Map<String,List<ExecutableMemberDoc>> classToConstructorParamAnnotation = new HashMap<String,List<ExecutableMemberDoc>>();
+ 
+     /**
+      * The mapping of ClassDocs to Constructor arguments that use them as type parameters.
+      */
+-    public Map classToConstructorDocArgTypeParam = new HashMap();
++    public Map<String,List<ExecutableMemberDoc>> classToConstructorDocArgTypeParam = new HashMap<String,List<ExecutableMemberDoc>>();
+ 
+     /**
+      * The mapping of ClassDocs to ClassDocs that use them as type parameters.
+      */
+-    public Map classToClassTypeParam = new HashMap();
++    public Map<String,List<ClassDoc>> classToClassTypeParam = new HashMap<String,List<ClassDoc>>();
+ 
+     /**
+      * The mapping of AnnotationTypeDocs to ClassDocs that use them.
+      */
+-    public Map classToClassAnnotations = new HashMap();
++    public Map<String,List<ClassDoc>> classToClassAnnotations = new HashMap<String,List<ClassDoc>>();
+ 
+     /**
+      * The mapping of ClassDocs to ExecutableMemberDocs that use them as type parameters.
+      */
+-    public Map classToExecMemberDocTypeParam = new HashMap();
++    public Map<String,List<MethodDoc>> classToExecMemberDocTypeParam = new HashMap<String,List<MethodDoc>>();
+ 
+     /**
+      * The mapping of ClassDocs to ExecutableMemberDocs arguments that use them as type parameters.
+      */
+-    public Map classToExecMemberDocArgTypeParam = new HashMap();
++    public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocArgTypeParam = new HashMap<String,List<ExecutableMemberDoc>>();
+ 
+     /**
+      * The mapping of AnnotationTypeDocs to ExecutableMemberDocs that use them.
+      */
+-    public Map classToExecMemberDocAnnotations = new HashMap();
++    public Map<String,List<MethodDoc>> classToExecMemberDocAnnotations = new HashMap<String,List<MethodDoc>>();
+ 
+     /**
+      * The mapping of ClassDocs to ExecutableMemberDocs that have return type
+      * with type parameters of that class.
+      */
+-    public Map classToExecMemberDocReturnTypeParam = new HashMap();
++    public Map<String,List<MethodDoc>> classToExecMemberDocReturnTypeParam = new HashMap<String,List<MethodDoc>>();
+ 
+     /**
+      * The mapping of AnnotationTypeDocs to MethodDoc parameters that use them.
+      */
+-    public Map classToExecMemberDocParamAnnotation = new HashMap();
++    public Map<String,List<ExecutableMemberDoc>> classToExecMemberDocParamAnnotation = new HashMap<String,List<ExecutableMemberDoc>>();
+ 
+     /**
+      * The mapping of ClassDocs to FieldDocs that use them as type parameters.
+      */
+-    public Map classToFieldDocTypeParam = new HashMap();
++    public Map<String,List<FieldDoc>> classToFieldDocTypeParam = new HashMap<String,List<FieldDoc>>();
+ 
+     /**
+      * The mapping of AnnotationTypeDocs to FieldDocs that use them.
+      */
+-    public Map annotationToFieldDoc = new HashMap();
++    public Map<String,List<FieldDoc>> annotationToFieldDoc = new HashMap<String,List<FieldDoc>>();
+ 
+ 
+     public ClassUseMapper(RootDoc root, ClassTree classtree) {
+         this.classtree = classtree;
+ 
+         // Map subclassing, subinterfacing implementing, ...
+-        for (Iterator it = classtree.baseclasses().iterator(); it.hasNext();) {
+-            subclasses((ClassDoc)it.next());
++        for (Iterator<ClassDoc> it = classtree.baseclasses().iterator(); it.hasNext();) {
++            subclasses(it.next());
+         }
+-        for (Iterator it = classtree.baseinterfaces().iterator(); it.hasNext();) {
++        for (Iterator<ClassDoc> it = classtree.baseinterfaces().iterator(); it.hasNext();) {
+             // does subinterfacing as side-effect
+-            implementingClasses((ClassDoc)it.next());
++            implementingClasses(it.next());
+         }
+         // Map methods, fields, constructors using a class.
+         ClassDoc[] classes = root.classes();
+@@ -231,15 +231,15 @@
+     /**
+      * Return all subclasses of a class AND fill-in classToSubclass map.
+      */
+-    private Collection subclasses(ClassDoc cd) {
+-        Collection ret = (Collection)classToSubclass.get(cd.qualifiedName());
++    private Collection<ClassDoc> subclasses(ClassDoc cd) {
++        Collection<ClassDoc> ret = classToSubclass.get(cd.qualifiedName());
+         if (ret == null) {
+-            ret = new TreeSet();
+-            List subs = classtree.subclasses(cd);
++            ret = new TreeSet<ClassDoc>();
++            List<ClassDoc> subs = classtree.subclasses(cd);
+             if (subs != null) {
+                 ret.addAll(subs);
+-                for (Iterator it = subs.iterator(); it.hasNext();) {
+-                    ret.addAll(subclasses((ClassDoc)it.next()));
++                for (Iterator<ClassDoc> it = subs.iterator(); it.hasNext();) {
++                    ret.addAll(subclasses(it.next()));
+                 }
+             }
+             addAll(classToSubclass, cd, ret);
+@@ -250,15 +250,15 @@
+     /**
+      * Return all subinterfaces of an interface AND fill-in classToSubinterface map.
+      */
+-    private Collection subinterfaces(ClassDoc cd) {
+-        Collection ret = (Collection)classToSubinterface.get(cd.qualifiedName());
++    private Collection<ClassDoc> subinterfaces(ClassDoc cd) {
++        Collection<ClassDoc> ret = classToSubinterface.get(cd.qualifiedName());
+         if (ret == null) {
+-            ret = new TreeSet();
+-            List subs = classtree.subinterfaces(cd);
++            ret = new TreeSet<ClassDoc>();
++            List<ClassDoc> subs = classtree.subinterfaces(cd);
+             if (subs != null) {
+                 ret.addAll(subs);
+-                for (Iterator it = subs.iterator(); it.hasNext();) {
+-                    ret.addAll(subinterfaces((ClassDoc)it.next()));
++                for (Iterator<ClassDoc> it = subs.iterator(); it.hasNext();) {
++                    ret.addAll(subinterfaces(it.next()));
+                 }
+             }
+             addAll(classToSubinterface, cd, ret);
+@@ -272,19 +272,19 @@
+      * implementing subinterfaces) AND fill-in both classToImplementingClass
+      * and classToSubinterface maps.
+      */
+-    private Collection implementingClasses(ClassDoc cd) {
+-        Collection ret = (List)classToImplementingClass.get(cd.qualifiedName());
++    private Collection<ClassDoc> implementingClasses(ClassDoc cd) {
++        Collection<ClassDoc> ret = classToImplementingClass.get(cd.qualifiedName());
+         if (ret == null) {
+-            ret = new TreeSet();
+-            List impl = classtree.implementingclasses(cd);
++            ret = new TreeSet<ClassDoc>();
++            List<ClassDoc> impl = classtree.implementingclasses(cd);
+             if (impl != null) {
+                 ret.addAll(impl);
+-                for (Iterator it = impl.iterator(); it.hasNext();) {
+-                    ret.addAll(subclasses((ClassDoc)it.next()));
++                for (Iterator<ClassDoc> it = impl.iterator(); it.hasNext();) {
++                    ret.addAll(subclasses(it.next()));
+                 }
+             }
+-            for (Iterator it = subinterfaces(cd).iterator(); it.hasNext();) {
+-                ret.addAll(implementingClasses((ClassDoc)it.next()));
++            for (Iterator<ClassDoc> it = subinterfaces(cd).iterator(); it.hasNext();) {
++                ret.addAll(implementingClasses(it.next()));
+             }
+             addAll(classToImplementingClass, cd, ret);
+         }
+@@ -298,7 +298,7 @@
+     private void mapExecutable(ExecutableMemberDoc em) {
+         Parameter[] params = em.parameters();
+         boolean isConstructor = em.isConstructor();
+-        List classArgs = new ArrayList();
++        List<Type> classArgs = new ArrayList();
+         for (int k = 0; k < params.length; k++) {
+             Type pcd = params[k].type();
+             // primitives don't get mapped, also avoid dups
+@@ -325,34 +325,36 @@
+         }
+     }
+ 
+-    private List refList(Map map, ClassDoc cd) {
+-        List list = (List)map.get(cd.qualifiedName());
++    private <T> List<T> refList(Map<String,List<T>> map, ClassDoc cd) {
++        List<T> list = map.get(cd.qualifiedName());
+         if (list == null) {
+-            list = new ArrayList();
++            List<T> l = new ArrayList<T>();
++            list = l;
+             map.put(cd.qualifiedName(), list);
+         }
+         return list;
+     }
+ 
+-    private Set packageSet(ClassDoc cd) {
+-        Set pkgSet = (Set)classToPackage.get(cd.qualifiedName());
++    private Set<PackageDoc> packageSet(ClassDoc cd) {
++        Set<PackageDoc> pkgSet = classToPackage.get(cd.qualifiedName());
+         if (pkgSet == null) {
+-            pkgSet = new TreeSet();
++            pkgSet = new TreeSet<PackageDoc>();
+             classToPackage.put(cd.qualifiedName(), pkgSet);
+         }
+         return pkgSet;
+     }
+ 
+-    private Set classSet(ClassDoc cd) {
+-        Set clsSet = (Set)classToClass.get(cd.qualifiedName());
++    private Set<ClassDoc> classSet(ClassDoc cd) {
++        Set<ClassDoc> clsSet = classToClass.get(cd.qualifiedName());
+         if (clsSet == null) {
+-            clsSet = new TreeSet();
++            Set<ClassDoc> s = new TreeSet<ClassDoc>();
++            clsSet = s;
+             classToClass.put(cd.qualifiedName(), clsSet);
+         }
+         return clsSet;
+     }
+ 
+-    private void add(Map map, ClassDoc cd, ProgramElementDoc ref) {
++    private <T extends ProgramElementDoc> void add(Map<String,List<T>> map, ClassDoc cd, T ref) {
+         // add to specified map
+         refList(map, cd).add(ref);
+ 
+@@ -361,7 +363,7 @@
+ 
+         classSet(cd).add(ref instanceof MemberDoc?
+                 ((MemberDoc)ref).containingClass() :
+-                    ref);
++                    (ClassDoc)ref);
+     }
+ 
+     private void addAll(Map map, ClassDoc cd, Collection refs) {
+@@ -371,15 +373,13 @@
+         // add to specified map
+         refList(map, cd).addAll(refs);
+ 
+-        Set pkgSet = packageSet(cd);
+-        Set clsSet = classSet(cd);
++        Set<PackageDoc> pkgSet = packageSet(cd);
++        Set<ClassDoc> clsSet = classSet(cd);
+         // add ref's package to package map and class map
+-        for (Iterator it = refs.iterator(); it.hasNext();) {
+-            ProgramElementDoc pedoc = (ProgramElementDoc)it.next();
+-            pkgSet.add(pedoc.containingPackage());
+-            clsSet.add(pedoc instanceof MemberDoc?
+-                    ((MemberDoc)pedoc).containingClass() :
+-                        pedoc);
++        for (Iterator<ClassDoc> it = refs.iterator(); it.hasNext();) {
++	    ClassDoc cls = it.next();
++            pkgSet.add(cls.containingPackage());
++            clsSet.add(cls);
+ 
+         }
+     }
+@@ -392,8 +392,8 @@
+      * @param doc the doc whose type parameters are being checked.
+      * @param holder the holder that owns the type parameters.
+      */
+-    private void mapTypeParameters(Map map, Object doc,
+-            ProgramElementDoc holder) {
++    private <T extends ProgramElementDoc> void mapTypeParameters(Map<String,List<T>> map, Object doc,
++            T holder) {
+         TypeVariable[] typeVariables;
+         if (doc instanceof ClassDoc) {
+             typeVariables = ((ClassDoc) doc).typeParameters();
+@@ -438,8 +438,8 @@
+      * @param doc the doc whose type parameters are being checked.
+      * @param holder the holder that owns the type parameters.
+      */
+-    private void mapAnnotations(Map map, Object doc,
+-            Object holder) {
++    private <T extends ProgramElementDoc> void mapAnnotations(Map<String,List<T>> map, Object doc,
++            T holder) {
+         TypeVariable[] typeVariables;
+         AnnotationDesc[] annotations;
+         boolean isPackage = false;
+@@ -458,12 +458,31 @@
+             if (isPackage)
+                 refList(map, annotationDoc).add(holder);
+             else
+-                add(map, annotationDoc, (ProgramElementDoc) holder);
++                add(map, annotationDoc, holder);
+         }
+     }
+ 
+-    private void addTypeParameterToMap(Map map, Type type,
+-            ProgramElementDoc holder) {
++
++    /**
++     * Map the AnnotationType to the ProgramElementDocs that use them as
++     * type parameters.
++     *
++     * @param map the map the insert the information into.
++     * @param doc the doc whose type parameters are being checked.
++     * @param holder the holder that owns the type parameters.
++     */
++    private <T extends PackageDoc> void mapAnnotations(Map<String,List<T>> map, PackageDoc doc,
++            T holder) {
++        AnnotationDesc[] annotations;
++        annotations = doc.annotations();
++        for (int i = 0; i < annotations.length; i++) {
++            AnnotationTypeDoc annotationDoc = annotations[i].annotationType();
++            refList(map, annotationDoc).add(holder);
++	}
++    }
++
++    private <T extends ProgramElementDoc> void addTypeParameterToMap(Map<String,List<T>> map, Type type,
++            T holder) {
+         if (type instanceof ClassDoc) {
+             add(map, (ClassDoc) type, holder);
+         } else if (type instanceof ParameterizedType) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/langtools_merge-01.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,30 @@
+# HG changeset patch
+# User andrew
+# Date 1371734829 18000
+# Node ID 9aefba5680d55a2e3f718c03cd27cf027c7fc1f9
+# Parent  f422c843b477501acc2526c69609fd94204cdce1
+Fix merge error
+
+diff --git a/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java b/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java
+@@ -36,7 +36,6 @@
+ import com.sun.tools.javac.util.List;
+ import com.sun.tools.javac.util.ListBuffer;
+ import com.sun.tools.javac.util.Position;
+-import java.util.Locale;
+ 
+ /**
+  * This class holds the information from one run of javadoc.
+@@ -362,11 +361,4 @@
+     public Locale getLocale() {
+         return env.doclocale.locale;
+     }
+-
+-    /**
+-     * Return the locale provided by the user or the default locale value.
+-     */
+-    public Locale getLocale() {
+-        return env.doclocale.locale;
+-    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/langtools_merge-02.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,30 @@
+# HG changeset patch
+# User andrew
+# Date 1371735102 18000
+# Node ID 335cdc9887c56f560991275fe8d32e6edb6b3f1e
+# Parent  9aefba5680d55a2e3f718c03cd27cf027c7fc1f9
+Fix more merge issues
+
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/MethodBuilder.java
+@@ -102,6 +102,8 @@
+                     builder.methods,
+                     configuration.getMemberComparator());
+         }
++	return builder;
++    }
+ 
+     /**
+      * {@inheritDoc}
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/PackageSummaryBuilder.java
+@@ -179,6 +179,7 @@
+                     configuration.getText("doclet.Interface_Summary"),
+                     interfaceTableSummary, interfaceTableHeader, summaryContentTree);
+         }
++    }
+ 
+     /**
+      * Build the summary for the classes in this package.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/security/20130618/langtools_merge-03.patch	Sat Jun 22 16:38:24 2013 -0500
@@ -0,0 +1,18 @@
+# HG changeset patch
+# User andrew
+# Date 1371838665 18000
+# Node ID 41f5d151d8477b8450ecea825143c608c312291e
+# Parent  a5c99fd80b4c9f5049351bf5bff8517dd6d3b613
+Remove leftover tag
+
+diff --git a/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml b/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
+--- openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
++++ openjdk/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/resources/doclet.xml
+@@ -141,7 +141,6 @@
+                 <ConstantMembers/>
+             </ClassConstantSummary>
+         </ConstantSummaries>    
+-        <Footer/>
+     </ConstantSummary>
+     
+     <SerializedForm>